mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Made the pushback cache require colliders
This commit is contained in:
@ -172,15 +172,14 @@ impl<'a> PhysicsData<'a> {
|
|||||||
// Add PreviousPhysCache for all relevant entities
|
// Add PreviousPhysCache for all relevant entities
|
||||||
for entity in (
|
for entity in (
|
||||||
&self.read.entities,
|
&self.read.entities,
|
||||||
|
&self.read.colliders,
|
||||||
&self.write.velocities,
|
&self.write.velocities,
|
||||||
&self.write.positions,
|
&self.write.positions,
|
||||||
!&self.write.previous_phys_cache,
|
!&self.write.previous_phys_cache,
|
||||||
!&self.read.mountings,
|
!&self.read.mountings,
|
||||||
!&self.read.beams,
|
|
||||||
!&self.read.shockwaves,
|
|
||||||
)
|
)
|
||||||
.join()
|
.join()
|
||||||
.map(|(e, _, _, _, _, _, _)| e)
|
.map(|(e, _, _, _, _, _)| e)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
{
|
{
|
||||||
let _ = self
|
let _ = self
|
||||||
@ -200,30 +199,28 @@ impl<'a> PhysicsData<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update PreviousPhysCache
|
// Update PreviousPhysCache
|
||||||
for (_, vel, position, ori, mut phys_cache, collider, scale, cs, _, _, _) in (
|
for (_, vel, position, ori, mut phys_cache, collider, scale, cs, _) in (
|
||||||
&self.read.entities,
|
&self.read.entities,
|
||||||
&self.write.velocities,
|
&self.write.velocities,
|
||||||
&self.write.positions,
|
&self.write.positions,
|
||||||
&self.write.orientations,
|
&self.write.orientations,
|
||||||
&mut self.write.previous_phys_cache,
|
&mut self.write.previous_phys_cache,
|
||||||
self.read.colliders.maybe(),
|
&self.read.colliders,
|
||||||
self.read.scales.maybe(),
|
self.read.scales.maybe(),
|
||||||
self.read.char_states.maybe(),
|
self.read.char_states.maybe(),
|
||||||
!&self.read.mountings,
|
!&self.read.mountings,
|
||||||
!&self.read.beams,
|
|
||||||
!&self.read.shockwaves,
|
|
||||||
)
|
)
|
||||||
.join()
|
.join()
|
||||||
{
|
{
|
||||||
let scale = scale.map(|s| s.0).unwrap_or(1.0);
|
let scale = scale.map(|s| s.0).unwrap_or(1.0);
|
||||||
let z_limits = calc_z_limit(cs, collider);
|
let z_limits = calc_z_limit(cs, Some(collider));
|
||||||
let (z_min, z_max) = z_limits;
|
let (z_min, z_max) = z_limits;
|
||||||
let (z_min, z_max) = (z_min * scale, z_max * scale);
|
let (z_min, z_max) = (z_min * scale, z_max * scale);
|
||||||
let half_height = (z_max - z_min) / 2.0;
|
let half_height = (z_max - z_min) / 2.0;
|
||||||
|
|
||||||
phys_cache.velocity_dt = vel.0 * self.read.dt.0;
|
phys_cache.velocity_dt = vel.0 * self.read.dt.0;
|
||||||
let entity_center = position.0 + Vec3::new(0.0, 0.0, z_min + half_height);
|
let entity_center = position.0 + Vec3::new(0.0, 0.0, z_min + half_height);
|
||||||
let flat_radius = collider.map_or(0.5, Collider::bounding_radius) * scale;
|
let flat_radius = collider.bounding_radius() * scale;
|
||||||
let radius = (flat_radius.powi(2) + half_height.powi(2)).sqrt();
|
let radius = (flat_radius.powi(2) + half_height.powi(2)).sqrt();
|
||||||
|
|
||||||
// Move center to the middle between OLD and OLD+VEL_DT
|
// Move center to the middle between OLD and OLD+VEL_DT
|
||||||
@ -234,14 +231,14 @@ impl<'a> PhysicsData<'a> {
|
|||||||
phys_cache.scaled_radius = flat_radius;
|
phys_cache.scaled_radius = flat_radius;
|
||||||
|
|
||||||
let neighborhood_radius = match collider {
|
let neighborhood_radius = match collider {
|
||||||
Some(Collider::CapsulePrism { radius, .. }) => radius * scale,
|
Collider::CapsulePrism { radius, .. } => radius * scale,
|
||||||
Some(Collider::Voxel { .. } | Collider::Point) | None => flat_radius,
|
Collider::Voxel { .. } | Collider::Point => flat_radius,
|
||||||
};
|
};
|
||||||
phys_cache.neighborhood_radius = neighborhood_radius;
|
phys_cache.neighborhood_radius = neighborhood_radius;
|
||||||
|
|
||||||
let ori = ori.to_quat();
|
let ori = ori.to_quat();
|
||||||
let origins = match collider {
|
let origins = match collider {
|
||||||
Some(Collider::CapsulePrism { p0, p1, .. }) => {
|
Collider::CapsulePrism { p0, p1, .. } => {
|
||||||
let a = p1 - p0;
|
let a = p1 - p0;
|
||||||
let len = a.magnitude();
|
let len = a.magnitude();
|
||||||
// If origins are close enough, our capsule prism is cylinder
|
// If origins are close enough, our capsule prism is cylinder
|
||||||
@ -275,7 +272,7 @@ impl<'a> PhysicsData<'a> {
|
|||||||
Some((p0, p1))
|
Some((p0, p1))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(Collider::Voxel { .. } | Collider::Point) | None => None,
|
Collider::Voxel { .. } | Collider::Point => None,
|
||||||
};
|
};
|
||||||
phys_cache.origins = origins;
|
phys_cache.origins = origins;
|
||||||
phys_cache.ori = ori;
|
phys_cache.ori = ori;
|
||||||
@ -338,7 +335,7 @@ impl<'a> PhysicsData<'a> {
|
|||||||
&mut write.velocities,
|
&mut write.velocities,
|
||||||
previous_phys_cache,
|
previous_phys_cache,
|
||||||
&read.masses,
|
&read.masses,
|
||||||
read.colliders.maybe(),
|
&read.colliders,
|
||||||
!&read.mountings,
|
!&read.mountings,
|
||||||
read.stickies.maybe(),
|
read.stickies.maybe(),
|
||||||
&mut write.physics_states,
|
&mut write.physics_states,
|
||||||
@ -386,7 +383,7 @@ impl<'a> PhysicsData<'a> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let z_limits = calc_z_limit(char_state_maybe, collider);
|
let z_limits = calc_z_limit(char_state_maybe, Some(collider));
|
||||||
|
|
||||||
// Resets touch_entities in physics
|
// Resets touch_entities in physics
|
||||||
physics.touch_entities.clear();
|
physics.touch_entities.clear();
|
||||||
@ -482,7 +479,7 @@ impl<'a> PhysicsData<'a> {
|
|||||||
previous_cache_other,
|
previous_cache_other,
|
||||||
z_limits,
|
z_limits,
|
||||||
z_limits_other,
|
z_limits_other,
|
||||||
collider,
|
Some(collider),
|
||||||
collider_other,
|
collider_other,
|
||||||
*mass,
|
*mass,
|
||||||
*mass_other,
|
*mass_other,
|
||||||
|
Reference in New Issue
Block a user