aboutsummaryrefslogtreecommitdiff
path: root/azalea-core/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2024-02-26 00:55:27 -0600
committermat <git@matdoes.dev>2024-02-26 00:55:46 -0600
commit4f288b1c031065805f5eb11362fe762f2e295c12 (patch)
tree4c860b357b1d999d138bb218e62e29ef5e953dd6 /azalea-core/src
parente47dee388e1e7f051417244ab1c054f8b9acd755 (diff)
downloadazalea-drasl-4f288b1c031065805f5eb11362fe762f2e295c12.tar.xz
optimize physics a bit more
Diffstat (limited to 'azalea-core/src')
-rwxr-xr-xazalea-core/src/cursor3d.rs35
1 files changed, 15 insertions, 20 deletions
diff --git a/azalea-core/src/cursor3d.rs b/azalea-core/src/cursor3d.rs
index 0594a80a..dc96d890 100755
--- a/azalea-core/src/cursor3d.rs
+++ b/azalea-core/src/cursor3d.rs
@@ -3,9 +3,7 @@ use crate::position::BlockPos;
pub struct Cursor3d {
index: usize,
- origin_x: i32,
- origin_y: i32,
- origin_z: i32,
+ origin: BlockPos,
width: usize,
height: usize,
@@ -14,6 +12,12 @@ pub struct Cursor3d {
end: usize,
}
+impl Cursor3d {
+ pub fn origin(&self) -> BlockPos {
+ self.origin
+ }
+}
+
impl Iterator for Cursor3d {
type Item = CursorIteration;
@@ -40,9 +44,9 @@ impl Iterator for Cursor3d {
Some(CursorIteration {
pos: BlockPos {
- x: self.origin_x + x as i32,
- y: self.origin_y + y as i32,
- z: self.origin_z + z as i32,
+ x: self.origin.x + x as i32,
+ y: self.origin.y + y as i32,
+ z: self.origin.z + z as i32,
},
iteration_type: iteration_type.into(),
})
@@ -64,30 +68,21 @@ pub struct CursorIteration {
}
impl Cursor3d {
- pub fn new(
- origin_x: i32,
- origin_y: i32,
- origin_z: i32,
- end_x: i32,
- end_y: i32,
- end_z: i32,
- ) -> Self {
- let width = (end_x - origin_x + 1)
+ pub fn new(origin: BlockPos, end: BlockPos) -> Self {
+ let width = (end.x - origin.x + 1)
.try_into()
.expect("Impossible width.");
- let height = (end_y - origin_y + 1)
+ let height = (end.y - origin.y + 1)
.try_into()
.expect("Impossible height.");
- let depth = (end_z - origin_z + 1)
+ let depth = (end.z - origin.z + 1)
.try_into()
.expect("Impossible depth.");
Self {
index: 0,
- origin_x,
- origin_y,
- origin_z,
+ origin,
width,
height,