2018-09-18 03:17:35 +00:00
|
|
|
#include <QThread>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include "posepreviewmanager.h"
|
|
|
|
|
|
|
|
PosePreviewManager::PosePreviewManager()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PosePreviewManager::~PosePreviewManager()
|
|
|
|
{
|
|
|
|
delete m_previewMesh;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PosePreviewManager::isRendering()
|
|
|
|
{
|
|
|
|
return nullptr != m_poseMeshCreator;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PosePreviewManager::postUpdate(const Poser &poser,
|
2018-10-25 00:19:38 +00:00
|
|
|
const Outcome &outcome,
|
2018-10-26 23:04:45 +00:00
|
|
|
const std::map<int, RiggerVertexWeights> &resultWeights)
|
2018-09-18 03:17:35 +00:00
|
|
|
{
|
|
|
|
if (nullptr != m_poseMeshCreator)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
qDebug() << "Pose mesh generating..";
|
|
|
|
|
|
|
|
QThread *thread = new QThread;
|
2018-10-25 00:19:38 +00:00
|
|
|
m_poseMeshCreator = new PoseMeshCreator(poser.resultNodes(), outcome, resultWeights);
|
2018-09-18 03:17:35 +00:00
|
|
|
m_poseMeshCreator->moveToThread(thread);
|
|
|
|
connect(thread, &QThread::started, m_poseMeshCreator, &PoseMeshCreator::process);
|
|
|
|
connect(m_poseMeshCreator, &PoseMeshCreator::finished, this, &PosePreviewManager::poseMeshReady);
|
|
|
|
connect(m_poseMeshCreator, &PoseMeshCreator::finished, thread, &QThread::quit);
|
|
|
|
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
|
|
|
thread->start();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
MeshLoader *PosePreviewManager::takeResultPreviewMesh()
|
|
|
|
{
|
|
|
|
if (nullptr == m_previewMesh)
|
|
|
|
return nullptr;
|
|
|
|
return new MeshLoader(*m_previewMesh);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PosePreviewManager::poseMeshReady()
|
|
|
|
{
|
|
|
|
delete m_previewMesh;
|
|
|
|
m_previewMesh = m_poseMeshCreator->takeResultMesh();
|
|
|
|
|
|
|
|
qDebug() << "Pose mesh generation done";
|
|
|
|
|
|
|
|
delete m_poseMeshCreator;
|
|
|
|
m_poseMeshCreator = nullptr;
|
|
|
|
|
2018-09-21 07:10:18 +00:00
|
|
|
emit resultPreviewMeshChanged();
|
2018-09-18 03:17:35 +00:00
|
|
|
emit renderDone();
|
|
|
|
}
|