- add some fixes for collision callbacks and android to native bullet

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8429 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent 79c807c861
commit 2360562947
  1. 5
      engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp
  2. 4
      engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.cpp
  3. 1
      engine/src/bullet/native/jmeClasses.cpp
  4. 42
      engine/src/bullet/native/jmePhysicsSpace.cpp

@ -183,8 +183,9 @@ extern "C" {
{ {
btCollisionObject *co1 = (btCollisionObject *)pair.m_pProxy0->m_clientObject; btCollisionObject *co1 = (btCollisionObject *)pair.m_pProxy0->m_clientObject;
jmeUserPointer *up1 = (jmeUserPointer*)co1 -> getUserPointer(); jmeUserPointer *up1 = (jmeUserPointer*)co1 -> getUserPointer();
jobject javaCollisionObject1 = m_env->NewLocalRef(up1->javaCollisionObject);
m_env->CallVoidMethod(m_object, jmeClasses::PhysicsGhostObject_addOverlappingObject, up1->javaCollisionObject); m_env->CallVoidMethod(m_object, jmeClasses::PhysicsGhostObject_addOverlappingObject, javaCollisionObject1);
m_env->DeleteLocalRef(javaCollisionObject1);
if (m_env->ExceptionCheck()) { if (m_env->ExceptionCheck()) {
m_env->Throw(m_env->ExceptionOccurred()); m_env->Throw(m_env->ExceptionOccurred());
return false; return false;

@ -90,8 +90,6 @@ extern "C" {
(JNIEnv *env, jclass clazz, jlong shapeId, jobject callback) { (JNIEnv *env, jclass clazz, jlong shapeId, jobject callback) {
btCollisionShape* shape = (btCollisionShape*) shapeId; btCollisionShape* shape = (btCollisionShape*) shapeId;
if (shape->isConcave()) { if (shape->isConcave()) {
fprintf(stdout,"Concave shape");
fflush(stdout);
btConcaveShape* concave = (btConcaveShape*) shape; btConcaveShape* concave = (btConcaveShape*) shape;
DebugCallback* clb = new DebugCallback(env, callback); DebugCallback* clb = new DebugCallback(env, callback);
btVector3 min = btVector3(-1e30, -1e30, -1e30); btVector3 min = btVector3(-1e30, -1e30, -1e30);
@ -99,8 +97,6 @@ extern "C" {
concave->processAllTriangles(clb, min, max); concave->processAllTriangles(clb, min, max);
delete(clb); delete(clb);
} else if (shape->isConvex()) { } else if (shape->isConvex()) {
fprintf(stdout,"Convex shape");
fflush(stdout);
btConvexShape* convexShape = (btConvexShape*) shape; btConvexShape* convexShape = (btConvexShape*) shape;
// Check there is a hull shape to render // Check there is a hull shape to render
if (convexShape->getUserPointer() == NULL) { if (convexShape->getUserPointer() == NULL) {

@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "jmeClasses.h" #include "jmeClasses.h"
#include <stdio.h>
/** /**
* Author: Normen Hansen * Author: Normen Hansen

@ -52,7 +52,7 @@ void jmePhysicsSpace::attachThread() {
#ifdef JNI_VERSION_1_2 #ifdef JNI_VERSION_1_2
vm->AttachCurrentThread((void**) &env, NULL); vm->AttachCurrentThread((void**) &env, NULL);
#else #else
vm->AttachCurrentThread(vm, &env, NULL); vm->AttachCurrentThread(&env, NULL);
#endif #endif
} }
@ -208,20 +208,28 @@ void jmePhysicsSpace::createPhysicsSpace(jfloat minX, jfloat minY, jfloat minZ,
void jmePhysicsSpace::preTickCallback(btDynamicsWorld *world, btScalar timeStep) { void jmePhysicsSpace::preTickCallback(btDynamicsWorld *world, btScalar timeStep) {
jmePhysicsSpace* dynamicsWorld = (jmePhysicsSpace*) world->getWorldUserInfo(); jmePhysicsSpace* dynamicsWorld = (jmePhysicsSpace*) world->getWorldUserInfo();
JNIEnv* env = dynamicsWorld->getEnv(); JNIEnv* env = dynamicsWorld->getEnv();
env->CallVoidMethod(dynamicsWorld->getJavaPhysicsSpace(), jmeClasses::PhysicsSpace_preTick, timeStep); jobject javaPhysicsSpace = env->NewLocalRef(dynamicsWorld->getJavaPhysicsSpace());
if (env->ExceptionCheck()) { if (javaPhysicsSpace != NULL) {
env->Throw(env->ExceptionOccurred()); env->CallVoidMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_preTick, timeStep);
return; env->DeleteLocalRef(javaPhysicsSpace);
if (env->ExceptionCheck()) {
env->Throw(env->ExceptionOccurred());
return;
}
} }
} }
void jmePhysicsSpace::postTickCallback(btDynamicsWorld *world, btScalar timeStep) { void jmePhysicsSpace::postTickCallback(btDynamicsWorld *world, btScalar timeStep) {
jmePhysicsSpace* dynamicsWorld = (jmePhysicsSpace*) world->getWorldUserInfo(); jmePhysicsSpace* dynamicsWorld = (jmePhysicsSpace*) world->getWorldUserInfo();
JNIEnv* env = dynamicsWorld->getEnv(); JNIEnv* env = dynamicsWorld->getEnv();
env->CallVoidMethod(dynamicsWorld->getJavaPhysicsSpace(), jmeClasses::PhysicsSpace_postTick, timeStep); jobject javaPhysicsSpace = env->NewLocalRef(dynamicsWorld->getJavaPhysicsSpace());
if (env->ExceptionCheck()) { if (javaPhysicsSpace != NULL) {
env->Throw(env->ExceptionOccurred()); env->CallVoidMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_postTick, timeStep);
return; env->DeleteLocalRef(javaPhysicsSpace);
if (env->ExceptionCheck()) {
env->Throw(env->ExceptionOccurred());
return;
}
} }
} }
@ -235,10 +243,18 @@ bool jmePhysicsSpace::contactProcessedCallback(btManifoldPoint &cp, void *body0,
jmePhysicsSpace *dynamicsWorld = up0->space; jmePhysicsSpace *dynamicsWorld = up0->space;
if (dynamicsWorld != NULL) { if (dynamicsWorld != NULL) {
JNIEnv* env = dynamicsWorld->getEnv(); JNIEnv* env = dynamicsWorld->getEnv();
env->CallVoidMethod(dynamicsWorld->getJavaPhysicsSpace(), jmeClasses::PhysicsSpace_addCollisionEvent, up0->javaCollisionObject, up1->javaCollisionObject, (jlong) & cp); jobject javaPhysicsSpace = env->NewLocalRef(dynamicsWorld->getJavaPhysicsSpace());
if (env->ExceptionCheck()) { if (javaPhysicsSpace != NULL) {
env->Throw(env->ExceptionOccurred()); jobject javaCollisionObject0 = env->NewLocalRef(up0->javaCollisionObject);
return true; jobject javaCollisionObject1 = env->NewLocalRef(up1->javaCollisionObject);
env->CallVoidMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_addCollisionEvent, javaCollisionObject0, javaCollisionObject1, (jlong) & cp);
env->DeleteLocalRef(javaPhysicsSpace);
env->DeleteLocalRef(javaCollisionObject0);
env->DeleteLocalRef(javaCollisionObject1);
if (env->ExceptionCheck()) {
env->Throw(env->ExceptionOccurred());
return true;
}
} }
} }
} }

Loading…
Cancel
Save