Skip to content

Commit 6a9d106

Browse files
Merge pull request #1
Overhaul rotation
2 parents 9120771 + 2724501 commit 6a9d106

File tree

8 files changed

+262
-314
lines changed

8 files changed

+262
-314
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
/.idea

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ edition = "2021"
99
bevy = { version = "0.10.1", features = ["dynamic_linking"] }
1010
bevy_eventlistener = "0.2.2"
1111
bevy_mod_picking = "0.13.0"
12+
derivative = "2.2.0"

src/cell.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl CellCoordinates {
8989
cube_side_length: u32,
9090
) -> Option<(CellCoordinates, bool)> {
9191
let normal = self.normal_direction();
92-
if normal.abs() == direction.abs() {
92+
if normal.is_parallel_to(direction) {
9393
return None; // We ignore directions which would go out of and into the cube
9494
}
9595

@@ -145,7 +145,7 @@ impl CellCoordinates {
145145
radial_direction: RadialDirection,
146146
cube_side_length: u32,
147147
) -> Option<(CellCoordinates, bool)> {
148-
if radial_direction.rotation_axis().abs() == self.normal_direction().abs() {
148+
if radial_direction.rotation_axis().is_parallel_to(self.normal_direction()) {
149149
// The direction is not possible to go in on this side
150150
return None;
151151
}
@@ -163,8 +163,12 @@ impl CellCoordinates {
163163
diagonal: (CartesianDirection, CartesianDirection),
164164
cube_side_length: u32,
165165
) -> Option<(CellCoordinates, bool)> {
166-
let Some(cell1) = self.get_cell_in_direction(diagonal.0, cube_side_length) else {return None};
167-
let Some(cell2) = cell1.0.get_cell_in_direction(diagonal.1, cube_side_length) else {return None};
166+
let Some(cell1) = self.get_cell_in_direction(diagonal.0, cube_side_length) else {
167+
return None;
168+
};
169+
let Some(cell2) = cell1.0.get_cell_in_direction(diagonal.1, cube_side_length) else {
170+
return None;
171+
};
168172
if cell1.1 && cell2.1 {
169173
// The second element tells us if the transformation went over a cube edge, in this
170174
// case we are in a corner, which means we have a true neighbor in cell2

0 commit comments

Comments
 (0)