diff --git a/src/builtins/crouch.rs b/src/builtins/crouch.rs index 0752cb079..9a075352a 100644 --- a/src/builtins/crouch.rs +++ b/src/builtins/crouch.rs @@ -119,7 +119,7 @@ impl TnuaAction for TnuaBuiltinCrouch { let impulse_or_spring_force = |spring_offset: Float| -> TnuaVelChange { let spring_force = spring_force(spring_offset); - let spring_force_boost = spring_force.calc_boost(ctx.frame_duration); + let spring_force_boost = crate::util::calc_boost(&spring_force, ctx.frame_duration); let impulse_boost = self.impulse_boost(spring_offset); if spring_force_boost.length_squared() < impulse_boost.powi(2) { TnuaVelChange::boost(impulse_boost * ctx.up_direction.adjust_precision()) diff --git a/src/builtins/knockback.rs b/src/builtins/knockback.rs index c2266ef32..34ebe2dd9 100644 --- a/src/builtins/knockback.rs +++ b/src/builtins/knockback.rs @@ -108,7 +108,7 @@ impl TnuaAction for TnuaBuiltinKnockback { if boundary.is_cleared() { return TnuaActionLifecycleDirective::Finished; } else { - let regular_boost = motor.lin.calc_boost(ctx.frame_duration); + let regular_boost = crate::util::calc_boost(&motor.lin, ctx.frame_duration); if let Some((component_direction, component_limit)) = boundary .calc_boost_part_on_boundary_axis_after_limit( ctx.tracker.velocity, diff --git a/src/util/mod.rs b/src/util/mod.rs index 4bc835c4b..10a2222b2 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -147,3 +147,12 @@ pub fn rotation_arc_around_axis( Quaternion::from_rotation_arc_2d(Vector2::X, desired_forward_in_plane_coords); Some(rotation_to_set_forward.xyz().z) } + +/// Temporary until we get an official release of the physics integration layer crate with +/// `calc_boost` in it. +pub(crate) fn calc_boost( + vel_change: &bevy_tnua_physics_integration_layer::data_for_backends::TnuaVelChange, + frame_duration: Float, +) -> Vector3 { + vel_change.acceleration * frame_duration + vel_change.boost +}