//TODO: boroadphase!
physicsSpaceId = createPhysicsSpace(worldMin.x, worldMin.y, worldMin.z, worldMax.x, worldMax.y, worldMax.z, 3, false);
pQueueTL.set(pQueue);
- physicsSpaceTL.set(this);
+// physicsSpaceTL.set(this);
// collisionConfiguration = new DefaultCollisionConfiguration();
// dispatcher = new CollisionDispatcher(collisionConfiguration);
removeCollisionObject((PhysicsCollisionObject) obj);
} else if (obj instanceof PhysicsJoint) {
removeJoint((PhysicsJoint) obj);
+ } else if (obj == null) {
+ return;
} else {
- throw (new UnsupportedOperationException("Cannot remove this kind of object from the physics space."));
+ throw (new UnsupportedOperationException("Cannot remove this kind of object from the physics space."+obj));
}
}
@Override
protected void finalize() throws Throwable {
- for(PhysicsJoint o : physicsJoints) {
- remove(o);
- }
- physicsJoints.clear();
- for(PhysicsCollisionObject o : physicsNodes.values()) {
- remove(o);
+ for(;;) {
+ try {
+ while(physicsJoints.size() > 0) {
+ remove(physicsJoints.get(0));
+ }
+ while(physicsNodes.size() > 0) {
+ for(PhysicsRigidBody node : physicsNodes.values()) {
+ remove(node);
+ break;
+ }
+ }
+ super.finalize();
+ Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Finalizing PhysicsSpace {0}", Long.toHexString(physicsSpaceId));
+ finalizeNative(physicsSpaceId);
+ break;
+ } catch(Exception ex) {
+ Logger.getLogger(PhysicsSpace.class.getName()).log(Level.SEVERE, "finalize failed.", ex);
+ }
}
- physicsNodes.clear();
- super.finalize();
- Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Finalizing PhysicsSpace {0}", Long.toHexString(physicsSpaceId));
- finalizeNative(physicsSpaceId);
}
private native void finalizeNative(long objectId);
// if(threading){
// cci.m_defaultMaxPersistentManifoldPoolSize = 32768;
// }
- btCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration(cci);
+ collisionConfiguration = new btDefaultCollisionConfiguration(cci);
btVector3 min = btVector3(minX, minY, minZ);
btVector3 max = btVector3(maxX, maxY, maxZ);
- btBroadphaseInterface* broadphase;
+ // btBroadphaseInterface* broadphase;
switch (broadphaseId) {
case 0:
break;
}
- btCollisionDispatcher* dispatcher;
- btConstraintSolver* solver;
+ // btCollisionDispatcher* dispatcher;
+ // btConstraintSolver* solver;
// use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
if (threading) {
btThreadSupportInterface* dispatchThreads = createDispatchThreadSupport(4);
world->getSolverInfo().m_solverMode = SOLVER_SIMD + SOLVER_USE_WARMSTARTING; //+SOLVER_RANDMIZE_ORDER;
world->getDispatchInfo().m_enableSPU = true;
}
-
- broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
+ ghostPairCallback = new btGhostPairCallback();
+ broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(ghostPairCallback);
dynamicsWorld->setGravity(btVector3(0, -9.81f, 0));
}
jmePhysicsSpace::~jmePhysicsSpace() {
+ delete dispatcher;
+ delete solver;
+ delete broadphase;
+ delete collisionConfiguration;
+ delete ghostPairCallback;
delete(dynamicsWorld);
getEnv()->DeleteWeakGlobalRef(this->javaPhysicsSpace);
}
JNIEnv* env;
JavaVM* vm;
btDynamicsWorld* dynamicsWorld;
+
+ btCollisionDispatcher* dispatcher;
+ btConstraintSolver* solver;
+ btBroadphaseInterface* broadphase;
+ btCollisionConfiguration* collisionConfiguration;
+ btOverlappingPairCallback *ghostPairCallback;
+
jobject javaPhysicsSpace;
btThreadSupportInterface* createSolverThreadSupport(int);
btThreadSupportInterface* createDispatchThreadSupport(int);