mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-14 11:20:03 +02:00
update entity MotionType when it changes
This commit is contained in:
parent
8bd3779d7d
commit
51da678675
3 changed files with 10 additions and 3 deletions
|
@ -103,6 +103,7 @@ bool DeleteEntityOperator::preRecursion(OctreeElement* element) {
|
|||
entityTreeElement->removeEntityItem(theEntity); // remove it from the element
|
||||
_tree->setContainingElement(entityItemID, NULL); // update or id to element lookup
|
||||
_tree->removeEntityFromPhysicsEngine(theEntity);
|
||||
theEntity->destroyMotionState();
|
||||
delete theEntity; // now actually delete the entity!
|
||||
_foundCount++;
|
||||
}
|
||||
|
|
|
@ -119,8 +119,8 @@ EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemPropert
|
|||
|
||||
EntityItem::~EntityItem() {
|
||||
#ifdef USE_BULLET_PHYSICS
|
||||
// make sure the _motionState is already deleted (e.g. the entity has been removed
|
||||
// from the physics simulation) BEFORE you get here
|
||||
// Make sure the EntityItem has been removed from the physics engine AND
|
||||
// that its _motionState has been destroyed BEFORE you get here.
|
||||
assert(_motionState == NULL);
|
||||
#endif // USE_BULLET_PHYSICS
|
||||
}
|
||||
|
|
|
@ -619,6 +619,13 @@ void EntityTree::updateEntityState(EntityItem* entity) {
|
|||
break;
|
||||
}
|
||||
entity->setSimulationState(newState);
|
||||
|
||||
if (_physicsEngine) {
|
||||
EntityMotionState* motionState = entity->getMotionState();
|
||||
if (motionState) {
|
||||
_physicsEngine->updateEntityMotionType(motionState);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -659,7 +666,6 @@ void EntityTree::removeEntityFromPhysicsEngine(EntityItem* entity) {
|
|||
EntityMotionState* motionState = entity->getMotionState();
|
||||
if (motionState) {
|
||||
_physicsEngine->removeEntity(static_cast<CustomMotionState*>(motionState));
|
||||
entity->destroyMotionState();
|
||||
}
|
||||
#endif // USE_BULLET_PHYSICS
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue