Native SweepTest: fix formatting
This commit is contained in:
parent
55829d46cf
commit
fe7f30d5ec
@ -470,65 +470,64 @@ extern "C" {
|
||||
|
||||
|
||||
|
||||
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) {
|
||||
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) {
|
||||
|
||||
jmePhysicsSpace* space = reinterpret_cast<jmePhysicsSpace*> (spaceId);
|
||||
if (space == NULL) {
|
||||
jclass newExc = env->FindClass("java/lang/NullPointerException");
|
||||
env->ThrowNew(newExc, "The physics space does not exist.");
|
||||
return;
|
||||
}
|
||||
jmePhysicsSpace* space = reinterpret_cast<jmePhysicsSpace*> (spaceId);
|
||||
if (space == NULL) {
|
||||
jclass newExc = env->FindClass("java/lang/NullPointerException");
|
||||
env->ThrowNew(newExc, "The physics space does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
btCollisionShape* shape = reinterpret_cast<btCollisionShape*> (shapeId);
|
||||
if (shape == NULL) {
|
||||
jclass newExc = env->FindClass("java/lang/NullPointerException");
|
||||
env->ThrowNew(newExc, "The shape does not exist.");
|
||||
return;
|
||||
}
|
||||
btCollisionShape* shape = reinterpret_cast<btCollisionShape*> (shapeId);
|
||||
if (shape == NULL) {
|
||||
jclass newExc = env->FindClass("java/lang/NullPointerException");
|
||||
env->ThrowNew(newExc, "The shape does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
struct AllConvexResultCallback : public btCollisionWorld::ConvexResultCallback {
|
||||
struct AllConvexResultCallback : public btCollisionWorld::ConvexResultCallback {
|
||||
|
||||
AllConvexResultCallback(const btTransform& convexFromWorld, const btTransform & convexToWorld) : m_convexFromWorld(convexFromWorld), m_convexToWorld(convexToWorld) {
|
||||
}
|
||||
jobject resultlist;
|
||||
JNIEnv* env;
|
||||
btTransform m_convexFromWorld; //used to calculate hitPointWorld from hitFraction
|
||||
btTransform m_convexToWorld;
|
||||
AllConvexResultCallback(const btTransform& convexFromWorld, const btTransform & convexToWorld) : m_convexFromWorld(convexFromWorld), m_convexToWorld(convexToWorld) {
|
||||
}
|
||||
jobject resultlist;
|
||||
JNIEnv* env;
|
||||
btTransform m_convexFromWorld; //used to calculate hitPointWorld from hitFraction
|
||||
btTransform m_convexToWorld;
|
||||
|
||||
btVector3 m_hitNormalWorld;
|
||||
btVector3 m_hitPointWorld;
|
||||
btVector3 m_hitNormalWorld;
|
||||
btVector3 m_hitPointWorld;
|
||||
|
||||
virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& convexResult, bool normalInWorldSpace) {
|
||||
if (normalInWorldSpace) {
|
||||
m_hitNormalWorld = convexResult.m_hitNormalLocal;
|
||||
}
|
||||
else {
|
||||
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);
|
||||
virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& convexResult, bool normalInWorldSpace) {
|
||||
if (normalInWorldSpace) {
|
||||
m_hitNormalWorld = convexResult.m_hitNormalLocal;
|
||||
}
|
||||
else {
|
||||
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);
|
||||
|
||||
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();
|
||||
jmeBulletUtil::convert(env, to, &native_to);
|
||||
btTransform native_to = btTransform();
|
||||
jmeBulletUtil::convert(env, to, &native_to);
|
||||
|
||||
btTransform native_from = btTransform();
|
||||
jmeBulletUtil::convert(env, from, &native_from);
|
||||
btTransform native_from = btTransform();
|
||||
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);
|
||||
resultCallback.env = env;
|
||||
resultCallback.resultlist = resultlist;
|
||||
space->getDynamicsWorld()->convexSweepTest((btConvexShape *) shape, native_from, native_to, resultCallback, native_allowed_ccd_penetration);
|
||||
return;
|
||||
}
|
||||
AllConvexResultCallback resultCallback(native_from, native_to);
|
||||
resultCallback.env = env;
|
||||
resultCallback.resultlist = resultlist;
|
||||
space->getDynamicsWorld()->convexSweepTest((btConvexShape *) shape, native_from, native_to, resultCallback, native_allowed_ccd_penetration);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -42,13 +42,13 @@ public:
|
||||
static void convert(JNIEnv* env, jobject in, btVector3* 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, btQuaternion* out);
|
||||
static void convert(JNIEnv* env, jobject in, btQuaternion* 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, 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 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:
|
||||
jmeBulletUtil(){};
|
||||
~jmeBulletUtil(){};
|
||||
|
Loading…
x
Reference in New Issue
Block a user