From 23995b2ef1ba499f9018ae5d164a1fd7eefaf47b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20B=C3=B6klin?= Date: Sat, 24 Apr 2021 18:40:28 +0200 Subject: [PATCH] Preserve current fluid medium --- common/systems/src/phys.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/common/systems/src/phys.rs b/common/systems/src/phys.rs index 24f387218e..5467202658 100644 --- a/common/systems/src/phys.rs +++ b/common/systems/src/phys.rs @@ -863,11 +863,12 @@ impl<'a> PhysicsData<'a> { depth, vel: Vel::zero(), }) - .or_else(|| { - Some(Fluid::Air { + .or_else(|| match physics_state.in_fluid { + Some(Fluid::Water { .. }) => Some(Fluid::Air { elevation: pos.0.z, - vel: Vel::zero(), - }) + vel: Vel::default(), + }), + fluid => fluid, }); tgt_pos = pos.0; @@ -1539,11 +1540,12 @@ fn box_voxel_collision<'a, T: BaseVol + ReadVol>( depth, vel: Vel::zero(), }) - .or_else(|| { - Some(Fluid::Air { + .or_else(|| match physics_state.in_fluid { + Some(Fluid::Water { .. }) => Some(Fluid::Air { elevation: pos.0.z, - vel: Vel::zero(), - }) + vel: Vel::default(), + }), + fluid => fluid, }); }