mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 22:10:25 +02:00
Merge pull request #15187 from SamGondelman/wearables
Case 21721: Fix wearable duplication on domain switch
This commit is contained in:
commit
840f3a3a2e
4 changed files with 38 additions and 12 deletions
|
@ -5772,6 +5772,7 @@ void Application::reloadResourceCaches() {
|
||||||
|
|
||||||
queryOctree(NodeType::EntityServer, PacketType::EntityQuery);
|
queryOctree(NodeType::EntityServer, PacketType::EntityQuery);
|
||||||
|
|
||||||
|
getMyAvatar()->prepareAvatarEntityDataForReload();
|
||||||
// Clear the entities and their renderables
|
// Clear the entities and their renderables
|
||||||
getEntities()->clear();
|
getEntities()->clear();
|
||||||
|
|
||||||
|
@ -6947,9 +6948,6 @@ void Application::updateWindowTitle() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::clearDomainOctreeDetails(bool clearAll) {
|
void Application::clearDomainOctreeDetails(bool clearAll) {
|
||||||
// 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 the rest of these things...
|
// if we're about to quit, we really don't need to do the rest of these things...
|
||||||
if (_aboutToQuit) {
|
if (_aboutToQuit) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3450,6 +3450,34 @@ float MyAvatar::getGravity() {
|
||||||
return _characterController.getGravity();
|
return _characterController.getGravity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyAvatar::setSessionUUID(const QUuid& sessionUUID) {
|
||||||
|
QUuid oldID = getSessionUUID();
|
||||||
|
Avatar::setSessionUUID(sessionUUID);
|
||||||
|
QUuid id = getSessionUUID();
|
||||||
|
if (id != oldID) {
|
||||||
|
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
||||||
|
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
|
||||||
|
if (entityTree) {
|
||||||
|
QList<QUuid> avatarEntityIDs;
|
||||||
|
_avatarEntitiesLock.withReadLock([&] {
|
||||||
|
avatarEntityIDs = _packedAvatarEntityData.keys();
|
||||||
|
});
|
||||||
|
entityTree->withWriteLock([&] {
|
||||||
|
for (const auto& entityID : avatarEntityIDs) {
|
||||||
|
auto entity = entityTree->findEntityByID(entityID);
|
||||||
|
if (!entity) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
entity->setOwningAvatarID(id);
|
||||||
|
if (entity->getParentID() == oldID) {
|
||||||
|
entity->setParentID(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MyAvatar::increaseSize() {
|
void MyAvatar::increaseSize() {
|
||||||
float minScale = getDomainMinScale();
|
float minScale = getDomainMinScale();
|
||||||
float maxScale = getDomainMaxScale();
|
float maxScale = getDomainMaxScale();
|
||||||
|
|
|
@ -1213,6 +1213,12 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* @function MyAvatar.setSessionUUID
|
||||||
|
* @param {Uuid} sessionUUID
|
||||||
|
*/
|
||||||
|
virtual void setSessionUUID(const QUuid& sessionUUID) override;
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Increase the avatar's scale by five percent, up to a minimum scale of <code>1000</code>.
|
* Increase the avatar's scale by five percent, up to a minimum scale of <code>1000</code>.
|
||||||
* @function MyAvatar.increaseSize
|
* @function MyAvatar.increaseSize
|
||||||
|
|
|
@ -1646,11 +1646,9 @@ bool EntityScriptingInterface::actionWorker(const QUuid& entityID,
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
const QUuid myNodeID = nodeList->getSessionUUID();
|
const QUuid myNodeID = nodeList->getSessionUUID();
|
||||||
|
|
||||||
EntityItemProperties properties;
|
|
||||||
|
|
||||||
EntityItemPointer entity;
|
EntityItemPointer entity;
|
||||||
bool doTransmit = false;
|
bool doTransmit = false;
|
||||||
_entityTree->withWriteLock([this, &entity, entityID, myNodeID, &doTransmit, actor, &properties] {
|
_entityTree->withWriteLock([this, &entity, entityID, myNodeID, &doTransmit, actor] {
|
||||||
EntitySimulationPointer simulation = _entityTree->getSimulation();
|
EntitySimulationPointer simulation = _entityTree->getSimulation();
|
||||||
entity = _entityTree->findEntityByEntityItemID(entityID);
|
entity = _entityTree->findEntityByEntityItemID(entityID);
|
||||||
if (!entity) {
|
if (!entity) {
|
||||||
|
@ -1669,16 +1667,12 @@ bool EntityScriptingInterface::actionWorker(const QUuid& entityID,
|
||||||
|
|
||||||
doTransmit = actor(simulation, entity);
|
doTransmit = actor(simulation, entity);
|
||||||
_entityTree->entityChanged(entity);
|
_entityTree->entityChanged(entity);
|
||||||
if (doTransmit) {
|
|
||||||
properties.setEntityHostType(entity->getEntityHostType());
|
|
||||||
properties.setOwningAvatarID(entity->getOwningAvatarID());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// transmit the change
|
// transmit the change
|
||||||
if (doTransmit) {
|
if (doTransmit) {
|
||||||
_entityTree->withReadLock([&] {
|
EntityItemProperties properties = _entityTree->resultWithReadLock<EntityItemProperties>([&] {
|
||||||
properties = entity->getProperties();
|
return entity->getProperties();
|
||||||
});
|
});
|
||||||
|
|
||||||
properties.setActionDataDirty();
|
properties.setActionDataDirty();
|
||||||
|
|
Loading…
Reference in a new issue