- throw error on dynamic mesh collision shape

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7216 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 14 years ago
parent eef7e8299b
commit c036d36c96
  1. 10
      engine/src/jbullet/com/jme3/bullet/objects/PhysicsRigidBody.java

@ -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 {

Loading…
Cancel
Save