aboutsummaryrefslogtreecommitdiff
path: root/azalea-physics/src/collision/mod.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2022-11-15 14:52:26 -0600
committerGitHub <noreply@github.com>2022-11-15 14:52:26 -0600
commit0d004b72ac22641978c6ef93ca8641eb621e2f48 (patch)
tree61eca3b0bd0339b36b947afd76724b2b6447572c /azalea-physics/src/collision/mod.rs
parentb9da6f74756abb8daf7253765fdc5f5521381090 (diff)
downloadazalea-drasl-0d004b72ac22641978c6ef93ca8641eb621e2f48.tar.xz
Rename "dimension" to "world" (#39)
* rename "dimension" to "world" * Update mod.rs
Diffstat (limited to 'azalea-physics/src/collision/mod.rs')
-rwxr-xr-xazalea-physics/src/collision/mod.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/azalea-physics/src/collision/mod.rs b/azalea-physics/src/collision/mod.rs
index d5502f3d..aa585aa8 100755
--- a/azalea-physics/src/collision/mod.rs
+++ b/azalea-physics/src/collision/mod.rs
@@ -1,18 +1,18 @@
mod blocks;
-mod dimension_collisions;
mod discrete_voxel_shape;
mod mergers;
mod shape;
+mod world_collisions;
use std::ops::DerefMut;
use azalea_core::{Axis, Vec3, AABB, EPSILON};
use azalea_world::entity::{Entity, EntityData};
-use azalea_world::{Dimension, MoveEntityError};
+use azalea_world::{MoveEntityError, World};
pub use blocks::BlockWithShape;
-use dimension_collisions::CollisionGetter;
pub use discrete_voxel_shape::*;
pub use shape::*;
+use world_collisions::CollisionGetter;
pub enum MoverType {
Own,
@@ -34,7 +34,7 @@ pub trait MovableEntity {
) -> Result<(), MoveEntityError>;
}
-impl HasCollision for Dimension {
+impl HasCollision for World {
// private Vec3 collide(Vec3 var1) {
// AABB var2 = this.getBoundingBox();
// List var3 = this.level.getEntityCollisions(this, var2.expandTowards(var1));
@@ -63,7 +63,7 @@ impl HasCollision for Dimension {
fn collide(&self, movement: &Vec3, entity: &EntityData) -> Vec3 {
let entity_bounding_box = entity.bounding_box;
// TODO: get_entity_collisions
- // let entity_collisions = dimension.get_entity_collisions(self, entity_bounding_box.expand_towards(movement));
+ // let entity_collisions = world.get_entity_collisions(self, entity_bounding_box.expand_towards(movement));
let entity_collisions = Vec::new();
if movement.length_sqr() == 0.0 {
*movement
@@ -83,7 +83,7 @@ impl HasCollision for Dimension {
}
}
-impl<D: DerefMut<Target = Dimension>> MovableEntity for Entity<'_, D> {
+impl<D: DerefMut<Target = World>> MovableEntity for Entity<'_, D> {
/// Move an entity by a given delta, checking for collisions.
fn move_colliding(
&mut self,
@@ -111,7 +111,7 @@ impl<D: DerefMut<Target = Dimension>> MovableEntity for Entity<'_, D> {
// movement = this.maybeBackOffFromEdge(movement, moverType);
- let collide_result = { self.dimension.collide(movement, self) };
+ let collide_result = { self.world.collide(movement, self) };
let move_distance = collide_result.length_sqr();
@@ -127,7 +127,7 @@ impl<D: DerefMut<Target = Dimension>> MovableEntity for Entity<'_, D> {
}
};
- self.dimension.set_entity_pos(self.id, new_pos)?;
+ self.world.set_entity_pos(self.id, new_pos)?;
}
let x_collision = movement.x != collide_result.x;
@@ -141,7 +141,7 @@ impl<D: DerefMut<Target = Dimension>> MovableEntity for Entity<'_, D> {
let _block_pos_below = self.on_pos_legacy();
// let _block_state_below = self
- // .dimension
+ // .world
// .get_block_state(&block_pos_below)
// .expect("Couldn't get block state below");
@@ -198,7 +198,7 @@ fn collide_bounding_box(
entity: Option<&EntityData>,
movement: &Vec3,
entity_bounding_box: &AABB,
- dimension: &Dimension,
+ world: &World,
entity_collisions: Vec<VoxelShape>,
) -> Vec3 {
let mut collision_boxes: Vec<VoxelShape> = Vec::with_capacity(entity_collisions.len() + 1);
@@ -210,7 +210,7 @@ fn collide_bounding_box(
// TODO: world border
let block_collisions =
- dimension.get_block_collisions(entity, entity_bounding_box.expand_towards(movement));
+ world.get_block_collisions(entity, entity_bounding_box.expand_towards(movement));
let block_collisions = block_collisions.collect::<Vec<_>>();
collision_boxes.extend(block_collisions);
collide_with_shapes(movement, *entity_bounding_box, &collision_boxes)