mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 20:23:06 +02:00
attempt some clean-ups in edge/unexpected situations
This commit is contained in:
parent
4ce3465bf7
commit
c0c1116c69
3 changed files with 16 additions and 2 deletions
|
@ -88,6 +88,13 @@ EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemPropert
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityItem::~EntityItem() {
|
EntityItem::~EntityItem() {
|
||||||
|
// clear out any left-over actions
|
||||||
|
EntityTree* entityTree = _element ? _element->getTree() : nullptr;
|
||||||
|
EntitySimulation* simulation = entityTree ? entityTree->getSimulation() : nullptr;
|
||||||
|
if (simulation) {
|
||||||
|
clearActions(simulation);
|
||||||
|
}
|
||||||
|
|
||||||
// these pointers MUST be correct at delete, else we probably have a dangling backpointer
|
// these pointers MUST be correct at delete, else we probably have a dangling backpointer
|
||||||
// to this EntityItem in the corresponding data structure.
|
// to this EntityItem in the corresponding data structure.
|
||||||
assert(!_simulated);
|
assert(!_simulated);
|
||||||
|
@ -1450,7 +1457,8 @@ void EntityItem::setActionData(QByteArray actionData) {
|
||||||
|
|
||||||
if (_objectActions.contains(actionID)) {
|
if (_objectActions.contains(actionID)) {
|
||||||
EntityActionPointer action = _objectActions[actionID];
|
EntityActionPointer action = _objectActions[actionID];
|
||||||
// XXX make sure types match?
|
// TODO: make sure types match? there isn't currently a way to
|
||||||
|
// change the type of an existing action.
|
||||||
action->deserialize(serializedAction);
|
action->deserialize(serializedAction);
|
||||||
} else {
|
} else {
|
||||||
auto actionFactory = DependencyManager::get<EntityActionFactoryInterface>();
|
auto actionFactory = DependencyManager::get<EntityActionFactoryInterface>();
|
||||||
|
|
|
@ -27,6 +27,13 @@ void ObjectAction::updateAction(btCollisionWorld* collisionWorld, btScalar delta
|
||||||
if (!_active) {
|
if (!_active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (_ownerEntity.expired()) {
|
||||||
|
qDebug() << "warning -- action with no entity removing self from btCollisionWorld.";
|
||||||
|
btDynamicsWorld* dynamicsWorld = static_cast<btDynamicsWorld*>(collisionWorld);
|
||||||
|
dynamicsWorld->removeAction(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
updateActionWorker(deltaTimeStep);
|
updateActionWorker(deltaTimeStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -443,7 +443,6 @@ EntityActionPointer PhysicsEngine::getActionByID(const QUuid& actionID) const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PhysicsEngine::addAction(EntityActionPointer action) {
|
void PhysicsEngine::addAction(EntityActionPointer action) {
|
||||||
assert(action);
|
assert(action);
|
||||||
const QUuid& actionID = action->getID();
|
const QUuid& actionID = action->getID();
|
||||||
|
|
Loading…
Reference in a new issue