diff options
| author | mat <git@matdoes.dev> | 2025-06-11 22:58:41 -0630 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-06-11 22:58:41 -0630 |
| commit | a2606569bb79867d07a075bcf7b05730e4264d72 (patch) | |
| tree | fb97fb52aa0c4d7575f6bd5e4e36c2f01c87f942 /azalea-physics/src/collision/shape.rs | |
| parent | 89ddd5e85f4f2fb98697df15528df6e07a3ddd07 (diff) | |
| download | azalea-drasl-a2606569bb79867d07a075bcf7b05730e4264d72.tar.xz | |
use owned instead of borrowed Vec3 more
Diffstat (limited to 'azalea-physics/src/collision/shape.rs')
| -rw-r--r-- | azalea-physics/src/collision/shape.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/azalea-physics/src/collision/shape.rs b/azalea-physics/src/collision/shape.rs index 4d430ee7..9caae590 100644 --- a/azalea-physics/src/collision/shape.rs +++ b/azalea-physics/src/collision/shape.rs @@ -98,9 +98,9 @@ impl Shapes { } pub fn collide( - axis: &Axis, + axis: Axis, entity_box: &AABB, - collision_boxes: &Vec<VoxelShape>, + collision_boxes: &[VoxelShape], mut movement: f64, ) -> f64 { for shape in collision_boxes { @@ -408,7 +408,7 @@ impl VoxelShape { } } - pub fn clip(&self, from: &Vec3, to: &Vec3, block_pos: BlockPos) -> Option<BlockHitResult> { + pub fn clip(&self, from: Vec3, to: Vec3, block_pos: BlockPos) -> Option<BlockHitResult> { if self.is_empty() { return None; } @@ -416,7 +416,7 @@ impl VoxelShape { if vector.length_squared() < EPSILON { return None; } - let right_after_start = from + &(vector * 0.001); + let right_after_start = from + (vector * 0.001); if self.shape().is_full_wide( self.find_index(Axis::X, right_after_start.x - block_pos.x as f64), @@ -436,8 +436,8 @@ impl VoxelShape { } } - pub fn collide(&self, axis: &Axis, entity_box: &AABB, movement: f64) -> f64 { - self.collide_x(AxisCycle::between(*axis, Axis::X), entity_box, movement) + pub fn collide(&self, axis: Axis, entity_box: &AABB, movement: f64) -> f64 { + self.collide_x(AxisCycle::between(axis, Axis::X), entity_box, movement) } pub fn collide_x(&self, axis_cycle: AxisCycle, entity_box: &AABB, mut movement: f64) -> f64 { if self.shape().is_empty() { @@ -753,8 +753,8 @@ mod tests { let block_shape = &*BLOCK_SHAPE; let block_hit_result = block_shape .clip( - &Vec3::new(-0.3, 0.5, 0.), - &Vec3::new(5.3, 0.5, 0.), + Vec3::new(-0.3, 0.5, 0.), + Vec3::new(5.3, 0.5, 0.), BlockPos::new(0, 0, 0), ) .unwrap(); |
