Fixed rare physics crash

This commit is contained in:
Anuken
2026-09-27 18:45:23 -04:00
parent 663b0b8737
commit f3bfa418a5
2 changed files with 11 additions and 2 deletions
+10 -1
View File
@@ -26,6 +26,7 @@ public class PhysicsProcess implements AsyncProcess{
private PhysicsWorld[] physics;
private Seq<PhysicRef> refs = new Seq<>(false, 20, PhysicRef.class);
private Seq<Future<?>> futures = new Seq<>(false, layers, Future.class);
private Seq<PhysicRef> pendingAdds = new Seq<>(false, 20, PhysicRef.class);
private static volatile long maxPhysicsTime = 0;
@@ -44,7 +45,8 @@ public class PhysicsProcess implements AsyncProcess{
PhysicRef ref = new PhysicRef(unit, body);
refs.add(ref);
if(ref.lastLayer >= 0) physics[ref.lastLayer].add(body);
//defer adds until physics update is done
pendingAdds.add(ref);
}
@Override
@@ -68,6 +70,13 @@ public class PhysicsProcess implements AsyncProcess{
PerfCounter.unitPhysicsAsync.add(maxPhysicsTime);
maxPhysicsTime = 0;
//flush newly added entities
for(int i = 0; i < pendingAdds.size; i++){
PhysicRef ref = pendingAdds.items[i];
if(ref.lastLayer >= 0) physics[ref.lastLayer].add(ref.body);
}
pendingAdds.clear();
//move entities
for(PhysicRef ref : refs){
Physicsc entity = ref.entity;
+1 -1
View File
@@ -26,4 +26,4 @@ org.gradle.caching=true
org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000
android.enableR8.fullMode=false
archash=8eb00ffff0
archash=7445105cd2