mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Treat projectile-terrainentity collisions in a manner that's accurate to the voxel collider instead of as a cylinder.
This commit is contained in:
parent
d39d11d2fa
commit
13d98f8f3e
@ -368,6 +368,12 @@ impl<'a> PhysicsData<'a> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't apply repulsion or projectile collision to voxel colliders
|
||||||
|
// in the e-e loop (the latter is handled in the e-t loop)
|
||||||
|
if matches!(collider_other, Some(Collider::Voxel { .. })) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
entity_entity_collision_checks += 1;
|
entity_entity_collision_checks += 1;
|
||||||
|
|
||||||
const MIN_COLLISION_DIST: f32 = 0.3;
|
const MIN_COLLISION_DIST: f32 = 0.3;
|
||||||
@ -403,17 +409,9 @@ impl<'a> PhysicsData<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Don't apply repulsive force to projectiles or if
|
// Don't apply repulsive force to projectiles or if
|
||||||
// we're
|
// we are a terrain-like entity
|
||||||
// colliding
|
|
||||||
// with a terrain-like entity, or if we are a
|
|
||||||
// terrain-like
|
|
||||||
// entity
|
|
||||||
if diff.magnitude_squared() > 0.0
|
if diff.magnitude_squared() > 0.0
|
||||||
&& !is_projectile
|
&& !is_projectile
|
||||||
&& !matches!(
|
|
||||||
collider_other,
|
|
||||||
Some(Collider::Voxel { .. })
|
|
||||||
)
|
|
||||||
&& !matches!(collider, Some(Collider::Voxel { .. }))
|
&& !matches!(collider, Some(Collider::Voxel { .. }))
|
||||||
{
|
{
|
||||||
let force = 400.0
|
let force = 400.0
|
||||||
@ -864,17 +862,19 @@ impl<'a> PhysicsData<'a> {
|
|||||||
.filter_map(|entity| {
|
.filter_map(|entity| {
|
||||||
positions
|
positions
|
||||||
.get(entity)
|
.get(entity)
|
||||||
|
.zip(read.uids.get(entity))
|
||||||
.zip(velocities.get(entity))
|
.zip(velocities.get(entity))
|
||||||
.zip(previous_phys_cache.get(entity))
|
.zip(previous_phys_cache.get(entity))
|
||||||
.zip(read.colliders.get(entity))
|
.zip(read.colliders.get(entity))
|
||||||
.zip(orientations.get(entity))
|
.zip(orientations.get(entity))
|
||||||
.map(|((((pos, vel), previous_cache), collider), ori)| {
|
.map(|(((((pos, uid), vel), previous_cache), collider), ori)| {
|
||||||
(entity, pos, vel, previous_cache, collider, ori)
|
(entity, uid, pos, vel, previous_cache, collider, ori)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.for_each(
|
.for_each(
|
||||||
|(
|
|(
|
||||||
entity_other,
|
entity_other,
|
||||||
|
other,
|
||||||
pos_other,
|
pos_other,
|
||||||
vel_other,
|
vel_other,
|
||||||
previous_cache_other,
|
previous_cache_other,
|
||||||
@ -975,6 +975,10 @@ impl<'a> PhysicsData<'a> {
|
|||||||
vel.0 = ori_from.mul_direction(vel.0) + vel_other;
|
vel.0 = ori_from.mul_direction(vel.0) + vel_other;
|
||||||
tgt_pos = cpos.0;
|
tgt_pos = cpos.0;
|
||||||
|
|
||||||
|
if vel != old_vel {
|
||||||
|
physics_state.touch_entities.push(*other);
|
||||||
|
}
|
||||||
|
|
||||||
// union in the state updates, so that the state isn't just
|
// union in the state updates, so that the state isn't just
|
||||||
// based on the most
|
// based on the most
|
||||||
// recent terrain that collision was attempted with
|
// recent terrain that collision was attempted with
|
||||||
|
Loading…
Reference in New Issue
Block a user