protected void preRebuild() { collisionShape.calculateLocalInertia(mass, localInertia); if (constructionInfo == null) { constructionInfo = new RigidBodyConstructionInfo(mass, motionState, collisionShape.getCShape(), localInertia); } else { constructionInfo.mass = mass; constructionInfo.collisionShape = collisionShape.getCShape(); constructionInfo.motionState = motionState; } }
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 { collisionShape.calculateLocalInertia(mass, localInertia); constructionInfo.collisionShape = collisionShape.getCShape(); rBody.setCollisionShape(collisionShape.getCShape()); } }
/** * Sets the mass of this PhysicsRigidBody, objects with mass=0 are static. * @param mass */ 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); } if (rBody != null) { rBody.setMassProps(mass, localInertia); if (mass == 0.0f) { rBody.setCollisionFlags(rBody.getCollisionFlags() | CollisionFlags.STATIC_OBJECT); } else { rBody.setCollisionFlags(rBody.getCollisionFlags() & ~CollisionFlags.STATIC_OBJECT); } } }
protected void preRebuild() { collisionShape.calculateLocalInertia(mass, localInertia); if (constructionInfo == null) { constructionInfo = new RigidBodyConstructionInfo(mass, motionState, collisionShape.getCShape(), localInertia); } else { constructionInfo.mass = mass; constructionInfo.collisionShape = collisionShape.getCShape(); constructionInfo.motionState = motionState; } }
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 { collisionShape.calculateLocalInertia(mass, localInertia); constructionInfo.collisionShape = collisionShape.getCShape(); rBody.setCollisionShape(collisionShape.getCShape()); } }
/** * Sets the mass of this PhysicsRigidBody, objects with mass=0 are static. * @param mass */ 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); } if (rBody != null) { rBody.setMassProps(mass, localInertia); if (mass == 0.0f) { rBody.setCollisionFlags(rBody.getCollisionFlags() | CollisionFlags.STATIC_OBJECT); } else { rBody.setCollisionFlags(rBody.getCollisionFlags() & ~CollisionFlags.STATIC_OBJECT); } } }