From 6f82263de58c6f33cca8cc36276b5e478801b352 Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 19 Jan 2026 15:05:44 +0600 Subject: minor physics optimizations --- azalea-physics/src/collision/shape.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'azalea-physics/src') 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>, - x_coords: Vec, - y_coords: Vec, - z_coords: Vec, + 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 { + 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] -- cgit v1.2.3