Showing the changes to interface/src/renderer/GeometryCache.cpp (1 of 2 files). Show all
Unified · Split
| @@ -547,7 +547,8 @@ NetworkGeometry::NetworkGeometry(const QUrl& url, const QSharedPointer<NetworkGe · 546 unmodified lines | |||
| 547 | Resource(url, delayLoad), | 547 | Resource(url, delayLoad), |
| 548 | _mapping(mapping), | 548 | _mapping(mapping), |
| 549 | _textureBase(textureBase.isValid() ? textureBase : url), | 549 | _textureBase(textureBase.isValid() ? textureBase : url), |
| 550 | _fallback(fallback) { | 550 | _fallback(fallback) |
| 551 | { | ||
| 551 | 552 | ||
| 552 | if (url.isEmpty()) { | 553 | if (url.isEmpty()) { |
| 553 | // make the minimal amount of dummy geometry to satisfy Model | 554 | // make the minimal amount of dummy geometry to satisfy Model |
| @@ -562,6 +563,8 @@ NetworkGeometry::NetworkGeometry(const QUrl& url, const QSharedPointer<NetworkGe · 8 unmodified lines | |||
| 562 | _geometry.leftHandJointIndex = -1; | 563 | _geometry.leftHandJointIndex = -1; |
| 563 | _geometry.rightHandJointIndex = -1; | 564 | _geometry.rightHandJointIndex = -1; |
| 564 | } | 565 | } |
| 566 | |||
| 567 | connect(this, &Resource::loaded, this, &NetworkGeometry::replaceTexturesWithPendingChanges); | ||
| 565 | } | 568 | } |
| 566 | 569 | ||
| 567 | bool NetworkGeometry::isLoadedWithTextures() const { | 570 | bool NetworkGeometry::isLoadedWithTextures() const { |
| @@ -710,27 +713,33 @@ void NetworkGeometry::clearLoadPriority(const QPointer<QObject>& owner) { · 142 unmodified lines | |||
| 710 | } | 713 | } |
| 711 | 714 | ||
| 712 | void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& url) { | 715 | void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& url) { |
| 713 | for (int i = 0; i < _meshes.size(); i++) { | 716 | if (_meshes.size() > 0) { |
| 714 | NetworkMesh& mesh = _meshes[i]; | 717 | for (int i = 0; i < _meshes.size(); i++) { |
| 715 | for (int j = 0; j < mesh.parts.size(); j++) { | 718 | NetworkMesh& mesh = _meshes[i]; |
| 716 | NetworkMeshPart& part = mesh.parts[j]; | 719 | for (int j = 0; j < mesh.parts.size(); j++) { |
| 717 | 720 | NetworkMeshPart& part = mesh.parts[j]; | |
| 718 | QSharedPointer<NetworkTexture> matchingTexture = QSharedPointer<NetworkTexture>(); | 721 | |
| 719 | if (part.diffuseTextureName == name) { | 722 | QSharedPointer<NetworkTexture> matchingTexture = QSharedPointer<NetworkTexture>(); |
| 720 | part.diffuseTexture = | 723 | if (part.diffuseTextureName == name) { |
| 724 | part.diffuseTexture = | ||
| 721 | Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE, | 725 | Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE, |
| 722 | _geometry.meshes[i].isEye, QByteArray()); | 726 | _geometry.meshes[i].isEye, QByteArray()); |
| 723 | part.diffuseTexture->setLoadPriorities(_loadPriorities); | 727 | part.diffuseTexture->setLoadPriorities(_loadPriorities); |
| 724 | } else if (part.normalTextureName == name) { | 728 | } else if (part.normalTextureName == name) { |
| 725 | part.normalTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE, | 729 | part.normalTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE, |
| 726 | false, QByteArray()); | 730 | false, QByteArray()); |
| 727 | part.normalTexture->setLoadPriorities(_loadPriorities); | 731 | part.normalTexture->setLoadPriorities(_loadPriorities); |
| 728 | } else if (part.specularTextureName == name) { | 732 | } else if (part.specularTextureName == name) { |
| 729 | part.specularTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE, | 733 | part.specularTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE, |
| 730 | false, QByteArray()); | 734 | false, QByteArray()); |
| 731 | part.specularTexture->setLoadPriorities(_loadPriorities); | 735 | part.specularTexture->setLoadPriorities(_loadPriorities); |
| 736 | } | ||
| 732 | } | 737 | } |
| 733 | } | 738 | } |
| 739 | } else { | ||
| 740 | qDebug() << "Adding a name url pair to pending" << name << url; | ||
| 741 | // we don't have meshes downloaded yet, so hold this texture as pending | ||
| 742 | _pendingTextureChanges.insert(name, url); | ||
| 734 | } | 743 | } |
| 735 | } | 744 | } |
| 736 | 745 | ||
| @@ -760,6 +769,15 @@ QStringList NetworkGeometry::getTextureNames() const { · 23 unmodified lines | |||
| 760 | return result; | 769 | return result; |
| 761 | } | 770 | } |
| 762 | 771 | ||
| 772 | void NetworkGeometry::replaceTexturesWithPendingChanges() { | ||
| 773 | |||
| 774 | QHash<QString, QUrl>::Iterator it = _pendingTextureChanges.begin(); | ||
| 775 | while (it != _pendingTextureChanges.end()) { | ||
| 776 | setTextureWithNameToURL(it.key(), it.value()); | ||
| 777 | it = _pendingTextureChanges.erase(it); | ||
| 778 | } | ||
| 779 | } | ||
| 780 | |||
| 763 | /// Reads geometry in a worker thread. | 781 | /// Reads geometry in a worker thread. |
| 764 | class GeometryReader : public QRunnable { | 782 | class GeometryReader : public QRunnable { |
| 765 | public: | 783 | public: |
| @@ -807,6 +825,7 @@ void NetworkGeometry::init() { · 41 unmodified lines | |||
| 807 | _geometry = FBXGeometry(); | 825 | _geometry = FBXGeometry(); |
| 808 | _meshes.clear(); | 826 | _meshes.clear(); |
| 809 | _lods.clear(); | 827 | _lods.clear(); |
| 828 | _pendingTextureChanges.clear(); | ||
| 810 | _request.setUrl(_url); | 829 | _request.setUrl(_url); |
| 811 | Resource::init(); | 830 | Resource::init(); |
| 812 | } | 831 | } |