From a1dd0f9061de2d3d8ff80fd56a29c69897ccc4a6 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Sun, 3 Jun 2012 01:08:10 +0000 Subject: [PATCH] - fix bullet ghost overlap, thanks to @iwgeric git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9449 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- ...m_jme3_bullet_objects_PhysicsGhostObject.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/engine/src/bullet-native/com_jme3_bullet_objects_PhysicsGhostObject.cpp b/engine/src/bullet-native/com_jme3_bullet_objects_PhysicsGhostObject.cpp index 2fb48f54b..ddd89c411 100644 --- a/engine/src/bullet-native/com_jme3_bullet_objects_PhysicsGhostObject.cpp +++ b/engine/src/bullet-native/com_jme3_bullet_objects_PhysicsGhostObject.cpp @@ -172,17 +172,24 @@ extern "C" { class jmeGhostOverlapCallback : public btOverlapCallback { JNIEnv* m_env; jobject m_object; + btCollisionObject *m_ghost; public: - jmeGhostOverlapCallback(JNIEnv *env, jobject object) + jmeGhostOverlapCallback(JNIEnv *env, jobject object, btCollisionObject *ghost) :m_env(env), - m_object(object) + m_object(object), + m_ghost(ghost) { } virtual ~jmeGhostOverlapCallback() {} virtual bool processOverlap(btBroadphasePair& pair) { - btCollisionObject *co1 = (btCollisionObject *)pair.m_pProxy1->m_clientObject; - jmeUserPointer *up1 = (jmeUserPointer*)co1 -> getUserPointer(); + btCollisionObject *other; + if(pair.m_pProxy1->m_clientObject == m_ghost){ + other = (btCollisionObject *)pair.m_pProxy0->m_clientObject; + }else{ + other = (btCollisionObject *)pair.m_pProxy1->m_clientObject; + } + jmeUserPointer *up1 = (jmeUserPointer*)other -> getUserPointer(); jobject javaCollisionObject1 = m_env->NewLocalRef(up1->javaCollisionObject); m_env->CallVoidMethod(m_object, jmeClasses::PhysicsGhostObject_addOverlappingObject, javaCollisionObject1); m_env->DeleteLocalRef(javaCollisionObject1); @@ -209,7 +216,7 @@ extern "C" { return; } btHashedOverlappingPairCache * pc = ghost->getOverlappingPairCache(); - jmeGhostOverlapCallback cb(env, object); + jmeGhostOverlapCallback cb(env, object, ghost); pc -> processAllOverlappingPairs(&cb, NULL); } /*