aboutsummaryrefslogtreecommitdiff
path: root/azalea-physics/src/collision
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-11-18 20:44:49 -0600
committermat <git@matdoes.dev>2023-11-18 20:44:49 -0600
commitf0b58c7e748e1e94ad0dd08124cfc186e865709c (patch)
treee57770be77d78262f89cc146179122a0b849c6c2 /azalea-physics/src/collision
parent000abfa13665abccf543b875d10c8c2a48dd75be (diff)
downloadazalea-drasl-f0b58c7e748e1e94ad0dd08124cfc186e865709c.tar.xz
share registries in swarms and fix some bugs
Diffstat (limited to 'azalea-physics/src/collision')
-rwxr-xr-xazalea-physics/src/collision/shape.rs23
1 files changed, 15 insertions, 8 deletions
diff --git a/azalea-physics/src/collision/shape.rs b/azalea-physics/src/collision/shape.rs
index 6329184f..94b0cfde 100755
--- a/azalea-physics/src/collision/shape.rs
+++ b/azalea-physics/src/collision/shape.rs
@@ -52,7 +52,7 @@ pub fn box_shape_unchecked(
if x_bits < 0 || y_bits < 0 || z_bits < 0 {
return VoxelShape::Array(ArrayVoxelShape::new(
- BLOCK_SHAPE.shape(),
+ BLOCK_SHAPE.shape().to_owned(),
vec![min_x, max_x],
vec![min_y, max_y],
vec![min_z, max_z],
@@ -253,7 +253,14 @@ impl Shapes {
op_false_true,
);
- Self::matches_anywhere_with_mergers(x_merger, y_merger, z_merger, a.shape(), b.shape(), op)
+ Self::matches_anywhere_with_mergers(
+ x_merger,
+ y_merger,
+ z_merger,
+ a.shape().to_owned(),
+ b.shape().to_owned(),
+ op,
+ )
}
pub fn matches_anywhere_with_mergers(
@@ -347,7 +354,7 @@ impl VoxelShape {
}
}
- pub fn shape(&self) -> DiscreteVoxelShape {
+ pub fn shape(&self) -> &DiscreteVoxelShape {
match self {
VoxelShape::Array(s) => s.shape(),
VoxelShape::Cube(s) => s.shape(),
@@ -372,7 +379,7 @@ impl VoxelShape {
}
VoxelShape::Array(ArrayVoxelShape::new(
- self.shape(),
+ self.shape().to_owned(),
self.get_coords(Axis::X).iter().map(|c| c + x).collect(),
self.get_coords(Axis::Y).iter().map(|c| c + y).collect(),
self.get_coords(Axis::Z).iter().map(|c| c + z).collect(),
@@ -648,8 +655,8 @@ impl CubeVoxelShape {
}
impl ArrayVoxelShape {
- fn shape(&self) -> DiscreteVoxelShape {
- self.shape.clone()
+ fn shape(&self) -> &DiscreteVoxelShape {
+ &self.shape
}
fn get_coords(&self, axis: Axis) -> Vec<f64> {
@@ -658,8 +665,8 @@ impl ArrayVoxelShape {
}
impl CubeVoxelShape {
- fn shape(&self) -> DiscreteVoxelShape {
- self.shape.clone()
+ fn shape(&self) -> &DiscreteVoxelShape {
+ &self.shape
}
fn get_coords(&self, axis: Axis) -> Vec<f64> {