Native SweepTest: fix formatting

experimental
shadowislord 10 years ago
parent 55829d46cf
commit fe7f30d5ec
  1. 117
      jme3-bullet-native/src/native/cpp/com_jme3_bullet_PhysicsSpace.cpp
  2. 6
      jme3-bullet-native/src/native/cpp/jmeBulletUtil.h

@ -470,65 +470,64 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_sweepTest_1native JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_sweepTest_1native
(JNIEnv * env, jobject object, jlong shapeId, jobject from, jobject to, jlong spaceId, jobject resultlist, jfloat allowedCcdPenetration) { (JNIEnv * env, jobject object, jlong shapeId, jobject from, jobject to, jlong spaceId, jobject resultlist, jfloat allowedCcdPenetration) {
jmePhysicsSpace* space = reinterpret_cast<jmePhysicsSpace*> (spaceId); jmePhysicsSpace* space = reinterpret_cast<jmePhysicsSpace*> (spaceId);
if (space == NULL) { if (space == NULL) {
jclass newExc = env->FindClass("java/lang/NullPointerException"); jclass newExc = env->FindClass("java/lang/NullPointerException");
env->ThrowNew(newExc, "The physics space does not exist."); env->ThrowNew(newExc, "The physics space does not exist.");
return; return;
} }
btCollisionShape* shape = reinterpret_cast<btCollisionShape*> (shapeId); btCollisionShape* shape = reinterpret_cast<btCollisionShape*> (shapeId);
if (shape == NULL) { if (shape == NULL) {
jclass newExc = env->FindClass("java/lang/NullPointerException"); jclass newExc = env->FindClass("java/lang/NullPointerException");
env->ThrowNew(newExc, "The shape does not exist."); env->ThrowNew(newExc, "The shape does not exist.");
return; return;
} }
struct AllConvexResultCallback : public btCollisionWorld::ConvexResultCallback { struct AllConvexResultCallback : public btCollisionWorld::ConvexResultCallback {
AllConvexResultCallback(const btTransform& convexFromWorld, const btTransform & convexToWorld) : m_convexFromWorld(convexFromWorld), m_convexToWorld(convexToWorld) { AllConvexResultCallback(const btTransform& convexFromWorld, const btTransform & convexToWorld) : m_convexFromWorld(convexFromWorld), m_convexToWorld(convexToWorld) {
} }
jobject resultlist; jobject resultlist;
JNIEnv* env; JNIEnv* env;
btTransform m_convexFromWorld; //used to calculate hitPointWorld from hitFraction btTransform m_convexFromWorld; //used to calculate hitPointWorld from hitFraction
btTransform m_convexToWorld; btTransform m_convexToWorld;
btVector3 m_hitNormalWorld; btVector3 m_hitNormalWorld;
btVector3 m_hitPointWorld; btVector3 m_hitPointWorld;
virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& convexResult, bool normalInWorldSpace) { virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& convexResult, bool normalInWorldSpace) {
if (normalInWorldSpace) { if (normalInWorldSpace) {
m_hitNormalWorld = convexResult.m_hitNormalLocal; m_hitNormalWorld = convexResult.m_hitNormalLocal;
} }
else { else {
m_hitNormalWorld = convexResult.m_hitCollisionObject->getWorldTransform().getBasis() * convexResult.m_hitNormalLocal; m_hitNormalWorld = convexResult.m_hitCollisionObject->getWorldTransform().getBasis() * convexResult.m_hitNormalLocal;
} }
m_hitPointWorld.setInterpolate3(m_convexFromWorld.getBasis() * m_convexFromWorld.getOrigin(), m_convexToWorld.getBasis() * m_convexToWorld.getOrigin(), convexResult.m_hitFraction); m_hitPointWorld.setInterpolate3(m_convexFromWorld.getBasis() * m_convexFromWorld.getOrigin(), m_convexToWorld.getBasis() * m_convexToWorld.getOrigin(), convexResult.m_hitFraction);
jmeBulletUtil::addSweepResult(env, resultlist, &m_hitNormalWorld, &m_hitPointWorld, convexResult.m_hitFraction, convexResult.m_hitCollisionObject); jmeBulletUtil::addSweepResult(env, resultlist, &m_hitNormalWorld, &m_hitPointWorld, convexResult.m_hitFraction, convexResult.m_hitCollisionObject);
return 1.f; return 1.f;
} }
}; };
btTransform native_to = btTransform(); btTransform native_to = btTransform();
jmeBulletUtil::convert(env, to, &native_to); jmeBulletUtil::convert(env, to, &native_to);
btTransform native_from = btTransform(); btTransform native_from = btTransform();
jmeBulletUtil::convert(env, from, &native_from); jmeBulletUtil::convert(env, from, &native_from);
btScalar native_allowed_ccd_penetration = btScalar(allowedCcdPenetration); btScalar native_allowed_ccd_penetration = btScalar(allowedCcdPenetration);
AllConvexResultCallback resultCallback(native_from, native_to);
AllConvexResultCallback resultCallback(native_from, native_to); resultCallback.env = env;
resultCallback.env = env; resultCallback.resultlist = resultlist;
resultCallback.resultlist = resultlist; space->getDynamicsWorld()->convexSweepTest((btConvexShape *) shape, native_from, native_to, resultCallback, native_allowed_ccd_penetration);
space->getDynamicsWorld()->convexSweepTest((btConvexShape *) shape, native_from, native_to, resultCallback, native_allowed_ccd_penetration); return;
return; }
}
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -42,13 +42,13 @@ public:
static void convert(JNIEnv* env, jobject in, btVector3* out); static void convert(JNIEnv* env, jobject in, btVector3* out);
static void convert(JNIEnv* env, const btVector3* in, jobject out); static void convert(JNIEnv* env, const btVector3* in, jobject out);
static void convert(JNIEnv* env, jobject in, btMatrix3x3* out); static void convert(JNIEnv* env, jobject in, btMatrix3x3* out);
static void convert(JNIEnv* env, jobject in, btQuaternion* out); static void convert(JNIEnv* env, jobject in, btQuaternion* out);
static void convert(JNIEnv* env, const btMatrix3x3* in, jobject out); static void convert(JNIEnv* env, const btMatrix3x3* in, jobject out);
static void convertQuat(JNIEnv* env, jobject in, btMatrix3x3* out); static void convertQuat(JNIEnv* env, jobject in, btMatrix3x3* out);
static void convertQuat(JNIEnv* env, const btMatrix3x3* in, jobject out); static void convertQuat(JNIEnv* env, const btMatrix3x3* in, jobject out);
static void convert(JNIEnv* env, jobject in, btTransform* out); static void convert(JNIEnv* env, jobject in, btTransform* out);
static void addResult(JNIEnv* env, jobject resultlist, btVector3* hitnormal, btVector3* m_hitPointWorld,const btScalar m_hitFraction,const btCollisionObject* hitobject); static void addResult(JNIEnv* env, jobject resultlist, btVector3* hitnormal, btVector3* m_hitPointWorld,const btScalar m_hitFraction,const btCollisionObject* hitobject);
static void addSweepResult(JNIEnv* env, jobject resultlist, btVector3* hitnormal, btVector3* m_hitPointWorld, const btScalar m_hitFraction, const btCollisionObject* hitobject); static void addSweepResult(JNIEnv* env, jobject resultlist, btVector3* hitnormal, btVector3* m_hitPointWorld, const btScalar m_hitFraction, const btCollisionObject* hitobject);
private: private:
jmeBulletUtil(){}; jmeBulletUtil(){};
~jmeBulletUtil(){}; ~jmeBulletUtil(){};

Loading…
Cancel
Save