mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-10-02 11:10:50 +03:00
Fixed rare physics crash
This commit is contained in:
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user