Skip to content

Commit 1f9f8a7

Browse files
committed
Align the min coordinate of background grid to multiples of cube size
1 parent 6ca4888 commit 1f9f8a7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The following changes are present in the `main` branch of the repository and are not yet part of a release:
44

5-
- No major changes since last release
5+
- Lib: In the `UniformCartesianCubeGrid3d::from_aabb` constructor, re-align the min-coordinate of the AABB to multiples of the cube size by default. This way multiple frames of an animation will be automatically consistent in terms of marching cubes grid alignment without having to manually specify an AABB for the entire simulation.
66

77
## Version 0.9.1
88

splashsurf_lib/src/uniform_grid.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,14 @@ impl<I: Index, R: Real> UniformCartesianCubeGrid3d<I, R> {
282282
return Err(GridConstructionError::InconsistentAabb);
283283
}
284284

285+
// Align the min coordinate of the AABB to the cube grid to get consistent results between frames
286+
let aligned_min = aabb
287+
.min()
288+
.unscale(cell_size)
289+
.map(|x| x.floor())
290+
.scale(cell_size);
291+
let aabb = Aabb3d::new(aligned_min, aabb.max().clone());
292+
285293
let n_cells_real = aabb.extents() / cell_size;
286294
let n_cells_per_dim = Self::checked_n_cells_per_dim(&n_cells_real)
287295
.ok_or(GridConstructionError::IndexTypeTooSmallCellsPerDim)?;

0 commit comments

Comments
 (0)