protect physics against bad entity properties

This commit is contained in:
Andrew Meadows 2016-06-21 13:55:11 -07:00
parent 937bd0c1be
commit 4c9ec7ca43
2 changed files with 30 additions and 23 deletions

View file

@ -152,6 +152,11 @@ PhysicsMotionType EntityMotionState::computePhysicsMotionType() const {
}
assert(entityTreeIsLocked());
if (_entity->getShapeType() == SHAPE_TYPE_STATIC_MESH
|| (_body && _body->getCollisionShape()->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)) {
return MOTION_TYPE_STATIC;
}
if (_entity->getDynamic()) {
if (!_entity->getParentID().isNull()) {
// if something would have been dynamic but is a child of something else, force it to be kinematic, instead.

View file

@ -203,6 +203,7 @@ void ObjectMotionState::handleEasyChanges(uint32_t& flags) {
}
}
if (_body->getCollisionShape()->getShapeType() != TRIANGLE_MESH_SHAPE_PROXYTYPE) {
if (flags & Simulation::DIRTY_LINEAR_VELOCITY) {
btVector3 newLinearVelocity = glmToBullet(getObjectLinearVelocity());
if (!(flags & Simulation::DIRTY_PHYSICS_ACTIVATION)) {
@ -233,6 +234,7 @@ void ObjectMotionState::handleEasyChanges(uint32_t& flags) {
}
_body->setAngularVelocity(newAngularVelocity);
}
}
if (flags & Simulation::DIRTY_MATERIAL) {
updateBodyMaterialProperties();