Fix entity payloads not being removed on delete

This commit is contained in:
Ryan Huffman 2015-06-05 10:26:09 -07:00
parent ba5eab7460
commit 37d9394140
2 changed files with 4 additions and 5 deletions

View file

@ -1000,13 +1000,12 @@ void EntityTreeRenderer::deletingEntity(const EntityItemID& entityID) {
_entityScripts.remove(entityID);
// here's where we remove the entity payload from the scene
auto entity = static_cast<EntityTree*>(_tree)->findEntityByID(entityID);
if (entity && _entitiesInScene.contains(entity)) {
if (_entitiesInScene.contains(entityID)) {
auto entity = _entitiesInScene.take(entityID);
render::PendingChanges pendingChanges;
auto scene = _viewState->getMain3DScene();
entity->removeFromScene(entity, scene, pendingChanges);
scene->enqueuePendingChanges(pendingChanges);
_entitiesInScene.remove(entity);
}
}
@ -1021,7 +1020,7 @@ void EntityTreeRenderer::addEntityToScene(EntityItemPointer entity) {
render::PendingChanges pendingChanges;
auto scene = _viewState->getMain3DScene();
if (entity->addToScene(entity, scene, pendingChanges)) {
_entitiesInScene.insert(entity);
_entitiesInScene.insert(entity->getEntityItemID(), entity);
}
scene->enqueuePendingChanges(pendingChanges);
}

View file

@ -188,7 +188,7 @@ private:
float _previousStageHour;
int _previousStageDay;
QSet<EntityItemPointer> _entitiesInScene;
QHash<EntityItemID, EntityItemPointer> _entitiesInScene;
};