From 087197aff414c61026da95d5f5dad6b2f295fb1f Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Sun, 24 Jun 2018 17:08:05 +0200 Subject: [PATCH] Fix bullet skipping enqueued tasks - #867 --- .../src/main/java/com/jme3/bullet/PhysicsSpace.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java b/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java index f0df9740c..bfb0c4661 100644 --- a/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java +++ b/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java @@ -193,19 +193,16 @@ public class PhysicsSpace { private native long createPhysicsSpace(float minX, float minY, float minZ, float maxX, float maxY, float maxZ, int broadphaseType, boolean threading); private void preTick_native(float f) { - AppTask task = pQueue.poll(); - task = pQueue.poll(); - while (task != null) { - while (task.isCancelled()) { - task = pQueue.poll(); - } - try { + AppTask task; + while((task=pQueue.poll())!=null){ + if(task.isCancelled())continue; + try{ task.invoke(); } catch (Exception ex) { logger.log(Level.SEVERE, null, ex); } - task = pQueue.poll(); } + for (Iterator it = tickListeners.iterator(); it.hasNext();) { PhysicsTickListener physicsTickCallback = it.next(); physicsTickCallback.prePhysicsTick(this, f);