(cherry picked from commit b152bf02af4eb17cf5c169ca9c577154c83901f7)
Showing the changes to libraries/render-utils/src/Model.cpp (1 of 2 files). Show all
Unified · Split
| @@ -1074,15 +1074,11 @@ int Model::getLastFreeJointIndex(int jointIndex) const { · 1073 unmodified lines | ||
| 1074 | 1074 | |
| 1075 | 1075 | void Model::setTextures(const QVariantMap& textures) { |
| 1076 | 1076 | if (isLoaded()) { |
| 1077 | − _needsUpdateTextures = true; | |
| 1077 | + _pendingTextures.clear(); | |
| 1078 | 1078 | _needsFixupInScene = true; |
| 1079 | 1079 | _renderGeometry->setTextures(textures); |
| 1080 | 1080 | } else { |
| 1081 | − // FIXME(Huffman): Disconnect previously connected lambdas so we don't set textures multiple | |
| 1082 | − // after the geometry has finished loading. | |
| 1083 | − connect(&_renderWatcher, &GeometryResourceWatcher::finished, this, [this, textures]() { | |
| 1084 | − _renderGeometry->setTextures(textures); | |
| 1085 | − }); | |
| 1081 | + _pendingTextures = textures; | |
| 1086 | 1082 | } |
| 1087 | 1083 | } |
| 1088 | 1084 | |
| @@ -1106,7 +1102,8 @@ void Model::setURL(const QUrl& url) { · 17 unmodified lines | ||
| 1106 | 1102 | } |
| 1107 | 1103 | |
| 1108 | 1104 | _needsReload = true; |
| 1109 | − _needsUpdateTextures = true; | |
| 1105 | + // One might be tempted to _pendingTextures.clear(), thinking that a new URL means an old texture doesn't apply. | |
| 1106 | + // But sometimes, particularly when first setting the values, the texture might be set first. So let's not clear here. | |
| 1110 | 1107 | _visualGeometryRequestFailed = false; |
| 1111 | 1108 | _needsFixupInScene = true; |
| 1112 | 1109 | invalidCalculatedMeshBoxes(); |
| @@ -1123,6 +1120,8 @@ void Model::setURL(const QUrl& url) { · 10 unmodified lines | ||
| 1123 | 1120 | void Model::loadURLFinished(bool success) { |
| 1124 | 1121 | if (!success) { |
| 1125 | 1122 | _visualGeometryRequestFailed = true; |
| 1123 | + } else if (!_pendingTextures.empty()) { | |
| 1124 | + setTextures(_pendingTextures); | |
| 1126 | 1125 | } |
| 1127 | 1126 | emit setURLFinished(success); |
| 1128 | 1127 | } |