- 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;
jmeUserPointer *up1 = (jmeUserPointer*)co1 -> getUserPointer();
m_env->CallVoidMethod(m_object, jmeClasses::PhysicsGhostObject_addOverlappingObject, up1->javaCollisionObject);
jobject javaCollisionObject1 = m_env->NewLocalRef(up1->javaCollisionObject);
m_env->CallVoidMethod(m_object, jmeClasses::PhysicsGhostObject_addOverlappingObject, javaCollisionObject1);
m_env->DeleteLocalRef(javaCollisionObject1);
if (m_env->ExceptionCheck()) {
m_env->Throw(m_env->ExceptionOccurred());
return false;

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

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

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