From 3482904c76c300178109e9a9e9f2fa3d217387f5 Mon Sep 17 00:00:00 2001 From: sgold Date: Wed, 18 Sep 2019 19:56:16 -0700 Subject: [PATCH] CollisionShape: add isNonMoving() and test buildscript --- ...bullet_collision_shapes_CollisionShape.cpp | 19 +++++++++++++++++ .../collision/shapes/CollisionShape.java | 21 +++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/jme3-bullet-native/src/native/cpp/com_jme3_bullet_collision_shapes_CollisionShape.cpp b/jme3-bullet-native/src/native/cpp/com_jme3_bullet_collision_shapes_CollisionShape.cpp index dc48be257..bfdaa20de 100644 --- a/jme3-bullet-native/src/native/cpp/com_jme3_bullet_collision_shapes_CollisionShape.cpp +++ b/jme3-bullet-native/src/native/cpp/com_jme3_bullet_collision_shapes_CollisionShape.cpp @@ -105,6 +105,25 @@ extern "C" { } delete(shape); } + + /* + * Class: com_jme3_bullet_collision_shapes_CollisionShape + * Method: isNonMoving + * Signature: (J)Z + */ + JNIEXPORT jboolean JNICALL Java_com_jme3_bullet_collision_shapes_CollisionShape_isNonMoving + (JNIEnv *env, jobject object, jlong shapeId) { + btCollisionShape *pShape + = reinterpret_cast (shapeId); + if (pShape == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return false; + } + + return pShape->isNonMoving(); + } + #ifdef __cplusplus } #endif diff --git a/jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/CollisionShape.java b/jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/CollisionShape.java index acdd6ed04..94d39973d 100644 --- a/jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/CollisionShape.java +++ b/jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/CollisionShape.java @@ -87,7 +87,7 @@ public abstract class CollisionShape implements Savable { //// objectId.calculateLocalInertia(mass, vector); //// } // } -// +// // private native void calculateLocalInertia(long objectId, long shapeId, float mass); /** @@ -129,6 +129,19 @@ public abstract class CollisionShape implements Savable { return scale; } + /** + * Test whether this shape can be applied to a dynamic rigid body. The only + * non-moving shapes are the heightfield, mesh, and plane shapes. + * + * @return true if non-moving, false otherwise + */ + public boolean isNonMoving() { + boolean result = isNonMoving(objectId); + return result; + } + + native private boolean isNonMoving(long objectId); + /** * Read the collision margin for this shape. * @@ -137,7 +150,7 @@ public abstract class CollisionShape implements Savable { public float getMargin() { return getMargin(objectId); } - + private native float getMargin(long objectId); /** @@ -177,9 +190,9 @@ public abstract class CollisionShape implements Savable { setMargin(objectId, margin); this.margin = margin; } - + private native void setLocalScaling(long obectId, Vector3f scale); - + private native void setMargin(long objectId, float margin); /**