mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:29:47 +02:00
try to not clear my avatar entities on domain switch
This commit is contained in:
parent
20d65ab183
commit
3e6061e435
10 changed files with 34 additions and 31 deletions
|
@ -6948,7 +6948,7 @@ void Application::clearDomainOctreeDetails(bool clearAll) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// reset the model renderer
|
// reset the model renderer
|
||||||
clearAll ? getEntities()->clear() : getEntities()->clearNonLocalEntities();
|
clearAll ? getEntities()->clear() : getEntities()->clearDomainAndNonOwnedEntities();
|
||||||
|
|
||||||
auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
|
auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
|
||||||
|
|
||||||
|
|
|
@ -196,8 +196,8 @@ void EntityTreeRenderer::resetEntitiesScriptEngine() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeRenderer::stopNonLocalEntityScripts() {
|
void EntityTreeRenderer::stopDomainAndNonOwnedEntities() {
|
||||||
leaveNonLocalEntities();
|
leaveDomainAndNonOwnedEntities();
|
||||||
// unload and stop the engine
|
// unload and stop the engine
|
||||||
if (_entitiesScriptEngine) {
|
if (_entitiesScriptEngine) {
|
||||||
QList<EntityItemID> entitiesWithEntityScripts = _entitiesScriptEngine->getListOfEntityScriptIDs();
|
QList<EntityItemID> entitiesWithEntityScripts = _entitiesScriptEngine->getListOfEntityScriptIDs();
|
||||||
|
@ -206,7 +206,7 @@ void EntityTreeRenderer::stopNonLocalEntityScripts() {
|
||||||
EntityItemPointer entityItem = getTree()->findEntityByEntityItemID(entityID);
|
EntityItemPointer entityItem = getTree()->findEntityByEntityItemID(entityID);
|
||||||
|
|
||||||
if (entityItem) {
|
if (entityItem) {
|
||||||
if (!entityItem->isLocalEntity()) {
|
if (!(entityItem->isLocalEntity() || (entityItem->isAvatarEntity() && entityItem->getOwningAvatarID() == getTree()->getMyAvatarSessionUUID()))) {
|
||||||
_entitiesScriptEngine->unloadEntityScript(entityID, true);
|
_entitiesScriptEngine->unloadEntityScript(entityID, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,8 +214,8 @@ void EntityTreeRenderer::stopNonLocalEntityScripts() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeRenderer::clearNonLocalEntities() {
|
void EntityTreeRenderer::clearDomainAndNonOwnedEntities() {
|
||||||
stopNonLocalEntityScripts();
|
stopDomainAndNonOwnedEntities();
|
||||||
|
|
||||||
std::unordered_map<EntityItemID, EntityRendererPointer> savedEntities;
|
std::unordered_map<EntityItemID, EntityRendererPointer> savedEntities;
|
||||||
// remove all entities from the scene
|
// remove all entities from the scene
|
||||||
|
@ -225,7 +225,7 @@ void EntityTreeRenderer::clearNonLocalEntities() {
|
||||||
for (const auto& entry : _entitiesInScene) {
|
for (const auto& entry : _entitiesInScene) {
|
||||||
const auto& renderer = entry.second;
|
const auto& renderer = entry.second;
|
||||||
const EntityItemPointer& entityItem = renderer->getEntity();
|
const EntityItemPointer& entityItem = renderer->getEntity();
|
||||||
if (!entityItem->isLocalEntity()) {
|
if (!(entityItem->isLocalEntity() || (entityItem->isAvatarEntity() && entityItem->getOwningAvatarID() == getTree()->getMyAvatarSessionUUID()))) {
|
||||||
renderer->removeFromScene(scene, transaction);
|
renderer->removeFromScene(scene, transaction);
|
||||||
} else {
|
} else {
|
||||||
savedEntities[entry.first] = entry.second;
|
savedEntities[entry.first] = entry.second;
|
||||||
|
@ -239,7 +239,7 @@ void EntityTreeRenderer::clearNonLocalEntities() {
|
||||||
|
|
||||||
_layeredZones.clearNonLocalLayeredZones();
|
_layeredZones.clearNonLocalLayeredZones();
|
||||||
|
|
||||||
OctreeProcessor::clearNonLocalEntities();
|
OctreeProcessor::clearDomainAndNonOwnedEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeRenderer::clear() {
|
void EntityTreeRenderer::clear() {
|
||||||
|
@ -655,22 +655,22 @@ bool EntityTreeRenderer::checkEnterLeaveEntities() {
|
||||||
return didUpdate;
|
return didUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeRenderer::leaveNonLocalEntities() {
|
void EntityTreeRenderer::leaveDomainAndNonOwnedEntities() {
|
||||||
if (_tree && !_shuttingDown) {
|
if (_tree && !_shuttingDown) {
|
||||||
QVector<EntityItemID> currentLocalEntitiesInside;
|
QVector<EntityItemID> currentEntitiesInsideToSave;
|
||||||
foreach (const EntityItemID& entityID, _currentEntitiesInside) {
|
foreach (const EntityItemID& entityID, _currentEntitiesInside) {
|
||||||
EntityItemPointer entityItem = getTree()->findEntityByEntityItemID(entityID);
|
EntityItemPointer entityItem = getTree()->findEntityByEntityItemID(entityID);
|
||||||
if (!entityItem->isLocalEntity()) {
|
if (!(entityItem->isLocalEntity() || (entityItem->isAvatarEntity() && entityItem->getOwningAvatarID() == getTree()->getMyAvatarSessionUUID()))) {
|
||||||
emit leaveEntity(entityID);
|
emit leaveEntity(entityID);
|
||||||
if (_entitiesScriptEngine) {
|
if (_entitiesScriptEngine) {
|
||||||
_entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity");
|
_entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
currentLocalEntitiesInside.push_back(entityID);
|
currentEntitiesInsideToSave.push_back(entityID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentEntitiesInside = currentLocalEntitiesInside;
|
_currentEntitiesInside = currentEntitiesInsideToSave;
|
||||||
forceRecheckEntities();
|
forceRecheckEntities();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ public:
|
||||||
virtual void init() override;
|
virtual void init() override;
|
||||||
|
|
||||||
/// clears the tree
|
/// clears the tree
|
||||||
virtual void clearNonLocalEntities() override;
|
virtual void clearDomainAndNonOwnedEntities() override;
|
||||||
virtual void clear() override;
|
virtual void clear() override;
|
||||||
|
|
||||||
/// reloads the entity scripts, calling unload and preload
|
/// reloads the entity scripts, calling unload and preload
|
||||||
|
@ -170,7 +170,7 @@ private:
|
||||||
bool findBestZoneAndMaybeContainingEntities(QVector<EntityItemID>* entitiesContainingAvatar = nullptr);
|
bool findBestZoneAndMaybeContainingEntities(QVector<EntityItemID>* entitiesContainingAvatar = nullptr);
|
||||||
|
|
||||||
bool applyLayeredZones();
|
bool applyLayeredZones();
|
||||||
void stopNonLocalEntityScripts();
|
void stopDomainAndNonOwnedEntities();
|
||||||
|
|
||||||
void checkAndCallPreload(const EntityItemID& entityID, bool reload = false, bool unloadFirst = false);
|
void checkAndCallPreload(const EntityItemID& entityID, bool reload = false, bool unloadFirst = false);
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ private:
|
||||||
|
|
||||||
QScriptValueList createEntityArgs(const EntityItemID& entityID);
|
QScriptValueList createEntityArgs(const EntityItemID& entityID);
|
||||||
bool checkEnterLeaveEntities();
|
bool checkEnterLeaveEntities();
|
||||||
void leaveNonLocalEntities();
|
void leaveDomainAndNonOwnedEntities();
|
||||||
void leaveAllEntities();
|
void leaveAllEntities();
|
||||||
void forceRecheckEntities();
|
void forceRecheckEntities();
|
||||||
|
|
||||||
|
|
|
@ -78,13 +78,14 @@ OctreeElementPointer EntityTree::createNewElement(unsigned char* octalCode) {
|
||||||
return std::static_pointer_cast<OctreeElement>(newElement);
|
return std::static_pointer_cast<OctreeElement>(newElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::eraseNonLocalEntities() {
|
void EntityTree::eraseDomainAndNonOwnedEntities() {
|
||||||
emit clearingEntities();
|
emit clearingEntities();
|
||||||
|
|
||||||
if (_simulation) {
|
if (_simulation) {
|
||||||
// local entities are not in the simulation, so we clear ALL
|
// local entities are not in the simulation, so we clear ALL
|
||||||
_simulation->clearEntities();
|
_simulation->clearEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->withWriteLock([&] {
|
this->withWriteLock([&] {
|
||||||
QHash<EntityItemID, EntityItemPointer> savedEntities;
|
QHash<EntityItemID, EntityItemPointer> savedEntities;
|
||||||
// NOTE: lock the Tree first, then lock the _entityMap.
|
// NOTE: lock the Tree first, then lock the _entityMap.
|
||||||
|
@ -93,10 +94,10 @@ void EntityTree::eraseNonLocalEntities() {
|
||||||
foreach(EntityItemPointer entity, _entityMap) {
|
foreach(EntityItemPointer entity, _entityMap) {
|
||||||
EntityTreeElementPointer element = entity->getElement();
|
EntityTreeElementPointer element = entity->getElement();
|
||||||
if (element) {
|
if (element) {
|
||||||
element->cleanupNonLocalEntities();
|
element->cleanupDomainAndNonOwnedEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity->isLocalEntity()) {
|
if (entity->isLocalEntity() || (entity->isAvatarEntity() && entity->getOwningAvatarID() == getMyAvatarSessionUUID())) {
|
||||||
savedEntities[entity->getEntityItemID()] = entity;
|
savedEntities[entity->getEntityItemID()] = entity;
|
||||||
} else {
|
} else {
|
||||||
int32_t spaceIndex = entity->getSpaceIndex();
|
int32_t spaceIndex = entity->getSpaceIndex();
|
||||||
|
@ -114,15 +115,16 @@ void EntityTree::eraseNonLocalEntities() {
|
||||||
|
|
||||||
{
|
{
|
||||||
QWriteLocker locker(&_needsParentFixupLock);
|
QWriteLocker locker(&_needsParentFixupLock);
|
||||||
QVector<EntityItemWeakPointer> localEntitiesNeedsParentFixup;
|
QVector<EntityItemWeakPointer> needParentFixup;
|
||||||
|
|
||||||
foreach (EntityItemWeakPointer entityItem, _needsParentFixup) {
|
foreach (EntityItemWeakPointer entityItem, _needsParentFixup) {
|
||||||
if (!entityItem.expired() && entityItem.lock()->isLocalEntity()) {
|
auto entity = entityItem.lock();
|
||||||
localEntitiesNeedsParentFixup.push_back(entityItem);
|
if (entity && (entity->isLocalEntity() || (entity->isAvatarEntity() && entity->getOwningAvatarID() == getMyAvatarSessionUUID()))) {
|
||||||
|
needParentFixup.push_back(entityItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_needsParentFixup = localEntitiesNeedsParentFixup;
|
_needsParentFixup = needParentFixup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void eraseNonLocalEntities() override;
|
virtual void eraseDomainAndNonOwnedEntities() override;
|
||||||
virtual void eraseAllOctreeElements(bool createNewRoot = true) override;
|
virtual void eraseAllOctreeElements(bool createNewRoot = true) override;
|
||||||
|
|
||||||
virtual void readBitstreamToTree(const unsigned char* bitstream,
|
virtual void readBitstreamToTree(const unsigned char* bitstream,
|
||||||
|
@ -255,6 +255,7 @@ public:
|
||||||
QByteArray computeNonce(const QString& certID, const QString ownerKey);
|
QByteArray computeNonce(const QString& certID, const QString ownerKey);
|
||||||
bool verifyNonce(const QString& certID, const QString& nonce, EntityItemID& id);
|
bool verifyNonce(const QString& certID, const QString& nonce, EntityItemID& id);
|
||||||
|
|
||||||
|
QUuid getMyAvatarSessionUUID() { return _myAvatar ? _myAvatar->getSessionUUID() : QUuid(); }
|
||||||
void setMyAvatar(std::shared_ptr<AvatarData> myAvatar) { _myAvatar = myAvatar; }
|
void setMyAvatar(std::shared_ptr<AvatarData> myAvatar) { _myAvatar = myAvatar; }
|
||||||
|
|
||||||
void swapStaleProxies(std::vector<int>& proxies) { proxies.swap(_staleProxies); }
|
void swapStaleProxies(std::vector<int>& proxies) { proxies.swap(_staleProxies); }
|
||||||
|
|
|
@ -697,11 +697,11 @@ EntityItemPointer EntityTreeElement::getEntityWithEntityItemID(const EntityItemI
|
||||||
return foundEntity;
|
return foundEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeElement::cleanupNonLocalEntities() {
|
void EntityTreeElement::cleanupDomainAndNonOwnedEntities() {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
EntityItems savedEntities;
|
EntityItems savedEntities;
|
||||||
foreach(EntityItemPointer entity, _entityItems) {
|
foreach(EntityItemPointer entity, _entityItems) {
|
||||||
if (!entity->isLocalEntity()) {
|
if (!(entity->isLocalEntity() || (entity->isAvatarEntity() && entity->getOwningAvatarID() == getTree()->getMyAvatarSessionUUID()))) {
|
||||||
entity->preDelete();
|
entity->preDelete();
|
||||||
entity->_element = NULL;
|
entity->_element = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -190,7 +190,7 @@ public:
|
||||||
EntityItemPointer getEntityWithEntityItemID(const EntityItemID& id) const;
|
EntityItemPointer getEntityWithEntityItemID(const EntityItemID& id) const;
|
||||||
void getEntitiesInside(const AACube& box, QVector<EntityItemPointer>& foundEntities);
|
void getEntitiesInside(const AACube& box, QVector<EntityItemPointer>& foundEntities);
|
||||||
|
|
||||||
void cleanupNonLocalEntities();
|
void cleanupDomainAndNonOwnedEntities();
|
||||||
void cleanupEntities(); /// called by EntityTree on cleanup this will free all entities
|
void cleanupEntities(); /// called by EntityTree on cleanup this will free all entities
|
||||||
bool removeEntityItem(EntityItemPointer entity, bool deletion = false);
|
bool removeEntityItem(EntityItemPointer entity, bool deletion = false);
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ public:
|
||||||
|
|
||||||
OctreeElementPointer getRoot() { return _rootElement; }
|
OctreeElementPointer getRoot() { return _rootElement; }
|
||||||
|
|
||||||
virtual void eraseNonLocalEntities() { _isDirty = true; };
|
virtual void eraseDomainAndNonOwnedEntities() { _isDirty = true; };
|
||||||
virtual void eraseAllOctreeElements(bool createNewRoot = true);
|
virtual void eraseAllOctreeElements(bool createNewRoot = true);
|
||||||
|
|
||||||
virtual void readBitstreamToTree(const unsigned char* bitstream, uint64_t bufferSizeBytes, ReadBitstreamToTreeParams& args);
|
virtual void readBitstreamToTree(const unsigned char* bitstream, uint64_t bufferSizeBytes, ReadBitstreamToTreeParams& args);
|
||||||
|
|
|
@ -198,10 +198,10 @@ void OctreeProcessor::processDatagram(ReceivedMessage& message, SharedNodePointe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OctreeProcessor::clearNonLocalEntities() {
|
void OctreeProcessor::clearDomainAndNonOwnedEntities() {
|
||||||
if (_tree) {
|
if (_tree) {
|
||||||
_tree->withWriteLock([&] {
|
_tree->withWriteLock([&] {
|
||||||
_tree->eraseNonLocalEntities();
|
_tree->eraseDomainAndNonOwnedEntities();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
|
||||||
/// clears the tree
|
/// clears the tree
|
||||||
virtual void clearNonLocalEntities();
|
virtual void clearDomainAndNonOwnedEntities();
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
float getAverageElementsPerPacket() const { return _elementsPerPacket.getAverage(); }
|
float getAverageElementsPerPacket() const { return _elementsPerPacket.getAverage(); }
|
||||||
|
|
Loading…
Reference in a new issue