Skip to content

Commit

Permalink
Make a temporary calc_boost function until the method gets released
Browse files Browse the repository at this point in the history
  • Loading branch information
idanarye committed Oct 11, 2024
1 parent 0661053 commit 1b2cb00
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/builtins/crouch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion src/builtins/knockback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 1b2cb00

Please sign in to comment.