diff options
| author | mat <git@matdoes.dev> | 2026-01-19 15:05:44 +0600 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-01-19 13:28:15 +0400 |
| commit | 6f82263de58c6f33cca8cc36276b5e478801b352 (patch) | |
| tree | 6230d62ce601efa2ae31f9fb363e8d756d787d4d /azalea-physics/src | |
| parent | 70bd9c94dd7ca68777a0ead5f9432812e535bee3 (diff) | |
| download | azalea-drasl-6f82263de58c6f33cca8cc36276b5e478801b352.tar.xz | |
minor physics optimizations
Diffstat (limited to 'azalea-physics/src')
| -rw-r--r-- | azalea-physics/src/collision/shape.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/azalea-physics/src/collision/shape.rs b/azalea-physics/src/collision/shape.rs index 4726ff85..63dd1b4d 100644 --- a/azalea-physics/src/collision/shape.rs +++ b/azalea-physics/src/collision/shape.rs @@ -607,9 +607,9 @@ pub struct CubeVoxelShape { #[allow(dead_code)] faces: Option<Vec<VoxelShape>>, - x_coords: Vec<f64>, - y_coords: Vec<f64>, - z_coords: Vec<f64>, + x_coords: Box<[f64]>, + y_coords: Box<[f64]>, + z_coords: Box<[f64]>, } impl ArrayVoxelShape { @@ -631,9 +631,7 @@ impl ArrayVoxelShape { zs, } } -} -impl ArrayVoxelShape { fn shape(&self) -> &DiscreteVoxelShape { &self.shape } @@ -665,13 +663,10 @@ impl CubeVoxelShape { &self.shape } - fn calculate_coords(shape: &DiscreteVoxelShape, axis: Axis) -> Vec<f64> { + fn calculate_coords(shape: &DiscreteVoxelShape, axis: Axis) -> Box<[f64]> { let size = shape.size(axis); - let mut parts = Vec::with_capacity(size as usize); - for i in 0..=size { - parts.push(i as f64 / size as f64); - } - parts + + (0..=size).map(|i| i as f64 / size as f64).collect() } #[inline] |
