Skip to content

Commit 025c77d

Browse files
committed
chore: cargo fmt
1 parent 82e483f commit 025c77d

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

src/shape/voxels.rs

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,18 @@ impl Voxels {
319319
///
320320
/// This is the same as [`Voxels::combine_voxel_states`] but localized to a single voxel and its
321321
/// neighbors.
322-
pub fn propagate_voxel_change(&mut self, other: &mut Self, voxel: Point<i32>, origin_shift: Vector<i32>) {
323-
let center_is_empty = self.get_voxel_state(voxel).map(|vox| vox.is_empty()).unwrap_or(true);
324-
let center_state_delta = other.update_neighbors_state(voxel - origin_shift, center_is_empty);
322+
pub fn propagate_voxel_change(
323+
&mut self,
324+
other: &mut Self,
325+
voxel: Point<i32>,
326+
origin_shift: Vector<i32>,
327+
) {
328+
let center_is_empty = self
329+
.get_voxel_state(voxel)
330+
.map(|vox| vox.is_empty())
331+
.unwrap_or(true);
332+
let center_state_delta =
333+
other.update_neighbors_state(voxel - origin_shift, center_is_empty);
325334

326335
if let Some(state_id) = self.get_linear_index(voxel) {
327336
self.states[state_id as usize].0 |= center_state_delta.0;
@@ -344,12 +353,12 @@ impl Voxels {
344353

345354
// Intersect the domains + 1 cell.
346355
let d0 = [self.domain_mins - one, self.domain_maxs + one * 2];
347-
let d1 = [other.domain_mins - one + origin_shift, other.domain_maxs + one * 2 + origin_shift];
348-
349-
let d01 = [
350-
d0[0].sup(&d1[0]),
351-
d0[1].inf(&d1[1]),
356+
let d1 = [
357+
other.domain_mins - one + origin_shift,
358+
other.domain_maxs + one * 2 + origin_shift,
352359
];
360+
361+
let d01 = [d0[0].sup(&d1[0]), d0[1].inf(&d1[1])];
353362
// Iterate on the domain intersection. If the voxel exists (and is non-empty) on both shapes, we
354363
// simply need to combine their bitmasks. If it doesn’t exist on both shapes, we need to
355364
// actually check the neighbors.
@@ -367,23 +376,27 @@ impl Voxels {
367376
#[cfg(feature = "dim3")]
368377
let key0 = Point::new(i, j, _k);
369378
let key1 = key0 - origin_shift;
370-
let id0 = self.get_linear_index(key0).filter(|id| !self.states[*id as usize].is_empty());
371-
let id1 = other.get_linear_index(key1).filter(|id| !other.states[*id as usize].is_empty());
379+
let id0 = self
380+
.get_linear_index(key0)
381+
.filter(|id| !self.states[*id as usize].is_empty());
382+
let id1 = other
383+
.get_linear_index(key1)
384+
.filter(|id| !other.states[*id as usize].is_empty());
372385

373386
match (id0, id1) {
374387
(Some(id0), Some(id1)) => {
375388
self.states[id0 as usize].0 |= other.states[id1 as usize].0;
376389
other.states[id1 as usize].0 |= self.states[id0 as usize].0;
377390
}
378391
(Some(id0), None) => {
379-
self.states[id0 as usize].0 |= other.compute_voxel_neighborhood_bits(key1).0;
392+
self.states[id0 as usize].0 |=
393+
other.compute_voxel_neighborhood_bits(key1).0;
380394
}
381395
(None, Some(id1)) => {
382-
other.states[id1 as usize].0 |= self.compute_voxel_neighborhood_bits(key0).0;
383-
}
384-
(None, None) => {
385-
/* Nothing to adjust. */
396+
other.states[id1 as usize].0 |=
397+
self.compute_voxel_neighborhood_bits(key0).0;
386398
}
399+
(None, None) => { /* Nothing to adjust. */ }
387400
}
388401
}
389402
}
@@ -891,14 +904,12 @@ impl Voxels {
891904
next[k] += 1;
892905

893906
if let Some(next_id) = self.get_linear_index(next) {
894-
if !self.states[next_id as usize].is_empty()
895-
{
907+
if !self.states[next_id as usize].is_empty() {
896908
occupied_faces |= 1 << (k * 2);
897909
}
898910
}
899911
if let Some(prev_id) = self.get_linear_index(prev) {
900-
if !self.states[prev_id as usize].is_empty()
901-
{
912+
if !self.states[prev_id as usize].is_empty() {
902913
occupied_faces |= 1 << (k * 2 + 1);
903914
}
904915
}

0 commit comments

Comments
 (0)