dust3d/src/meshresultpostprocessor.cpp

53 lines
1.2 KiB
C++
Raw Normal View History

#include <QGuiApplication>
#include "meshresultpostprocessor.h"
#include "uvunwrap.h"
#include "triangletangentresolve.h"
2020-11-17 14:31:51 +00:00
MeshResultPostProcessor::MeshResultPostProcessor(const Object &object)
{
2020-11-17 14:31:51 +00:00
m_object = new Object;
*m_object = object;
}
MeshResultPostProcessor::~MeshResultPostProcessor()
{
2020-11-17 14:31:51 +00:00
delete m_object;
}
2020-11-17 14:31:51 +00:00
Object *MeshResultPostProcessor::takePostProcessedObject()
{
2020-11-17 14:31:51 +00:00
Object *object = m_object;
m_object = nullptr;
return object;
}
void MeshResultPostProcessor::poseProcess()
{
#ifndef NDEBUG
return;
#endif
2020-11-17 14:31:51 +00:00
if (!m_object->nodes.empty()) {
{
std::vector<std::vector<QVector2D>> triangleVertexUvs;
std::set<int> seamVertices;
2019-05-12 08:15:07 +00:00
std::map<QUuid, std::vector<QRectF>> partUvRects;
2020-11-17 14:31:51 +00:00
uvUnwrap(*m_object, triangleVertexUvs, seamVertices, partUvRects);
m_object->setTriangleVertexUvs(triangleVertexUvs);
m_object->setPartUvRects(partUvRects);
}
{
std::vector<QVector3D> triangleTangents;
2020-11-17 14:31:51 +00:00
triangleTangentResolve(*m_object, triangleTangents);
m_object->setTriangleTangents(triangleTangents);
}
}
}
void MeshResultPostProcessor::process()
{
poseProcess();
emit finished();
}