Skip to content

Commit

Permalink
PhysicsRigidBody: argument validation
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Sep 1, 2018
1 parent a744d3d commit 289ebf7
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import jme3utilities.Validate;

/**
* A collision object for rigid bodies, based on Bullet's btRigidBody.
Expand Down Expand Up @@ -686,11 +687,14 @@ public void clearForces() {
*/
@Override
public void setCollisionShape(CollisionShape collisionShape) {
super.setCollisionShape(collisionShape);
if (collisionShape instanceof MeshCollisionShape && mass != 0) {
Validate.nonNull(collisionShape, "collision shape");
if (collisionShape instanceof MeshCollisionShape && mass != 0f) {
throw new IllegalStateException(
"Dynamic rigidbody can not have mesh collision shape!");
}

super.setCollisionShape(collisionShape);

if (objectId == 0) {
rebuildRigidBody();
} else {
Expand Down

0 comments on commit 289ebf7

Please sign in to comment.