History

Getting rid of the NetworkMEshPart and simplifying the thinking around the MOdel regarding its RenderItems

Sam Gateau committed 11 years ago

Commit 85f230b1 parent 4f7b8574 files · +82 −126Browse files

Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 4 files). Show all

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+50−36
@@ -1761,15 +1761,14 @@ bool NetworkGeometry::isLoadedWithTextures() const { · 1760 unmodified lines
17611761 if (!isLoaded()) {
17621762 return false;
17631763 }
1764+
17641765 if (!_isLoadedWithTextures) {
1765− for (auto&& mesh : _meshes) {
1766− for (auto && part : mesh->_parts) {
1767− if ((part->diffuseTexture && !part->diffuseTexture->isLoaded()) ||
1768− (part->normalTexture && !part->normalTexture->isLoaded()) ||
1769− (part->specularTexture && !part->specularTexture->isLoaded()) ||
1770− (part->emissiveTexture && !part->emissiveTexture->isLoaded())) {
1771− return false;
1772− }
1766+ for (auto&& material : _materials) {
1767+ if ((material->diffuseTexture && !material->diffuseTexture->isLoaded()) ||
1768+ (material->normalTexture && !material->normalTexture->isLoaded()) ||
1769+ (material->specularTexture && !material->specularTexture->isLoaded()) ||
1770+ (material->emissiveTexture && !material->emissiveTexture->isLoaded())) {
1771+ return false;
17731772 }
17741773 }
17751774 _isLoadedWithTextures = true;
@@ -1778,8 +1777,23 @@ bool NetworkGeometry::isLoadedWithTextures() const { · 2 unmodified lines
17781777 }
17791778
17801779 void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& url) {
1780+
1781+
17811782 if (_meshes.size() > 0) {
17821783 auto textureCache = DependencyManager::get<TextureCache>();
1784+ for (auto&& material : _materials) {
1785+ QSharedPointer<NetworkTexture> matchingTexture = QSharedPointer<NetworkTexture>();
1786+ if (material->diffuseTextureName == name) {
1787+ material->diffuseTexture = textureCache->getTexture(url, DEFAULT_TEXTURE, /* _geometry->meshes[i].isEye*/ false);
1788+ } else if (material->normalTextureName == name) {
1789+ material->normalTexture = textureCache->getTexture(url);
1790+ } else if (material->specularTextureName == name) {
1791+ material->specularTexture = textureCache->getTexture(url);
1792+ } else if (material->emissiveTextureName == name) {
1793+ material->emissiveTexture = textureCache->getTexture(url);
1794+ }
1795+ }
1796+/*
17831797 for (size_t i = 0; i < _meshes.size(); i++) {
17841798 NetworkMesh& mesh = *(_meshes[i].get());
17851799 for (size_t j = 0; j < mesh._parts.size(); j++) {
@@ -1795,7 +1809,7 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u · 9 unmodified lines
17951809 part.emissiveTexture = textureCache->getTexture(url);
17961810 }
17971811 }
1798− }
1812+ }*/
17991813 } else {
18001814 qCWarning(renderutils) << "Ignoring setTextureWirthNameToURL() geometry not ready." << name << url;
18011815 }
@@ -1804,7 +1818,28 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u · 2 unmodified lines
18041818
18051819 QStringList NetworkGeometry::getTextureNames() const {
18061820 QStringList result;
1807− for (size_t i = 0; i < _meshes.size(); i++) {
1821+ for (auto&& material : _materials) {
1822+ if (!material->diffuseTextureName.isEmpty() && material->diffuseTexture) {
1823+ QString textureURL = material->diffuseTexture->getURL().toString();
1824+ result << material->diffuseTextureName + ":" + textureURL;
1825+ }
1826+
1827+ if (!material->normalTextureName.isEmpty() && material->normalTexture) {
1828+ QString textureURL = material->normalTexture->getURL().toString();
1829+ result << material->normalTextureName + ":" + textureURL;
1830+ }
1831+
1832+ if (!material->specularTextureName.isEmpty() && material->specularTexture) {
1833+ QString textureURL = material->specularTexture->getURL().toString();
1834+ result << material->specularTextureName + ":" + textureURL;
1835+ }
1836+
1837+ if (!material->emissiveTextureName.isEmpty() && material->emissiveTexture) {
1838+ QString textureURL = material->emissiveTexture->getURL().toString();
1839+ result << material->emissiveTextureName + ":" + textureURL;
1840+ }
1841+ }
1842+ /* for (size_t i = 0; i < _meshes.size(); i++) {
18081843 const NetworkMesh& mesh = *(_meshes[i].get());
18091844 for (size_t j = 0; j < mesh._parts.size(); j++) {
18101845 const NetworkMeshPart& part = *(mesh._parts[j].get());
@@ -1829,7 +1864,7 @@ QStringList NetworkGeometry::getTextureNames() const { · 18 unmodified lines
18291864 result << part.emissiveTextureName + ":" + textureURL;
18301865 }
18311866 }
1832− }
1867+ }*/
18331868 return result;
18341869 }
18351870
@@ -1915,8 +1950,8 @@ static NetworkMesh* buildNetworkMesh(const FBXMesh& mesh, const QUrl& textureBas · 79 unmodified lines
19151950
19161951 // process network parts
19171952 foreach (const FBXMeshPart& part, mesh.parts) {
1918− NetworkMeshPart* networkPart = new NetworkMeshPart();
1919−/*
1953+ /* NetworkMeshPart* networkPart = new NetworkMeshPart();
1954+
19201955 if (!part.diffuseTexture.filename.isEmpty()) {
19211956 networkPart->diffuseTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(part.diffuseTexture.filename)), DEFAULT_TEXTURE,
19221957 mesh.isEye, part.diffuseTexture.content);
@@ -1937,8 +1972,9 @@ static NetworkMesh* buildNetworkMesh(const FBXMesh& mesh, const QUrl& textureBas · 14 unmodified lines
19371972 false, part.emissiveTexture.content);
19381973 networkPart->emissiveTextureName = part.emissiveTexture.name;
19391974 checkForTexcoordLightmap = true;
1940− }*/
1975+ }
19411976 networkMesh->_parts.emplace_back(networkPart);
1977+ */
19421978 totalIndices += (part.quadIndices.size() + part.triangleIndices.size());
19431979 }
19441980
@@ -2151,25 +2187,3 @@ const NetworkMaterial* NetworkGeometry::getShapeMaterial(int shapeID) { · 206 unmodified lines
21512187 }
21522188 }
21532189
2154−bool NetworkMeshPart::isTranslucent() const {
2155− return diffuseTexture && diffuseTexture->isTranslucent();
2156−}
2157−
2158−bool NetworkMesh::isPartTranslucent(const FBXMesh& fbxMesh, int partIndex) const {
2159− assert(partIndex >= 0);
2160− assert((size_t)partIndex < _parts.size());
2161− // return (_parts.at(partIndex)->isTranslucent() || fbxMesh.parts.at(partIndex).opacity != 1.0f);
2162− // TODO FIX That
2163− return (_parts.at(partIndex)->isTranslucent());
2164−}
2165−
2166−int NetworkMesh::getTranslucentPartCount(const FBXMesh& fbxMesh) const {
2167− int count = 0;
2168−
2169− for (size_t i = 0; i < _parts.size(); i++) {
2170− if (isPartTranslucent(fbxMesh, i)) {
2171− count++;
2172− }
2173− }
2174− return count;
2175−}