diff --git a/interface/src/ui/overlays/ModelOverlay.cpp b/interface/src/ui/overlays/ModelOverlay.cpp index c8056c11c8..875352ebb4 100644 --- a/interface/src/ui/overlays/ModelOverlay.cpp +++ b/interface/src/ui/overlays/ModelOverlay.cpp @@ -131,6 +131,9 @@ void ModelOverlay::update(float deltatime) { if (!_texturesLoaded && _model->getGeometry() && _model->getGeometry()->areTexturesLoaded()) { _texturesLoaded = true; + if (!_modelTextures.isEmpty()) { + _model->setTextures(_modelTextures); + } _model->updateRenderItems(); } } @@ -229,8 +232,7 @@ void ModelOverlay::setProperties(const QVariantMap& properties) { if (texturesValue.isValid() && texturesValue.canConvert(QVariant::Map)) { _texturesLoaded = false; QVariantMap textureMap = texturesValue.toMap(); - QMetaObject::invokeMethod(_model.get(), "setTextures", Qt::AutoConnection, - Q_ARG(const QVariantMap&, textureMap)); + _modelTextures = textureMap; } auto groupCulledValue = properties["isGroupCulled"]; diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 7cfb1f6bc8..9bf6c31784 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -1074,15 +1074,11 @@ int Model::getLastFreeJointIndex(int jointIndex) const { void Model::setTextures(const QVariantMap& textures) { if (isLoaded()) { - _needsUpdateTextures = true; + _pendingTextures.clear(); _needsFixupInScene = true; _renderGeometry->setTextures(textures); } else { - // FIXME(Huffman): Disconnect previously connected lambdas so we don't set textures multiple - // after the geometry has finished loading. - connect(&_renderWatcher, &GeometryResourceWatcher::finished, this, [this, textures]() { - _renderGeometry->setTextures(textures); - }); + _pendingTextures = textures; } } @@ -1106,7 +1102,8 @@ void Model::setURL(const QUrl& url) { } _needsReload = true; - _needsUpdateTextures = true; + // One might be tempted to _pendingTextures.clear(), thinking that a new URL means an old texture doesn't apply. + // But sometimes, particularly when first setting the values, the texture might be set first. So let's not clear here. _visualGeometryRequestFailed = false; _needsFixupInScene = true; invalidCalculatedMeshBoxes(); @@ -1123,6 +1120,8 @@ void Model::setURL(const QUrl& url) { void Model::loadURLFinished(bool success) { if (!success) { _visualGeometryRequestFailed = true; + } else if (!_pendingTextures.empty()) { + setTextures(_pendingTextures); } emit setURLFinished(success); } diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index 4180288106..67e6d178ea 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -457,7 +457,7 @@ protected: bool _needsFixupInScene { true }; // needs to be removed/re-added to scene bool _needsReload { true }; bool _needsUpdateClusterMatrices { true }; - mutable bool _needsUpdateTextures { true }; + QVariantMap _pendingTextures { }; friend class ModelMeshPartPayload; Rig _rig; diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 41774629e7..7175685b4f 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -40,7 +40,6 @@ var HOVER_TEXTURES = { var UNSELECTED_COLOR = { red: 0x1F, green: 0xC6, blue: 0xA6}; var SELECTED_COLOR = {red: 0xF3, green: 0x91, blue: 0x29}; var HOVER_COLOR = {red: 0xD0, green: 0xD0, blue: 0xD0}; // almost white for now -var conserveResources = true; Script.include("/~/system/libraries/controllers.js"); @@ -431,7 +430,7 @@ function addAvatarNode(id) { alpha: 0.8, color: color(selected, false, 0.0), ignoreRayIntersection: false - }, selected, !conserveResources); + }, selected, true); } // Each open/refresh will capture a stable set of avatarsOfInterest, within the specified filter. var avatarsOfInterest = {}; @@ -496,7 +495,6 @@ function populateNearbyUserList(selectData, oldAudioData) { print('PAL data:', JSON.stringify(avatarPalDatum)); }); getConnectionData(false, location.domainID); // Even admins don't get relationship data in requestUsernameFromID (which is still needed for admin status, which comes from domain). - conserveResources = Object.keys(avatarsOfInterest).length > 20; sendToQml({ method: 'nearbyUsers', params: data }); if (selectData) { selectData[2] = true; @@ -719,7 +717,7 @@ function onTabletScreenChanged(type, url) { ContextOverlay.enabled = false; Users.requestsDomainListData = true; - audioTimer = createAudioInterval(conserveResources ? AUDIO_LEVEL_CONSERVED_UPDATE_INTERVAL_MS : AUDIO_LEVEL_UPDATE_INTERVAL_MS); + audioTimer = createAudioInterval(AUDIO_LEVEL_UPDATE_INTERVAL_MS); tablet.tabletShownChanged.connect(tabletVisibilityChanged); Script.update.connect(updateOverlays); @@ -874,7 +872,6 @@ startup(); var isWired = false; var audioTimer; var AUDIO_LEVEL_UPDATE_INTERVAL_MS = 100; // 10hz for now (change this and change the AVERAGING_RATIO too) -var AUDIO_LEVEL_CONSERVED_UPDATE_INTERVAL_MS = 300; function off() { if (isWired) { Script.update.disconnect(updateOverlays);