3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-26 12:55:27 +02:00

more correct AvatarEntityData settings when switching domains

This commit is contained in:
Andrew Meadows 2018-12-21 11:56:08 -08:00
parent 9d6acf007a
commit e2d6e6f3dc
3 changed files with 22 additions and 16 deletions

View file

@ -6756,8 +6756,10 @@ void Application::updateWindowTitle() const {
}
void Application::clearDomainOctreeDetails() {
// before we delete all entities get MyAvatar's AvatarEntityData ready
getMyAvatar()->prepareAvatarEntityDataForReload();
// if we're about to quit, we really don't need to do any of these things...
// if we're about to quit, we really don't need to do the rest of these things...
if (_aboutToQuit) {
return;
}
@ -6785,9 +6787,6 @@ void Application::clearDomainOctreeDetails() {
ShaderCache::instance().clearUnusedResources();
DependencyManager::get<TextureCache>()->clearUnusedResources();
DependencyManager::get<recording::ClipCache>()->clearUnusedResources();
// we just deleted all of MyAvatar's AvatarEntities so we flag it to reload from settings
getMyAvatar()->rememberToReloadAvatarEntityDataFromSettings();
}
void Application::domainURLChanged(QUrl domainURL) {

View file

@ -1501,8 +1501,8 @@ void MyAvatar::updateAvatarEntities() {
// We collect changes to AvatarEntities and then handle them all in one spot per frame: updateAvatarEntities().
// Basically this is a "transaction pattern" with an extra complication: these changes can come from two
// "directions" and the "authoritative source" of each direction is different, so maintain two distinct sets of
// transaction lists;
// "directions" and the "authoritative source" of each direction is different, so we maintain two distinct sets
// of transaction lists:
//
// The _entitiesToDelete/Add/Update lists are for changes whose "authoritative sources" are already
// correctly stored in _cachedAvatarEntityBlobs. These come from loadAvatarEntityDataFromSettings() and
@ -1690,10 +1690,7 @@ bool MyAvatar::updateStaleAvatarEntityBlobs() const {
return false;
}
std::set<QUuid> staleBlobs;
_avatarEntitiesLock.withWriteLock([&] {
staleBlobs = std::move(_staleCachedAvatarEntityBlobs);
});
std::set<QUuid> staleBlobs = std::move(_staleCachedAvatarEntityBlobs);
int32_t numFound = 0;
for (const auto& id : staleBlobs) {
bool found = false;
@ -1717,9 +1714,20 @@ bool MyAvatar::updateStaleAvatarEntityBlobs() const {
return true;
}
void MyAvatar::rememberToReloadAvatarEntityDataFromSettings() {
AvatarEntityMap emptyMap;
setAvatarEntityData(emptyMap);
void MyAvatar::prepareAvatarEntityDataForReload() {
saveAvatarEntityDataToSettings();
_avatarEntitiesLock.withWriteLock([&] {
_packedAvatarEntityData.clear();
_entitiesToDelete.clear();
_entitiesToAdd.clear();
_entitiesToUpdate.clear();
_cachedAvatarEntityBlobs.clear();
_cachedAvatarEntityBlobsToDelete.clear();
_cachedAvatarEntityBlobsToAddOrUpdate.clear();
_cachedAvatarEntityBlobUpdatesToSkip.clear();
});
_reloadAvatarEntityDataFromSettings = true;
}

View file

@ -1187,7 +1187,7 @@ public:
glm::vec3 getNextPosition() { return _goToPending ? _goToPosition : getWorldPosition(); }
void updateAvatarEntities() override;
void rememberToReloadAvatarEntityDataFromSettings();
void prepareAvatarEntityDataForReload();
/**jsdoc
* Create a new grab.
@ -1614,7 +1614,6 @@ signals:
*/
void disableHandTouchForIDChanged(const QUuid& entityID, bool disable);
private slots:
void leaveDomain();
void updateCollisionCapsuleCache();
@ -1980,7 +1979,7 @@ private:
std::vector<QUuid> _cachedAvatarEntityBlobUpdatesToSkip;
//
// Also these lists for tracking delayed changes to blobs and Settings
std::set<QUuid> _staleCachedAvatarEntityBlobs;
mutable std::set<QUuid> _staleCachedAvatarEntityBlobs;
//
// keep a ScriptEngine around so we don't have to instantiate on the fly (these are very slow to create/delete)
QScriptEngine* _myScriptEngine { nullptr };