diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2022-11-15 14:52:26 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-15 14:52:26 -0600 |
| commit | 0d004b72ac22641978c6ef93ca8641eb621e2f48 (patch) | |
| tree | 61eca3b0bd0339b36b947afd76724b2b6447572c /azalea-physics/src/collision | |
| parent | b9da6f74756abb8daf7253765fdc5f5521381090 (diff) | |
| download | azalea-drasl-0d004b72ac22641978c6ef93ca8641eb621e2f48.tar.xz | |
Rename "dimension" to "world" (#39)
* rename "dimension" to "world"
* Update mod.rs
Diffstat (limited to 'azalea-physics/src/collision')
| -rwxr-xr-x | azalea-physics/src/collision/mod.rs | 22 | ||||
| -rw-r--r--[-rwxr-xr-x] | azalea-physics/src/collision/world_collisions.rs (renamed from azalea-physics/src/collision/dimension_collisions.rs) | 14 |
2 files changed, 18 insertions, 18 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) diff --git a/azalea-physics/src/collision/dimension_collisions.rs b/azalea-physics/src/collision/world_collisions.rs index fd4e5141..65f7f5bb 100755..100644 --- a/azalea-physics/src/collision/dimension_collisions.rs +++ b/azalea-physics/src/collision/world_collisions.rs @@ -2,7 +2,7 @@ use crate::collision::{BlockWithShape, VoxelShape, AABB}; use azalea_block::BlockState; use azalea_core::{ChunkPos, ChunkSectionPos, Cursor3d, CursorIterationType, EPSILON}; use azalea_world::entity::EntityData; -use azalea_world::{Chunk, Dimension}; +use azalea_world::{Chunk, World}; use parking_lot::Mutex; use std::sync::Arc; @@ -16,7 +16,7 @@ pub trait CollisionGetter { ) -> BlockCollisions<'a>; } -impl CollisionGetter for Dimension { +impl CollisionGetter for World { fn get_block_collisions<'a>( &'a self, entity: Option<&EntityData>, @@ -27,7 +27,7 @@ impl CollisionGetter for Dimension { } pub struct BlockCollisions<'a> { - pub dimension: &'a Dimension, + pub world: &'a World, // context: CollisionContext, pub aabb: AABB, pub entity_shape: VoxelShape, @@ -37,7 +37,7 @@ pub struct BlockCollisions<'a> { impl<'a> BlockCollisions<'a> { // TODO: the entity is stored in the context - pub fn new(dimension: &'a Dimension, _entity: Option<&EntityData>, aabb: AABB) -> Self { + pub fn new(world: &'a World, _entity: Option<&EntityData>, aabb: AABB) -> Self { let origin_x = (aabb.min_x - EPSILON) as i32 - 1; let origin_y = (aabb.min_y - EPSILON) as i32 - 1; let origin_z = (aabb.min_z - EPSILON) as i32 - 1; @@ -49,7 +49,7 @@ impl<'a> BlockCollisions<'a> { let cursor = Cursor3d::new(origin_x, origin_y, origin_z, end_x, end_y, end_z); Self { - dimension, + world, aabb, entity_shape: VoxelShape::from(aabb), cursor, @@ -75,7 +75,7 @@ impl<'a> BlockCollisions<'a> { // return var7; // } - self.dimension[&chunk_pos].as_ref() + self.world[&chunk_pos].as_ref() } } @@ -97,7 +97,7 @@ impl<'a> Iterator for BlockCollisions<'a> { let pos = item.pos; let block_state: BlockState = chunk .lock() - .get(&(&pos).into(), self.dimension.min_y()) + .get(&(&pos).into(), self.world.min_y()) .unwrap_or(BlockState::Air); // TODO: continue if self.only_suffocating_blocks and the block is not suffocating |
