Fix part cache
parent
c87c4482c1
commit
7ce09d1cd6
|
@ -37,7 +37,6 @@ Document::~Document()
|
|||
{
|
||||
delete (dust3d::MeshGenerator::GeneratedCacheContext*)m_generatedCacheContext;
|
||||
delete m_resultMesh;
|
||||
delete m_postProcessedObject;
|
||||
delete textureImage;
|
||||
delete textureImageByteArray;
|
||||
delete textureNormalImage;
|
||||
|
@ -2148,7 +2147,7 @@ void Document::generateTexture()
|
|||
|
||||
m_isTextureObsolete = false;
|
||||
|
||||
auto object = std::make_unique<dust3d::Object>(*m_postProcessedObject);
|
||||
auto object = std::make_unique<dust3d::Object>(*m_uvMappedObject);
|
||||
|
||||
auto snapshot = std::make_unique<dust3d::Snapshot>();
|
||||
toSnapshot(snapshot.get());
|
||||
|
@ -2174,7 +2173,10 @@ void Document::textureReady()
|
|||
delete m_resultTextureMesh;
|
||||
m_resultTextureMesh = m_textureGenerator->takeResultMesh().release();
|
||||
|
||||
m_postProcessedObject->alphaEnabled = m_textureGenerator->hasTransparencySettings();
|
||||
auto object = m_textureGenerator->takeObject();
|
||||
if (nullptr != object)
|
||||
m_uvMappedObject = std::move(object);
|
||||
//m_uvMappedObject->alphaEnabled = m_textureGenerator->hasTransparencySettings();
|
||||
|
||||
m_textureImageUpdateVersion++;
|
||||
|
||||
|
@ -2221,8 +2223,7 @@ void Document::postProcess()
|
|||
|
||||
void Document::postProcessedMeshResultReady()
|
||||
{
|
||||
delete m_postProcessedObject;
|
||||
m_postProcessedObject = m_postProcessor->takePostProcessedObject();
|
||||
m_uvMappedObject.reset(m_postProcessor->takePostProcessedObject());
|
||||
|
||||
delete m_postProcessor;
|
||||
m_postProcessor = nullptr;
|
||||
|
@ -2236,9 +2237,9 @@ void Document::postProcessedMeshResultReady()
|
|||
}
|
||||
}
|
||||
|
||||
const dust3d::Object& Document::currentPostProcessedObject() const
|
||||
const dust3d::Object& Document::currentUvMappedObject() const
|
||||
{
|
||||
return *m_postProcessedObject;
|
||||
return *m_uvMappedObject;
|
||||
}
|
||||
|
||||
void Document::setComponentCombineMode(dust3d::Uuid componentId, dust3d::CombineMode combineMode)
|
||||
|
|
|
@ -689,7 +689,7 @@ public:
|
|||
void updateTextureMetalnessImage(QImage* image);
|
||||
void updateTextureRoughnessImage(QImage* image);
|
||||
void updateTextureAmbientOcclusionImage(QImage* image);
|
||||
const dust3d::Object& currentPostProcessedObject() const;
|
||||
const dust3d::Object& currentUvMappedObject() const;
|
||||
bool isExportReady() const;
|
||||
bool isPostProcessResultObsolete() const;
|
||||
bool isMeshGenerating() const;
|
||||
|
@ -876,7 +876,7 @@ private:
|
|||
UvMapGenerator* m_textureGenerator = nullptr;
|
||||
bool m_isPostProcessResultObsolete = false;
|
||||
MeshResultPostProcessor* m_postProcessor = nullptr;
|
||||
dust3d::Object* m_postProcessedObject = new dust3d::Object;
|
||||
std::unique_ptr<dust3d::Object> m_uvMappedObject = std::make_unique<dust3d::Object>();
|
||||
ModelMesh* m_resultTextureMesh = nullptr;
|
||||
unsigned long long m_textureImageUpdateVersion = 0;
|
||||
bool m_smoothNormal = false;
|
||||
|
|
|
@ -1030,7 +1030,7 @@ void DocumentWindow::exportFbxToFilename(const QString& filename)
|
|||
return;
|
||||
}
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
dust3d::Object skeletonResult = m_document->currentPostProcessedObject();
|
||||
dust3d::Object skeletonResult = m_document->currentUvMappedObject();
|
||||
FbxFileWriter fbxFileWriter(skeletonResult,
|
||||
filename,
|
||||
m_document->textureImage,
|
||||
|
@ -1060,7 +1060,7 @@ void DocumentWindow::exportGlbToFilename(const QString& filename)
|
|||
return;
|
||||
}
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
dust3d::Object skeletonResult = m_document->currentPostProcessedObject();
|
||||
dust3d::Object skeletonResult = m_document->currentUvMappedObject();
|
||||
QImage* textureMetalnessRoughnessAmbientOcclusionImage = UvMapGenerator::combineMetalnessRoughnessAmbientOcclusionImages(m_document->textureMetalnessImage,
|
||||
m_document->textureRoughnessImage,
|
||||
m_document->textureAmbientOcclusionImage);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <QPainter>
|
||||
#include <dust3d/uv/uv_map_packer.h>
|
||||
|
||||
size_t UvMapGenerator::m_textureSize = 1024;
|
||||
size_t UvMapGenerator::m_textureSize = 4096;
|
||||
|
||||
UvMapGenerator::UvMapGenerator(std::unique_ptr<dust3d::Object> object, std::unique_ptr<dust3d::Snapshot> snapshot)
|
||||
: m_object(std::move(object))
|
||||
|
|
|
@ -649,11 +649,8 @@ std::unique_ptr<MeshCombiner::Mesh> MeshGenerator::combinePartMesh(const std::st
|
|||
return nullptr;
|
||||
|
||||
auto& partCache = m_cacheContext->parts[partIdString];
|
||||
partCache.objectNodes.clear();
|
||||
partCache.objectEdges.clear();
|
||||
partCache.objectNodeVertices.clear();
|
||||
partCache.vertices.clear();
|
||||
partCache.faces.clear();
|
||||
partCache.reset();
|
||||
|
||||
partCache.color = partColor;
|
||||
partCache.metalness = metalness;
|
||||
partCache.roughness = roughness;
|
||||
|
@ -829,12 +826,7 @@ std::unique_ptr<MeshCombiner::Mesh> MeshGenerator::combineComponentMesh(const st
|
|||
}
|
||||
}
|
||||
|
||||
componentCache.sharedQuadEdges.clear();
|
||||
componentCache.noneSeamVertices.clear();
|
||||
componentCache.objectNodes.clear();
|
||||
componentCache.objectEdges.clear();
|
||||
componentCache.objectNodeVertices.clear();
|
||||
componentCache.mesh.reset();
|
||||
componentCache.reset();
|
||||
|
||||
std::string linkDataType = String::valueOrEmpty(*component, "linkDataType");
|
||||
if ("partId" == linkDataType) {
|
||||
|
|
|
@ -53,6 +53,20 @@ public:
|
|||
float roughness = 1.0;
|
||||
bool isSuccessful = false;
|
||||
bool joined = true;
|
||||
void reset()
|
||||
{
|
||||
vertices.clear();
|
||||
faces.clear();
|
||||
triangleUvs.clear();
|
||||
objectNodes.clear();
|
||||
objectEdges.clear();
|
||||
objectNodeVertices.clear();
|
||||
color = Color(1.0, 1.0, 1.0);
|
||||
metalness = 0.0;
|
||||
roughness = 1.0;
|
||||
isSuccessful = false;
|
||||
joined = true;
|
||||
}
|
||||
};
|
||||
|
||||
struct GeneratedComponent {
|
||||
|
@ -63,6 +77,16 @@ public:
|
|||
std::vector<ObjectNode> objectNodes;
|
||||
std::vector<std::pair<std::pair<Uuid, Uuid>, std::pair<Uuid, Uuid>>> objectEdges;
|
||||
std::vector<std::pair<Vector3, std::pair<Uuid, Uuid>>> objectNodeVertices;
|
||||
void reset()
|
||||
{
|
||||
mesh.reset();
|
||||
sharedQuadEdges.clear();
|
||||
partTriangleUvs.clear();
|
||||
noneSeamVertices.clear();
|
||||
objectNodes.clear();
|
||||
objectEdges.clear();
|
||||
objectNodeVertices.clear();
|
||||
}
|
||||
};
|
||||
|
||||
struct GeneratedCacheContext {
|
||||
|
|
Loading…
Reference in New Issue