|
|
@ -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 |
|
|
|
} |
|
|
|
} |
|
|
|