|
|
|
@ -40,6 +40,7 @@ import com.jme3.scene.Spatial; |
|
|
|
|
import com.jme3.bullet.PhysicsSpace; |
|
|
|
|
import com.jme3.bullet.collision.PhysicsCollisionObject; |
|
|
|
|
import com.jme3.bullet.collision.shapes.CollisionShape; |
|
|
|
|
import com.jme3.bullet.collision.shapes.MeshCollisionShape; |
|
|
|
|
import com.jme3.bullet.joints.PhysicsJoint; |
|
|
|
|
import com.jme3.bullet.objects.infos.RigidBodyMotionState; |
|
|
|
|
import com.jme3.bullet.util.Converter; |
|
|
|
@ -100,6 +101,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject { |
|
|
|
|
*/ |
|
|
|
|
protected void rebuildRigidBody() { |
|
|
|
|
boolean removed = false; |
|
|
|
|
if(collisionShape instanceof MeshCollisionShape && mass != 0){ |
|
|
|
|
throw new IllegalStateException("Dynamic rigidbody can not have mesh collision shape!"); |
|
|
|
|
} |
|
|
|
|
if (rBody != null) { |
|
|
|
|
if (rBody.isInWorld()) { |
|
|
|
|
PhysicsSpace.getPhysicsSpace().remove(this); |
|
|
|
@ -316,6 +320,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject { |
|
|
|
|
*/ |
|
|
|
|
public void setMass(float mass) { |
|
|
|
|
this.mass = mass; |
|
|
|
|
if(collisionShape instanceof MeshCollisionShape && mass != 0){ |
|
|
|
|
throw new IllegalStateException("Dynamic rigidbody can not have mesh collision shape!"); |
|
|
|
|
} |
|
|
|
|
if (collisionShape != null) { |
|
|
|
|
collisionShape.calculateLocalInertia(mass, localInertia); |
|
|
|
|
} |
|
|
|
@ -516,6 +523,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject { |
|
|
|
|
|
|
|
|
|
public void setCollisionShape(CollisionShape collisionShape) { |
|
|
|
|
super.setCollisionShape(collisionShape); |
|
|
|
|
if(collisionShape instanceof MeshCollisionShape && mass!=0){ |
|
|
|
|
throw new IllegalStateException("Dynamic rigidbody can not have mesh collision shape!"); |
|
|
|
|
} |
|
|
|
|
if (rBody == null) { |
|
|
|
|
rebuildRigidBody(); |
|
|
|
|
} else { |
|
|
|
|