Gracefully handle 0 acceleration for walking targets #19

Merged
Quaternions merged 1 commits from aidan9382/strafe-project:walk-0-accel into master 2025-11-18 19:47:05 +00:00

View File

@@ -100,7 +100,6 @@ enum TransientAcceleration{
time:Time,
},
//walk target will never be reached
#[expect(dead_code)]
Unreachable{
acceleration:Planar64Vec3,
}
@@ -116,6 +115,10 @@ impl TransientAcceleration{
fn with_target_diff(target_diff:Planar64Vec3,accel:Planar64,time:Time)->Self{
if target_diff==vec3::ZERO{
TransientAcceleration::Reached
}else if accel==Planar64::ZERO{
aidan9382 marked this conversation as resolved Outdated

Please use Planar64::ZERO instead of 0, 0 is implicitly converted to Planar64 for the comparison at run time.

Please use Planar64::ZERO instead of 0, 0 is implicitly converted to Planar64 for the comparison at run time.

my brain just assumed it was a static number for some reason

my brain just assumed it was a static number for some reason
TransientAcceleration::Unreachable{
acceleration:vec3::ZERO
}
}else{
//normal friction acceleration is clippedAcceleration.dot(normal)*friction
TransientAcceleration::Reachable{