mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-27 06:51:30 -08:00
Clamp movement vectors to prevent infinite loops
This commit is contained in:
parent
f5a0b5ec1a
commit
ca19d525c4
1 changed files with 6 additions and 2 deletions
|
|
@ -12,7 +12,7 @@ import static mindustry.Vars.*;
|
|||
|
||||
public class EntityCollisions{
|
||||
//move in 1-unit chunks (can this be made more efficient?)
|
||||
private static final float seg = 1f;
|
||||
private static final float seg = 1f, maxDelta = 1000f;
|
||||
|
||||
//tile collisions
|
||||
private Vec2 vector = new Vec2(), l1 = new Vec2();
|
||||
|
|
@ -34,7 +34,11 @@ public class EntityCollisions{
|
|||
}
|
||||
|
||||
public void move(Hitboxc entity, float deltax, float deltay, SolidPred solidCheck){
|
||||
if(Math.abs(deltax) < 0.0001f & Math.abs(deltay) < 0.0001f) return;
|
||||
//check for NaN
|
||||
if((Math.abs(deltax) < 0.0001f && Math.abs(deltay) < 0.0001f) || deltax != deltax || deltay != deltay) return;
|
||||
|
||||
deltax = Mathf.clamp(deltax, -maxDelta, maxDelta);
|
||||
deltay = Mathf.clamp(deltay, -maxDelta, maxDelta);
|
||||
|
||||
boolean movedx = false;
|
||||
entity.hitboxTile(r1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue