Просмотр исходного кода

- add VehicleWheel.getDeltaRotation(), thanks to @niclas

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9060 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
nor..67 14 лет назад
Родитель
Сommit
2511d6960e

+ 16 - 0
engine/src/bullet-native/com_jme3_bullet_objects_VehicleWheel.cpp

@@ -142,6 +142,22 @@ extern "C" {
         return vehicle->getWheelInfo(wheelIndex).m_skidInfo;
     }
 
+    /*
+     * Class:     com_jme3_bullet_objects_VehicleWheel
+     * Method:    getDeltaRotation
+     * Signature: (J)F
+     */
+    JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_VehicleWheel_getDeltaRotation
+    (JNIEnv *env, jobject object, jlong vehicleId, jint wheelIndex) {
+        btRaycastVehicle* vehicle = reinterpret_cast<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->getWheelInfo(wheelIndex).m_deltaRotation;
+    }
+
 #ifdef __cplusplus
 }
 #endif

+ 8 - 0
engine/src/bullet-native/com_jme3_bullet_objects_VehicleWheel.h

@@ -55,6 +55,14 @@ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_VehicleWheel_getCollisionNor
 JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_VehicleWheel_getSkidInfo
   (JNIEnv *, jobject, jlong, jint);
 
+/*
+ * Class:     com_jme3_bullet_objects_VehicleWheel
+ * Method:    getDeltaRotation
+ * Signature: (JI)F
+ */
+JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_VehicleWheel_getDeltaRotation
+  (JNIEnv *, jobject, jlong, jint);
+
 #ifdef __cplusplus
 }
 #endif

+ 10 - 0
engine/src/bullet/com/jme3/bullet/objects/VehicleWheel.java

@@ -349,6 +349,16 @@ public class VehicleWheel implements Savable {
     }
 
     public native float getSkidInfo(long wheelId, int wheelIndex);
+    
+    /**
+     * returns how many degrees the wheel has turned since the last physics
+     * step.
+     */
+    public float getDeltaRotation() {
+        return getDeltaRotation(wheelId, wheelIndex);
+    }
+    
+    public native float getDeltaRotation(long wheelId, int wheelIndex);
 
     @Override
     public void read(JmeImporter im) throws IOException {

+ 8 - 0
engine/src/jbullet/com/jme3/bullet/objects/VehicleWheel.java

@@ -331,6 +331,14 @@ public class VehicleWheel implements Savable {
     public float getSkidInfo() {
         return wheelInfo.skidInfo;
     }
+    
+    /**
+     * returns how many degrees the wheel has turned since the last physics
+     * step.
+     */
+    public float getDeltaRotation() {
+        return wheelInfo.deltaRotation;
+    }
 
     @Override
     public void read(JmeImporter im) throws IOException {