working toward fixing compound hulls

This commit is contained in:
Seth Alves 2017-04-09 17:23:56 -07:00
parent 8d00f0ab8f
commit a1cab2c0d1
4 changed files with 19 additions and 12 deletions

View file

@ -32,6 +32,7 @@ class GeometryExtra {
public:
const QVariantHash& mapping;
const QUrl& textureBaseUrl;
bool combineParts;
};
QUrl resolveTextureBaseUrl(const QUrl& url, const QUrl& textureBaseUrl) {
@ -89,7 +90,7 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) {
}
auto modelCache = DependencyManager::get<ModelCache>();
GeometryExtra extra{ mapping, _textureBaseUrl };
GeometryExtra extra{ mapping, _textureBaseUrl, false }; // XXX
// Get the raw GeometryResource
_geometryResource = modelCache->getResource(url, QUrl(), &extra).staticCast<GeometryResource>();
@ -129,8 +130,8 @@ void GeometryMappingResource::onGeometryMappingLoaded(bool success) {
class GeometryReader : public QRunnable {
public:
GeometryReader(QWeakPointer<Resource>& resource, const QUrl& url, const QVariantHash& mapping,
const QByteArray& data) :
_resource(resource), _url(url), _mapping(mapping), _data(data) {
const QByteArray& data, bool combineParts) :
_resource(resource), _url(url), _mapping(mapping), _data(data), _combineParts(combineParts) {
DependencyManager::get<StatTracker>()->incrementStat("PendingProcessing");
}
@ -142,6 +143,7 @@ private:
QUrl _url;
QVariantHash _mapping;
QByteArray _data;
bool _combineParts;
};
void GeometryReader::run() {
@ -210,8 +212,8 @@ void GeometryReader::run() {
class GeometryDefinitionResource : public GeometryResource {
Q_OBJECT
public:
GeometryDefinitionResource(const QUrl& url, const QVariantHash& mapping, const QUrl& textureBaseUrl) :
GeometryResource(url, resolveTextureBaseUrl(url, textureBaseUrl)), _mapping(mapping) {}
GeometryDefinitionResource(const QUrl& url, const QVariantHash& mapping, const QUrl& textureBaseUrl, bool combineParts) :
GeometryResource(url, resolveTextureBaseUrl(url, textureBaseUrl)), _mapping(mapping), _combineParts(combineParts) {}
QString getType() const override { return "GeometryDefinition"; }
@ -222,10 +224,11 @@ protected:
private:
QVariantHash _mapping;
bool _combineParts;
};
void GeometryDefinitionResource::downloadFinished(const QByteArray& data) {
QThreadPool::globalInstance()->start(new GeometryReader(_self, _url, _mapping, data));
QThreadPool::globalInstance()->start(new GeometryReader(_self, _url, _mapping, data, _combineParts));
}
void GeometryDefinitionResource::setGeometryDefinition(FBXGeometry::Pointer fbxGeometry) {
@ -266,7 +269,7 @@ ModelCache::ModelCache() {
}
QSharedPointer<Resource> ModelCache::createResource(const QUrl& url, const QSharedPointer<Resource>& fallback,
const void* extra) {
const void* extra) {
Resource* resource = nullptr;
if (url.path().toLower().endsWith(".fst")) {
resource = new GeometryMappingResource(url);
@ -274,14 +277,15 @@ QSharedPointer<Resource> ModelCache::createResource(const QUrl& url, const QShar
const GeometryExtra* geometryExtra = static_cast<const GeometryExtra*>(extra);
auto mapping = geometryExtra ? geometryExtra->mapping : QVariantHash();
auto textureBaseUrl = geometryExtra ? geometryExtra->textureBaseUrl : QUrl();
resource = new GeometryDefinitionResource(url, mapping, textureBaseUrl);
bool combineParts = geometryExtra ? geometryExtra->combineParts : false;
resource = new GeometryDefinitionResource(url, mapping, textureBaseUrl, combineParts);
}
return QSharedPointer<Resource>(resource, &Resource::deleter);
}
GeometryResource::Pointer ModelCache::getGeometryResource(const QUrl& url, const QVariantHash& mapping, const QUrl& textureBaseUrl) {
GeometryExtra geometryExtra = { mapping, textureBaseUrl };
GeometryExtra geometryExtra = { mapping, textureBaseUrl, false }; // XXX
GeometryResource::Pointer resource = getResource(url, QUrl(), &geometryExtra).staticCast<GeometryResource>();
if (resource) {
if (resource->isLoaded() && resource->shouldSetTextures()) {

View file

@ -142,7 +142,7 @@ protected:
friend class GeometryMappingResource;
virtual QSharedPointer<Resource> createResource(const QUrl& url, const QSharedPointer<Resource>& fallback,
const void* extra) override;
const void* extra) override;
private:
ModelCache();

View file

@ -295,8 +295,8 @@ protected:
/// Creates a new resource.
virtual QSharedPointer<Resource> createResource(const QUrl& url, const QSharedPointer<Resource>& fallback,
const void* extra) = 0;
const void* extra) = 0;
void addUnusedResource(const QSharedPointer<Resource>& resource);
void removeUnusedResource(const QSharedPointer<Resource>& resource);

View file

@ -10,6 +10,7 @@
//
#include <QCommandLineParser>
#include <Trace.h>
#include <VHACD.h>
#include "VHACDUtilApp.h"
#include "VHACDUtil.h"
@ -98,6 +99,8 @@ VHACDUtilApp::VHACDUtilApp(int argc, char* argv[]) :
{
vhacd::VHACDUtil vUtil;
DependencyManager::set<tracing::Tracer>();
// parse command-line
QCommandLineParser parser;
parser.setApplicationDescription("High Fidelity Object Decomposer");