Browse Source

Bullet RigidBody : prevent from breaking the API & reverted

Dokthar 10 years ago
parent
commit
7f2c7c5d35

+ 12 - 8
jme3-bullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java

@@ -626,10 +626,16 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
 
     private native float getAngularSleepingThreshold(long objectId);
 
-    public Vector3f getAngularFactor() {
-        Vector3f vec = new Vector3f();
-        getAngularFactor(objectId, vec);
-	return vec;
+    public float getAngularFactor() {
+        return getAngularFactor(null).getX();
+    }
+	
+    public Vector3f getAngularFactor(Vector3f store) {
+    	// doing like this prevent from breaking the API
+        if(store == null) 
+            store = new Vector3f();
+        getAngularFactor(objectId, store);
+        return store;
     }
 
     private native void getAngularFactor(long objectId, Vector3f vec);
@@ -694,8 +700,7 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
         capsule.write(getGravity(), "gravity", Vector3f.ZERO);
         capsule.write(getFriction(), "friction", 0.5f);
         capsule.write(getRestitution(), "restitution", 0);
-        capsule.write(getAngularFactor(), "angularFactor", Vector3f.UNIT_XYZ);
-        capsule.write(getLinearFactor(), "linearFactor", Vector3f.UNIT_XYZ);
+        capsule.write(getAngularFactor(), "angularFactor", 1);
         capsule.write(kinematic, "kinematic", false);
 
         capsule.write(getLinearDamping(), "linearDamping", 0);
@@ -725,8 +730,7 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
         setKinematic(capsule.readBoolean("kinematic", false));
 
         setRestitution(capsule.readFloat("restitution", 0));
-        setAngularFactor((Vector3f) capsule.readSavable("angularFactor", Vector3f.UNIT_XYZ.clone()));
-        setLinearFactor((Vector3f) capsule.readSavable("linearFactor", Vector3f.UNIT_XYZ.clone()));
+        setAngularFactor(capsule.readFloat("angularFactor", 1));
         setDamping(capsule.readFloat("linearDamping", 0), capsule.readFloat("angularDamping", 0));
         setSleepingThresholds(capsule.readFloat("linearSleepingThreshold", 0.8f), capsule.readFloat("angularSleepingThreshold", 1.0f));
         setCcdMotionThreshold(capsule.readFloat("ccdMotionThreshold", 0));