From 0a648e2e8f59a2779bbfbedb6bd1ecb97030e0ec Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 26 Aug 2021 19:00:28 -0400 Subject: [PATCH 1/2] Fixed arrows dealing damage to entities if entity walked near arrow that stuck to terrain several seconds prior. --- common/systems/src/phys.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/systems/src/phys.rs b/common/systems/src/phys.rs index e404e24c72..86e0c765a5 100644 --- a/common/systems/src/phys.rs +++ b/common/systems/src/phys.rs @@ -419,7 +419,10 @@ impl<'a> PhysicsData<'a> { <= pos_other.z + z_limits_other.1 * previous_cache_other.scale { - if !collided { + // If entities have not yet collided this tick (but just + // did) and if entity is either in mid air or is not sticky, + // then mark them as colliding with the other entity + if !collided && (is_mid_air || !is_sticky) { physics.touch_entities.insert(*other); entity_entity_collisions += 1; } From 7dcbd6aaf0da82906f0e5fc9ce8638d3ebf5242c Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 28 Aug 2021 18:31:44 -0400 Subject: [PATCH 2/2] Renamed variable to make more explicit what it does. --- common/systems/src/phys.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/systems/src/phys.rs b/common/systems/src/phys.rs index 86e0c765a5..b75c7e9315 100644 --- a/common/systems/src/phys.rs +++ b/common/systems/src/phys.rs @@ -401,7 +401,7 @@ impl<'a> PhysicsData<'a> { .ceil() as usize; let step_delta = 1.0 / increments as f32; - let mut collided = false; + let mut collision_registered = false; for i in 0..increments { let factor = i as f32 * step_delta; @@ -422,7 +422,7 @@ impl<'a> PhysicsData<'a> { // If entities have not yet collided this tick (but just // did) and if entity is either in mid air or is not sticky, // then mark them as colliding with the other entity - if !collided && (is_mid_air || !is_sticky) { + if !collision_registered && (is_mid_air || !is_sticky) { physics.touch_entities.insert(*other); entity_entity_collisions += 1; } @@ -475,7 +475,7 @@ impl<'a> PhysicsData<'a> { Vec3::from(diff.normalized()) * force * step_delta; } - collided = true; + collision_registered = true; } } },