Merge pull request #5063 from huffman/fix-entity-delete-payload

Team Teaching - Fix entity payloads not being removed on delete
This commit is contained in:
Brad Hefta-Gaub 2015-06-05 11:03:46 -07:00
commit 4c52076e13
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;
};