mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Remove dead commented code, updated changelog, commented profiling spans
(but left in for easy reuse later), fix clippy complaint
This commit is contained in:
parent
57922d9802
commit
4f6eb286e6
@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Sprite spawn rates
|
- Sprite spawn rates
|
||||||
- The Interact button can be used on campfires to sit
|
- The Interact button can be used on campfires to sit
|
||||||
- Made map icons fade out when near the edge of the map display
|
- Made map icons fade out when near the edge of the map display
|
||||||
|
- Roughly doubled the speed of entity vs terrain physics checks
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
@ -114,7 +114,6 @@ pub trait ReadVol: BaseVol {
|
|||||||
|
|
||||||
/// Call provided closure with each block in the supplied Aabb
|
/// Call provided closure with each block in the supplied Aabb
|
||||||
/// Portions of the Aabb outside the volume are ignored
|
/// Portions of the Aabb outside the volume are ignored
|
||||||
//#[inline]
|
|
||||||
fn for_each_in(&self, aabb: Aabb<i32>, mut f: impl FnMut(Vec3<i32>, Self::Vox))
|
fn for_each_in(&self, aabb: Aabb<i32>, mut f: impl FnMut(Vec3<i32>, Self::Vox))
|
||||||
where
|
where
|
||||||
Self::Vox: Copy,
|
Self::Vox: Copy,
|
||||||
|
@ -54,9 +54,8 @@ impl<V: RectRasterableVol + ReadVol + Debug> ReadVol for VolGrid2d<V> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// Call provided closure with each block in the supplied Aabb
|
/// Call provided closure with each block in the supplied Aabb
|
||||||
// /// Areas outside loaded chunks are ignored
|
/// Areas outside loaded chunks are ignored
|
||||||
#[inline]
|
|
||||||
fn for_each_in(&self, aabb: Aabb<i32>, mut f: impl FnMut(Vec3<i32>, Self::Vox))
|
fn for_each_in(&self, aabb: Aabb<i32>, mut f: impl FnMut(Vec3<i32>, Self::Vox))
|
||||||
where
|
where
|
||||||
Self::Vox: Copy,
|
Self::Vox: Copy,
|
||||||
@ -155,7 +154,6 @@ impl<V: RectRasterableVol> VolGrid2d<V> {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn chunk_size() -> Vec2<u32> { V::RECT_SIZE }
|
pub fn chunk_size() -> Vec2<u32> { V::RECT_SIZE }
|
||||||
|
|
||||||
//#[inline]
|
|
||||||
pub fn insert(&mut self, key: Vec2<i32>, chunk: Arc<V>) -> Option<Arc<V>> {
|
pub fn insert(&mut self, key: Vec2<i32>, chunk: Arc<V>) -> Option<Arc<V>> {
|
||||||
self.chunks.insert(key, chunk)
|
self.chunks.insert(key, chunk)
|
||||||
}
|
}
|
||||||
@ -165,14 +163,12 @@ impl<V: RectRasterableVol> VolGrid2d<V> {
|
|||||||
self.chunks.get(&key).map(|arc_chunk| arc_chunk.as_ref())
|
self.chunks.get(&key).map(|arc_chunk| arc_chunk.as_ref())
|
||||||
}
|
}
|
||||||
|
|
||||||
//#[inline]
|
|
||||||
pub fn get_key_arc(&self, key: Vec2<i32>) -> Option<&Arc<V>> { self.chunks.get(&key) }
|
pub fn get_key_arc(&self, key: Vec2<i32>) -> Option<&Arc<V>> { self.chunks.get(&key) }
|
||||||
|
|
||||||
pub fn clear(&mut self) { self.chunks.clear(); }
|
pub fn clear(&mut self) { self.chunks.clear(); }
|
||||||
|
|
||||||
pub fn drain(&mut self) -> hash_map::Drain<Vec2<i32>, Arc<V>> { self.chunks.drain() }
|
pub fn drain(&mut self) -> hash_map::Drain<Vec2<i32>, Arc<V>> { self.chunks.drain() }
|
||||||
|
|
||||||
//#[inline]
|
|
||||||
pub fn remove(&mut self, key: Vec2<i32>) -> Option<Arc<V>> { self.chunks.remove(&key) }
|
pub fn remove(&mut self, key: Vec2<i32>) -> Option<Arc<V>> { self.chunks.remove(&key) }
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
@ -181,14 +177,12 @@ impl<V: RectRasterableVol> VolGrid2d<V> {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn pos_key(&self, pos: Vec3<i32>) -> Vec2<i32> { Self::chunk_key(pos) }
|
pub fn pos_key(&self, pos: Vec3<i32>) -> Vec2<i32> { Self::chunk_key(pos) }
|
||||||
|
|
||||||
//#[inline]
|
|
||||||
pub fn iter(&self) -> ChunkIter<V> {
|
pub fn iter(&self) -> ChunkIter<V> {
|
||||||
ChunkIter {
|
ChunkIter {
|
||||||
iter: self.chunks.iter(),
|
iter: self.chunks.iter(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//#[inline]
|
|
||||||
pub fn cached(&self) -> CachedVolGrid2d<V> { CachedVolGrid2d::new(self) }
|
pub fn cached(&self) -> CachedVolGrid2d<V> { CachedVolGrid2d::new(self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1342,7 +1342,7 @@ fn box_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
clippy::cast_possible_truncation,
|
clippy::cast_possible_truncation,
|
||||||
clippy::cast_sign_loss
|
clippy::cast_sign_loss
|
||||||
)]
|
)]
|
||||||
prof_span!("box_voxel_collision");
|
//prof_span!("box_voxel_collision");
|
||||||
|
|
||||||
// Convience function to compute the player aabb
|
// Convience function to compute the player aabb
|
||||||
fn player_aabb(pos: Vec3<f32>, radius: f32, z_range: Range<f32>) -> Aabb<f32> {
|
fn player_aabb(pos: Vec3<f32>, radius: f32, z_range: Range<f32>) -> Aabb<f32> {
|
||||||
@ -1362,9 +1362,9 @@ fn box_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
|
|
||||||
// Function for determining whether the player at a specific position collides
|
// Function for determining whether the player at a specific position collides
|
||||||
// with blocks with the given criteria
|
// with blocks with the given criteria
|
||||||
fn collision_with<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
fn collision_with<T: BaseVol<Vox = Block> + ReadVol>(
|
||||||
pos: Vec3<f32>,
|
pos: Vec3<f32>,
|
||||||
terrain: &'a T,
|
terrain: &T,
|
||||||
hit: impl Fn(&Block) -> bool,
|
hit: impl Fn(&Block) -> bool,
|
||||||
near_aabb: Aabb<i32>,
|
near_aabb: Aabb<i32>,
|
||||||
radius: f32,
|
radius: f32,
|
||||||
@ -1430,12 +1430,12 @@ fn box_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
.clamped(1, MAX_INCREMENTS);
|
.clamped(1, MAX_INCREMENTS);
|
||||||
let old_pos = pos.0;
|
let old_pos = pos.0;
|
||||||
for _ in 0..increments {
|
for _ in 0..increments {
|
||||||
prof_span!("increment");
|
//prof_span!("increment");
|
||||||
const MAX_ATTEMPTS: usize = 16;
|
const MAX_ATTEMPTS: usize = 16;
|
||||||
pos.0 += pos_delta / increments as f32;
|
pos.0 += pos_delta / increments as f32;
|
||||||
|
|
||||||
let try_colliding_block = |pos: &Pos| {
|
let try_colliding_block = |pos: &Pos| {
|
||||||
prof_span!("most colliding check");
|
//prof_span!("most colliding check");
|
||||||
// Calculate the player's AABB
|
// Calculate the player's AABB
|
||||||
let player_aabb = player_aabb(pos.0, radius, z_range.clone());
|
let player_aabb = player_aabb(pos.0, radius, z_range.clone());
|
||||||
|
|
||||||
@ -1530,7 +1530,7 @@ fn box_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
&& dir.z < -0.1
|
&& dir.z < -0.1
|
||||||
// ...and the space above is free...
|
// ...and the space above is free...
|
||||||
&& {
|
&& {
|
||||||
prof_span!("space above free");
|
//prof_span!("space above free");
|
||||||
!collision_with(
|
!collision_with(
|
||||||
Vec3::new(pos.0.x, pos.0.y, (pos.0.z + 0.1).ceil()),
|
Vec3::new(pos.0.x, pos.0.y, (pos.0.z + 0.1).ceil()),
|
||||||
&terrain,
|
&terrain,
|
||||||
@ -1542,7 +1542,7 @@ fn box_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
}
|
}
|
||||||
// ...and there is a collision with a block beneath our current hitbox...
|
// ...and there is a collision with a block beneath our current hitbox...
|
||||||
&& {
|
&& {
|
||||||
prof_span!("collision beneath");
|
//prof_span!("collision beneath");
|
||||||
collision_with(
|
collision_with(
|
||||||
pos.0 + resolve_dir - Vec3::unit_z() * 1.25,
|
pos.0 + resolve_dir - Vec3::unit_z() * 1.25,
|
||||||
&terrain,
|
&terrain,
|
||||||
@ -1596,7 +1596,7 @@ fn box_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
physics_state.on_ground = on_ground;
|
physics_state.on_ground = on_ground;
|
||||||
// If the space below us is free, then "snap" to the ground
|
// If the space below us is free, then "snap" to the ground
|
||||||
} else if vel.0.z <= 0.0 && was_on_ground && block_snap && {
|
} else if vel.0.z <= 0.0 && was_on_ground && block_snap && {
|
||||||
prof_span!("snap check");
|
//prof_span!("snap check");
|
||||||
collision_with(
|
collision_with(
|
||||||
pos.0 - Vec3::unit_z() * 1.1,
|
pos.0 - Vec3::unit_z() * 1.1,
|
||||||
&terrain,
|
&terrain,
|
||||||
@ -1606,7 +1606,7 @@ fn box_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
z_range.clone(),
|
z_range.clone(),
|
||||||
)
|
)
|
||||||
} {
|
} {
|
||||||
prof_span!("snap!!");
|
//prof_span!("snap!!");
|
||||||
let snap_height = terrain
|
let snap_height = terrain
|
||||||
.get(Vec3::new(pos.0.x, pos.0.y, pos.0.z - 0.1).map(|e| e.floor() as i32))
|
.get(Vec3::new(pos.0.x, pos.0.y, pos.0.z - 0.1).map(|e| e.floor() as i32))
|
||||||
.ok()
|
.ok()
|
||||||
@ -1643,7 +1643,7 @@ fn box_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
|
|
||||||
let mut liquid = None::<(LiquidKind, f32)>;
|
let mut liquid = None::<(LiquidKind, f32)>;
|
||||||
let mut wall_dir_collisions = [false; 4];
|
let mut wall_dir_collisions = [false; 4];
|
||||||
prof_span!(guard, "liquid/walls");
|
//prof_span!(guard, "liquid/walls");
|
||||||
terrain.for_each_in(near_aabb, |block_pos, block| {
|
terrain.for_each_in(near_aabb, |block_pos, block| {
|
||||||
// Check for liquid blocks
|
// Check for liquid blocks
|
||||||
if let Some(block_liquid) = block.liquid_kind() {
|
if let Some(block_liquid) = block.liquid_kind() {
|
||||||
@ -1680,7 +1680,7 @@ fn box_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
drop(guard);
|
//drop(guard);
|
||||||
|
|
||||||
// Use wall collision results to determine if we are against a wall
|
// Use wall collision results to determine if we are against a wall
|
||||||
let mut on_wall = None;
|
let mut on_wall = None;
|
||||||
|
Loading…
Reference in New Issue
Block a user