@@ -46,16 +46,21 @@ extern "C" {
4646 * Signature: (FFFFFFI)J
4747 */
4848 JNIEXPORT jlong JNICALL Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace
49- (JNIEnv * env, jobject object, jfloat minX, jfloat minY, jfloat minZ, jfloat maxX, jfloat maxY, jfloat maxZ, jint broadphase, jboolean threading) {
49+ (JNIEnv * env, jobject object, jfloat minX, jfloat minY, jfloat minZ,
50+ jfloat maxX, jfloat maxY, jfloat maxZ, jint broadphase,
51+ jboolean threading) {
5052 jmeClasses::initJavaClasses (env);
53+
5154 jmePhysicsSpace* space = new jmePhysicsSpace (env, object);
5255 if (space == NULL ) {
5356 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
5457 env->ThrowNew (newExc, " The physics space has not been created." );
5558 return 0 ;
5659 }
57- space->createPhysicsSpace (minX, minY, minZ, maxX, maxY, maxZ, broadphase, threading);
58- return reinterpret_cast <jlong>(space);
60+
61+ space->createPhysicsSpace (minX, minY, minZ, maxX, maxY, maxZ,
62+ broadphase, threading);
63+ return reinterpret_cast <jlong> (space);
5964 }
6065
6166 /*
@@ -64,8 +69,9 @@ extern "C" {
6469 * Signature: (JFIF)V
6570 */
6671 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_stepSimulation
67- (JNIEnv * env, jobject object, jlong spaceId, jfloat tpf, jint maxSteps, jfloat accuracy) {
68- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
72+ (JNIEnv * env, jobject object, jlong spaceId, jfloat tpf, jint maxSteps,
73+ jfloat accuracy) {
74+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
6975 if (space == NULL ) {
7076 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
7177 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -81,8 +87,8 @@ extern "C" {
8187 */
8288 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addCollisionObject
8389 (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) {
84- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
85- btCollisionObject* collisionObject = reinterpret_cast <btCollisionObject*>(objectId);
90+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
91+ btCollisionObject* collisionObject = reinterpret_cast <btCollisionObject*> (objectId);
8692 if (space == NULL ) {
8793 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
8894 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -93,7 +99,7 @@ extern "C" {
9399 env->ThrowNew (newExc, " The collision object does not exist." );
94100 return ;
95101 }
96- jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer ();
102+ jmeUserPointer *userPointer = (jmeUserPointer*) collisionObject->getUserPointer ();
97103 userPointer -> space = space;
98104
99105 space->getDynamicsWorld ()->addCollisionObject (collisionObject);
@@ -106,8 +112,8 @@ extern "C" {
106112 */
107113 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeCollisionObject
108114 (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) {
109- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
110- btCollisionObject* collisionObject = reinterpret_cast <btCollisionObject*>(objectId);
115+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
116+ btCollisionObject* collisionObject = reinterpret_cast <btCollisionObject*> (objectId);
111117 if (space == NULL ) {
112118 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
113119 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -119,7 +125,7 @@ extern "C" {
119125 return ;
120126 }
121127 space->getDynamicsWorld ()->removeCollisionObject (collisionObject);
122- jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer ();
128+ jmeUserPointer *userPointer = (jmeUserPointer*) collisionObject->getUserPointer ();
123129 userPointer -> space = NULL ;
124130 }
125131
@@ -130,8 +136,8 @@ extern "C" {
130136 */
131137 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addRigidBody
132138 (JNIEnv * env, jobject object, jlong spaceId, jlong rigidBodyId) {
133- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
134- btRigidBody* collisionObject = reinterpret_cast <btRigidBody*>(rigidBodyId);
139+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
140+ btRigidBody* collisionObject = reinterpret_cast <btRigidBody*> (rigidBodyId);
135141 if (space == NULL ) {
136142 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
137143 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -142,7 +148,7 @@ extern "C" {
142148 env->ThrowNew (newExc, " The collision object does not exist." );
143149 return ;
144150 }
145- jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer ();
151+ jmeUserPointer *userPointer = (jmeUserPointer*) collisionObject->getUserPointer ();
146152 userPointer -> space = space;
147153 space->getDynamicsWorld ()->addRigidBody (collisionObject);
148154 }
@@ -154,8 +160,8 @@ extern "C" {
154160 */
155161 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeRigidBody
156162 (JNIEnv * env, jobject object, jlong spaceId, jlong rigidBodyId) {
157- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
158- btRigidBody* collisionObject = reinterpret_cast <btRigidBody*>(rigidBodyId);
163+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
164+ btRigidBody* collisionObject = reinterpret_cast <btRigidBody*> (rigidBodyId);
159165 if (space == NULL ) {
160166 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
161167 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -166,7 +172,7 @@ extern "C" {
166172 env->ThrowNew (newExc, " The collision object does not exist." );
167173 return ;
168174 }
169- jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer ();
175+ jmeUserPointer *userPointer = (jmeUserPointer*) collisionObject->getUserPointer ();
170176 userPointer -> space = NULL ;
171177 space->getDynamicsWorld ()->removeRigidBody (collisionObject);
172178 }
@@ -178,8 +184,8 @@ extern "C" {
178184 */
179185 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addCharacterObject
180186 (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) {
181- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
182- btCollisionObject* collisionObject = reinterpret_cast <btCollisionObject*>(objectId);
187+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
188+ btCollisionObject* collisionObject = reinterpret_cast <btCollisionObject*> (objectId);
183189 if (space == NULL ) {
184190 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
185191 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -190,12 +196,12 @@ extern "C" {
190196 env->ThrowNew (newExc, " The collision object does not exist." );
191197 return ;
192198 }
193- jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer ();
199+ jmeUserPointer *userPointer = (jmeUserPointer*) collisionObject->getUserPointer ();
194200 userPointer -> space = space;
195201 space->getDynamicsWorld ()->addCollisionObject (collisionObject,
196202 btBroadphaseProxy::CharacterFilter,
197203 btBroadphaseProxy::StaticFilter | btBroadphaseProxy::DefaultFilter
198- );
204+ );
199205 }
200206
201207 /*
@@ -205,8 +211,8 @@ extern "C" {
205211 */
206212 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeCharacterObject
207213 (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) {
208- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
209- btCollisionObject* collisionObject = reinterpret_cast <btCollisionObject*>(objectId);
214+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
215+ btCollisionObject* collisionObject = reinterpret_cast <btCollisionObject*> (objectId);
210216 if (space == NULL ) {
211217 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
212218 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -217,7 +223,7 @@ extern "C" {
217223 env->ThrowNew (newExc, " The collision object does not exist." );
218224 return ;
219225 }
220- jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer ();
226+ jmeUserPointer *userPointer = (jmeUserPointer*) collisionObject->getUserPointer ();
221227 userPointer -> space = NULL ;
222228 space->getDynamicsWorld ()->removeCollisionObject (collisionObject);
223229 }
@@ -229,8 +235,8 @@ extern "C" {
229235 */
230236 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addAction
231237 (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) {
232- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
233- btActionInterface* actionObject = reinterpret_cast <btActionInterface*>(objectId);
238+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
239+ btActionInterface* actionObject = reinterpret_cast <btActionInterface*> (objectId);
234240 if (space == NULL ) {
235241 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
236242 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -251,8 +257,8 @@ extern "C" {
251257 */
252258 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeAction
253259 (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) {
254- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
255- btActionInterface* actionObject = reinterpret_cast <btActionInterface*>(objectId);
260+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
261+ btActionInterface* actionObject = reinterpret_cast <btActionInterface*> (objectId);
256262 if (space == NULL ) {
257263 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
258264 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -273,8 +279,8 @@ extern "C" {
273279 */
274280 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addVehicle
275281 (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) {
276- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
277- btActionInterface* actionObject = reinterpret_cast <btActionInterface*>(objectId);
282+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
283+ btActionInterface* actionObject = reinterpret_cast <btActionInterface*> (objectId);
278284 if (space == NULL ) {
279285 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
280286 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -295,8 +301,8 @@ extern "C" {
295301 */
296302 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeVehicle
297303 (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) {
298- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
299- btActionInterface* actionObject = reinterpret_cast <btActionInterface*>(objectId);
304+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
305+ btActionInterface* actionObject = reinterpret_cast <btActionInterface*> (objectId);
300306 if (space == NULL ) {
301307 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
302308 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -317,8 +323,8 @@ extern "C" {
317323 */
318324 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addConstraint
319325 (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) {
320- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
321- btTypedConstraint* constraint = reinterpret_cast <btTypedConstraint*>(objectId);
326+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
327+ btTypedConstraint* constraint = reinterpret_cast <btTypedConstraint*> (objectId);
322328 if (space == NULL ) {
323329 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
324330 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -339,8 +345,8 @@ extern "C" {
339345 */
340346 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addConstraintC
341347 (JNIEnv * env, jobject object, jlong spaceId, jlong objectId, jboolean collision) {
342- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
343- btTypedConstraint* constraint = reinterpret_cast <btTypedConstraint*>(objectId);
348+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
349+ btTypedConstraint* constraint = reinterpret_cast <btTypedConstraint*> (objectId);
344350 if (space == NULL ) {
345351 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
346352 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -361,8 +367,8 @@ extern "C" {
361367 */
362368 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeConstraint
363369 (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) {
364- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
365- btTypedConstraint* constraint = reinterpret_cast <btTypedConstraint*>(objectId);
370+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
371+ btTypedConstraint* constraint = reinterpret_cast <btTypedConstraint*> (objectId);
366372 if (space == NULL ) {
367373 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
368374 env->ThrowNew (newExc, " The physics space does not exist." );
@@ -383,14 +389,15 @@ extern "C" {
383389 */
384390 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_setGravity
385391 (JNIEnv * env, jobject object, jlong spaceId, jobject vector) {
386- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
392+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
387393 if (space == NULL ) {
388394 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
389395 env->ThrowNew (newExc, " The physics space does not exist." );
390396 return ;
391397 }
392398 btVector3 gravity = btVector3 ();
393399 jmeBulletUtil::convert (env, vector, &gravity);
400+
394401 space->getDynamicsWorld ()->setGravity (gravity);
395402 }
396403
@@ -411,13 +418,13 @@ extern "C" {
411418 */
412419 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_finalizeNative
413420 (JNIEnv * env, jobject object, jlong spaceId) {
414- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
421+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
415422 if (space == NULL ) {
416423 return ;
417424 }
418425 delete (space);
419426 }
420-
427+
421428 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_rayTest_1native
422429 (JNIEnv * env, jobject object, jobject from, jobject to, jlong spaceId, jobject resultlist, jint flags) {
423430
@@ -465,13 +472,12 @@ extern "C" {
465472 resultCallback.resultlist = resultlist;
466473 resultCallback.m_flags = flags;
467474 space->getDynamicsWorld ()->rayTest (native_from, native_to, resultCallback);
475+
468476 return ;
469477 }
470478
471-
472-
473479 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_sweepTest_1native
474- (JNIEnv * env, jobject object, jlong shapeId, jobject from, jobject to, jlong spaceId, jobject resultlist, jfloat allowedCcdPenetration) {
480+ (JNIEnv * env, jobject object, jlong shapeId, jobject from, jobject to, jlong spaceId, jobject resultlist, jfloat allowedCcdPenetration) {
475481
476482 jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
477483 if (space == NULL ) {
@@ -489,7 +495,7 @@ extern "C" {
489495
490496 struct AllConvexResultCallback : public btCollisionWorld ::ConvexResultCallback {
491497
492- AllConvexResultCallback (const btTransform& convexFromWorld, const btTransform & convexToWorld) : m_convexFromWorld(convexFromWorld), m_convexToWorld(convexToWorld) {
498+ AllConvexResultCallback (const btTransform& convexFromWorld, const btTransform & convexToWorld) : m_convexFromWorld(convexFromWorld), m_convexToWorld(convexToWorld) {
493499 }
494500 jobject resultlist;
495501 JNIEnv* env;
@@ -500,17 +506,16 @@ extern "C" {
500506 btVector3 m_hitPointWorld;
501507
502508 virtual btScalar addSingleResult (btCollisionWorld::LocalConvexResult& convexResult, bool normalInWorldSpace) {
503- if (normalInWorldSpace) {
504- m_hitNormalWorld = convexResult.m_hitNormalLocal ;
505- }
506- else {
507- m_hitNormalWorld = convexResult.m_hitCollisionObject ->getWorldTransform ().getBasis () * convexResult.m_hitNormalLocal ;
508- }
509- m_hitPointWorld.setInterpolate3 (m_convexFromWorld.getBasis () * m_convexFromWorld.getOrigin (), m_convexToWorld.getBasis () * m_convexToWorld.getOrigin (), convexResult.m_hitFraction );
509+ if (normalInWorldSpace) {
510+ m_hitNormalWorld = convexResult.m_hitNormalLocal ;
511+ } else {
512+ m_hitNormalWorld = convexResult.m_hitCollisionObject ->getWorldTransform ().getBasis () * convexResult.m_hitNormalLocal ;
513+ }
514+ m_hitPointWorld.setInterpolate3 (m_convexFromWorld.getBasis () * m_convexFromWorld.getOrigin (), m_convexToWorld.getBasis () * m_convexToWorld.getOrigin (), convexResult.m_hitFraction );
510515
511- jmeBulletUtil::addSweepResult (env, resultlist, &m_hitNormalWorld, &m_hitPointWorld, convexResult.m_hitFraction , convexResult.m_hitCollisionObject );
516+ jmeBulletUtil::addSweepResult (env, resultlist, &m_hitNormalWorld, &m_hitPointWorld, convexResult.m_hitFraction , convexResult.m_hitCollisionObject );
512517
513- return 1 .f ;
518+ return 1 .f ;
514519 }
515520 };
516521
@@ -528,16 +533,16 @@ extern "C" {
528533 space->getDynamicsWorld ()->convexSweepTest ((btConvexShape *) shape, native_from, native_to, resultCallback, native_allowed_ccd_penetration);
529534 return ;
530535 }
531-
536+
532537 JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_setSolverNumIterations
533538 (JNIEnv *env, jobject object, jlong spaceId, jint value) {
534- jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*>(spaceId);
539+ jmePhysicsSpace* space = reinterpret_cast <jmePhysicsSpace*> (spaceId);
535540 if (space == NULL ) {
536541 jclass newExc = env->FindClass (" java/lang/NullPointerException" );
537542 env->ThrowNew (newExc, " The physics space does not exist." );
538543 return ;
539544 }
540-
545+
541546 space->getDynamicsWorld ()->getSolverInfo ().m_numIterations = value;
542547 }
543548
0 commit comments