Skip to content

Commit

Permalink
Avert collision static detection rounding error (minetest#12822)
Browse files Browse the repository at this point in the history
  • Loading branch information
TurkeyMcMac committed Sep 30, 2022
1 parent 6eb7d57 commit e832cee
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/collision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,12 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
time_notification_done = false;
}

v3f newpos_f = *pos_f + (*speed_f + accel_f * 0.5f * dtime) * dtime;
v3f dpos_f = (*speed_f + accel_f * 0.5f * dtime) * dtime;
v3f newpos_f = *pos_f + dpos_f;
*speed_f += accel_f * dtime;

// If the object is static, there are no collisions
if (newpos_f == *pos_f)
if (dpos_f == v3f())
return result;

// Limit speed for avoiding hangs
Expand Down

0 comments on commit e832cee

Please sign in to comment.