|
|
@ -150,8 +150,8 @@ void jmePhysicsSpace::createPhysicsSpace(jfloat minX, jfloat minY, jfloat minZ, |
|
|
|
dynamicsWorld->getPairCache()->setOverlapFilterCallback(new jmeFilterCallback()); |
|
|
|
dynamicsWorld->getPairCache()->setOverlapFilterCallback(new jmeFilterCallback()); |
|
|
|
dynamicsWorld->setInternalTickCallback(&jmePhysicsSpace::preTickCallback, static_cast<void *> (this), true); |
|
|
|
dynamicsWorld->setInternalTickCallback(&jmePhysicsSpace::preTickCallback, static_cast<void *> (this), true); |
|
|
|
dynamicsWorld->setInternalTickCallback(&jmePhysicsSpace::postTickCallback, static_cast<void *> (this)); |
|
|
|
dynamicsWorld->setInternalTickCallback(&jmePhysicsSpace::postTickCallback, static_cast<void *> (this)); |
|
|
|
if (gContactProcessedCallback == NULL) { |
|
|
|
if (gContactStartedCallback == NULL) { |
|
|
|
gContactProcessedCallback = &jmePhysicsSpace::contactProcessedCallback; |
|
|
|
gContactStartedCallback = &jmePhysicsSpace::contactStartedCallback; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -183,11 +183,10 @@ void jmePhysicsSpace::postTickCallback(btDynamicsWorld *world, btScalar timeStep |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool jmePhysicsSpace::contactProcessedCallback(btManifoldPoint &cp, void *body0, void *body1) { |
|
|
|
void jmePhysicsSpace::contactStartedCallback(btPersistentManifold* const &pm) { |
|
|
|
// printf("contactProcessedCallback %d %dn", body0, body1);
|
|
|
|
const btCollisionObject* co0 = pm->getBody0(); |
|
|
|
btCollisionObject* co0 = (btCollisionObject*) body0; |
|
|
|
const btCollisionObject* co1 = pm->getBody1(); |
|
|
|
jmeUserPointer *up0 = (jmeUserPointer*) co0 -> getUserPointer(); |
|
|
|
jmeUserPointer *up0 = (jmeUserPointer*) co0 -> getUserPointer(); |
|
|
|
btCollisionObject* co1 = (btCollisionObject*) body1; |
|
|
|
|
|
|
|
jmeUserPointer *up1 = (jmeUserPointer*) co1 -> getUserPointer(); |
|
|
|
jmeUserPointer *up1 = (jmeUserPointer*) co1 -> getUserPointer(); |
|
|
|
if (up0 != NULL) { |
|
|
|
if (up0 != NULL) { |
|
|
|
jmePhysicsSpace *dynamicsWorld = (jmePhysicsSpace *)up0->space; |
|
|
|
jmePhysicsSpace *dynamicsWorld = (jmePhysicsSpace *)up0->space; |
|
|
@ -197,18 +196,18 @@ bool jmePhysicsSpace::contactProcessedCallback(btManifoldPoint &cp, void *body0, |
|
|
|
if (javaPhysicsSpace != NULL) { |
|
|
|
if (javaPhysicsSpace != NULL) { |
|
|
|
jobject javaCollisionObject0 = env->NewLocalRef(up0->javaCollisionObject); |
|
|
|
jobject javaCollisionObject0 = env->NewLocalRef(up0->javaCollisionObject); |
|
|
|
jobject javaCollisionObject1 = env->NewLocalRef(up1->javaCollisionObject); |
|
|
|
jobject javaCollisionObject1 = env->NewLocalRef(up1->javaCollisionObject); |
|
|
|
env->CallVoidMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_addCollisionEvent, javaCollisionObject0, javaCollisionObject1, (jlong) & cp); |
|
|
|
for(int i=0;i<pm->getNumContacts();i++){ |
|
|
|
|
|
|
|
env->CallVoidMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_addCollisionEvent, javaCollisionObject0, javaCollisionObject1, (jlong) & pm->getContactPoint(i)); |
|
|
|
|
|
|
|
if (env->ExceptionCheck()) { |
|
|
|
|
|
|
|
env->Throw(env->ExceptionOccurred()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
env->DeleteLocalRef(javaPhysicsSpace); |
|
|
|
env->DeleteLocalRef(javaPhysicsSpace); |
|
|
|
env->DeleteLocalRef(javaCollisionObject0); |
|
|
|
env->DeleteLocalRef(javaCollisionObject0); |
|
|
|
env->DeleteLocalRef(javaCollisionObject1); |
|
|
|
env->DeleteLocalRef(javaCollisionObject1); |
|
|
|
if (env->ExceptionCheck()) { |
|
|
|
|
|
|
|
env->Throw(env->ExceptionOccurred()); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
btDynamicsWorld* jmePhysicsSpace::getDynamicsWorld() { |
|
|
|
btDynamicsWorld* jmePhysicsSpace::getDynamicsWorld() { |
|
|
|