[patch]
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/build.xml
— a/engine/src/bullet/native/build.xml Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/build.xml Sat Oct 15 08:11:40 2011 +0900
@@ -5,6 +5,9 @@
<!-- load properties -->
<property file="src/bullet/native/bullet.properties"/>
<!-- condition for mac platform check -->
</and>
</condition>
<!-- condition for x86_64 check -->
@@ -41,7 +47,7 @@
<fileset refid="lib.jme.jars"/>
</pathconvert>
- <target name="build-bullet-natives" description="builds the native bullet library for the platform being run on" depends="-create-folders, create-native-headers, -nativelib-osx, -nativelib-windows, -nativelib-linux">
<class name="com.jme3.bullet.collision.PhysicsCollisionObject"/>
<class name="com.jme3.bullet.objects.PhysicsCharacter"/>
<class name="com.jme3.bullet.objects.PhysicsGhostObject"/>
@@ -78,6 +85,7 @@
<class name="com.jme3.bullet.joints.HingeJoint"/>
<class name="com.jme3.bullet.joints.Point2PointJoint"/>
<class name="com.jme3.bullet.joints.SixDofJoint"/>
<class name="com.jme3.bullet.joints.SliderJoint"/>
<class name="com.jme3.bullet.joints.motors.RotationalLimitMotor"/>
<class name="com.jme3.bullet.joints.motors.TranslationalLimitMotor"/>
@@ -172,7 +180,10 @@
<includepath path="${bullet.java.include}/linux"/>
<includepath path="${bullet.bullet.include}"/>
<!–compilerarg value="-m32"/–>
- <compilerarg value="-m32"/>
- <compilerarg value="-static-libgcc"/>
<linker name="${bullet.linux.compiler}">
- <!-- linkerarg value="-static-libgcc"/ -->
<libset dir="${bullet.folder}/src/BulletMultiThreaded" libs="BulletMultiThreaded"/>
<libset dir="${bullet.folder}/src/BulletDynamics" libs="BulletDynamics"/>
<libset dir="${bullet.folder}/src/BulletCollision" libs="BulletCollision"/>
@@ -181,6 +192,36 @@
</cc>
<delete file="${bullet.output.dir}/linux/history.xml"/>
</target>
- <target name="-nativelib-solaris" if="isSolaris">
-
<echo message="Building Solaris version of native bullet"/><br />
-
<mkdir dir="${bullet.output.dir}/linux"/><br />
-
<cc name="${bullet.solaris.compiler}" warnings="severe" debug="${bullet.compile.debug}" link="shared" outfile="${bullet.output.dir}/solaris/${bullet.library.name}" objdir="${bullet.build.dir}"><br />
-
<fileset dir="${bullet.source.dir}"><br />
-
<include name="*.cpp"><br />
-
</include><br />
-
</fileset><br />
-
<includepath path="${bullet.java.include}"/><br />
-
<includepath path="${bullet.java.include}/solaris"/><br />
-
<includepath path="${bullet.bullet.include}"/><br />
-
<!--compilerarg value="-m32"/--><br />
- <compilerarg value="-m32"/>
- <compilerarg value="-fno-strict-aliasing"/>
- <compilerarg value="-pthread"/>
- <compilerarg value="-fPIC"/>
- <compilerarg value="-D_REENTRANT"/>
- <compilerarg value="-static-libstdc++"/>
- <compilerarg value="-static-libgcc"/>
- <compilerarg value="-D_REENTRANT"/>
-
<linker name="${bullet.solaris.compiler}"><br />
- <linkerarg value="-R/usr/sfw/lib"/>
-
<libset dir="${bullet.folder}/src/BulletMultiThreaded" libs="BulletMultiThreaded"/><br />
-
<libset dir="${bullet.folder}/src/BulletDynamics" libs="BulletDynamics"/><br />
-
<libset dir="${bullet.folder}/src/BulletCollision" libs="BulletCollision"/><br />
-
<libset dir="${bullet.folder}/src/LinearMath" libs="LinearMath"/><br />
-
</linker><br />
-
</cc><br />
-
<delete file="${bullet.output.dir}/solaris/history.xml"/><br />
- </target>
<target name="-nativelib-windows" if="isWindows">
<echo message="Building Windows version of native bullet"/>
@@ -194,10 +235,11 @@
<includepath path="${bullet.java.include}/win32"/>
<includepath path="${bullet.bullet.include}"/>
<!–compilerarg value="-m32"/–>
- <!-- compilerarg value="-static-libgcc -static-libstdc++"/ -->
<linker name="${bullet.windows.compiler}" debug="${bullet.compile.debug}" >
<linkerarg value="-o${bullet.library.name}.dll" />
<linkerarg value="–kill-at" />
- <linkerarg value="-static"/>
<libset dir="${bullet.folder}/lib" libs="BulletMultiThreaded,BulletDynamics,BulletCollision,LinearMath"/>
</linker>
</cc>
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/bullet.properties
— a/engine/src/bullet/native/bullet.properties Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/bullet.properties Sat Oct 15 08:11:40 2011 +0900
@@ -1,12 +1,15 @@
-#####################################################
+####################################################
these are the ant build properties for bullet-jme #
#####################################################
bullet.library.name=bulletjme
bullet.library.version=0.9
change if bullet folder has different location
-bullet.folder=…/bullet-trunk
-
+# bullet.folder=…/bullet-trunk
+# bullet.folder=…/bullet-trunk.win32
+# bullet.folder=…/bullet-trunk.linux
+# bullet.folder=…/bullet-trunk.mac
+bullet.folder=…/bullet-trunk.solaris
compile options
bullet.compile.debug=false
@@ -16,9 +19,11 @@
change this to msvc for MS Visual Studio compiler
bullet.windows.compiler=g++
bullet.linux.compiler=g++
-
+bullet.solaris.compiler=g++
native header include directories
-bullet.java.include=${java.home}/…/include
+# bullet.java.include=${java.home}/…/include:${java.home}/…/include/win32
+bullet.java.include=${java.home}/…/include:${java.home}/…/include/solaris
+# bullet.java.include=${java.home}/…/include:${java.home}/…/include/linux
OSX has no JRE, only JDK
bullet.osx.java.include=${java.home}/include
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp
— a/engine/src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp Sat Oct 15 08:11:40 2011 +0900
@@ -32,7 +32,7 @@
#include "com_jme3_bullet_PhysicsSpace.h"
#include "jmePhysicsSpace.h"
#include "jmeBulletUtil.h"
-
+#include "jmeUserPointer.h"
/**
- Author: Normen Hansen
*/
@@ -93,6 +93,9 @@
env->ThrowNew(newExc, "The collision object does not exist.");
return;
}
+
space->getDynamicsWorld()->addCollisionObject(collisionObject);
}
@@ -116,6 +119,8 @@
return;
}
space->getDynamicsWorld()->removeCollisionObject(collisionObject);
}
/*
@@ -137,6 +142,8 @@
env->ThrowNew(newExc, "The collision object does not exist.");
return;
}
space->getDynamicsWorld()->addRigidBody(collisionObject);
}
@@ -159,6 +166,8 @@
env->ThrowNew(newExc, "The collision object does not exist.");
return;
}
space->getDynamicsWorld()->removeRigidBody(collisionObject);
}
@@ -181,7 +190,12 @@
env->ThrowNew(newExc, "The collision object does not exist.");
return;
}
-
jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer();<br />
-
userPointer -> space = space;<br />
-
space->getDynamicsWorld()->addCollisionObject(collisionObject,<br />
-
btBroadphaseProxy::CharacterFilter,<br />
-
btBroadphaseProxy::StaticFilter | btBroadphaseProxy::DefaultFilter<br />
-
);<br />
}
/*
@@ -203,6 +217,8 @@
env->ThrowNew(newExc, "The collision object does not exist.");
return;
}
space->getDynamicsWorld()->removeCollisionObject(collisionObject);
}
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.cpp
— a/engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.cpp Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.cpp Sat Oct 15 08:11:40 2011 +0900
@@ -35,6 +35,8 @@
*/
#include "com_jme3_bullet_collision_PhysicsCollisionObject.h"
#include "jmeBulletUtil.h"
+#include "jmePhysicsSpace.h"
+#include "jmeUserPointer.h"
#ifdef __cplusplus
extern "C" {
@@ -75,8 +77,73 @@
env->ThrowNew(newExc, "The native object does not exist.");
return;
}
-
if (collisionObject -> getUserPointer() != NULL){<br />
-
jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer();<br />
-
delete(userPointer);<br />
-
}<br />
delete(collisionObject);
}
- /*
-
* Class: com_jme3_bullet_collision_PhysicsCollisionObject<br />
-
* Method: initUserPointer<br />
-
* Signature: (JII)V<br />
-
*/<br />
- JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_initUserPointer
-
(JNIEnv *env, jobject object, jlong objectId, jint group, jint groups) {<br />
-
btCollisionObject* collisionObject = (btCollisionObject*) objectId;<br />
-
if (collisionObject == NULL) {<br />
-
jclass newExc = env->FindClass("java/lang/NullPointerException");<br />
-
env->ThrowNew(newExc, "The native object does not exist.");<br />
-
return;<br />
-
}<br />
-
jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer();<br />
-
if (userPointer != NULL) {<br />
+// delete(userPointer);
-
}<br />
-
userPointer = new jmeUserPointer();<br />
-
userPointer -> javaCollisionObject = env->NewWeakGlobalRef(object);<br />
-
userPointer -> group = group;<br />
-
userPointer -> groups = groups;<br />
-
userPointer -> space = NULL;<br />
-
collisionObject -> setUserPointer(userPointer);<br />
- }
- /*
-
* Class: com_jme3_bullet_collision_PhysicsCollisionObject<br />
-
* Method: setCollisionGroup<br />
-
* Signature: (JI)V<br />
-
*/<br />
- JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_setCollisionGroup
-
(JNIEnv *env, jobject object, jlong objectId, jint group) {<br />
-
btCollisionObject* collisionObject = (btCollisionObject*) objectId;<br />
-
if (collisionObject == NULL) {<br />
-
jclass newExc = env->FindClass("java/lang/NullPointerException");<br />
-
env->ThrowNew(newExc, "The native object does not exist.");<br />
-
return;<br />
-
}<br />
-
jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer();<br />
-
if (userPointer != NULL){<br />
-
userPointer -> group = group;<br />
-
}<br />
- }
- /*
-
* Class: com_jme3_bullet_collision_PhysicsCollisionObject<br />
-
* Method: setCollideWithGroups<br />
-
* Signature: (JI)V<br />
-
*/<br />
- JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_setCollideWithGroups
-
(JNIEnv *env, jobject object, jlong objectId, jint groups) {<br />
-
btCollisionObject* collisionObject = (btCollisionObject*) objectId;<br />
-
if (collisionObject == NULL) {<br />
-
jclass newExc = env->FindClass("java/lang/NullPointerException");<br />
-
env->ThrowNew(newExc, "The native object does not exist.");<br />
-
return;<br />
-
}<br />
-
jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer();<br />
-
if (userPointer != NULL){<br />
-
userPointer -> groups = groups;<br />
-
}<br />
- }
+
#ifdef __cplusplus
}
#endif
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.h
— a/engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.h Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.h Sat Oct 15 08:11:40 2011 +0900
@@ -43,6 +43,14 @@
#define com_jme3_bullet_collision_PhysicsCollisionObject_COLLISION_GROUP_16 32768L
/*
- Class: com_jme3_bullet_collision_PhysicsCollisionObject
-
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_initUserPointer
- (JNIEnv , jobject, jlong, jint, jint);
+
+/
-
- Class: com_jme3_bullet_collision_PhysicsCollisionObject
- Method: attachCollisionShape
- Signature: (JJ)V
/
@@ -51,6 +59,22 @@
/
- Class: com_jme3_bullet_collision_PhysicsCollisionObject
-
- Method: setCollisionGroup
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_setCollisionGroup
- (JNIEnv , jobject, jlong, jint);
+
+/
-
- Class: com_jme3_bullet_collision_PhysicsCollisionObject
-
- Method: setCollideWithGroups
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_setCollideWithGroups
- (JNIEnv , jobject, jlong, jint);
+
+/
-
- Class: com_jme3_bullet_collision_PhysicsCollisionObject
- Method: finalizeNative
- Signature: (J)V
*/
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_joints_SixDofSpringJoint.cpp
— /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/engine/src/bullet/native/com_jme3_bullet_joints_SixDofSpringJoint.cpp Sat Oct 15 08:11:40 2011 +0900
@@ -0,0 +1,103 @@
+
+/**
-
-
/
+#include "com_jme3_bullet_joints_SixDofSpringJoint.h"
+#include "jmeBulletUtil.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/
-
- Class: com_jme3_bullet_joints_SixDofSpringJoint
-
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_enableSpring
- (JNIEnv *env, jobject object, jlong jointId, jint index, jboolean onOff) {
- btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
- joint -> enableSpring(index, onOff);
+}
+
+
+/*
-
- Class: com_jme3_bullet_joints_SixDofSpringJoint
-
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setStiffness
- (JNIEnv *env, jobject object, jlong jointId, jint index, jfloat stiffness) {
- btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
- joint -> setStiffness(index, stiffness);
+}
+
+/*
-
- Class: com_jme3_bullet_joints_SixDofSpringJoint
-
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setDamping
- (JNIEnv *env, jobject object, jlong jointId, jint index, jfloat damping) {
- btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
- joint -> setDamping(index, damping);
+}
+
+/*
-
- Class: com_jme3_bullet_joints_SixDofSpringJoint
-
- Method: setEquilibriumPoint
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setEquilibriumPoint__J
- (JNIEnv *env, jobject object, jlong jointId) {
- btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
- joint -> setEquilibriumPoint();
+}
+
+/*
-
- Class: com_jme3_bullet_joints_SixDofSpringJoint
-
- Method: setEquilibriumPoint
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setEquilibriumPoint__JI
- (JNIEnv *env, jobject object, jlong jointId, jint index) {
- btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
- joint -> setEquilibriumPoint(index);
+}
+
+
+
+
+/*
-
- Class: com_jme3_bullet_joints_SixDofSpringJoint
-
-
- Signature: (JJLcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Lcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Z)J
- */
+JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_createJoint
- (JNIEnv * env, jobject object, jlong bodyIdA, jlong bodyIdB, jobject pivotA, jobject rotA, jobject pivotB, jobject rotB, jboolean useLinearReferenceFrameA) {
-
jmeClasses::initJavaClasses(env);<br />
-
btRigidBody* bodyA = (btRigidBody*) bodyIdA;<br />
-
btRigidBody* bodyB = (btRigidBody*) bodyIdB;<br />
-
btMatrix3x3* mtx1 = &btMatrix3x3();<br />
-
btMatrix3x3* mtx2 = &btMatrix3x3();<br />
+/* btTransform* transA = &btTransform(*mtx1);
-
jmeBulletUtil::convert(env, pivotA, &transA->getOrigin());<br />
-
jmeBulletUtil::convert(env, rotA, &transA->getBasis());<br />
-
btTransform* transB = &btTransform(*mtx2);<br />
-
jmeBulletUtil::convert(env, pivotB, &transB->getOrigin());<br />
-
jmeBulletUtil::convert(env, rotB, &transB->getBasis());<br />
+*/
-
btTransform transA;<br />
-
jmeBulletUtil::convert(env, pivotA, &transA.getOrigin());<br />
-
jmeBulletUtil::convert(env, rotA, &transA.getBasis());<br />
-
btTransform transB;<br />
-
jmeBulletUtil::convert(env, pivotB, &transB.getOrigin());<br />
-
jmeBulletUtil::convert(env, rotB, &transB.getBasis());<br />
+
-
btGeneric6DofSpringConstraint* joint = new btGeneric6DofSpringConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA);<br />
-
return (long)joint;<br />
- }
+
+#ifdef __cplusplus
+}
+#endif
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_joints_SixDofSpringJoint.h
— /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/engine/src/bullet/native/com_jme3_bullet_joints_SixDofSpringJoint.h Sat Oct 15 08:11:40 2011 +0900
@@ -0,0 +1,61 @@
+/* DO NOT EDIT THIS FILE - it is machine generated /
+#include <jni.h>
+/ Header for class com_jme3_bullet_joints_SixDofSpringJoint /
+
+#ifndef _Included_com_jme3_bullet_joints_SixDofSpringJoint
+#define _Included_com_jme3_bullet_joints_SixDofSpringJoint
+#ifdef __cplusplus
+extern "C" {
+#endif
+/
-
- Class: com_jme3_bullet_joints_SixDofSpringJoint
-
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_enableSpring
- (JNIEnv , jobject, jlong, jint, jboolean);
+
+/
-
- Class: com_jme3_bullet_joints_SixDofSpringJoint
-
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setStiffness
- (JNIEnv , jobject, jlong, jint, jfloat);
+
+/
-
- Class: com_jme3_bullet_joints_SixDofSpringJoint
-
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setDamping
- (JNIEnv , jobject, jlong, jint, jfloat);
+
+/
-
- Class: com_jme3_bullet_joints_SixDofSpringJoint
-
- Method: setEquilibriumPoint
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setEquilibriumPoint__J
- (JNIEnv , jobject, jlong);
+
+/
-
- Class: com_jme3_bullet_joints_SixDofSpringJoint
-
- Method: setEquilibriumPoint
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setEquilibriumPoint__JI
- (JNIEnv , jobject, jlong, jint);
+
+/
-
- Class: com_jme3_bullet_joints_SixDofSpringJoint
-
-
- Signature: (JJLcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Lcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Z)J
- */
+JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_createJoint
- (JNIEnv *, jobject, jlong, jlong, jobject, jobject, jobject, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_objects_PhysicsCharacter.cpp
— a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsCharacter.cpp Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsCharacter.cpp Sat Oct 15 08:11:40 2011 +0900
@@ -68,7 +68,7 @@
env->ThrowNew(newExc, "The native object does not exist.");
return;
}
ghost->setCollisionFlags(ghost->getCollisionFlags() & ~btCollisionObject::CF_NO_CONTACT_RESPONSE);
}
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp
— a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp Sat Oct 15 08:11:40 2011 +0900
@@ -37,8 +37,10 @@
#include <BulletCollision/CollisionDispatch/btGhostObject.h>
#include "com_jme3_bullet_objects_PhysicsGhostObject.h"
+#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"
#include "jmeBulletUtil.h"
-
+#include "jmePhysicsSpace.h"
+#include "jmeUserPointer.h"
#ifdef __cplusplus
extern "C" {
#endif
@@ -166,9 +168,51 @@
}
jmeBulletUtil::convert(env, &ghost->getWorldTransform().getBasis(), value);
}
+
- class jmeGhostOverlapCallback : public btOverlapCallback {
-
JNIEnv* m_env;<br />
-
jobject m_object;<br />
- public:
-
jmeGhostOverlapCallback(JNIEnv *env, jobject object)<br />
-
:m_env(env),<br />
-
m_object(object)<br />
-
{<br />
-
}<br />
-
virtual ~jmeGhostOverlapCallback() {}<br />
-
virtual bool processOverlap(btBroadphasePair& pair)<br />
-
{<br />
-
btCollisionObject *co1 = (btCollisionObject *)pair.m_pProxy0->m_clientObject;<br />
-
jmeUserPointer *up1 = (jmeUserPointer*)co1 -> getUserPointer();<br />
+
-
m_env->CallVoidMethod(m_object, jmeClasses::PhysicsGhostObject_addOverlappingObject, up1->javaCollisionObject);<br />
-
if (m_env->ExceptionCheck()) {<br />
-
m_env->Throw(m_env->ExceptionOccurred());<br />
-
return false;<br />
-
}<br />
+
-
return false;<br />
-
}<br />
- };
/*
- Class: com_jme3_bullet_objects_PhysicsGhostObject
-
* Method: getOverlappingObjects<br />
-
* Signature: (J)V<br />
-
*/<br />
- JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_getOverlappingObjects
-
(JNIEnv *env, jobject object, jlong objectId) {<br />
-
btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId;<br />
-
if (ghost == NULL) {<br />
-
jclass newExc = env->FindClass("java/lang/NullPointerException");<br />
-
env->ThrowNew(newExc, "The native object does not exist.");<br />
-
return;<br />
-
}<br />
-
btHashedOverlappingPairCache * pc = ghost->getOverlappingPairCache();<br />
-
jmeGhostOverlapCallback cb(env, object);<br />
-
pc -> processAllOverlappingPairs(&cb, NULL);<br />
- }
- /*
-
* Class: com_jme3_bullet_objects_PhysicsGhostObject<br />
- Method: getOverlappingCount
- Signature: (J)I
/
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.h
— a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.h Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.h Sat Oct 15 08:11:40 2011 +0900
@@ -107,6 +107,14 @@
/
- Class: com_jme3_bullet_objects_PhysicsGhostObject
-
- Method: getOverlappingObjects
-
- */
+JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_getOverlappingObjects
- (JNIEnv , jobject, jlong);
+
+/
-
- Class: com_jme3_bullet_objects_PhysicsGhostObject
- Method: getOverlappingCount
- Signature: (J)I
/
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_objects_PhysicsRigidBody.cpp
— a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsRigidBody.cpp Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsRigidBody.cpp Sat Oct 15 08:11:40 2011 +0900
@@ -54,6 +54,7 @@
btVector3 localInertia = btVector3();
shape->calculateLocalInertia(mass, localInertia);
btRigidBody body = new btRigidBody(mass, motionState, shape, localInertia);
return (long) body;
}
@@ -433,7 +434,7 @@
env->ThrowNew(newExc, "The native object does not exist.");
return;
}
}
/*
@@ -756,7 +757,7 @@
env->ThrowNew(newExc, "The native object does not exist.");
return;
}
}
/*
@@ -772,7 +773,7 @@
env->ThrowNew(newExc, "The native object does not exist.");
return;
}
}
/
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp
— a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp Sat Oct 15 08:11:40 2011 +0900
@@ -36,6 +36,7 @@
#include "com_jme3_bullet_objects_PhysicsVehicle.h"
#include "jmeBulletUtil.h"
+#include "jmePhysicsSpace.h"
#include "BulletDynamics/Vehicle/btRaycastVehicle.h"
#ifdef __cplusplus
@@ -66,13 +67,13 @@
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_objects_PhysicsVehicle_createVehicleRaycaster
(JNIEnv env, jobject object, jlong bodyId, jlong spaceId) {
//btRigidBody body = (btRigidBody) bodyId;
jclass newExc = env->FindClass("java/lang/NullPointerException");
env->ThrowNew(newExc, "The native object does not exist.");
return 0;
}
return (long) caster;
}
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.cpp
— a/engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.cpp Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.cpp Sat Oct 15 08:11:40 2011 +0900
@@ -105,7 +105,7 @@
// Check there is a hull shape to render
if (convexShape->getUserPointer() == NULL) {
// create a hull approximation
float margin = convexShape->getMargin();
hull->buildHull(margin);
convexShape->setUserPointer(hull);
@@ -146,7 +146,7 @@
return;
}
}
-
convexShape->setUserPointer(NULL);
}
}
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.h
— a/engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.h Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.h Sat Oct 15 08:11:40 2011 +0900
@@ -7,7 +7,6 @@
#ifdef __cplusplus
extern "C" {
#endif
-/* Inaccessible static: _00024assertionsDisabled /
/
- Class: com_jme3_bullet_util_DebugShapeFactory
- Method: getVertices
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/jmeBulletUtil.h
— a/engine/src/bullet/native/jmeBulletUtil.h Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/jmeBulletUtil.h Sat Oct 15 08:11:40 2011 +0900
@@ -49,4 +49,4 @@
jmeBulletUtil(){};
~jmeBulletUtil(){};
-};
No newline at end of file
+};
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/jmeClasses.cpp
— a/engine/src/bullet/native/jmeClasses.cpp Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/jmeClasses.cpp Sat Oct 15 08:11:40 2011 +0900
@@ -38,6 +38,10 @@
jclass jmeClasses::PhysicsSpace;
jmethodID jmeClasses::PhysicsSpace_preTick;
jmethodID jmeClasses::PhysicsSpace_postTick;
+jmethodID jmeClasses::PhysicsSpace_addCollisionEvent;
+
+jclass jmeClasses::PhysicsGhostObject;
+jmethodID jmeClasses::PhysicsGhostObject_addOverlappingObject;
jclass jmeClasses::Vector3f;
jmethodID jmeClasses::Vector3f_set;
@@ -106,6 +110,18 @@
PhysicsSpace_preTick = env->GetMethodID(PhysicsSpace, "preTick_native", "(F)V");
PhysicsSpace_postTick = env->GetMethodID(PhysicsSpace, "postTick_native", "(F)V");
- Author: Normen Hansen
/
@@ -170,16 +171,33 @@
// return true when pairs need collision
virtual bool needBroadphaseCollision(btBroadphaseProxy proxy0, btBroadphaseProxy * proxy1) const {
+// bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
+// collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
-
if (collides) {<br />
-
btCollisionObject* co0 = (btCollisionObject*)proxy0->m_clientObject;<br />
-
btCollisionObject* co1 = (btCollisionObject*)proxy1->m_clientObject;<br />
-
jmeUserPointer *up0 = (jmeUserPointer*)co0 -> getUserPointer();<br />
-
jmeUserPointer *up1 = (jmeUserPointer*)co1 -> getUserPointer();<br />
-
if (up0 != NULL && up1 != NULL) {<br />
-
collides = (up0->group & up1->groups) != 0;<br />
-
collides = collides && (up1->group & up0->groups);<br />
- //add some additional logic here that modified 'collides'
+ //add some additional logic here that modified 'collides'
+ return collides;
+ }
+ return false;
+ }
return collides;
}
};
dynamicsWorld->getPairCache()->setOverlapFilterCallback(new jmeFilterCallback());
dynamicsWorld->setInternalTickCallback(&jmePhysicsSpace::preTickCallback, static_cast<void *> (this), true);
dynamicsWorld->setInternalTickCallback(&jmePhysicsSpace::postTickCallback, static_cast<void *> (this));
+ if (gContactProcessedCallback == NULL) {
+ gContactProcessedCallback = &jmePhysicsSpace::contactProcessedCallback;
+ }
}
void jmePhysicsSpace::preTickCallback(btDynamicsWorld *world, btScalar timeStep) {
@@ -201,7 +219,25 @@
return;
}
}
-
+bool jmePhysicsSpace::contactProcessedCallback(btManifoldPoint &cp, void *body0, void *body1) {
+// printf("contactProcessedCallback %d %dn", body0, body1);
+ btCollisionObject* co0 = (btCollisionObject*)body0;
+ jmeUserPointer *up0 = (jmeUserPointer*)co0 -> getUserPointer();
+ btCollisionObject* co1 = (btCollisionObject*)body1;
+ jmeUserPointer *up1 = (jmeUserPointer*)co1 -> getUserPointer();
+ if (up0 != NULL) {
+ 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;
+ }
+ }
+ }
+ return true;
+}
btDynamicsWorld* jmePhysicsSpace::getDynamicsWorld() {
return dynamicsWorld;
}
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/jmePhysicsSpace.h
--- a/engine/src/bullet/native/jmePhysicsSpace.h Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/jmePhysicsSpace.h Sat Oct 15 08:11:40 2011 +0900
@@ -46,6 +46,8 @@
#include "BulletMultiThreaded/SpuCollisionTaskProcess.h"
#include "BulletMultiThreaded/SequentialThreadSupport.h"
#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
+#include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h"
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
/**
* Author: Normen Hansen
@@ -70,4 +72,5 @@
JNIEnv* getEnv();
static void preTickCallback(btDynamicsWorld*, btScalar);
static void postTickCallback(btDynamicsWorld*, btScalar);
-};
No newline at end of file
+ static bool contactProcessedCallback(btManifoldPoint &, void *, void *);
+};
[/patch]