From 72167db3971b1ea38173dfd8ac3b98b517e13480 Mon Sep 17 00:00:00 2001 From: Ygor Souza Date: Thu, 22 Apr 2021 21:12:35 +0200 Subject: [PATCH] Skip physics pass for arrows stuck on surfaces This keeps the arrow velocity from changing, which is what was causing the ProjectileHit outcome to be pushed multiple times for the same arrow, since the outcome checks if the arrow velocity is above a given threshold. --- common/systems/src/phys.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/systems/src/phys.rs b/common/systems/src/phys.rs index 83bb7975f0..80d881fdab 100644 --- a/common/systems/src/phys.rs +++ b/common/systems/src/phys.rs @@ -562,6 +562,7 @@ impl<'a> PhysicsData<'a> { ( positions, velocities, + read.stickies.maybe(), &read.bodies, &write.physics_states, &read.masses, @@ -574,14 +575,17 @@ impl<'a> PhysicsData<'a> { prof_span!(guard, "velocity update rayon job"); guard }, - |_guard, (pos, vel, body, physics_state, mass, density, _)| { + |_guard, (pos, vel, sticky, body, physics_state, mass, density, _)| { let in_loaded_chunk = read .terrain .get_key(read.terrain.pos_key(pos.0.map(|e| e.floor() as i32))) .is_some(); // Apply physics only if in a loaded chunk - if in_loaded_chunk { + if in_loaded_chunk + // And not already stuck on a block (e.g., for arrows) + && !(physics_state.on_surface().is_some() && sticky.is_some()) + { // Clamp dt to an effective 10 TPS, to prevent gravity from slamming the // players into the floor when stationary if other systems cause the server // to lag (as observed in the 0.9 release party).