This commit is contained in:
Anuken
2025-09-26 12:33:04 -04:00
parent eb3648bcb5
commit fd632a3b55
2 changed files with 12 additions and 1 deletions

View File

@@ -129,6 +129,7 @@ public class PhysicsProcess implements AsyncProcess{
private final Seq<PhysicsBody> seq = new Seq<>(PhysicsBody.class);
private final Rect rect = new Rect();
private final Vec2 vec = new Vec2();
private final Rand rand = new Rand();
public PhysicsWorld(Rect bounds){
for(int i = 0; i < layers; i++){
@@ -180,7 +181,14 @@ public class PhysicsProcess implements AsyncProcess{
float dst = Mathf.dst(body.x, body.y, other.x, other.y);
if(dst < rs){
vec.set(body.x - other.x, body.y - other.y).setLength(rs - dst);
vec.set(body.x - other.x, body.y - other.y);
if(vec.isZero()){ //exact stacked bodies will move in random directions away from each other
vec.trns(rand.random(360f), rs - dst);
}else{
vec.setLength(rs - dst);
}
float ms = body.mass + other.mass;
float m1 = other.mass / ms, m2 = body.mass / ms;

View File

@@ -752,6 +752,9 @@ public class MobileInput extends InputHandler implements GestureListener{
if(!commandMode){
queueCommandMode = false;
}else{
mode = none;
schematicMode = false;
}
//cannot rebuild and place at the same time