diff --git a/engine/lib/bullet/jME3-bullet-natives.jar b/engine/lib/bullet/jME3-bullet-natives.jar index 36a545433..28cb31a07 100644 Binary files a/engine/lib/bullet/jME3-bullet-natives.jar and b/engine/lib/bullet/jME3-bullet-natives.jar differ diff --git a/engine/lib/bullet/jarcontent/native/macosx/libbulletjme.jnilib b/engine/lib/bullet/jarcontent/native/macosx/libbulletjme.jnilib index 637b8238c..277a83998 100755 Binary files a/engine/lib/bullet/jarcontent/native/macosx/libbulletjme.jnilib and b/engine/lib/bullet/jarcontent/native/macosx/libbulletjme.jnilib differ diff --git a/engine/src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp b/engine/src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp index 8d33c1901..9e8b1cee0 100644 --- a/engine/src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp @@ -50,7 +50,7 @@ extern "C" { jmeClasses::initJavaClasses(env); jmePhysicsSpace* space = new jmePhysicsSpace(env, object); if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space has not been created."); return 0; } @@ -67,7 +67,7 @@ extern "C" { (JNIEnv * env, jobject object, jlong spaceId, jfloat tpf, jint maxSteps, jfloat accuracy) { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } @@ -84,12 +84,12 @@ extern "C" { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; btCollisionObject* collisionObject = (btCollisionObject*) objectId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } if (collisionObject == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The collision object does not exist."); return; } @@ -106,12 +106,12 @@ extern "C" { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; btCollisionObject* collisionObject = (btCollisionObject*) objectId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } if (collisionObject == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The collision object does not exist."); return; } @@ -128,12 +128,12 @@ extern "C" { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; btRigidBody* collisionObject = (btRigidBody*) rigidBodyId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } if (collisionObject == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The collision object does not exist."); return; } @@ -150,12 +150,12 @@ extern "C" { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; btRigidBody* collisionObject = (btRigidBody*) rigidBodyId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } if (collisionObject == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The collision object does not exist."); return; } @@ -172,12 +172,12 @@ extern "C" { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; btCollisionObject* collisionObject = (btCollisionObject*) objectId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } if (collisionObject == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The collision object does not exist."); return; } @@ -194,12 +194,12 @@ extern "C" { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; btCollisionObject* collisionObject = (btCollisionObject*) objectId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } if (collisionObject == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The collision object does not exist."); return; } @@ -216,12 +216,12 @@ extern "C" { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; btActionInterface* actionObject = (btActionInterface*) objectId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } if (actionObject == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The action object does not exist."); return; } @@ -238,12 +238,12 @@ extern "C" { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; btActionInterface* actionObject = (btActionInterface*) objectId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } if (actionObject == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The action object does not exist."); return; } @@ -260,12 +260,12 @@ extern "C" { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; btActionInterface* actionObject = (btActionInterface*) objectId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } if (actionObject == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The vehicle object does not exist."); return; } @@ -282,12 +282,12 @@ extern "C" { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; btActionInterface* actionObject = (btActionInterface*) objectId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } if (actionObject == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The action object does not exist."); return; } @@ -304,12 +304,12 @@ extern "C" { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; btTypedConstraint* constraint = (btTypedConstraint*) objectId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } if (constraint == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The constraint object does not exist."); return; } @@ -326,12 +326,12 @@ extern "C" { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; btTypedConstraint* constraint = (btTypedConstraint*) objectId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } if (constraint == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The constraint object does not exist."); return; } @@ -347,7 +347,7 @@ extern "C" { (JNIEnv * env, jobject object, jlong spaceId, jobject vector) { jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId; if (space == NULL) { - jclass newExc = env->FindClass("java/lang/IllegalStateException"); + jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } diff --git a/engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.cpp b/engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.cpp index db9594be3..38eeb67e0 100644 --- a/engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.cpp @@ -70,6 +70,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_finalizeNative (JNIEnv * env, jobject object, jlong objectId) { btCollisionObject* collisionObject = (btCollisionObject*) objectId; + if (collisionObject == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } delete(collisionObject); } #ifdef __cplusplus diff --git a/engine/src/bullet/native/com_jme3_bullet_collision_shapes_CollisionShape.cpp b/engine/src/bullet/native/com_jme3_bullet_collision_shapes_CollisionShape.cpp index 3d5618ed4..a2d635dd1 100644 --- a/engine/src/bullet/native/com_jme3_bullet_collision_shapes_CollisionShape.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_collision_shapes_CollisionShape.cpp @@ -48,6 +48,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_collision_shapes_CollisionShape_getMargin (JNIEnv * env, jobject object, jlong shapeId) { btCollisionShape* shape = (btCollisionShape*) shapeId; + if (shape == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return shape->getMargin(); } @@ -59,6 +64,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_shapes_CollisionShape_setLocalScaling (JNIEnv * env, jobject object, jlong shapeId, jobject scale) { btCollisionShape* shape = (btCollisionShape*) shapeId; + if (shape == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 scl = btVector3(); jmeBulletUtil::convert(env, scale, &scl); shape->setLocalScaling(scl); @@ -72,6 +82,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_shapes_CollisionShape_setMargin (JNIEnv * env, jobject object, jlong shapeId, jfloat newMargin) { btCollisionShape* shape = (btCollisionShape*) shapeId; + if (shape == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } shape->setMargin(newMargin); } @@ -83,6 +98,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_shapes_CollisionShape_finalizeNative (JNIEnv * env, jobject object, jlong shapeId) { btCollisionShape* shape = (btCollisionShape*) shapeId; + if (shape == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } delete(shape); } #ifdef __cplusplus diff --git a/engine/src/bullet/native/com_jme3_bullet_collision_shapes_CompoundCollisionShape.cpp b/engine/src/bullet/native/com_jme3_bullet_collision_shapes_CompoundCollisionShape.cpp index 5db7f5186..a196c2cc0 100644 --- a/engine/src/bullet/native/com_jme3_bullet_collision_shapes_CompoundCollisionShape.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_collision_shapes_CompoundCollisionShape.cpp @@ -60,7 +60,17 @@ extern "C" { JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_CompoundCollisionShape_addChildShape (JNIEnv *env, jobject object, jlong compoundId, jlong childId, jobject childLocation, jobject childRotation) { btCompoundShape* shape = (btCompoundShape*) compoundId; + if (shape == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } btCollisionShape* child = (btCollisionShape*) childId; + if (shape == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } btMatrix3x3 mtx = btMatrix3x3(); btTransform trans = btTransform(mtx); jmeBulletUtil::convert(env, childLocation, &trans.getOrigin()); @@ -77,7 +87,17 @@ extern "C" { JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_CompoundCollisionShape_removeChildShape (JNIEnv * env, jobject object, jlong compoundId, jlong childId) { btCompoundShape* shape = (btCompoundShape*) compoundId; + if (shape == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } btCollisionShape* child = (btCollisionShape*) childId; + if (shape == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } shape->removeChildShape(child); return 0; } diff --git a/engine/src/bullet/native/com_jme3_bullet_joints_ConeJoint.cpp b/engine/src/bullet/native/com_jme3_bullet_joints_ConeJoint.cpp index ad64cd596..5b9caa4d9 100644 --- a/engine/src/bullet/native/com_jme3_bullet_joints_ConeJoint.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_joints_ConeJoint.cpp @@ -48,6 +48,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_ConeJoint_setLimit (JNIEnv * env, jobject object, jlong jointId, jfloat swingSpan1, jfloat swingSpan2, jfloat twistSpan) { btConeTwistConstraint* joint = (btConeTwistConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } //TODO: extended setLimit! joint->setLimit(swingSpan1, swingSpan2, twistSpan); } @@ -60,6 +65,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_ConeJoint_setAngularOnly (JNIEnv * env, jobject object, jlong jointId, jboolean angularOnly) { btConeTwistConstraint* joint = (btConeTwistConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setAngularOnly(angularOnly); } diff --git a/engine/src/bullet/native/com_jme3_bullet_joints_HingeJoint.cpp b/engine/src/bullet/native/com_jme3_bullet_joints_HingeJoint.cpp index 46ae4ee67..35703ba8d 100644 --- a/engine/src/bullet/native/com_jme3_bullet_joints_HingeJoint.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_joints_HingeJoint.cpp @@ -48,6 +48,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_HingeJoint_enableMotor (JNIEnv * env, jobject object, jlong jointId, jboolean enable, jfloat targetVelocity, jfloat maxMotorImpulse) { btHingeConstraint* joint = (btHingeConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->enableAngularMotor(enable, targetVelocity, maxMotorImpulse); } @@ -59,6 +64,11 @@ extern "C" { JNIEXPORT jboolean JNICALL Java_com_jme3_bullet_joints_HingeJoint_getEnableAngularMotor (JNIEnv * env, jobject object, jlong jointId) { btHingeConstraint* joint = (btHingeConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return false; + } return joint->getEnableAngularMotor(); } @@ -70,6 +80,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_HingeJoint_getMotorTargetVelocity (JNIEnv * env, jobject object, jlong jointId) { btHingeConstraint* joint = (btHingeConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getMotorTargetVelosity(); } @@ -81,6 +96,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_HingeJoint_getMaxMotorImpulse (JNIEnv * env, jobject object, jlong jointId) { btHingeConstraint* joint = (btHingeConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getMaxMotorImpulse(); } @@ -92,6 +112,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_HingeJoint_setLimit__JFF (JNIEnv * env, jobject object, jlong jointId, jfloat low, jfloat high) { btHingeConstraint* joint = (btHingeConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } return joint->setLimit(low, high); } @@ -103,6 +128,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_HingeJoint_setLimit__JFFFFF (JNIEnv * env, jobject object, jlong jointId, jfloat low, jfloat high, jfloat softness, jfloat biasFactor, jfloat relaxationFactor) { btHingeConstraint* joint = (btHingeConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } return joint->setLimit(low, high, softness, biasFactor, relaxationFactor); } @@ -114,6 +144,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_HingeJoint_getUpperLimit (JNIEnv * env, jobject object, jlong jointId) { btHingeConstraint* joint = (btHingeConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getUpperLimit(); } @@ -125,6 +160,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_HingeJoint_getLowerLimit (JNIEnv * env, jobject object, jlong jointId) { btHingeConstraint* joint = (btHingeConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getLowerLimit(); } @@ -136,6 +176,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_HingeJoint_setAngularOnly (JNIEnv * env, jobject object, jlong jointId, jboolean angular) { btHingeConstraint* joint = (btHingeConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setAngularOnly(angular); } @@ -147,6 +192,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_HingeJoint_getHingeAngle (JNIEnv * env, jobject object, jlong jointId) { btHingeConstraint* joint = (btHingeConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getHingeAngle(); } diff --git a/engine/src/bullet/native/com_jme3_bullet_joints_PhysicsJoint.cpp b/engine/src/bullet/native/com_jme3_bullet_joints_PhysicsJoint.cpp index 74cda4c35..edf532e12 100644 --- a/engine/src/bullet/native/com_jme3_bullet_joints_PhysicsJoint.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_joints_PhysicsJoint.cpp @@ -48,6 +48,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_PhysicsJoint_getAppliedImpulse (JNIEnv * env, jobject object, jlong jointId) { btTypedConstraint* joint = (btTypedConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getAppliedImpulse(); } diff --git a/engine/src/bullet/native/com_jme3_bullet_joints_Point2PointJoint.cpp b/engine/src/bullet/native/com_jme3_bullet_joints_Point2PointJoint.cpp index e32455571..35a9f3791 100644 --- a/engine/src/bullet/native/com_jme3_bullet_joints_Point2PointJoint.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_joints_Point2PointJoint.cpp @@ -48,6 +48,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_Point2PointJoint_setDamping (JNIEnv * env, jobject object, jlong jointId, jfloat damping) { btPoint2PointConstraint* joint = (btPoint2PointConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->m_setting.m_damping = damping; } @@ -59,6 +64,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_Point2PointJoint_setImpulseClamp (JNIEnv * env, jobject object, jlong jointId, jfloat clamp) { btPoint2PointConstraint* joint = (btPoint2PointConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->m_setting.m_impulseClamp = clamp; } @@ -70,6 +80,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_Point2PointJoint_setTau (JNIEnv * env, jobject object, jlong jointId, jfloat tau) { btPoint2PointConstraint* joint = (btPoint2PointConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->m_setting.m_tau = tau; } @@ -81,6 +96,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_Point2PointJoint_getDamping (JNIEnv * env, jobject object, jlong jointId) { btPoint2PointConstraint* joint = (btPoint2PointConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->m_setting.m_damping; } @@ -92,6 +112,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_Point2PointJoint_getImpulseClamp (JNIEnv * env, jobject object, jlong jointId) { btPoint2PointConstraint* joint = (btPoint2PointConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->m_setting.m_damping; } @@ -103,6 +128,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_Point2PointJoint_getTau (JNIEnv * env, jobject object, jlong jointId) { btPoint2PointConstraint* joint = (btPoint2PointConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->m_setting.m_damping; } @@ -117,8 +147,8 @@ extern "C" { btRigidBody* bodyA = (btRigidBody*) bodyIdA; btRigidBody* bodyB = (btRigidBody*) bodyIdB; //TODO: matrix not needed? - btMatrix3x3 mtx1=btMatrix3x3(); - btMatrix3x3 mtx2=btMatrix3x3(); + btMatrix3x3 mtx1 = btMatrix3x3(); + btMatrix3x3 mtx2 = btMatrix3x3(); btTransform transA = btTransform(mtx1); jmeBulletUtil::convert(env, pivotA, &transA.getOrigin()); btTransform transB = btTransform(mtx2); diff --git a/engine/src/bullet/native/com_jme3_bullet_joints_SixDofJoint.cpp b/engine/src/bullet/native/com_jme3_bullet_joints_SixDofJoint.cpp index 59fbb2e64..65e5924ee 100644 --- a/engine/src/bullet/native/com_jme3_bullet_joints_SixDofJoint.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_joints_SixDofJoint.cpp @@ -48,7 +48,12 @@ extern "C" { JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofJoint_getRotationalLimitMotor (JNIEnv * env, jobject object, jlong jointId, jint index) { btGeneric6DofConstraint* joint = (btGeneric6DofConstraint*) jointId; - return (long)joint->getRotationalLimitMotor(index); + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } + return (long) joint->getRotationalLimitMotor(index); } /* @@ -59,7 +64,12 @@ extern "C" { JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofJoint_getTranslationalLimitMotor (JNIEnv * env, jobject object, jlong jointId) { btGeneric6DofConstraint* joint = (btGeneric6DofConstraint*) jointId; - return (long)joint->getTranslationalLimitMotor(); + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } + return (long) joint->getTranslationalLimitMotor(); } /* @@ -70,6 +80,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofJoint_setLinearUpperLimit (JNIEnv * env, jobject object, jlong jointId, jobject vector) { btGeneric6DofConstraint* joint = (btGeneric6DofConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec = btVector3(); jmeBulletUtil::convert(env, vector, &vec); joint->setLinearUpperLimit(vec); @@ -83,6 +98,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofJoint_setLinearLowerLimit (JNIEnv * env, jobject object, jlong jointId, jobject vector) { btGeneric6DofConstraint* joint = (btGeneric6DofConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec = btVector3(); jmeBulletUtil::convert(env, vector, &vec); joint->setLinearLowerLimit(vec); @@ -96,6 +116,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofJoint_setAngularUpperLimit (JNIEnv * env, jobject object, jlong jointId, jobject vector) { btGeneric6DofConstraint* joint = (btGeneric6DofConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec = btVector3(); jmeBulletUtil::convert(env, vector, &vec); joint->setAngularUpperLimit(vec); @@ -109,6 +134,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofJoint_setAngularLowerLimit (JNIEnv * env, jobject object, jlong jointId, jobject vector) { btGeneric6DofConstraint* joint = (btGeneric6DofConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec = btVector3(); jmeBulletUtil::convert(env, vector, &vec); joint->setAngularLowerLimit(vec); @@ -133,7 +163,7 @@ extern "C" { jmeBulletUtil::convert(env, pivotB, &transB.getOrigin()); jmeBulletUtil::convert(env, rotB, &transB.getBasis()); btGeneric6DofConstraint* joint = new btGeneric6DofConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA); - return (long)joint; + return (long) joint; } #ifdef __cplusplus } diff --git a/engine/src/bullet/native/com_jme3_bullet_joints_SliderJoint.cpp b/engine/src/bullet/native/com_jme3_bullet_joints_SliderJoint.cpp index 7922ac968..d59760cfc 100644 --- a/engine/src/bullet/native/com_jme3_bullet_joints_SliderJoint.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_joints_SliderJoint.cpp @@ -48,6 +48,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getLowerLinLimit (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getLowerLinLimit(); } @@ -59,6 +64,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setLowerLinLimit (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setLowerLinLimit(value); } @@ -70,6 +80,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getUpperLinLimit (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getUpperLinLimit(); } @@ -81,6 +96,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setUpperLinLimit (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setUpperLinLimit(value); } @@ -92,6 +112,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getLowerAngLimit (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getLowerAngLimit(); } @@ -103,6 +128,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setLowerAngLimit (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setLowerAngLimit(value); } @@ -114,6 +144,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getUpperAngLimit (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getUpperAngLimit(); } @@ -125,6 +160,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setUpperAngLimit (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setUpperAngLimit(value); } @@ -136,6 +176,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getSoftnessDirLin (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getSoftnessDirLin(); } @@ -147,6 +192,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setSoftnessDirLin (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setSoftnessDirLin(value); } @@ -158,6 +208,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getRestitutionDirLin (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getRestitutionDirLin(); } @@ -169,6 +224,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setRestitutionDirLin (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setRestitutionDirLin(value); } @@ -180,6 +240,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getDampingDirLin (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getDampingDirLin(); } @@ -191,6 +256,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setDampingDirLin (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setDampingDirLin(value); } @@ -202,6 +272,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getSoftnessDirAng (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getSoftnessDirAng(); } @@ -213,6 +288,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setSoftnessDirAng (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setSoftnessDirAng(value); } @@ -224,6 +304,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getRestitutionDirAng (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getRestitutionDirAng(); } @@ -235,6 +320,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setRestitutionDirAng (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setRestitutionDirAng(value); } @@ -246,6 +336,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getDampingDirAng (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getDampingDirAng(); } @@ -257,6 +352,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setDampingDirAng (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setDampingDirAng(value); } @@ -268,6 +368,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getSoftnessLimLin (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getSoftnessLimLin(); } @@ -279,6 +384,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setSoftnessLimLin (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setSoftnessLimLin(value); } @@ -290,6 +400,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getRestitutionLimLin (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getRestitutionLimLin(); } @@ -301,6 +416,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setRestitutionLimLin (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setRestitutionLimLin(value); } @@ -312,6 +432,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getDampingLimLin (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getDampingLimLin(); } @@ -323,6 +448,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setDampingLimLin (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setDampingLimLin(value); } @@ -334,6 +464,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getSoftnessLimAng (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getSoftnessLimAng(); } @@ -345,6 +480,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setSoftnessLimAng (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setSoftnessLimAng(value); } @@ -356,6 +496,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getRestitutionLimAng (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getRestitutionLimAng(); } @@ -367,6 +512,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setRestitutionLimAng (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setRestitutionLimAng(value); } @@ -378,6 +528,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getDampingLimAng (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getDampingLimAng(); } @@ -389,6 +544,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setDampingLimAng (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setDampingLimAng(value); } @@ -400,6 +560,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getSoftnessOrthoLin (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getSoftnessOrthoLin(); } @@ -411,6 +576,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setSoftnessOrthoLin (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setSoftnessOrthoLin(value); } @@ -422,6 +592,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getRestitutionOrthoLin (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getRestitutionOrthoLin(); } @@ -433,6 +608,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setRestitutionOrthoLin (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setRestitutionOrthoLin(value); } @@ -444,6 +624,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getDampingOrthoLin (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getDampingOrthoLin(); } @@ -455,6 +640,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setDampingOrthoLin (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setDampingOrthoLin(value); } @@ -466,6 +656,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getSoftnessOrthoAng (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getSoftnessOrthoAng(); } @@ -477,6 +672,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setSoftnessOrthoAng (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setSoftnessOrthoAng(value); } @@ -488,6 +688,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getRestitutionOrthoAng (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getRestitutionOrthoAng(); } @@ -499,6 +704,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setRestitutionOrthoAng (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setRestitutionOrthoAng(value); } @@ -510,6 +720,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getDampingOrthoAng (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getDampingOrthoAng(); } @@ -521,6 +736,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setDampingOrthoAng (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setDampingOrthoAng(value); } @@ -532,6 +752,11 @@ extern "C" { JNIEXPORT jboolean JNICALL Java_com_jme3_bullet_joints_SliderJoint_isPoweredLinMotor (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return false; + } return joint->getPoweredLinMotor(); } @@ -543,6 +768,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setPoweredLinMotor (JNIEnv * env, jobject object, jlong jointId, jboolean value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setPoweredLinMotor(value); } @@ -554,6 +784,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getTargetLinMotorVelocity (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getTargetLinMotorVelocity(); } @@ -565,6 +800,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setTargetLinMotorVelocity (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setTargetLinMotorVelocity(value); } @@ -576,6 +816,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getMaxLinMotorForce (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getMaxLinMotorForce(); } @@ -587,6 +832,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setMaxLinMotorForce (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setMaxLinMotorForce(value); } @@ -598,6 +848,11 @@ extern "C" { JNIEXPORT jboolean JNICALL Java_com_jme3_bullet_joints_SliderJoint_isPoweredAngMotor (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return false; + } return joint->getPoweredAngMotor(); } @@ -609,6 +864,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setPoweredAngMotor (JNIEnv * env, jobject object, jlong jointId, jboolean value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setPoweredAngMotor(value); } @@ -620,6 +880,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getTargetAngMotorVelocity (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getTargetAngMotorVelocity(); } @@ -631,6 +896,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setTargetAngMotorVelocity (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setTargetAngMotorVelocity(value); } @@ -642,6 +912,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_SliderJoint_getMaxAngMotorForce (JNIEnv * env, jobject object, jlong jointId) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return joint->getMaxAngMotorForce(); } @@ -653,6 +928,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SliderJoint_setMaxAngMotorForce (JNIEnv * env, jobject object, jlong jointId, jfloat value) { btSliderConstraint* joint = (btSliderConstraint*) jointId; + if (joint == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } joint->setMaxAngMotorForce(value); } @@ -666,8 +946,8 @@ extern "C" { jmeClasses::initJavaClasses(env); btRigidBody* bodyA = (btRigidBody*) bodyIdA; btRigidBody* bodyB = (btRigidBody*) bodyIdB; - btMatrix3x3 mtx1=btMatrix3x3(); - btMatrix3x3 mtx2=btMatrix3x3(); + btMatrix3x3 mtx1 = btMatrix3x3(); + btMatrix3x3 mtx2 = btMatrix3x3(); btTransform transA = btTransform(mtx1); jmeBulletUtil::convert(env, pivotA, &transA.getOrigin()); jmeBulletUtil::convert(env, rotA, &transA.getBasis()); @@ -675,7 +955,7 @@ extern "C" { jmeBulletUtil::convert(env, pivotB, &transB.getOrigin()); jmeBulletUtil::convert(env, rotB, &transB.getBasis()); btSliderConstraint* joint = new btSliderConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA); - return (long)joint; + return (long) joint; } #ifdef __cplusplus diff --git a/engine/src/bullet/native/com_jme3_bullet_joints_motors_RotationalLimitMotor.cpp b/engine/src/bullet/native/com_jme3_bullet_joints_motors_RotationalLimitMotor.cpp index 6c9e5d930..818d674a6 100644 --- a/engine/src/bullet/native/com_jme3_bullet_joints_motors_RotationalLimitMotor.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_joints_motors_RotationalLimitMotor.cpp @@ -48,6 +48,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_getLoLimit (JNIEnv *env, jobject object, jlong motorId) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return motor->m_loLimit; } @@ -59,6 +64,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_setLoLimit (JNIEnv *env, jobject object, jlong motorId, jfloat value) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } motor->m_loLimit = value; } @@ -70,6 +80,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_getHiLimit (JNIEnv *env, jobject object, jlong motorId) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return motor->m_hiLimit; } @@ -81,6 +96,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_setHiLimit (JNIEnv *env, jobject object, jlong motorId, jfloat value) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } motor->m_hiLimit = value; } @@ -92,6 +112,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_getTargetVelocity (JNIEnv *env, jobject object, jlong motorId) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return motor->m_targetVelocity; } @@ -103,6 +128,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_setTargetVelocity (JNIEnv *env, jobject object, jlong motorId, jfloat value) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } motor->m_targetVelocity = value; } @@ -114,6 +144,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_getMaxMotorForce (JNIEnv *env, jobject object, jlong motorId) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return motor->m_maxMotorForce; } @@ -125,6 +160,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_setMaxMotorForce (JNIEnv *env, jobject object, jlong motorId, jfloat value) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } motor->m_maxMotorForce = value; } @@ -136,6 +176,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_getMaxLimitForce (JNIEnv *env, jobject object, jlong motorId) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return motor->m_maxLimitForce; } @@ -147,6 +192,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_setMaxLimitForce (JNIEnv *env, jobject object, jlong motorId, jfloat value) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } motor->m_maxLimitForce = value; } @@ -158,6 +208,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_getDamping (JNIEnv *env, jobject object, jlong motorId) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return motor->m_damping; } @@ -169,6 +224,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_setDamping (JNIEnv *env, jobject object, jlong motorId, jfloat value) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } motor->m_damping = value; } @@ -180,6 +240,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_getLimitSoftness (JNIEnv *env, jobject object, jlong motorId) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return motor->m_limitSoftness; } @@ -191,6 +256,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_setLimitSoftness (JNIEnv *env, jobject object, jlong motorId, jfloat value) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } motor->m_limitSoftness = value; } @@ -202,6 +272,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_getERP (JNIEnv *env, jobject object, jlong motorId) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return motor->m_stopERP; } @@ -213,6 +288,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_setERP (JNIEnv *env, jobject object, jlong motorId, jfloat value) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } motor->m_stopERP = value; } @@ -224,6 +304,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_getBounce (JNIEnv *env, jobject object, jlong motorId) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return motor->m_bounce; } @@ -235,6 +320,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_setBounce (JNIEnv *env, jobject object, jlong motorId, jfloat value) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } motor->m_bounce = value; } @@ -246,6 +336,11 @@ extern "C" { JNIEXPORT jboolean JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_isEnableMotor (JNIEnv *env, jobject object, jlong motorId) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return false; + } return motor->m_enableMotor; } @@ -257,6 +352,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_RotationalLimitMotor_setEnableMotor (JNIEnv *env, jobject object, jlong motorId, jboolean value) { btRotationalLimitMotor* motor = (btRotationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } motor->m_enableMotor = value; } diff --git a/engine/src/bullet/native/com_jme3_bullet_joints_motors_TranslationalLimitMotor.cpp b/engine/src/bullet/native/com_jme3_bullet_joints_motors_TranslationalLimitMotor.cpp index 288df911d..827385457 100644 --- a/engine/src/bullet/native/com_jme3_bullet_joints_motors_TranslationalLimitMotor.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_joints_motors_TranslationalLimitMotor.cpp @@ -48,6 +48,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_getLowerLimit (JNIEnv *env, jobject object, jlong motorId, jobject vector) { btTranslationalLimitMotor* motor = (btTranslationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &motor->m_lowerLimit, vector); } @@ -59,6 +64,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_setLowerLimit (JNIEnv *env, jobject object, jlong motorId, jobject vector) { btTranslationalLimitMotor* motor = (btTranslationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, vector, &motor->m_lowerLimit); } @@ -70,6 +80,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_getUpperLimit (JNIEnv *env, jobject object, jlong motorId, jobject vector) { btTranslationalLimitMotor* motor = (btTranslationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &motor->m_upperLimit, vector); } @@ -81,6 +96,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_setUpperLimit (JNIEnv *env, jobject object, jlong motorId, jobject vector) { btTranslationalLimitMotor* motor = (btTranslationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, vector, &motor->m_upperLimit); } @@ -92,6 +112,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_getAccumulatedImpulse (JNIEnv *env, jobject object, jlong motorId, jobject vector) { btTranslationalLimitMotor* motor = (btTranslationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &motor->m_accumulatedImpulse, vector); } @@ -103,6 +128,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_setAccumulatedImpulse (JNIEnv *env, jobject object, jlong motorId, jobject vector) { btTranslationalLimitMotor* motor = (btTranslationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, vector, &motor->m_accumulatedImpulse); } @@ -114,6 +144,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_getLetLimitSoftness (JNIEnv *env, jobject object, jlong motorId) { btTranslationalLimitMotor* motor = (btTranslationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return motor->m_limitSoftness; } @@ -125,6 +160,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_setLimitSoftness (JNIEnv *env, jobject object, jlong motorId, jfloat value) { btTranslationalLimitMotor* motor = (btTranslationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } motor->m_limitSoftness = value; } @@ -136,6 +176,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_getDamping (JNIEnv *env, jobject object, jlong motorId) { btTranslationalLimitMotor* motor = (btTranslationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return motor->m_damping; } @@ -147,6 +192,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_setDamping (JNIEnv *env, jobject object, jlong motorId, jfloat value) { btTranslationalLimitMotor* motor = (btTranslationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } motor->m_damping = value; } @@ -158,6 +208,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_getRestitution (JNIEnv *env, jobject object, jlong motorId) { btTranslationalLimitMotor* motor = (btTranslationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return motor->m_restitution; } @@ -169,6 +224,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_setRestitution (JNIEnv *env, jobject object, jlong motorId, jfloat value) { btTranslationalLimitMotor* motor = (btTranslationalLimitMotor*) motorId; + if (motor == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } motor->m_restitution = value; } diff --git a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsCharacter.cpp b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsCharacter.cpp index a98da9bb3..ea525480e 100644 --- a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsCharacter.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsCharacter.cpp @@ -63,6 +63,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_setCharacterFlags (JNIEnv *env, jobject object, jlong ghostId) { btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) ghostId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } ghost->setCollisionFlags(ghost->getCollisionFlags() | btCollisionObject::CF_CHARACTER_OBJECT); ghost->setCollisionFlags(ghost->getCollisionFlags() & ~btCollisionObject::CF_NO_CONTACT_RESPONSE); } @@ -75,6 +80,11 @@ extern "C" { JNIEXPORT jlong JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_createCharacterObject (JNIEnv *env, jobject object, jlong objectId, jlong shapeId, jfloat stepHeight) { btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } //TODO: check convexshape! btConvexShape* shape = (btConvexShape*) shapeId; btKinematicCharacterController* character = new btKinematicCharacterController(ghost, shape, stepHeight); @@ -89,6 +99,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_warp (JNIEnv *env, jobject object, jlong objectId, jobject vector) { btKinematicCharacterController* character = (btKinematicCharacterController*) objectId; + if (character == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec = btVector3(); jmeBulletUtil::convert(env, vector, &vec); character->warp(vec); @@ -102,6 +117,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_setWalkDirection (JNIEnv *env, jobject object, jlong objectId, jobject vector) { btKinematicCharacterController* character = (btKinematicCharacterController*) objectId; + if (character == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec = btVector3(); jmeBulletUtil::convert(env, vector, &vec); character->setWalkDirection(vec); @@ -115,6 +135,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_setUpAxis (JNIEnv *env, jobject object, jlong objectId, jint value) { btKinematicCharacterController* character = (btKinematicCharacterController*) objectId; + if (character == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } character->setUpAxis(value); } @@ -126,6 +151,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_setFallSpeed (JNIEnv *env, jobject object, jlong objectId, jfloat value) { btKinematicCharacterController* character = (btKinematicCharacterController*) objectId; + if (character == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } character->setFallSpeed(value); } @@ -137,6 +167,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_setJumpSpeed (JNIEnv *env, jobject object, jlong objectId, jfloat value) { btKinematicCharacterController* character = (btKinematicCharacterController*) objectId; + if (character == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } character->setJumpSpeed(value); } @@ -148,6 +183,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_setGravity (JNIEnv *env, jobject object, jlong objectId, jfloat value) { btKinematicCharacterController* character = (btKinematicCharacterController*) objectId; + if (character == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } character->setGravity(value); } @@ -159,6 +199,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_getGravity (JNIEnv *env, jobject object, jlong objectId) { btKinematicCharacterController* character = (btKinematicCharacterController*) objectId; + if (character == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return character->getGravity(); } @@ -170,6 +215,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_setMaxSlope (JNIEnv *env, jobject object, jlong objectId, jfloat value) { btKinematicCharacterController* character = (btKinematicCharacterController*) objectId; + if (character == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } character->setMaxSlope(value); } @@ -181,6 +231,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_getMaxSlope (JNIEnv *env, jobject object, jlong objectId) { btKinematicCharacterController* character = (btKinematicCharacterController*) objectId; + if (character == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return character->getMaxSlope(); } @@ -192,6 +247,11 @@ extern "C" { JNIEXPORT jboolean JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_onGround (JNIEnv *env, jobject object, jlong objectId) { btKinematicCharacterController* character = (btKinematicCharacterController*) objectId; + if (character == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return false; + } return character->onGround(); } @@ -203,6 +263,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_jump (JNIEnv *env, jobject object, jlong objectId) { btKinematicCharacterController* character = (btKinematicCharacterController*) objectId; + if (character == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } character->jump(); } @@ -213,8 +278,13 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_getPhysicsLocation (JNIEnv *env, jobject object, jlong objectId, jobject value) { - btGhostObject* character = (btGhostObject*) objectId; - jmeBulletUtil::convert(env, &character->getWorldTransform().getOrigin(), value); + btGhostObject* ghost = (btGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } + jmeBulletUtil::convert(env, &ghost->getWorldTransform().getOrigin(), value); } /* @@ -224,8 +294,13 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_setCcdSweptSphereRadius (JNIEnv *env, jobject object, jlong objectId, jfloat value) { - btGhostObject* character = (btGhostObject*) objectId; - character->setCcdSweptSphereRadius(value); + btGhostObject* ghost = (btGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } + ghost->setCcdSweptSphereRadius(value); } /* @@ -235,8 +310,13 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_setCcdMotionThreshold (JNIEnv *env, jobject object, jlong objectId, jfloat value) { - btGhostObject* character = (btGhostObject*) objectId; - character->setCcdMotionThreshold(value); + btGhostObject* ghost = (btGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } + ghost->setCcdMotionThreshold(value); } /* @@ -246,8 +326,13 @@ extern "C" { */ JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_getCcdSweptSphereRadius (JNIEnv *env, jobject object, jlong objectId) { - btGhostObject* character = (btGhostObject*) objectId; - return character->getCcdSweptSphereRadius(); + btGhostObject* ghost = (btGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } + return ghost->getCcdSweptSphereRadius(); } /* @@ -257,8 +342,13 @@ extern "C" { */ JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_getCcdMotionThreshold (JNIEnv *env, jobject object, jlong objectId) { - btGhostObject* character = (btGhostObject*) objectId; - return character->getCcdMotionThreshold(); + btGhostObject* ghost = (btGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } + return ghost->getCcdMotionThreshold(); } /* @@ -268,8 +358,13 @@ extern "C" { */ JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_getCcdSquareMotionThreshold (JNIEnv *env, jobject object, jlong objectId) { - btGhostObject* character = (btGhostObject*) objectId; - return character->getCcdSquareMotionThreshold(); + btGhostObject* ghost = (btGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } + return ghost->getCcdSquareMotionThreshold(); } /* @@ -280,6 +375,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_finalizeNativeCharacter (JNIEnv *env, jobject object, jlong objectId) { btKinematicCharacterController* character = (btKinematicCharacterController*) objectId; + if (character == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } delete(character); } diff --git a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp index 4bac1bee6..42d496eb7 100644 --- a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp @@ -63,6 +63,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_setGhostFlags (JNIEnv *env, jobject object, jlong objectId) { btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } ghost->setCollisionFlags(ghost->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE); } @@ -72,8 +77,13 @@ extern "C" { * Signature: (JLcom/jme3/math/Vector3f;)V */ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_setPhysicsLocation - (JNIEnv *env, jobject object, jlong objectId, jobject value){ - btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId; + (JNIEnv *env, jobject object, jlong objectId, jobject value) { + btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, value, &ghost->getWorldTransform().getOrigin()); } @@ -83,8 +93,13 @@ extern "C" { * Signature: (JLcom/jme3/math/Matrix3f;)V */ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_setPhysicsRotation__JLcom_jme3_math_Matrix3f_2 - (JNIEnv *env, jobject object, jlong objectId, jobject value){ - btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId; + (JNIEnv *env, jobject object, jlong objectId, jobject value) { + btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, value, &ghost->getWorldTransform().getBasis()); } @@ -94,8 +109,13 @@ extern "C" { * Signature: (JLcom/jme3/math/Quaternion;)V */ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_setPhysicsRotation__JLcom_jme3_math_Quaternion_2 - (JNIEnv *env, jobject object, jlong objectId, jobject value){ - btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId; + (JNIEnv *env, jobject object, jlong objectId, jobject value) { + btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convertQuat(env, value, &ghost->getWorldTransform().getBasis()); } @@ -105,8 +125,13 @@ extern "C" { * Signature: (JLcom/jme3/math/Vector3f;)V */ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_getPhysicsLocation - (JNIEnv *env, jobject object, jlong objectId, jobject value){ - btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId; + (JNIEnv *env, jobject object, jlong objectId, jobject value) { + btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &ghost->getWorldTransform().getOrigin(), value); } @@ -116,8 +141,13 @@ extern "C" { * Signature: (JLcom/jme3/math/Quaternion;)V */ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_getPhysicsRotation - (JNIEnv *env, jobject object, jlong objectId, jobject value){ - btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId; + (JNIEnv *env, jobject object, jlong objectId, jobject value) { + btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convertQuat(env, &ghost->getWorldTransform().getBasis(), value); } @@ -127,8 +157,13 @@ extern "C" { * Signature: (JLcom/jme3/math/Matrix3f;)V */ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_getPhysicsRotationMatrix - (JNIEnv *env, jobject object, jlong objectId, jobject value){ - btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId; + (JNIEnv *env, jobject object, jlong objectId, jobject value) { + btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &ghost->getWorldTransform().getBasis(), value); } @@ -138,8 +173,13 @@ extern "C" { * Signature: (J)I */ JNIEXPORT jint JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_getOverlappingCount - (JNIEnv *env, jobject object, jlong objectId){ - btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId; + (JNIEnv *env, jobject object, jlong objectId) { + btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return ghost->getNumOverlappingObjects(); } @@ -149,8 +189,13 @@ extern "C" { * Signature: (JF)V */ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_setCcdSweptSphereRadius - (JNIEnv *env, jobject object, jlong objectId, jfloat value){ - btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId; + (JNIEnv *env, jobject object, jlong objectId, jfloat value) { + btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } ghost->setCcdSweptSphereRadius(value); } @@ -160,8 +205,13 @@ extern "C" { * Signature: (JF)V */ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_setCcdMotionThreshold - (JNIEnv *env, jobject object, jlong objectId, jfloat value){ - btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId; + (JNIEnv *env, jobject object, jlong objectId, jfloat value) { + btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } ghost->setCcdMotionThreshold(value); } @@ -171,8 +221,13 @@ extern "C" { * Signature: (J)F */ JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_getCcdSweptSphereRadius - (JNIEnv *env, jobject object, jlong objectId){ - btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId; + (JNIEnv *env, jobject object, jlong objectId) { + btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return ghost->getCcdSweptSphereRadius(); } @@ -182,8 +237,13 @@ extern "C" { * Signature: (J)F */ JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_getCcdMotionThreshold - (JNIEnv *env, jobject object, jlong objectId){ - btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId; + (JNIEnv *env, jobject object, jlong objectId) { + btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return ghost->getCcdMotionThreshold(); } @@ -193,8 +253,13 @@ extern "C" { * Signature: (J)F */ JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_getCcdSquareMotionThreshold - (JNIEnv *env, jobject object, jlong objectId){ - btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId; + (JNIEnv *env, jobject object, jlong objectId) { + btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId; + if (ghost == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return ghost->getCcdSquareMotionThreshold(); } diff --git a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsRigidBody.cpp b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsRigidBody.cpp index 0533fa108..e6d3933e2 100644 --- a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsRigidBody.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsRigidBody.cpp @@ -65,6 +65,11 @@ extern "C" { JNIEXPORT jboolean JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_isInWorld (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return false; + } return body->isInWorld(); } @@ -76,16 +81,21 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setPhysicsLocation (JNIEnv *env, jobject object, jlong bodyId, jobject value) { btRigidBody* body = (btRigidBody*) bodyId; -// if (body->isStaticOrKinematicObject() || !body->isInWorld()) - ((jmeMotionState*)body->getMotionState())->setKinematicLocation(env, value); - body->setCenterOfMassTransform(((jmeMotionState*)body->getMotionState())->worldTransform); -// else{ -// btMatrix3x3* mtx = &btMatrix3x3(); -// btTransform* trans = &btTransform(*mtx); -// trans->setBasis(body->getCenterOfMassTransform().getBasis()); -// jmeBulletUtil::convert(env, value, &trans->getOrigin()); -// body->setCenterOfMassTransform(*trans); -// } + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } + // if (body->isStaticOrKinematicObject() || !body->isInWorld()) + ((jmeMotionState*) body->getMotionState())->setKinematicLocation(env, value); + body->setCenterOfMassTransform(((jmeMotionState*) body->getMotionState())->worldTransform); + // else{ + // btMatrix3x3* mtx = &btMatrix3x3(); + // btTransform* trans = &btTransform(*mtx); + // trans->setBasis(body->getCenterOfMassTransform().getBasis()); + // jmeBulletUtil::convert(env, value, &trans->getOrigin()); + // body->setCenterOfMassTransform(*trans); + // } } /* @@ -96,16 +106,21 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setPhysicsRotation__JLcom_jme3_math_Matrix3f_2 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { btRigidBody* body = (btRigidBody*) bodyId; -// if (body->isStaticOrKinematicObject() || !body->isInWorld()) - ((jmeMotionState*)body->getMotionState())->setKinematicRotation(env, value); - body->setCenterOfMassTransform(((jmeMotionState*)body->getMotionState())->worldTransform); -// else{ -// btMatrix3x3* mtx = &btMatrix3x3(); -// btTransform* trans = &btTransform(*mtx); -// trans->setOrigin(body->getCenterOfMassTransform().getOrigin()); -// jmeBulletUtil::convert(env, value, &trans->getBasis()); -// body->setCenterOfMassTransform(*trans); -// } + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } + // if (body->isStaticOrKinematicObject() || !body->isInWorld()) + ((jmeMotionState*) body->getMotionState())->setKinematicRotation(env, value); + body->setCenterOfMassTransform(((jmeMotionState*) body->getMotionState())->worldTransform); + // else{ + // btMatrix3x3* mtx = &btMatrix3x3(); + // btTransform* trans = &btTransform(*mtx); + // trans->setOrigin(body->getCenterOfMassTransform().getOrigin()); + // jmeBulletUtil::convert(env, value, &trans->getBasis()); + // body->setCenterOfMassTransform(*trans); + // } } /* @@ -116,16 +131,21 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setPhysicsRotation__JLcom_jme3_math_Quaternion_2 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { btRigidBody* body = (btRigidBody*) bodyId; -// if (body->isStaticOrKinematicObject() || !body->isInWorld()) - ((jmeMotionState*)body->getMotionState())->setKinematicRotationQuat(env, value); - body->setCenterOfMassTransform(((jmeMotionState*)body->getMotionState())->worldTransform); -// else{ -// btMatrix3x3* mtx = &btMatrix3x3(); -// btTransform* trans = &btTransform(*mtx); -// trans->setOrigin(body->getCenterOfMassTransform().getOrigin()); -// jmeBulletUtil::convertQuat(env, value, &trans->getBasis()); -// body->setCenterOfMassTransform(*trans); -// } + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } + // if (body->isStaticOrKinematicObject() || !body->isInWorld()) + ((jmeMotionState*) body->getMotionState())->setKinematicRotationQuat(env, value); + body->setCenterOfMassTransform(((jmeMotionState*) body->getMotionState())->worldTransform); + // else{ + // btMatrix3x3* mtx = &btMatrix3x3(); + // btTransform* trans = &btTransform(*mtx); + // trans->setOrigin(body->getCenterOfMassTransform().getOrigin()); + // jmeBulletUtil::convertQuat(env, value, &trans->getBasis()); + // body->setCenterOfMassTransform(*trans); + // } } /* @@ -136,6 +156,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getPhysicsLocation (JNIEnv *env, jobject object, jlong bodyId, jobject value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &body->getWorldTransform().getOrigin(), value); } @@ -147,6 +172,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getPhysicsRotation (JNIEnv *env, jobject object, jlong bodyId, jobject value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convertQuat(env, &body->getWorldTransform().getBasis(), value); } @@ -158,6 +188,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getPhysicsRotationMatrix (JNIEnv *env, jobject object, jlong bodyId, jobject value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &body->getWorldTransform().getBasis(), value); } @@ -169,6 +204,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setKinematic (JNIEnv *env, jobject object, jlong bodyId, jboolean value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } if (value) { body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); body->setActivationState(DISABLE_DEACTIVATION); @@ -186,6 +226,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setCcdSweptSphereRadius (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } body->setCcdSweptSphereRadius(value); } @@ -197,6 +242,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setCcdMotionThreshold (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } body->setCcdMotionThreshold(value); } @@ -208,6 +258,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getCcdSweptSphereRadius (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return body->getCcdSweptSphereRadius(); } @@ -219,6 +274,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getCcdMotionThreshold (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return body->getCcdMotionThreshold(); } @@ -230,6 +290,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getCcdSquareMotionThreshold (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return body->getCcdSquareMotionThreshold(); } @@ -241,6 +306,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setStatic (JNIEnv *env, jobject object, jlong bodyId, jboolean value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } if (value) { body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT); } else { @@ -256,6 +326,11 @@ extern "C" { JNIEXPORT jlong JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_updateMassProps (JNIEnv *env, jobject object, jlong bodyId, jlong shapeId, jfloat mass) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } btCollisionShape* shape = (btCollisionShape*) shapeId; btVector3 localInertia = btVector3(); shape->calculateLocalInertia(mass, localInertia); @@ -271,6 +346,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getGravity (JNIEnv *env, jobject object, jlong bodyId, jobject value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &body->getGravity(), value); } @@ -282,6 +362,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setGravity (JNIEnv *env, jobject object, jlong bodyId, jobject value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec = btVector3(); jmeBulletUtil::convert(env, value, &vec); body->setGravity(vec); @@ -295,6 +380,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getFriction (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return body->getFriction(); } @@ -306,6 +396,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setFriction (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } body->setFriction(value); } @@ -317,6 +412,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setDamping (JNIEnv *env, jobject object, jlong bodyId, jfloat value1, jfloat value2) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } body->setDamping(value1, value2); } @@ -328,6 +428,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setAngularDamping (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } body->setDamping(body->getLinearDamping(), value); } @@ -339,6 +444,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getLinearDamping (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return body->getLinearDamping(); } @@ -350,6 +460,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getAngularDamping (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return body->getAngularDamping(); } @@ -361,6 +476,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getRestitution (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return body->getRestitution(); } @@ -372,6 +492,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setRestitution (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } body->setRestitution(value); } @@ -383,6 +508,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getAngularVelocity (JNIEnv *env, jobject object, jlong bodyId, jobject value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &body->getAngularVelocity(), value); } @@ -394,8 +524,13 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setAngularVelocity (JNIEnv *env, jobject object, jlong bodyId, jobject value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec = btVector3(); - jmeBulletUtil::convert(env, value,&vec); + jmeBulletUtil::convert(env, value, &vec); body->setAngularVelocity(vec); } @@ -407,6 +542,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getLinearVelocity (JNIEnv *env, jobject object, jlong bodyId, jobject value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &body->getLinearVelocity(), value); } @@ -418,6 +558,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setLinearVelocity (JNIEnv *env, jobject object, jlong bodyId, jobject value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec = btVector3(); jmeBulletUtil::convert(env, value, &vec); body->setLinearVelocity(vec); @@ -431,6 +576,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyForce (JNIEnv *env, jobject object, jlong bodyId, jobject force, jobject location) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec1 = btVector3(); btVector3 vec2 = btVector3(); jmeBulletUtil::convert(env, force, &vec1); @@ -446,6 +596,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyCentralForce (JNIEnv *env, jobject object, jlong bodyId, jobject force) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec1 = btVector3(); jmeBulletUtil::convert(env, force, &vec1); body->applyCentralForce(vec1); @@ -459,6 +614,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyTorque (JNIEnv *env, jobject object, jlong bodyId, jobject force) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec1 = btVector3(); jmeBulletUtil::convert(env, force, &vec1); body->applyTorque(vec1); @@ -472,6 +632,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyImpulse (JNIEnv *env, jobject object, jlong bodyId, jobject force, jobject location) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec1 = btVector3(); btVector3 vec2 = btVector3(); jmeBulletUtil::convert(env, force, &vec1); @@ -487,6 +652,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyTorqueImpulse (JNIEnv *env, jobject object, jlong bodyId, jobject force) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec1 = btVector3(); jmeBulletUtil::convert(env, force, &vec1); body->applyTorqueImpulse(vec1); @@ -500,6 +670,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_clearForces (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } body->clearForces(); } @@ -511,6 +686,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setCollisionShape (JNIEnv *env, jobject object, jlong bodyId, jlong shapeId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btCollisionShape* shape = (btCollisionShape*) shapeId; body->setCollisionShape(shape); } @@ -523,6 +703,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_activate (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } body->activate(false); } @@ -534,6 +719,11 @@ extern "C" { JNIEXPORT jboolean JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_isActive (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return false; + } return body->isActive(); } @@ -545,6 +735,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setSleepingThresholds (JNIEnv *env, jobject object, jlong bodyId, jfloat linear, jfloat angular) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } body->setSleepingThresholds(linear, angular); } @@ -556,6 +751,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setLinearSleepingThreshold (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } body->setSleepingThresholds(value, body->getAngularSleepingThreshold()); } @@ -567,6 +767,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setAngularSleepingThreshold (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } body->setSleepingThresholds(body->getLinearSleepingThreshold(), value); } @@ -578,6 +783,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getLinearSleepingThreshold (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return body->getLinearSleepingThreshold(); } @@ -589,6 +799,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getAngularSleepingThreshold (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return body->getAngularSleepingThreshold(); } @@ -600,6 +815,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getAngularFactor (JNIEnv *env, jobject object, jlong bodyId) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return body->getAngularFactor().getX(); } @@ -611,6 +831,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setAngularFactor (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { btRigidBody* body = (btRigidBody*) bodyId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } btVector3 vec1 = btVector3(); vec1.setX(value); vec1.setY(value); diff --git a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp index dae400ae5..d9a96af5e 100644 --- a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp @@ -50,6 +50,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsVehicle_updateWheelTransform (JNIEnv *env, jobject object, jlong vehicleId, jint wheel, jboolean interpolated) { btRaycastVehicle* vehicle = (btRaycastVehicle*) vehicleId; + if (vehicle == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } vehicle->updateWheelTransform(wheel, interpolated); } @@ -62,6 +67,11 @@ extern "C" { (JNIEnv *env, jobject object, jlong bodyId, jlong spaceId) { //btRigidBody* body = (btRigidBody*) bodyId; btDiscreteDynamicsWorld* spsace = (btDiscreteDynamicsWorld*) spaceId; + if (spsace == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } btDefaultVehicleRaycaster* caster = new btDefaultVehicleRaycaster(spsace); return (long) caster; } @@ -74,6 +84,11 @@ extern "C" { JNIEXPORT jlong JNICALL Java_com_jme3_bullet_objects_PhysicsVehicle_createRaycastVehicle (JNIEnv *env, jobject object, jlong objectId, jlong casterId) { btRigidBody* body = (btRigidBody*) objectId; + if (body == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } body->setActivationState(DISABLE_DEACTIVATION); btVehicleRaycaster* caster = (btDefaultVehicleRaycaster*) casterId; btRaycastVehicle::btVehicleTuning tuning; @@ -90,6 +105,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsVehicle_setCoordinateSystem (JNIEnv *env, jobject object, jlong vehicleId, jint right, jint up, jint forward) { btRaycastVehicle* vehicle = (btRaycastVehicle*) vehicleId; + if (vehicle == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } vehicle->setCoordinateSystem(right, up, forward); } @@ -101,6 +121,11 @@ extern "C" { JNIEXPORT jlong JNICALL Java_com_jme3_bullet_objects_PhysicsVehicle_addWheel (JNIEnv *env, jobject object, jlong vehicleId, jobject location, jobject direction, jobject axle, jfloat restLength, jfloat radius, jobject tuning, jboolean frontWheel) { btRaycastVehicle* vehicle = (btRaycastVehicle*) vehicleId; + if (vehicle == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } btVector3 vec1 = btVector3(); btVector3 vec2 = btVector3(); btVector3 vec3 = btVector3(); @@ -120,6 +145,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsVehicle_resetSuspension (JNIEnv *env, jobject object, jlong vehicleId) { btRaycastVehicle* vehicle = (btRaycastVehicle*) vehicleId; + if (vehicle == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } vehicle->resetSuspension(); } @@ -131,6 +161,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsVehicle_applyEngineForce (JNIEnv *env, jobject object, jlong vehicleId, jint wheel, jfloat force) { btRaycastVehicle* vehicle = (btRaycastVehicle*) vehicleId; + if (vehicle == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } vehicle->applyEngineForce(force, wheel); } @@ -142,6 +177,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsVehicle_steer (JNIEnv *env, jobject object, jlong vehicleId, jint wheel, jfloat value) { btRaycastVehicle* vehicle = (btRaycastVehicle*) vehicleId; + if (vehicle == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } vehicle->setSteeringValue(value, wheel); } @@ -153,6 +193,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsVehicle_brake (JNIEnv *env, jobject object, jlong vehicleId, jint wheel, jfloat value) { btRaycastVehicle* vehicle = (btRaycastVehicle*) vehicleId; + if (vehicle == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } vehicle->setBrake(value, wheel); } @@ -164,6 +209,11 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsVehicle_getCurrentVehicleSpeedKmHour (JNIEnv *env, jobject object, jlong vehicleId) { btRaycastVehicle* vehicle = (btRaycastVehicle*) vehicleId; + if (vehicle == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return vehicle->getCurrentSpeedKmHour(); } @@ -175,6 +225,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsVehicle_getForwardVector (JNIEnv *env, jobject object, jlong vehicleId, jobject out) { btRaycastVehicle* vehicle = (btRaycastVehicle*) vehicleId; + if (vehicle == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &vehicle->getForwardVector(), out); } @@ -187,6 +242,11 @@ extern "C" { (JNIEnv *env, jobject object, jlong casterId, jlong vehicleId) { btVehicleRaycaster* rayCaster = (btVehicleRaycaster*) casterId; btRaycastVehicle* vehicle = (btRaycastVehicle*) vehicleId; + if (vehicle == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } delete(vehicle); delete(rayCaster); } diff --git a/engine/src/bullet/native/com_jme3_bullet_objects_VehicleWheel.cpp b/engine/src/bullet/native/com_jme3_bullet_objects_VehicleWheel.cpp index 6b493c53a..7224bff01 100644 --- a/engine/src/bullet/native/com_jme3_bullet_objects_VehicleWheel.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_objects_VehicleWheel.cpp @@ -49,6 +49,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_VehicleWheel_getWheelLocation (JNIEnv *env, jobject object, jlong wheelId, jobject out) { btWheelInfo* wheel = (btWheelInfo*) wheelId; + if (wheel == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &wheel->m_worldTransform.getOrigin(), out); } @@ -60,6 +65,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_VehicleWheel_getWheelRotation (JNIEnv *env, jobject object, jlong wheelId, jobject out) { btWheelInfo* wheel = (btWheelInfo*) wheelId; + if (wheel == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &wheel->m_worldTransform.getBasis(), out); } @@ -92,6 +102,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_VehicleWheel_getCollisionLocation (JNIEnv *env, jobject object, jlong wheelId, jobject out) { btWheelInfo* wheel = (btWheelInfo*) wheelId; + if (wheel == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &wheel->m_raycastInfo.m_contactPointWS, out); } @@ -103,6 +118,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_VehicleWheel_getCollisionNormal (JNIEnv *env, jobject object, jlong wheelId, jobject out) { btWheelInfo* wheel = (btWheelInfo*) wheelId; + if (wheel == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &wheel->m_raycastInfo.m_contactNormalWS, out); } @@ -114,12 +134,22 @@ extern "C" { JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_VehicleWheel_getSkidInfo (JNIEnv *env, jobject object, jlong wheelId) { btWheelInfo* wheel = (btWheelInfo*) wheelId; + if (wheel == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } return wheel->m_skidInfo; } JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_VehicleWheel_finalizeNative - (JNIEnv *env, jobject object, jlong wheelId){ + (JNIEnv *env, jobject object, jlong wheelId) { btWheelInfo* wheel = (btWheelInfo*) wheelId; + if (wheel == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } delete(wheel); } #ifdef __cplusplus diff --git a/engine/src/bullet/native/com_jme3_bullet_objects_infos_RigidBodyMotionState.cpp b/engine/src/bullet/native/com_jme3_bullet_objects_infos_RigidBodyMotionState.cpp index 2e31b2fc2..567bdf348 100644 --- a/engine/src/bullet/native/com_jme3_bullet_objects_infos_RigidBodyMotionState.cpp +++ b/engine/src/bullet/native/com_jme3_bullet_objects_infos_RigidBodyMotionState.cpp @@ -61,6 +61,11 @@ extern "C" { JNIEXPORT jboolean JNICALL Java_com_jme3_bullet_objects_infos_RigidBodyMotionState_applyTransform (JNIEnv *env, jobject object, jlong stateId, jobject location, jobject rotation) { jmeMotionState* motionState = (jmeMotionState*) stateId; + if (motionState == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return false; + } return motionState->applyTransform(env, location, rotation); } @@ -72,6 +77,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_infos_RigidBodyMotionState_getWorldLocation (JNIEnv *env, jobject object, jlong stateId, jobject value) { jmeMotionState* motionState = (jmeMotionState*) stateId; + if (motionState == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &motionState->worldTransform.getOrigin(), value); } @@ -83,6 +93,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_infos_RigidBodyMotionState_getWorldRotation (JNIEnv *env, jobject object, jlong stateId, jobject value) { jmeMotionState* motionState = (jmeMotionState*) stateId; + if (motionState == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convert(env, &motionState->worldTransform.getBasis(), value); } @@ -94,6 +109,11 @@ extern "C" { JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_infos_RigidBodyMotionState_getWorldRotationQuat (JNIEnv *env, jobject object, jlong stateId, jobject value) { jmeMotionState* motionState = (jmeMotionState*) stateId; + if (motionState == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } jmeBulletUtil::convertQuat(env, &motionState->worldTransform.getBasis(), value); } @@ -103,8 +123,13 @@ extern "C" { * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_infos_RigidBodyMotionState_finalizeNative - (JNIEnv *env, jobject object, jlong stateId){ + (JNIEnv *env, jobject object, jlong stateId) { jmeMotionState* motionState = (jmeMotionState*) stateId; + if (motionState == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } delete(motionState); }