mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
fix issue with preload not being called on import
This commit is contained in:
parent
971108494a
commit
df99c314aa
4 changed files with 19 additions and 4 deletions
|
@ -101,7 +101,7 @@ void EntityTreeRenderer::init() {
|
|||
_lastAvatarPosition = _viewState->getAvatarPosition() + glm::vec3((float)TREE_SCALE);
|
||||
|
||||
connect(entityTree, &EntityTree::deletingEntity, this, &EntityTreeRenderer::deletingEntity);
|
||||
connect(entityTree, &EntityTree::addingEntity, this, &EntityTreeRenderer::checkAndCallPreload);
|
||||
connect(entityTree, &EntityTree::addingEntity, this, &EntityTreeRenderer::addingEntity);
|
||||
connect(entityTree, &EntityTree::entityScriptChanging, this, &EntityTreeRenderer::entitySciptChanging);
|
||||
connect(entityTree, &EntityTree::changingEntityID, this, &EntityTreeRenderer::changingEntityID);
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItem* entity, bool isPre
|
|||
// can accomplish all we need to here with just the script "text" and the ID.
|
||||
EntityItemID entityID = entity->getEntityItemID();
|
||||
QString entityScript = entity->getScript();
|
||||
|
||||
|
||||
if (_entityScripts.contains(entityID)) {
|
||||
EntityScriptDetails details = _entityScripts[entityID];
|
||||
|
||||
|
@ -217,7 +217,6 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItem* entity, bool isPre
|
|||
|
||||
if (isPending && isPreload && isURL) {
|
||||
_waitingOnPreload.insert(url, entityID);
|
||||
|
||||
}
|
||||
|
||||
auto scriptCache = DependencyManager::get<ScriptCache>();
|
||||
|
@ -941,6 +940,10 @@ void EntityTreeRenderer::deletingEntity(const EntityItemID& entityID) {
|
|||
_entityScripts.remove(entityID);
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::addingEntity(const EntityItemID& entityID) {
|
||||
checkAndCallPreload(entityID);
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::entitySciptChanging(const EntityItemID& entityID) {
|
||||
if (_tree && !_shuttingDown) {
|
||||
checkAndCallUnload(entityID);
|
||||
|
|
|
@ -105,6 +105,7 @@ signals:
|
|||
void leaveEntity(const EntityItemID& entityItemID);
|
||||
|
||||
public slots:
|
||||
void addingEntity(const EntityItemID& entityID);
|
||||
void deletingEntity(const EntityItemID& entityID);
|
||||
void changingEntityID(const EntityItemID& oldEntityID, const EntityItemID& newEntityID);
|
||||
void entitySciptChanging(const EntityItemID& entityID);
|
||||
|
|
|
@ -404,7 +404,8 @@ void EntityTree::handleAddEntityResponse(const QByteArray& packet) {
|
|||
EntityItem* foundEntity = NULL;
|
||||
EntityItemID creatorTokenVersion = searchEntityID.convertToCreatorTokenVersion();
|
||||
EntityItemID knownIDVersion = searchEntityID.convertToKnownIDVersion();
|
||||
|
||||
|
||||
_changedEntityIDs[creatorTokenVersion] = knownIDVersion;
|
||||
|
||||
// First look for and find the "viewed version" of this entity... it's possible we got
|
||||
// the known ID version sent to us between us creating our local version, and getting this
|
||||
|
@ -592,6 +593,9 @@ EntityItem* EntityTree::findEntityByEntityItemID(const EntityItemID& entityID) /
|
|||
EntityTreeElement* containingElement = getContainingElement(entityID);
|
||||
if (containingElement) {
|
||||
foundEntity = containingElement->getEntityWithEntityItemID(entityID);
|
||||
if (!foundEntity && _changedEntityIDs.contains(entityID)) {
|
||||
foundEntity = containingElement->getEntityWithEntityItemID(_changedEntityIDs[entityID]);
|
||||
}
|
||||
}
|
||||
return foundEntity;
|
||||
}
|
||||
|
@ -958,6 +962,12 @@ EntityTreeElement* EntityTree::getContainingElement(const EntityItemID& entityIt
|
|||
creatorTokenOnly.isKnownID = false;
|
||||
element = _entityToElementMap.value(creatorTokenOnly);
|
||||
}
|
||||
|
||||
// If we still didn't find the entity, but the ID was in our changed entityIDs, search for the new ID version
|
||||
if (!element && _changedEntityIDs.contains(entityItemID)) {
|
||||
element = getContainingElement(_changedEntityIDs[entityItemID]);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
|
|
|
@ -195,6 +195,7 @@ private:
|
|||
EntityItemFBXService* _fbxService;
|
||||
|
||||
QHash<EntityItemID, EntityTreeElement*> _entityToElementMap;
|
||||
QHash<EntityItemID, EntityItemID> _changedEntityIDs;
|
||||
|
||||
EntitySimulation* _simulation;
|
||||
|
||||
|
|
Loading…
Reference in a new issue