2018-05-07 16:08:19 +00:00
|
|
|
#include <QGuiApplication>
|
|
|
|
#include "meshresultpostprocessor.h"
|
2018-10-26 23:04:45 +00:00
|
|
|
#include "uvunwrap.h"
|
|
|
|
#include "triangletangentresolve.h"
|
2018-05-07 16:08:19 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
MeshResultPostProcessor::MeshResultPostProcessor(const Outcome &outcome)
|
2018-05-07 16:08:19 +00:00
|
|
|
{
|
2018-10-25 00:19:38 +00:00
|
|
|
m_outcome = new Outcome;
|
|
|
|
*m_outcome = outcome;
|
2018-05-07 16:08:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MeshResultPostProcessor::~MeshResultPostProcessor()
|
|
|
|
{
|
2018-10-25 00:19:38 +00:00
|
|
|
delete m_outcome;
|
2018-05-07 16:08:19 +00:00
|
|
|
}
|
|
|
|
|
2018-10-26 23:04:45 +00:00
|
|
|
Outcome *MeshResultPostProcessor::takePostProcessedOutcome()
|
2018-05-07 16:08:19 +00:00
|
|
|
{
|
2018-10-25 00:19:38 +00:00
|
|
|
Outcome *outcome = m_outcome;
|
|
|
|
m_outcome = nullptr;
|
|
|
|
return outcome;
|
2018-05-07 16:08:19 +00:00
|
|
|
}
|
|
|
|
|
2018-10-26 23:04:45 +00:00
|
|
|
void MeshResultPostProcessor::poseProcess()
|
2018-05-07 16:08:19 +00:00
|
|
|
{
|
2018-10-25 15:28:10 +00:00
|
|
|
if (!m_outcome->nodes.empty()) {
|
2018-10-26 23:04:45 +00:00
|
|
|
{
|
|
|
|
std::vector<std::vector<QVector2D>> triangleVertexUvs;
|
|
|
|
std::set<int> seamVertices;
|
|
|
|
uvUnwrap(*m_outcome, triangleVertexUvs, seamVertices);
|
|
|
|
m_outcome->setTriangleVertexUvs(triangleVertexUvs);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
std::vector<QVector3D> triangleTangents;
|
|
|
|
triangleTangentResolve(*m_outcome, triangleTangents);
|
|
|
|
m_outcome->setTriangleTangents(triangleTangents);
|
|
|
|
}
|
2018-05-07 16:08:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-26 23:04:45 +00:00
|
|
|
void MeshResultPostProcessor::process()
|
|
|
|
{
|
|
|
|
poseProcess();
|
2018-05-07 16:08:19 +00:00
|
|
|
|
2018-10-26 23:04:45 +00:00
|
|
|
this->moveToThread(QGuiApplication::instance()->thread());
|
|
|
|
emit finished();
|
|
|
|
}
|