|
|
|
@ -36,6 +36,7 @@ |
|
|
|
|
* Author: Normen Hansen |
|
|
|
|
*/ |
|
|
|
|
jmePhysicsSpace::jmePhysicsSpace(JNIEnv* env, jobject javaSpace) { |
|
|
|
|
printf("hello\n"); |
|
|
|
|
//TODO: global ref? maybe not -> cleaning, rather callback class?
|
|
|
|
|
this->javaPhysicsSpace = env->NewWeakGlobalRef(javaSpace); |
|
|
|
|
this->env = env; |
|
|
|
@ -117,16 +118,16 @@ void jmePhysicsSpace::createPhysicsSpace(jfloat minX, jfloat minY, jfloat minZ, |
|
|
|
|
jmeUserPointer *up1 = (jmeUserPointer*) co1 -> getUserPointer(); |
|
|
|
|
if (up0 != NULL && up1 != NULL) { |
|
|
|
|
collides = (up0->group & up1->groups) != 0 || (up1->group & up0->groups) != 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(collides){ |
|
|
|
|
jmePhysicsSpace *dynamicsWorld = (jmePhysicsSpace *)up0->space; |
|
|
|
|
JNIEnv* env = dynamicsWorld->getEnv(); |
|
|
|
|
jobject javaPhysicsSpace = env->NewLocalRef(dynamicsWorld->getJavaPhysicsSpace()); |
|
|
|
|
jobject javaCollisionObject0 = env->NewLocalRef(up0->javaCollisionObject); |
|
|
|
|
jobject javaCollisionObject1 = env->NewLocalRef(up1->javaCollisionObject); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jboolean notifyResult = env->CallBooleanMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_notifyCollisionGroupListeners, javaCollisionObject0, javaCollisionObject1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
env->DeleteLocalRef(javaPhysicsSpace); |
|
|
|
|
env->DeleteLocalRef(javaCollisionObject0); |
|
|
|
|
env->DeleteLocalRef(javaCollisionObject1); |
|
|
|
@ -135,7 +136,7 @@ void jmePhysicsSpace::createPhysicsSpace(jfloat minX, jfloat minY, jfloat minZ, |
|
|
|
|
env->Throw(env->ExceptionOccurred()); |
|
|
|
|
return collides; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collides = (bool) notifyResult; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -221,4 +222,4 @@ jobject jmePhysicsSpace::getJavaPhysicsSpace() { |
|
|
|
|
|
|
|
|
|
jmePhysicsSpace::~jmePhysicsSpace() { |
|
|
|
|
delete(dynamicsWorld); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|