History

Merging back with master

Sam Gateau committed 11 years ago

Commit c37cdce2 parents 4e94464 c4c6e72427 files · +25473 −4250Browse files

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

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+19−17
@@ -1678,15 +1678,15 @@ void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch, bool noBlend) { · 1677 unmodified lines
1678 }1678 }
1679}1679}
1680 1680
1681GeometryReader::GeometryReader(const QUrl& url, QNetworkReply* reply, const QVariantHash& mapping) :1681GeometryReader::GeometryReader(const QUrl& url, const QByteArray& data, const QVariantHash& mapping) :
1682 _url(url),1682 _url(url),
1683 _reply(reply),1683 _data(data),
1684 _mapping(mapping) {1684 _mapping(mapping) {
1685}1685}
1686 1686
1687void GeometryReader::run() {1687void GeometryReader::run() {
1688 try {1688 try {
1689 if (!_reply) {1689 if (_data.isEmpty()) {
1690 throw QString("Reply is NULL ?!");1690 throw QString("Reply is NULL ?!");
1691 }1691 }
1692 QString urlname = _url.path().toLower();1692 QString urlname = _url.path().toLower();
@@ -1701,9 +1701,9 @@ void GeometryReader::run() { · 8 unmodified lines
1701 if (_url.path().toLower().endsWith(".fbx")) {1701 if (_url.path().toLower().endsWith(".fbx")) {
1702 const bool grabLightmaps = true;1702 const bool grabLightmaps = true;
1703 const float lightmapLevel = 1.0f;1703 const float lightmapLevel = 1.0f;
1704 fbxgeo = readFBX(_reply, _mapping, _url.path(), grabLightmaps, lightmapLevel);1704 fbxgeo = readFBX(_data, _mapping, _url.path(), grabLightmaps, lightmapLevel);
1705 } else if (_url.path().toLower().endsWith(".obj")) {1705 } else if (_url.path().toLower().endsWith(".obj")) {
1706 fbxgeo = OBJReader().readOBJ(_reply, _mapping, &_url);1706 fbxgeo = OBJReader().readOBJ(_data, _mapping, _url);
1707 } else {1707 } else {
1708 QString errorStr("usupported format");1708 QString errorStr("usupported format");
1709 emit onError(NetworkGeometry::ModelParseError, errorStr);1709 emit onError(NetworkGeometry::ModelParseError, errorStr);
@@ -1717,7 +1717,6 @@ void GeometryReader::run() { · 7 unmodified lines
1717 qCDebug(renderutils) << "Error reading " << _url << ": " << error;1717 qCDebug(renderutils) << "Error reading " << _url << ": " << error;
1718 emit onError(NetworkGeometry::ModelParseError, error);1718 emit onError(NetworkGeometry::ModelParseError, error);
1719 }1719 }
1720 _reply->deleteLater();
1721}1720}
1722 1721
1723NetworkGeometry::NetworkGeometry(const QUrl& url, bool delayLoad, const QVariantHash& mapping, const QUrl& textureBaseUrl) :1722NetworkGeometry::NetworkGeometry(const QUrl& url, bool delayLoad, const QVariantHash& mapping, const QUrl& textureBaseUrl) :
@@ -1746,8 +1745,10 @@ void NetworkGeometry::attemptRequest() { · 22 unmodified lines
1746 1745
1747void NetworkGeometry::attemptRequestInternal() {1746void NetworkGeometry::attemptRequestInternal() {
1748 if (_url.path().toLower().endsWith(".fst")) {1747 if (_url.path().toLower().endsWith(".fst")) {
1748 _mappingUrl = _url;
1749 requestMapping(_url);1749 requestMapping(_url);
1750 } else {1750 } else {
1751 _modelUrl = _url;
1751 requestModel(_url);1752 requestModel(_url);
1752 }1753 }
1753}1754}
@@ -1832,8 +1833,8 @@ void NetworkGeometry::requestMapping(const QUrl& url) { · 78 unmodified lines
1832 _resource->deleteLater();1833 _resource->deleteLater();
1833 }1834 }
1834 _resource = new Resource(url, false);1835 _resource = new Resource(url, false);
1835 connect(_resource, SIGNAL(loaded(QNetworkReply&)), SLOT(mappingRequestDone(QNetworkReply&)));1836 connect(_resource, &Resource::loaded, this, &NetworkGeometry::mappingRequestDone);
1836 connect(_resource, SIGNAL(failed(QNetworkReply::NetworkError)), SLOT(mappingRequestError(QNetworkReply::NetworkError)));1837 connect(_resource, &Resource::failed, this, &NetworkGeometry::mappingRequestError);
1837}1838}
1838 1839
1839void NetworkGeometry::requestModel(const QUrl& url) {1840void NetworkGeometry::requestModel(const QUrl& url) {
@@ -1841,18 +1842,19 @@ void NetworkGeometry::requestModel(const QUrl& url) { · 1 unmodified line
1841 if (_resource) {1842 if (_resource) {
1842 _resource->deleteLater();1843 _resource->deleteLater();
1843 }1844 }
1845 _modelUrl = url;
1844 _resource = new Resource(url, false);1846 _resource = new Resource(url, false);
1845 connect(_resource, SIGNAL(loaded(QNetworkReply&)), SLOT(modelRequestDone(QNetworkReply&)));1847 connect(_resource, &Resource::loaded, this, &NetworkGeometry::modelRequestDone);
1846 connect(_resource, SIGNAL(failed(QNetworkReply::NetworkError)), SLOT(modelRequestError(QNetworkReply::NetworkError)));1848 connect(_resource, &Resource::failed, this, &NetworkGeometry::modelRequestError);
1847}1849}
1848 1850
1849void NetworkGeometry::mappingRequestDone(QNetworkReply& reply) {1851void NetworkGeometry::mappingRequestDone(const QByteArray& data) {
1850 assert(_state == RequestMappingState);1852 assert(_state == RequestMappingState);
1851 1853
1852 // parse the mapping file1854 // parse the mapping file
1853 _mapping = FSTReader::readMapping(reply.readAll());1855 _mapping = FSTReader::readMapping(data);
1854 1856
1855 QUrl replyUrl = reply.url();1857 QUrl replyUrl = _mappingUrl;
1856 QString modelUrlStr = _mapping.value("filename").toString();1858 QString modelUrlStr = _mapping.value("filename").toString();
1857 if (modelUrlStr.isNull()) {1859 if (modelUrlStr.isNull()) {
1858 qCDebug(renderutils) << "Mapping file " << _url << "has no \"filename\" entry";1860 qCDebug(renderutils) << "Mapping file " << _url << "has no \"filename\" entry";
@@ -1867,8 +1869,8 @@ void NetworkGeometry::mappingRequestDone(QNetworkReply& reply) { · 8 unmodified lines
1867 _textureBaseUrl = replyUrl.resolved(texdir);1869 _textureBaseUrl = replyUrl.resolved(texdir);
1868 }1870 }
1869 1871
1870 QUrl modelUrl = replyUrl.resolved(modelUrlStr);1872 _modelUrl = replyUrl.resolved(modelUrlStr);
1871 requestModel(modelUrl);1873 requestModel(_modelUrl);
1872 }1874 }
1873}1875}
1874 1876
@@ -1878,13 +1880,13 @@ void NetworkGeometry::mappingRequestError(QNetworkReply::NetworkError error) { · 3 unmodified lines
1878 emit onFailure(*this, MappingRequestError);1880 emit onFailure(*this, MappingRequestError);
1879}1881}
1880 1882
1881void NetworkGeometry::modelRequestDone(QNetworkReply& reply) {1883void NetworkGeometry::modelRequestDone(const QByteArray& data) {
1882 assert(_state == RequestModelState);1884 assert(_state == RequestModelState);
1883 1885
1884 _state = ParsingModelState;1886 _state = ParsingModelState;
1885 1887
1886 // asynchronously parse the model file.1888 // asynchronously parse the model file.
1887 GeometryReader* geometryReader = new GeometryReader(reply.url(), &reply, _mapping);1889 GeometryReader* geometryReader = new GeometryReader(_modelUrl, data, _mapping);
1888 connect(geometryReader, SIGNAL(onSuccess(FBXGeometry*)), SLOT(modelParseSuccess(FBXGeometry*)));1890 connect(geometryReader, SIGNAL(onSuccess(FBXGeometry*)), SLOT(modelParseSuccess(FBXGeometry*)));
1889 connect(geometryReader, SIGNAL(onError(int, QString)), SLOT(modelParseError(int, QString)));1891 connect(geometryReader, SIGNAL(onError(int, QString)), SLOT(modelParseError(int, QString)));
1890 1892