mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 22:09:02 +02:00
fix the lingering model parts sometimes left behind when switching domains
This commit is contained in:
parent
a24fd13665
commit
5676246d75
2 changed files with 10 additions and 3 deletions
|
@ -93,16 +93,18 @@ void EntityTreeRenderer::clear() {
|
||||||
foreach (const EntityItemID& entityID, _entityScripts.keys()) {
|
foreach (const EntityItemID& entityID, _entityScripts.keys()) {
|
||||||
checkAndCallUnload(entityID);
|
checkAndCallUnload(entityID);
|
||||||
}
|
}
|
||||||
OctreeRenderer::clear();
|
|
||||||
_entityScripts.clear();
|
_entityScripts.clear();
|
||||||
|
|
||||||
auto scene = _viewState->getMain3DScene();
|
auto scene = _viewState->getMain3DScene();
|
||||||
render::PendingChanges pendingChanges;
|
render::PendingChanges pendingChanges;
|
||||||
|
|
||||||
foreach(auto entity, _entitiesInScene) {
|
foreach(auto entity, _entitiesInScene) {
|
||||||
entity->removeFromScene(entity, scene, pendingChanges);
|
entity->removeFromScene(entity, scene, pendingChanges);
|
||||||
}
|
}
|
||||||
scene->enqueuePendingChanges(pendingChanges);
|
scene->enqueuePendingChanges(pendingChanges);
|
||||||
_entitiesInScene.clear();
|
_entitiesInScene.clear();
|
||||||
|
|
||||||
|
OctreeRenderer::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeRenderer::init() {
|
void EntityTreeRenderer::init() {
|
||||||
|
@ -1003,7 +1005,7 @@ void EntityTreeRenderer::deletingEntity(const EntityItemID& entityID) {
|
||||||
checkAndCallUnload(entityID);
|
checkAndCallUnload(entityID);
|
||||||
}
|
}
|
||||||
_entityScripts.remove(entityID);
|
_entityScripts.remove(entityID);
|
||||||
|
|
||||||
// here's where we remove the entity payload from the scene
|
// here's where we remove the entity payload from the scene
|
||||||
if (_entitiesInScene.contains(entityID)) {
|
if (_entitiesInScene.contains(entityID)) {
|
||||||
auto entity = _entitiesInScene.take(entityID);
|
auto entity = _entitiesInScene.take(entityID);
|
||||||
|
@ -1164,6 +1166,7 @@ void EntityTreeRenderer::updateEntityRenderStatus(bool shouldRenderEntities) {
|
||||||
} else {
|
} else {
|
||||||
_entityIDsLastInScene = _entitiesInScene.keys();
|
_entityIDsLastInScene = _entitiesInScene.keys();
|
||||||
for (auto entityID : _entityIDsLastInScene) {
|
for (auto entityID : _entityIDsLastInScene) {
|
||||||
|
// FIXME - is this really right? do we want to do the deletingEntity() code or just remove from the scene.
|
||||||
deletingEntity(entityID);
|
deletingEntity(entityID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,6 +189,7 @@ void makeEntityItemStatusGetters(RenderableModelEntityItem* entity, render::Item
|
||||||
|
|
||||||
bool RenderableModelEntityItem::addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
bool RenderableModelEntityItem::addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
||||||
render::PendingChanges& pendingChanges) {
|
render::PendingChanges& pendingChanges) {
|
||||||
|
|
||||||
_myMetaItem = scene->allocateID();
|
_myMetaItem = scene->allocateID();
|
||||||
|
|
||||||
auto renderData = RenderableModelEntityItemMeta::Pointer(new RenderableModelEntityItemMeta(self));
|
auto renderData = RenderableModelEntityItemMeta::Pointer(new RenderableModelEntityItemMeta(self));
|
||||||
|
@ -199,7 +200,10 @@ bool RenderableModelEntityItem::addToScene(EntityItemPointer self, std::shared_p
|
||||||
if (_model) {
|
if (_model) {
|
||||||
render::Item::Status::Getters statusGetters;
|
render::Item::Status::Getters statusGetters;
|
||||||
makeEntityItemStatusGetters(this, statusGetters);
|
makeEntityItemStatusGetters(this, statusGetters);
|
||||||
return _model->addToScene(scene, pendingChanges, statusGetters);
|
|
||||||
|
// note: we don't care if the model fails to add items, we always added our meta item and therefore we return
|
||||||
|
// true so that the system knows our meta item is in the scene!
|
||||||
|
_model->addToScene(scene, pendingChanges, statusGetters);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue