Open GoogleCodeExporter opened 8 years ago
[deleted comment]
Adding setContactCallbacks() in the PhysicsSpace constructor to the updateQueue
seems to fix this issue.
setContactCallbacks() calls BulletGlobals.setContactAddedCallback() which then
adds the ContactCallback to a threadlocal.
public static void setContactAddedCallback(ContactAddedCallback callback) {
threadLocal.get().gContactAddedCallback = callback;
}
Index: src/com/jmex/jbullet/PhysicsSpace.java
===================================================================
--- src/com/jmex/jbullet/PhysicsSpace.java (revision 607)
+++ src/com/jmex/jbullet/PhysicsSpace.java (working copy)
@@ -31,6 +31,13 @@
*/
package com.jmex.jbullet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Future;
+
import com.bulletphysics.BulletGlobals;
import com.bulletphysics.ContactAddedCallback;
import com.bulletphysics.ContactDestroyedCallback;
@@ -58,17 +65,11 @@
import com.jmex.jbullet.collision.CollisionListener;
import com.jmex.jbullet.collision.CollisionObject;
import com.jmex.jbullet.joints.PhysicsJoint;
-import com.jmex.jbullet.nodes.PhysicsGhostNode;
import com.jmex.jbullet.nodes.PhysicsCharacterNode;
-import com.jmex.jbullet.nodes.PhysicsVehicleNode;
+import com.jmex.jbullet.nodes.PhysicsGhostNode;
import com.jmex.jbullet.nodes.PhysicsNode;
+import com.jmex.jbullet.nodes.PhysicsVehicleNode;
import com.jmex.jbullet.util.Converter;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Future;
/**
* <p>PhysicsSpace - The central jbullet-jme physics space</p>
@@ -204,7 +205,13 @@
broadphase.getOverlappingPairCache().setInternalGhostPairCallback(new GhostPairCallback());
GImpactCollisionAlgorithm.registerAlgorithm(dispatcher);
- setContactCallbacks();
+ pQueue.enqueue(new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ setContactCallbacks();
+ return null;
+ }
+ });
}
private void setContactCallbacks() {
Original comment by christoph.luder
on 21 Feb 2011 at 8:04
Original issue reported on code.google.com by
normen667
on 17 Feb 2010 at 8:53