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
1761 if (!isLoaded()) {1761 if (!isLoaded()) {
1762 return false;1762 return false;
1763 }1763 }
1764
1764 if (!_isLoadedWithTextures) {1765 if (!_isLoadedWithTextures) {
1765 for (auto&& mesh : _meshes) {1766 for (auto&& material : _materials) {
1766 for (auto && part : mesh->_parts) {1767 if ((material->diffuseTexture && !material->diffuseTexture->isLoaded()) ||
1767 if ((part->diffuseTexture && !part->diffuseTexture->isLoaded()) ||1768 (material->normalTexture && !material->normalTexture->isLoaded()) ||
1768 (part->normalTexture && !part->normalTexture->isLoaded()) ||1769 (material->specularTexture && !material->specularTexture->isLoaded()) ||
1769 (part->specularTexture && !part->specularTexture->isLoaded()) ||1770 (material->emissiveTexture && !material->emissiveTexture->isLoaded())) {
1770 (part->emissiveTexture && !part->emissiveTexture->isLoaded())) {1771 return false;
1771 return false;
1772 }
1773 }1772 }
1774 }1773 }
1775 _isLoadedWithTextures = true;1774 _isLoadedWithTextures = true;
@@ -1778,8 +1777,23 @@ bool NetworkGeometry::isLoadedWithTextures() const { · 2 unmodified lines
1778}1777}
1779 1778
1780void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& url) {1779void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& url) {
1780
1781
1781 if (_meshes.size() > 0) {1782 if (_meshes.size() > 0) {
1782 auto textureCache = DependencyManager::get<TextureCache>();1783 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/*
1783 for (size_t i = 0; i < _meshes.size(); i++) {1797 for (size_t i = 0; i < _meshes.size(); i++) {
1784 NetworkMesh& mesh = *(_meshes[i].get());1798 NetworkMesh& mesh = *(_meshes[i].get());
1785 for (size_t j = 0; j < mesh._parts.size(); j++) {1799 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
1795 part.emissiveTexture = textureCache->getTexture(url);1809 part.emissiveTexture = textureCache->getTexture(url);
1796 }1810 }
1797 }1811 }
1798 }1812 }*/
1799 } else {1813 } else {
1800 qCWarning(renderutils) << "Ignoring setTextureWirthNameToURL() geometry not ready." << name << url;1814 qCWarning(renderutils) << "Ignoring setTextureWirthNameToURL() geometry not ready." << name << url;
1801 }1815 }
@@ -1804,7 +1818,28 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u · 2 unmodified lines
1804 1818
1805QStringList NetworkGeometry::getTextureNames() const {1819QStringList NetworkGeometry::getTextureNames() const {
1806 QStringList result;1820 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++) {
1808 const NetworkMesh& mesh = *(_meshes[i].get());1843 const NetworkMesh& mesh = *(_meshes[i].get());
1809 for (size_t j = 0; j < mesh._parts.size(); j++) {1844 for (size_t j = 0; j < mesh._parts.size(); j++) {
1810 const NetworkMeshPart& part = *(mesh._parts[j].get());1845 const NetworkMeshPart& part = *(mesh._parts[j].get());
@@ -1829,7 +1864,7 @@ QStringList NetworkGeometry::getTextureNames() const { · 18 unmodified lines
1829 result << part.emissiveTextureName + ":" + textureURL;1864 result << part.emissiveTextureName + ":" + textureURL;
1830 }1865 }
1831 }1866 }
1832 }1867 }*/
1833 return result;1868 return result;
1834}1869}
1835 1870
@@ -1915,8 +1950,8 @@ static NetworkMesh* buildNetworkMesh(const FBXMesh& mesh, const QUrl& textureBas · 79 unmodified lines
1915 1950
1916 // process network parts1951 // process network parts
1917 foreach (const FBXMeshPart& part, mesh.parts) {1952 foreach (const FBXMeshPart& part, mesh.parts) {
1918 NetworkMeshPart* networkPart = new NetworkMeshPart();1953 /* NetworkMeshPart* networkPart = new NetworkMeshPart();
1919/*1954
1920 if (!part.diffuseTexture.filename.isEmpty()) {1955 if (!part.diffuseTexture.filename.isEmpty()) {
1921 networkPart->diffuseTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(part.diffuseTexture.filename)), DEFAULT_TEXTURE,1956 networkPart->diffuseTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(part.diffuseTexture.filename)), DEFAULT_TEXTURE,
1922 mesh.isEye, part.diffuseTexture.content);1957 mesh.isEye, part.diffuseTexture.content);
@@ -1937,8 +1972,9 @@ static NetworkMesh* buildNetworkMesh(const FBXMesh& mesh, const QUrl& textureBas · 14 unmodified lines
1937 false, part.emissiveTexture.content);1972 false, part.emissiveTexture.content);
1938 networkPart->emissiveTextureName = part.emissiveTexture.name;1973 networkPart->emissiveTextureName = part.emissiveTexture.name;
1939 checkForTexcoordLightmap = true;1974 checkForTexcoordLightmap = true;
1940 }*/1975 }
1941 networkMesh->_parts.emplace_back(networkPart);1976 networkMesh->_parts.emplace_back(networkPart);
1977 */
1942 totalIndices += (part.quadIndices.size() + part.triangleIndices.size());1978 totalIndices += (part.quadIndices.size() + part.triangleIndices.size());
1943 }1979 }
1944 1980
@@ -2151,25 +2187,3 @@ const NetworkMaterial* NetworkGeometry::getShapeMaterial(int shapeID) { · 206 unmodified lines
2151 }2187 }
2152}2188}
2153 2189
2154bool NetworkMeshPart::isTranslucent() const {
2155 return diffuseTexture && diffuseTexture->isTranslucent();
2156}
2157
2158bool 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
2166int 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}