Many source file name and data type are prefixed by "skeleton" before, now all are refactored.
The class MeshResultContext represents the outcome of mesh generation before, now we have material, pose and animation, so we just rename it as Outcome.
master
Jeremy Hu 2018-10-25 08:19:38 +08:00
parent dbc82fa8f1
commit 208d2a0166
135 changed files with 1593 additions and 1579 deletions

View File

@ -48,20 +48,20 @@ HEADERS += src/modelmeshbinder.h
SOURCES += src/modelwidget.cpp SOURCES += src/modelwidget.cpp
HEADERS += src/modelwidget.h HEADERS += src/modelwidget.h
SOURCES += src/skeletondocument.cpp SOURCES += src/document.cpp
HEADERS += src/skeletondocument.h HEADERS += src/document.h
SOURCES += src/skeletondocumentwindow.cpp SOURCES += src/documentwindow.cpp
HEADERS += src/skeletondocumentwindow.h HEADERS += src/documentwindow.h
SOURCES += src/skeletongraphicswidget.cpp SOURCES += src/skeletongraphicswidget.cpp
HEADERS += src/skeletongraphicswidget.h HEADERS += src/skeletongraphicswidget.h
SOURCES += src/skeletonparttreewidget.cpp SOURCES += src/parttreewidget.cpp
HEADERS += src/skeletonparttreewidget.h HEADERS += src/parttreewidget.h
SOURCES += src/skeletonpartwidget.cpp SOURCES += src/partwidget.cpp
HEADERS += src/skeletonpartwidget.h HEADERS += src/partwidget.h
SOURCES += src/aboutwidget.cpp SOURCES += src/aboutwidget.cpp
HEADERS += src/aboutwidget.h HEADERS += src/aboutwidget.h
@ -69,17 +69,17 @@ HEADERS += src/aboutwidget.h
SOURCES += src/meshgenerator.cpp SOURCES += src/meshgenerator.cpp
HEADERS += src/meshgenerator.h HEADERS += src/meshgenerator.h
SOURCES += src/dust3dutil.cpp SOURCES += src/util.cpp
HEADERS += src/dust3dutil.h HEADERS += src/util.h
SOURCES += src/turnaroundloader.cpp SOURCES += src/turnaroundloader.cpp
HEADERS += src/turnaroundloader.h HEADERS += src/turnaroundloader.h
SOURCES += src/skeletonsnapshot.cpp SOURCES += src/snapshot.cpp
HEADERS += src/skeletonsnapshot.h HEADERS += src/snapshot.h
SOURCES += src/skeletonxml.cpp SOURCES += src/snapshotxml.cpp
HEADERS += src/skeletonxml.h HEADERS += src/snapshotxml.h
SOURCES += src/ds3file.cpp SOURCES += src/ds3file.cpp
HEADERS += src/ds3file.h HEADERS += src/ds3file.h
@ -99,8 +99,8 @@ HEADERS += src/meshutil.h
SOURCES += src/texturegenerator.cpp SOURCES += src/texturegenerator.cpp
HEADERS += src/texturegenerator.h HEADERS += src/texturegenerator.h
SOURCES += src/meshresultcontext.cpp SOURCES += src/outcome.cpp
HEADERS += src/meshresultcontext.h HEADERS += src/outcome.h
SOURCES += src/meshresultpostprocessor.cpp SOURCES += src/meshresultpostprocessor.cpp
HEADERS += src/meshresultpostprocessor.h HEADERS += src/meshresultpostprocessor.h
@ -146,8 +146,11 @@ HEADERS += src/rigwidget.h
SOURCES += src/markiconcreator.cpp SOURCES += src/markiconcreator.cpp
HEADERS += src/markiconcreator.h HEADERS += src/markiconcreator.h
SOURCES += src/skeletonbonemark.cpp SOURCES += src/bonemark.cpp
HEADERS += src/skeletonbonemark.h HEADERS += src/bonemark.h
SOURCES += src/skeletonside.cpp
HEADERS += src/skeletonside.h
SOURCES += src/meshsplitter.cpp SOURCES += src/meshsplitter.cpp
HEADERS += src/meshsplitter.h HEADERS += src/meshsplitter.h

View File

@ -3,7 +3,7 @@
#include <QOpenGLFunctions> #include <QOpenGLFunctions>
#include "aboutwidget.h" #include "aboutwidget.h"
#include "version.h" #include "version.h"
#include "dust3dutil.h" #include "util.h"
AboutWidget::AboutWidget() AboutWidget::AboutWidget()
{ {

View File

@ -1,5 +1,5 @@
#ifndef ABOUT_WIDGET_H #ifndef DUST3D_ABOUT_WIDGET_H
#define ABOUT_WIDGET_H #define DUST3D_ABOUT_WIDGET_H
#include <QDialog> #include <QDialog>
class AboutWidget : public QDialog class AboutWidget : public QDialog

View File

@ -1,9 +1,9 @@
#include <QFormLayout> #include <QFormLayout>
#include <QCheckBox> #include <QCheckBox>
#include "advancesettingwidget.h" #include "advancesettingwidget.h"
#include "dust3dutil.h" #include "util.h"
AdvanceSettingWidget::AdvanceSettingWidget(const SkeletonDocument *document, QWidget *parent) : AdvanceSettingWidget::AdvanceSettingWidget(const Document *document, QWidget *parent) :
QDialog(parent), QDialog(parent),
m_document(document) m_document(document)
{ {
@ -18,5 +18,5 @@ AdvanceSettingWidget::AdvanceSettingWidget(const SkeletonDocument *document, QWi
setLayout(formLayout); setLayout(formLayout);
connect(this, &AdvanceSettingWidget::enableWeld, document, &SkeletonDocument::enableWeld); connect(this, &AdvanceSettingWidget::enableWeld, document, &Document::enableWeld);
} }

View File

@ -1,7 +1,7 @@
#ifndef ADVANCE_SETTING_WIDGET_H #ifndef DUST3D_ADVANCE_SETTING_WIDGET_H
#define ADVANCE_SETTING_WIDGET_H #define DUST3D_ADVANCE_SETTING_WIDGET_H
#include <QDialog> #include <QDialog>
#include "skeletondocument.h" #include "document.h"
class AdvanceSettingWidget : public QDialog class AdvanceSettingWidget : public QDialog
{ {
@ -9,9 +9,9 @@ class AdvanceSettingWidget : public QDialog
signals: signals:
void enableWeld(bool enabled); void enableWeld(bool enabled);
public: public:
AdvanceSettingWidget(const SkeletonDocument *document, QWidget *parent=nullptr); AdvanceSettingWidget(const Document *document, QWidget *parent=nullptr);
private: private:
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
}; };
#endif #endif

View File

@ -106,9 +106,9 @@ AmbientOcclusionBaker::~AmbientOcclusionBaker()
delete m_resultMesh; delete m_resultMesh;
} }
void AmbientOcclusionBaker::setInputMesh(const MeshResultContext &meshResultContext) void AmbientOcclusionBaker::setInputMesh(const Outcome &outcome)
{ {
m_meshResultContext = meshResultContext; m_outcome = outcome;
} }
void AmbientOcclusionBaker::setBakeSize(int width, int height) void AmbientOcclusionBaker::setBakeSize(int width, int height)
@ -141,7 +141,7 @@ void AmbientOcclusionBaker::process()
mergeGuidePainter.drawImage(0, 0, *m_borderImage); mergeGuidePainter.drawImage(0, 0, *m_borderImage);
mergeGuidePainter.end(); mergeGuidePainter.end();
m_resultMesh = new MeshLoader(m_meshResultContext); m_resultMesh = new MeshLoader(m_outcome);
m_resultMesh->setTextureImage(new QImage(*m_textureImage)); m_resultMesh->setTextureImage(new QImage(*m_textureImage));
//m_resultMesh->setNormalMapImage(new QImage(*m_textureImage)); //m_resultMesh->setNormalMapImage(new QImage(*m_textureImage));
} }
@ -153,7 +153,7 @@ void AmbientOcclusionBaker::process()
void AmbientOcclusionBaker::bake() void AmbientOcclusionBaker::bake()
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
if (m_meshResultContext.parts().empty()) if (m_outcome.parts().empty())
return; return;
m_context->makeCurrent(this); m_context->makeCurrent(this);
@ -170,7 +170,7 @@ void AmbientOcclusionBaker::bake()
std::vector<vertex_t> vertices; std::vector<vertex_t> vertices;
std::vector<int> indicies; std::vector<int> indicies;
std::vector<QVector3D> normals; std::vector<QVector3D> normals;
for (const auto &part: m_meshResultContext.parts()) { for (const auto &part: m_outcome.parts()) {
int i = 0; int i = 0;
int startIndex = vertices.size(); int startIndex = vertices.size();
for (const auto &it: part.second.vertices) { for (const auto &it: part.second.vertices) {

View File

@ -1,5 +1,5 @@
#ifndef AMBIENT_OCCLUSION_BAKER_H #ifndef DUST3D_AMBIENT_OCCLUSION_BAKER_H
#define AMBIENT_OCCLUSION_BAKER_H #define DUST3D_AMBIENT_OCCLUSION_BAKER_H
#include <QOffscreenSurface> #include <QOffscreenSurface>
#include <QScreen> #include <QScreen>
#include <QOpenGLFunctions> #include <QOpenGLFunctions>
@ -7,7 +7,7 @@
#include <QImage> #include <QImage>
#include <QThread> #include <QThread>
#include "qtlightmapper.h" #include "qtlightmapper.h"
#include "meshresultcontext.h" #include "outcome.h"
#include "meshloader.h" #include "meshloader.h"
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
@ -24,7 +24,7 @@ public slots:
public: public:
AmbientOcclusionBaker(QScreen *targetScreen = Q_NULLPTR); AmbientOcclusionBaker(QScreen *targetScreen = Q_NULLPTR);
~AmbientOcclusionBaker(); ~AmbientOcclusionBaker();
void setInputMesh(const MeshResultContext &meshResultContext); void setInputMesh(const Outcome &outcome);
void setBakeSize(int width, int height); void setBakeSize(int width, int height);
void setColorImage(const QImage &colorImage); void setColorImage(const QImage &colorImage);
void setBorderImage(const QImage &borderImage); void setBorderImage(const QImage &borderImage);
@ -38,7 +38,7 @@ public:
void setRenderThread(QThread *thread); void setRenderThread(QThread *thread);
private: private:
QOpenGLContext *m_context; QOpenGLContext *m_context;
MeshResultContext m_meshResultContext; Outcome m_outcome;
int m_bakeWidth; int m_bakeWidth;
int m_bakeHeight; int m_bakeHeight;
QImage *m_ambientOcclusionImage; QImage *m_ambientOcclusionImage;

View File

@ -1,6 +1,6 @@
#include <cmath> #include <cmath>
#include <map> #include <map>
#include "dust3dutil.h" #include "util.h"
#include "anglesmooth.h" #include "anglesmooth.h"
void angleSmooth(const std::vector<QVector3D> &vertices, void angleSmooth(const std::vector<QVector3D> &vertices,

View File

@ -1,5 +1,5 @@
#ifndef ANGLE_SMOOTH_H #ifndef DUST3D_ANGLE_SMOOTH_H
#define ANGLE_SMOOTH_H #define DUST3D_ANGLE_SMOOTH_H
#include <QVector3D> #include <QVector3D>
#include <vector> #include <vector>

View File

@ -1,5 +1,5 @@
#ifndef ANIMATION_PLAYER_H #ifndef DUST3D_ANIMATION_PLAYER_H
#define ANIMATION_PLAYER_H #define DUST3D_ANIMATION_PLAYER_H
#include <QObject> #include <QObject>
#include <QTimer> #include <QTimer>
#include <QTime> #include <QTime>

View File

@ -1,7 +1,8 @@
#include <QDebug> #include <QDebug>
#include <cmath> #include <cmath>
#include "theme.h" #include "theme.h"
#include "skeletonbonemark.h" #include "bonemark.h"
#include "skeletonside.h"
#include "autorigger.h" #include "autorigger.h"
AutoRigger::AutoRigger(const std::vector<QVector3D> &verticesPositions, AutoRigger::AutoRigger(const std::vector<QVector3D> &verticesPositions,
@ -11,11 +12,11 @@ AutoRigger::AutoRigger(const std::vector<QVector3D> &verticesPositions,
{ {
} }
bool AutoRigger::isCutOffSplitter(SkeletonBoneMark boneMark) bool AutoRigger::isCutOffSplitter(BoneMark boneMark)
{ {
return boneMark == SkeletonBoneMark::Neck || return boneMark == BoneMark::Neck ||
boneMark == SkeletonBoneMark::Shoulder || boneMark == BoneMark::Shoulder ||
boneMark == SkeletonBoneMark::Hip; boneMark == BoneMark::Hip;
} }
bool AutoRigger::calculateBodyTriangles(std::set<MeshSplitterTriangle> &bodyTriangles) bool AutoRigger::calculateBodyTriangles(std::set<MeshSplitterTriangle> &bodyTriangles)
@ -41,7 +42,7 @@ bool AutoRigger::calculateBodyTriangles(std::set<MeshSplitterTriangle> &bodyTria
return true; return true;
} }
bool AutoRigger::addMarkGroup(SkeletonBoneMark boneMark, SkeletonSide boneSide, QVector3D bonePosition, bool AutoRigger::addMarkGroup(BoneMark boneMark, SkeletonSide boneSide, QVector3D bonePosition,
const std::set<MeshSplitterTriangle> &markTriangles) const std::set<MeshSplitterTriangle> &markTriangles)
{ {
m_marks.push_back(AutoRiggerMark()); m_marks.push_back(AutoRiggerMark());
@ -55,9 +56,9 @@ bool AutoRigger::addMarkGroup(SkeletonBoneMark boneMark, SkeletonSide boneSide,
if (isCutOffSplitter(mark.boneMark)) { if (isCutOffSplitter(mark.boneMark)) {
if (!mark.split(m_inputTriangles)) { if (!mark.split(m_inputTriangles)) {
m_marksMap[std::make_pair(mark.boneMark, mark.boneSide)].push_back(m_marks.size() - 1); m_marksMap[std::make_pair(mark.boneMark, mark.boneSide)].push_back(m_marks.size() - 1);
m_errorMarkNames.push_back(SkeletonSideToDispName(mark.boneSide) + " " + SkeletonBoneMarkToDispName(mark.boneMark)); m_errorMarkNames.push_back(SkeletonSideToDispName(mark.boneSide) + " " + BoneMarkToDispName(mark.boneMark));
m_messages.push_back(std::make_pair(QtCriticalMsg, m_messages.push_back(std::make_pair(QtCriticalMsg,
tr("Mark \"%1 %2\" couldn't cut off the mesh").arg(SkeletonSideToDispName(mark.boneSide)).arg(SkeletonBoneMarkToString(mark.boneMark)))); tr("Mark \"%1 %2\" couldn't cut off the mesh").arg(SkeletonSideToDispName(mark.boneSide)).arg(BoneMarkToString(mark.boneMark))));
return false; return false;
} }
} }
@ -85,26 +86,26 @@ bool AutoRigger::validate()
{ {
bool foundError = false; bool foundError = false;
std::vector<std::pair<SkeletonBoneMark, SkeletonSide>> mustPresentedMarks; std::vector<std::pair<BoneMark, SkeletonSide>> mustPresentedMarks;
mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Neck, SkeletonSide::None)); mustPresentedMarks.push_back(std::make_pair(BoneMark::Neck, SkeletonSide::None));
mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Shoulder, SkeletonSide::Left)); mustPresentedMarks.push_back(std::make_pair(BoneMark::Shoulder, SkeletonSide::Left));
mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Elbow, SkeletonSide::Left)); mustPresentedMarks.push_back(std::make_pair(BoneMark::Elbow, SkeletonSide::Left));
mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Wrist, SkeletonSide::Left)); mustPresentedMarks.push_back(std::make_pair(BoneMark::Wrist, SkeletonSide::Left));
mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Shoulder, SkeletonSide::Right)); mustPresentedMarks.push_back(std::make_pair(BoneMark::Shoulder, SkeletonSide::Right));
mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Elbow, SkeletonSide::Right)); mustPresentedMarks.push_back(std::make_pair(BoneMark::Elbow, SkeletonSide::Right));
mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Wrist, SkeletonSide::Right)); mustPresentedMarks.push_back(std::make_pair(BoneMark::Wrist, SkeletonSide::Right));
mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Hip, SkeletonSide::Left)); mustPresentedMarks.push_back(std::make_pair(BoneMark::Hip, SkeletonSide::Left));
mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Knee, SkeletonSide::Left)); mustPresentedMarks.push_back(std::make_pair(BoneMark::Knee, SkeletonSide::Left));
mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Ankle, SkeletonSide::Left)); mustPresentedMarks.push_back(std::make_pair(BoneMark::Ankle, SkeletonSide::Left));
mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Hip, SkeletonSide::Right)); mustPresentedMarks.push_back(std::make_pair(BoneMark::Hip, SkeletonSide::Right));
mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Knee, SkeletonSide::Right)); mustPresentedMarks.push_back(std::make_pair(BoneMark::Knee, SkeletonSide::Right));
mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Ankle, SkeletonSide::Right)); mustPresentedMarks.push_back(std::make_pair(BoneMark::Ankle, SkeletonSide::Right));
for (const auto &pair: mustPresentedMarks) { for (const auto &pair: mustPresentedMarks) {
if (m_marksMap.find(pair) == m_marksMap.end()) { if (m_marksMap.find(pair) == m_marksMap.end()) {
foundError = true; foundError = true;
QString markDispName = SkeletonSideToDispName(pair.second) + " " + SkeletonBoneMarkToDispName(pair.first); QString markDispName = SkeletonSideToDispName(pair.second) + " " + BoneMarkToDispName(pair.first);
m_missingMarkNames.push_back(markDispName); m_missingMarkNames.push_back(markDispName);
m_messages.push_back(std::make_pair(QtCriticalMsg, m_messages.push_back(std::make_pair(QtCriticalMsg,
tr("Couldn't find valid \"%1\" mark").arg(markDispName))); tr("Couldn't find valid \"%1\" mark").arg(markDispName)));
@ -264,19 +265,19 @@ bool AutoRigger::rig()
if (!calculateBodyTriangles(bodyTriangles)) if (!calculateBodyTriangles(bodyTriangles))
return false; return false;
auto neckIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Neck, SkeletonSide::None)); auto neckIndicies = m_marksMap.find(std::make_pair(BoneMark::Neck, SkeletonSide::None));
auto leftShoulderIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Shoulder, SkeletonSide::Left)); auto leftShoulderIndicies = m_marksMap.find(std::make_pair(BoneMark::Shoulder, SkeletonSide::Left));
auto leftElbowIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Elbow, SkeletonSide::Left)); auto leftElbowIndicies = m_marksMap.find(std::make_pair(BoneMark::Elbow, SkeletonSide::Left));
auto leftWristIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Wrist, SkeletonSide::Left)); auto leftWristIndicies = m_marksMap.find(std::make_pair(BoneMark::Wrist, SkeletonSide::Left));
auto rightShoulderIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Shoulder, SkeletonSide::Right)); auto rightShoulderIndicies = m_marksMap.find(std::make_pair(BoneMark::Shoulder, SkeletonSide::Right));
auto rightElbowIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Elbow, SkeletonSide::Right)); auto rightElbowIndicies = m_marksMap.find(std::make_pair(BoneMark::Elbow, SkeletonSide::Right));
auto rightWristIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Wrist, SkeletonSide::Right)); auto rightWristIndicies = m_marksMap.find(std::make_pair(BoneMark::Wrist, SkeletonSide::Right));
auto leftHipIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Hip, SkeletonSide::Left)); auto leftHipIndicies = m_marksMap.find(std::make_pair(BoneMark::Hip, SkeletonSide::Left));
auto leftKneeIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Knee, SkeletonSide::Left)); auto leftKneeIndicies = m_marksMap.find(std::make_pair(BoneMark::Knee, SkeletonSide::Left));
auto leftAnkleIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Ankle, SkeletonSide::Left)); auto leftAnkleIndicies = m_marksMap.find(std::make_pair(BoneMark::Ankle, SkeletonSide::Left));
auto rightHipIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Hip, SkeletonSide::Right)); auto rightHipIndicies = m_marksMap.find(std::make_pair(BoneMark::Hip, SkeletonSide::Right));
auto rightKneeIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Knee, SkeletonSide::Right)); auto rightKneeIndicies = m_marksMap.find(std::make_pair(BoneMark::Knee, SkeletonSide::Right));
auto rightAnkleIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Ankle, SkeletonSide::Right)); auto rightAnkleIndicies = m_marksMap.find(std::make_pair(BoneMark::Ankle, SkeletonSide::Right));
// 1. Prepare all bones start and stop positions: // 1. Prepare all bones start and stop positions:
@ -625,7 +626,7 @@ bool AutoRigger::rig()
leftUpperLegBone.name = "LeftUpperLeg"; leftUpperLegBone.name = "LeftUpperLeg";
leftUpperLegBone.headPosition = m_resultBones[boneIndexMap["LeftHip"]].tailPosition; leftUpperLegBone.headPosition = m_resultBones[boneIndexMap["LeftHip"]].tailPosition;
leftUpperLegBone.tailPosition = leftLowerLegBoneStartPosition; leftUpperLegBone.tailPosition = leftLowerLegBoneStartPosition;
leftUpperLegBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Hip); leftUpperLegBone.color = BoneMarkToColor(BoneMark::Hip);
boneIndexMap[leftUpperLegBone.name] = leftUpperLegBone.index; boneIndexMap[leftUpperLegBone.name] = leftUpperLegBone.index;
m_resultBones[boneIndexMap["LeftHip"]].children.push_back(leftUpperLegBone.index); m_resultBones[boneIndexMap["LeftHip"]].children.push_back(leftUpperLegBone.index);
@ -635,7 +636,7 @@ bool AutoRigger::rig()
leftLowerLegBone.name = "LeftLowerLeg"; leftLowerLegBone.name = "LeftLowerLeg";
leftLowerLegBone.headPosition = m_resultBones[boneIndexMap["LeftUpperLeg"]].tailPosition; leftLowerLegBone.headPosition = m_resultBones[boneIndexMap["LeftUpperLeg"]].tailPosition;
leftLowerLegBone.tailPosition = leftFootBoneStartPosition; leftLowerLegBone.tailPosition = leftFootBoneStartPosition;
leftLowerLegBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Knee); leftLowerLegBone.color = BoneMarkToColor(BoneMark::Knee);
boneIndexMap[leftLowerLegBone.name] = leftLowerLegBone.index; boneIndexMap[leftLowerLegBone.name] = leftLowerLegBone.index;
m_resultBones[boneIndexMap["LeftUpperLeg"]].children.push_back(leftLowerLegBone.index); m_resultBones[boneIndexMap["LeftUpperLeg"]].children.push_back(leftLowerLegBone.index);
@ -645,7 +646,7 @@ bool AutoRigger::rig()
leftFootBone.name = "LeftFoot"; leftFootBone.name = "LeftFoot";
leftFootBone.headPosition = m_resultBones[boneIndexMap["LeftLowerLeg"]].tailPosition; leftFootBone.headPosition = m_resultBones[boneIndexMap["LeftLowerLeg"]].tailPosition;
leftFootBone.tailPosition = leftFootBoneStopPosition; leftFootBone.tailPosition = leftFootBoneStopPosition;
leftFootBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Ankle); leftFootBone.color = BoneMarkToColor(BoneMark::Ankle);
boneIndexMap[leftFootBone.name] = leftFootBone.index; boneIndexMap[leftFootBone.name] = leftFootBone.index;
m_resultBones[boneIndexMap["LeftLowerLeg"]].children.push_back(leftFootBone.index); m_resultBones[boneIndexMap["LeftLowerLeg"]].children.push_back(leftFootBone.index);
@ -664,7 +665,7 @@ bool AutoRigger::rig()
rightUpperLegBone.name = "RightUpperLeg"; rightUpperLegBone.name = "RightUpperLeg";
rightUpperLegBone.headPosition = m_resultBones[boneIndexMap["RightHip"]].tailPosition; rightUpperLegBone.headPosition = m_resultBones[boneIndexMap["RightHip"]].tailPosition;
rightUpperLegBone.tailPosition = rightLowerLegBoneStartPosition; rightUpperLegBone.tailPosition = rightLowerLegBoneStartPosition;
rightUpperLegBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Hip); rightUpperLegBone.color = BoneMarkToColor(BoneMark::Hip);
boneIndexMap[rightUpperLegBone.name] = rightUpperLegBone.index; boneIndexMap[rightUpperLegBone.name] = rightUpperLegBone.index;
m_resultBones[boneIndexMap["RightHip"]].children.push_back(rightUpperLegBone.index); m_resultBones[boneIndexMap["RightHip"]].children.push_back(rightUpperLegBone.index);
@ -674,7 +675,7 @@ bool AutoRigger::rig()
rightLowerLegBone.name = "RightLowerLeg"; rightLowerLegBone.name = "RightLowerLeg";
rightLowerLegBone.headPosition = m_resultBones[boneIndexMap["RightUpperLeg"]].tailPosition; rightLowerLegBone.headPosition = m_resultBones[boneIndexMap["RightUpperLeg"]].tailPosition;
rightLowerLegBone.tailPosition = rightFootBoneStartPosition; rightLowerLegBone.tailPosition = rightFootBoneStartPosition;
rightLowerLegBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Knee); rightLowerLegBone.color = BoneMarkToColor(BoneMark::Knee);
boneIndexMap[rightLowerLegBone.name] = rightLowerLegBone.index; boneIndexMap[rightLowerLegBone.name] = rightLowerLegBone.index;
m_resultBones[boneIndexMap["RightUpperLeg"]].children.push_back(rightLowerLegBone.index); m_resultBones[boneIndexMap["RightUpperLeg"]].children.push_back(rightLowerLegBone.index);
@ -684,7 +685,7 @@ bool AutoRigger::rig()
rightFootBone.name = "RightFoot"; rightFootBone.name = "RightFoot";
rightFootBone.headPosition = m_resultBones[boneIndexMap["RightLowerLeg"]].tailPosition; rightFootBone.headPosition = m_resultBones[boneIndexMap["RightLowerLeg"]].tailPosition;
rightFootBone.tailPosition = rightFootBoneStopPosition; rightFootBone.tailPosition = rightFootBoneStopPosition;
rightFootBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Ankle); rightFootBone.color = BoneMarkToColor(BoneMark::Ankle);
boneIndexMap[rightFootBone.name] = rightFootBone.index; boneIndexMap[rightFootBone.name] = rightFootBone.index;
m_resultBones[boneIndexMap["RightLowerLeg"]].children.push_back(rightFootBone.index); m_resultBones[boneIndexMap["RightLowerLeg"]].children.push_back(rightFootBone.index);
@ -723,7 +724,7 @@ bool AutoRigger::rig()
leftUpperArmBone.name = "LeftUpperArm"; leftUpperArmBone.name = "LeftUpperArm";
leftUpperArmBone.headPosition = m_resultBones[boneIndexMap["LeftShoulder"]].tailPosition; leftUpperArmBone.headPosition = m_resultBones[boneIndexMap["LeftShoulder"]].tailPosition;
leftUpperArmBone.tailPosition = leftLowerArmBoneStartPosition; leftUpperArmBone.tailPosition = leftLowerArmBoneStartPosition;
leftUpperArmBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Shoulder); leftUpperArmBone.color = BoneMarkToColor(BoneMark::Shoulder);
boneIndexMap[leftUpperArmBone.name] = leftUpperArmBone.index; boneIndexMap[leftUpperArmBone.name] = leftUpperArmBone.index;
m_resultBones[boneIndexMap["LeftShoulder"]].children.push_back(leftUpperArmBone.index); m_resultBones[boneIndexMap["LeftShoulder"]].children.push_back(leftUpperArmBone.index);
@ -733,7 +734,7 @@ bool AutoRigger::rig()
leftLowerArmBone.name = "LeftLowerArm"; leftLowerArmBone.name = "LeftLowerArm";
leftLowerArmBone.headPosition = m_resultBones[boneIndexMap["LeftUpperArm"]].tailPosition; leftLowerArmBone.headPosition = m_resultBones[boneIndexMap["LeftUpperArm"]].tailPosition;
leftLowerArmBone.tailPosition = leftHandBoneStartPosition; leftLowerArmBone.tailPosition = leftHandBoneStartPosition;
leftLowerArmBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Elbow); leftLowerArmBone.color = BoneMarkToColor(BoneMark::Elbow);
boneIndexMap[leftLowerArmBone.name] = leftLowerArmBone.index; boneIndexMap[leftLowerArmBone.name] = leftLowerArmBone.index;
m_resultBones[boneIndexMap["LeftUpperArm"]].children.push_back(leftLowerArmBone.index); m_resultBones[boneIndexMap["LeftUpperArm"]].children.push_back(leftLowerArmBone.index);
@ -743,7 +744,7 @@ bool AutoRigger::rig()
leftHandBone.name = "LeftHand"; leftHandBone.name = "LeftHand";
leftHandBone.headPosition = m_resultBones[boneIndexMap["LeftLowerArm"]].tailPosition; leftHandBone.headPosition = m_resultBones[boneIndexMap["LeftLowerArm"]].tailPosition;
leftHandBone.tailPosition = leftHandBoneStopPosition; leftHandBone.tailPosition = leftHandBoneStopPosition;
leftHandBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Wrist); leftHandBone.color = BoneMarkToColor(BoneMark::Wrist);
boneIndexMap[leftHandBone.name] = leftHandBone.index; boneIndexMap[leftHandBone.name] = leftHandBone.index;
m_resultBones[boneIndexMap["LeftLowerArm"]].children.push_back(leftHandBone.index); m_resultBones[boneIndexMap["LeftLowerArm"]].children.push_back(leftHandBone.index);
@ -762,7 +763,7 @@ bool AutoRigger::rig()
rightUpperArmBone.name = "RightUpperArm"; rightUpperArmBone.name = "RightUpperArm";
rightUpperArmBone.headPosition = m_resultBones[boneIndexMap["RightShoulder"]].tailPosition; rightUpperArmBone.headPosition = m_resultBones[boneIndexMap["RightShoulder"]].tailPosition;
rightUpperArmBone.tailPosition = rightLowerArmBoneStartPosition; rightUpperArmBone.tailPosition = rightLowerArmBoneStartPosition;
rightUpperArmBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Shoulder); rightUpperArmBone.color = BoneMarkToColor(BoneMark::Shoulder);
boneIndexMap[rightUpperArmBone.name] = rightUpperArmBone.index; boneIndexMap[rightUpperArmBone.name] = rightUpperArmBone.index;
m_resultBones[boneIndexMap["RightShoulder"]].children.push_back(rightUpperArmBone.index); m_resultBones[boneIndexMap["RightShoulder"]].children.push_back(rightUpperArmBone.index);
@ -772,7 +773,7 @@ bool AutoRigger::rig()
rightLowerArmBone.name = "RightLowerArm"; rightLowerArmBone.name = "RightLowerArm";
rightLowerArmBone.headPosition = m_resultBones[boneIndexMap["RightUpperArm"]].tailPosition; rightLowerArmBone.headPosition = m_resultBones[boneIndexMap["RightUpperArm"]].tailPosition;
rightLowerArmBone.tailPosition = rightHandBoneStartPosition; rightLowerArmBone.tailPosition = rightHandBoneStartPosition;
rightLowerArmBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Elbow); rightLowerArmBone.color = BoneMarkToColor(BoneMark::Elbow);
boneIndexMap[rightLowerArmBone.name] = rightLowerArmBone.index; boneIndexMap[rightLowerArmBone.name] = rightLowerArmBone.index;
m_resultBones[boneIndexMap["RightUpperArm"]].children.push_back(rightLowerArmBone.index); m_resultBones[boneIndexMap["RightUpperArm"]].children.push_back(rightLowerArmBone.index);
@ -782,7 +783,7 @@ bool AutoRigger::rig()
rightHandBone.name = "RightHand"; rightHandBone.name = "RightHand";
rightHandBone.headPosition = m_resultBones[boneIndexMap["RightLowerArm"]].tailPosition; rightHandBone.headPosition = m_resultBones[boneIndexMap["RightLowerArm"]].tailPosition;
rightHandBone.tailPosition = rightHandBoneStopPosition; rightHandBone.tailPosition = rightHandBoneStopPosition;
rightHandBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Wrist); rightHandBone.color = BoneMarkToColor(BoneMark::Wrist);
boneIndexMap[rightHandBone.name] = rightHandBone.index; boneIndexMap[rightHandBone.name] = rightHandBone.index;
m_resultBones[boneIndexMap["RightLowerArm"]].children.push_back(rightHandBone.index); m_resultBones[boneIndexMap["RightLowerArm"]].children.push_back(rightHandBone.index);
@ -792,7 +793,7 @@ bool AutoRigger::rig()
neckBone.name = "Neck"; neckBone.name = "Neck";
neckBone.headPosition = m_resultBones[boneIndexMap["Chest"]].tailPosition; neckBone.headPosition = m_resultBones[boneIndexMap["Chest"]].tailPosition;
neckBone.tailPosition = headBoneStartPosition; neckBone.tailPosition = headBoneStartPosition;
neckBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Neck); neckBone.color = BoneMarkToColor(BoneMark::Neck);
boneIndexMap[neckBone.name] = neckBone.index; boneIndexMap[neckBone.name] = neckBone.index;
m_resultBones[boneIndexMap["Chest"]].children.push_back(neckBone.index); m_resultBones[boneIndexMap["Chest"]].children.push_back(neckBone.index);

View File

@ -1,18 +1,19 @@
#ifndef AUTO_RIGGER_H #ifndef DUST3D_AUTO_RIGGER_H
#define AUTO_RIGGER_H #define DUST3D_AUTO_RIGGER_H
#include <QtGlobal> #include <QtGlobal>
#include <QVector3D> #include <QVector3D>
#include <QObject> #include <QObject>
#include <QColor> #include <QColor>
#include <QDebug> #include <QDebug>
#include "meshsplitter.h" #include "meshsplitter.h"
#include "skeletonbonemark.h" #include "bonemark.h"
#include "rigtype.h" #include "rigtype.h"
#include "skeletonside.h"
class AutoRiggerMark class AutoRiggerMark
{ {
public: public:
SkeletonBoneMark boneMark; BoneMark boneMark;
SkeletonSide boneSide; SkeletonSide boneSide;
QVector3D bonePosition; QVector3D bonePosition;
std::set<MeshSplitterTriangle> markTriangles; std::set<MeshSplitterTriangle> markTriangles;
@ -89,7 +90,7 @@ class AutoRigger : public QObject
public: public:
AutoRigger(const std::vector<QVector3D> &verticesPositions, AutoRigger(const std::vector<QVector3D> &verticesPositions,
const std::set<MeshSplitterTriangle> &inputTriangles); const std::set<MeshSplitterTriangle> &inputTriangles);
bool addMarkGroup(SkeletonBoneMark boneMark, SkeletonSide boneSide, QVector3D bonePosition, bool addMarkGroup(BoneMark boneMark, SkeletonSide boneSide, QVector3D bonePosition,
const std::set<MeshSplitterTriangle> &markTriangles); const std::set<MeshSplitterTriangle> &markTriangles);
const std::vector<std::pair<QtMsgType, QString>> &messages(); const std::vector<std::pair<QtMsgType, QString>> &messages();
bool rig(); bool rig();
@ -101,7 +102,7 @@ private:
bool validate(); bool validate();
void addTrianglesToVertices(const std::set<MeshSplitterTriangle> &triangles, std::set<int> &vertices); void addTrianglesToVertices(const std::set<MeshSplitterTriangle> &triangles, std::set<int> &vertices);
bool calculateBodyTriangles(std::set<MeshSplitterTriangle> &bodyTriangles); bool calculateBodyTriangles(std::set<MeshSplitterTriangle> &bodyTriangles);
bool isCutOffSplitter(SkeletonBoneMark boneMark); bool isCutOffSplitter(BoneMark boneMark);
void resolveBoundingBox(const std::set<int> &vertices, QVector3D &xMin, QVector3D &xMax, QVector3D &yMin, QVector3D &yMax, QVector3D &zMin, QVector3D &zMax); void resolveBoundingBox(const std::set<int> &vertices, QVector3D &xMin, QVector3D &xMax, QVector3D &yMin, QVector3D &yMax, QVector3D &zMin, QVector3D &zMax);
QVector3D findMinX(const std::set<int> &vertices); QVector3D findMinX(const std::set<int> &vertices);
QVector3D findMaxX(const std::set<int> &vertices); QVector3D findMaxX(const std::set<int> &vertices);
@ -117,7 +118,7 @@ private:
std::vector<QVector3D> m_verticesPositions; std::vector<QVector3D> m_verticesPositions;
std::set<MeshSplitterTriangle> m_inputTriangles; std::set<MeshSplitterTriangle> m_inputTriangles;
std::vector<AutoRiggerMark> m_marks; std::vector<AutoRiggerMark> m_marks;
std::map<std::pair<SkeletonBoneMark, SkeletonSide>, std::vector<int>> m_marksMap; std::map<std::pair<BoneMark, SkeletonSide>, std::vector<int>> m_marksMap;
std::vector<AutoRiggerBone> m_resultBones; std::vector<AutoRiggerBone> m_resultBones;
std::map<int, AutoRiggerVertexWeights> m_resultWeights; std::map<int, AutoRiggerVertexWeights> m_resultWeights;
std::vector<QString> m_missingMarkNames; std::vector<QString> m_missingMarkNames;

7
src/bonemark.cpp Normal file
View File

@ -0,0 +1,7 @@
#include <QObject>
#include "bonemark.h"
IMPL_BoneMarkToColor
IMPL_BoneMarkToString
IMPL_BoneMarkFromString
IMPL_BoneMarkToDispName

117
src/bonemark.h Normal file
View File

@ -0,0 +1,117 @@
#ifndef DUST3D_BONE_MARK_H
#define DUST3D_BONE_MARK_H
#include <QColor>
#include <QString>
enum class BoneMark
{
None = 0,
Neck,
Shoulder,
Elbow,
Wrist,
Hip,
Knee,
Ankle,
Count
};
#define BoneMarkHasSide(mark) ((mark) != BoneMark::Neck)
QColor BoneMarkToColor(BoneMark mark);
#define IMPL_BoneMarkToColor \
QColor BoneMarkToColor(BoneMark mark) \
{ \
switch (mark) { \
case BoneMark::Neck: \
return QColor(0xfc, 0x0d, 0x1b); \
case BoneMark::Shoulder: \
return QColor(0xfd, 0x80, 0x23); \
case BoneMark::Elbow: \
return QColor(0x29, 0xfd, 0x2f); \
case BoneMark::Wrist: \
return QColor(0xff, 0xfd, 0x38); \
case BoneMark::Hip: \
return QColor(0x2c, 0xff, 0xfe); \
case BoneMark::Knee: \
return QColor(0x0b, 0x24, 0xfb); \
case BoneMark::Ankle: \
return QColor(0xfc, 0x28, 0xfc); \
case BoneMark::None: \
return Qt::transparent; \
default: \
return Qt::transparent; \
} \
}
const char *BoneMarkToString(BoneMark mark);
#define IMPL_BoneMarkToString \
const char *BoneMarkToString(BoneMark mark) \
{ \
switch (mark) { \
case BoneMark::Neck: \
return "Neck"; \
case BoneMark::Shoulder: \
return "Shoulder"; \
case BoneMark::Elbow: \
return "Elbow"; \
case BoneMark::Wrist: \
return "Wrist"; \
case BoneMark::Hip: \
return "Hip"; \
case BoneMark::Knee: \
return "Knee"; \
case BoneMark::Ankle: \
return "Ankle"; \
case BoneMark::None: \
return "None"; \
default: \
return "None"; \
} \
}
BoneMark BoneMarkFromString(const char *markString);
#define IMPL_BoneMarkFromString \
BoneMark BoneMarkFromString(const char *markString) \
{ \
QString mark = markString; \
if (mark == "Neck") \
return BoneMark::Neck; \
if (mark == "Shoulder") \
return BoneMark::Shoulder; \
if (mark == "Elbow") \
return BoneMark::Elbow; \
if (mark == "Wrist") \
return BoneMark::Wrist; \
if (mark == "Hip") \
return BoneMark::Hip; \
if (mark == "Knee") \
return BoneMark::Knee; \
if (mark == "Ankle") \
return BoneMark::Ankle; \
return BoneMark::None; \
}
QString BoneMarkToDispName(BoneMark mark);
#define IMPL_BoneMarkToDispName \
QString BoneMarkToDispName(BoneMark mark) \
{ \
switch (mark) { \
case BoneMark::Neck: \
return QObject::tr("Neck"); \
case BoneMark::Shoulder: \
return QObject::tr("Shoulder (Arm Start)"); \
case BoneMark::Elbow: \
return QObject::tr("Elbow"); \
case BoneMark::Wrist: \
return QObject::tr("Wrist"); \
case BoneMark::Hip: \
return QObject::tr("Hip (Leg Start)"); \
case BoneMark::Knee: \
return QObject::tr("Knee"); \
case BoneMark::Ankle: \
return QObject::tr("Ankle"); \
case BoneMark::None: \
return QObject::tr("None"); \
default: \
return ""; \
} \
}
#endif

View File

@ -3,7 +3,7 @@
#include <QDebug> #include <QDebug>
#include <cmath> #include <cmath>
#include "ccdikresolver.h" #include "ccdikresolver.h"
#include "dust3dutil.h" #include "util.h"
CCDIKSolver::CCDIKSolver() : CCDIKSolver::CCDIKSolver() :
m_maxRound(4), m_maxRound(4),

View File

@ -1,5 +1,5 @@
#ifndef CCD_IK_SOLVER_H #ifndef DUST3D_CCD_IK_SOLVER_H
#define CCD_IK_SOLVER_H #define DUST3D_CCD_IK_SOLVER_H
#include <vector> #include <vector>
#include <QVector3D> #include <QVector3D>
#include <QQuaternion> #include <QQuaternion>

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
#ifndef SKELETON_DOCUMENT_H #ifndef DUST3D_DOCUMENT_H
#define SKELETON_DOCUMENT_H #define DUST3D_DOCUMENT_H
#include <QObject> #include <QObject>
#include <QUuid> #include <QUuid>
#include <vector> #include <vector>
@ -10,14 +10,14 @@
#include <cmath> #include <cmath>
#include <algorithm> #include <algorithm>
#include <QOpenGLWidget> #include <QOpenGLWidget>
#include "skeletonsnapshot.h" #include "snapshot.h"
#include "meshloader.h" #include "meshloader.h"
#include "meshgenerator.h" #include "meshgenerator.h"
#include "theme.h" #include "theme.h"
#include "texturegenerator.h" #include "texturegenerator.h"
#include "meshresultpostprocessor.h" #include "meshresultpostprocessor.h"
#include "ambientocclusionbaker.h" #include "ambientocclusionbaker.h"
#include "skeletonbonemark.h" #include "bonemark.h"
#include "riggenerator.h" #include "riggenerator.h"
#include "rigtype.h" #include "rigtype.h"
#include "posepreviewsgenerator.h" #include "posepreviewsgenerator.h"
@ -28,15 +28,15 @@
class MaterialPreviewsGenerator; class MaterialPreviewsGenerator;
class MotionsGenerator; class MotionsGenerator;
class SkeletonNode class Node
{ {
public: public:
SkeletonNode(const QUuid &withId=QUuid()) : Node(const QUuid &withId=QUuid()) :
x(0), x(0),
y(0), y(0),
z(0), z(0),
radius(0), radius(0),
boneMark(SkeletonBoneMark::None) boneMark(BoneMark::None)
{ {
id = withId.isNull() ? QUuid::createUuid() : withId; id = withId.isNull() ? QUuid::createUuid() : withId;
} }
@ -55,14 +55,14 @@ public:
float y; float y;
float z; float z;
float radius; float radius;
SkeletonBoneMark boneMark; BoneMark boneMark;
std::vector<QUuid> edgeIds; std::vector<QUuid> edgeIds;
}; };
class SkeletonEdge class Edge
{ {
public: public:
SkeletonEdge(const QUuid &withId=QUuid()) Edge(const QUuid &withId=QUuid())
{ {
id = withId.isNull() ? QUuid::createUuid() : withId; id = withId.isNull() ? QUuid::createUuid() : withId;
} }
@ -78,10 +78,10 @@ public:
} }
}; };
class SkeletonPart class Part
{ {
public: public:
~SkeletonPart() ~Part()
{ {
delete m_previewMesh; delete m_previewMesh;
} }
@ -103,7 +103,7 @@ public:
bool dirty; bool dirty;
bool wrapped; bool wrapped;
QUuid materialId; QUuid materialId;
SkeletonPart(const QUuid &withId=QUuid()) : Part(const QUuid &withId=QUuid()) :
visible(true), visible(true),
locked(false), locked(false),
subdived(false), subdived(false),
@ -156,7 +156,7 @@ public:
{ {
return visible && !disabled; return visible && !disabled;
} }
void copyAttributes(const SkeletonPart &other) void copyAttributes(const Part &other)
{ {
visible = other.visible; visible = other.visible;
locked = other.locked; locked = other.locked;
@ -186,7 +186,7 @@ public:
return new MeshLoader(*m_previewMesh); return new MeshLoader(*m_previewMesh);
} }
private: private:
Q_DISABLE_COPY(SkeletonPart); Q_DISABLE_COPY(Part);
MeshLoader *m_previewMesh = nullptr; MeshLoader *m_previewMesh = nullptr;
}; };
@ -197,13 +197,13 @@ enum class SkeletonProfile
Side Side
}; };
class SkeletonHistoryItem class HistoryItem
{ {
public: public:
SkeletonSnapshot snapshot; Snapshot snapshot;
}; };
enum class SkeletonDocumentEditMode enum class DocumentEditMode
{ {
Add = 0, Add = 0,
Select, Select,
@ -212,13 +212,13 @@ enum class SkeletonDocumentEditMode
ZoomOut ZoomOut
}; };
class SkeletonComponent class Component
{ {
public: public:
SkeletonComponent() Component()
{ {
} }
SkeletonComponent(const QUuid &withId, const QString &linkData=QString(), const QString &linkDataType=QString()) Component(const QUuid &withId, const QString &linkData=QString(), const QString &linkDataType=QString())
{ {
id = withId.isNull() ? QUuid::createUuid() : withId; id = withId.isNull() ? QUuid::createUuid() : withId;
if (!linkData.isEmpty()) { if (!linkData.isEmpty()) {
@ -359,13 +359,13 @@ private:
std::set<QUuid> m_childrenIdSet; std::set<QUuid> m_childrenIdSet;
}; };
class SkeletonPose class Pose
{ {
public: public:
SkeletonPose() Pose()
{ {
} }
~SkeletonPose() ~Pose()
{ {
delete m_previewMesh; delete m_previewMesh;
} }
@ -385,76 +385,76 @@ public:
return new MeshLoader(*m_previewMesh); return new MeshLoader(*m_previewMesh);
} }
private: private:
Q_DISABLE_COPY(SkeletonPose); Q_DISABLE_COPY(Pose);
MeshLoader *m_previewMesh = nullptr; MeshLoader *m_previewMesh = nullptr;
}; };
enum class SkeletonMotionClipType enum class MotionClipType
{ {
Pose, Pose,
Interpolation, Interpolation,
Motion Motion
}; };
class SkeletonMotionClip class MotionClip
{ {
public: public:
SkeletonMotionClip() MotionClip()
{ {
} }
SkeletonMotionClip(const QString &linkData, const QString &linkDataType) MotionClip(const QString &linkData, const QString &linkDataType)
{ {
if ("poseId" == linkDataType) { if ("poseId" == linkDataType) {
clipType = SkeletonMotionClipType::Pose; clipType = MotionClipType::Pose;
linkToId = QUuid(linkData); linkToId = QUuid(linkData);
} else if ("InterpolationType" == linkDataType) { } else if ("InterpolationType" == linkDataType) {
clipType = SkeletonMotionClipType::Interpolation; clipType = MotionClipType::Interpolation;
interpolationType = InterpolationTypeFromString(linkData.toUtf8().constData()); interpolationType = InterpolationTypeFromString(linkData.toUtf8().constData());
} else if ("motionId" == linkDataType) { } else if ("motionId" == linkDataType) {
clipType = SkeletonMotionClipType::Motion; clipType = MotionClipType::Motion;
linkToId = QUuid(linkData); linkToId = QUuid(linkData);
} }
} }
QString linkDataType() const QString linkDataType() const
{ {
if (SkeletonMotionClipType::Pose == clipType) if (MotionClipType::Pose == clipType)
return "poseId"; return "poseId";
if (SkeletonMotionClipType::Interpolation == clipType) if (MotionClipType::Interpolation == clipType)
return "InterpolationType"; return "InterpolationType";
if (SkeletonMotionClipType::Motion == clipType) if (MotionClipType::Motion == clipType)
return "motionId"; return "motionId";
return "poseId"; return "poseId";
} }
QString linkData() const QString linkData() const
{ {
if (SkeletonMotionClipType::Pose == clipType) if (MotionClipType::Pose == clipType)
return linkToId.toString(); return linkToId.toString();
if (SkeletonMotionClipType::Interpolation == clipType) if (MotionClipType::Interpolation == clipType)
return InterpolationTypeToString(interpolationType); return InterpolationTypeToString(interpolationType);
if (SkeletonMotionClipType::Motion == clipType) if (MotionClipType::Motion == clipType)
return linkToId.toString(); return linkToId.toString();
return linkToId.toString(); return linkToId.toString();
} }
float duration = 0.0; float duration = 0.0;
SkeletonMotionClipType clipType = SkeletonMotionClipType::Pose; MotionClipType clipType = MotionClipType::Pose;
QUuid linkToId; QUuid linkToId;
InterpolationType interpolationType; InterpolationType interpolationType;
}; };
class SkeletonMotion class Motion
{ {
public: public:
SkeletonMotion() Motion()
{ {
} }
~SkeletonMotion() ~Motion()
{ {
releasePreviewMeshs(); releasePreviewMeshs();
} }
QUuid id; QUuid id;
QString name; QString name;
bool dirty = true; bool dirty = true;
std::vector<SkeletonMotionClip> clips; std::vector<MotionClip> clips;
std::vector<std::pair<float, JointNodeTree>> jointNodeTrees; std::vector<std::pair<float, JointNodeTree>> jointNodeTrees;
void updatePreviewMeshs(std::vector<std::pair<float, MeshLoader *>> &previewMeshs) void updatePreviewMeshs(std::vector<std::pair<float, MeshLoader *>> &previewMeshs)
{ {
@ -469,7 +469,7 @@ public:
return new MeshLoader(*m_previewMeshs[0].second); return new MeshLoader(*m_previewMeshs[0].second);
} }
private: private:
Q_DISABLE_COPY(SkeletonMotion); Q_DISABLE_COPY(Motion);
void releasePreviewMeshs() void releasePreviewMeshs()
{ {
for (const auto &item: m_previewMeshs) { for (const auto &item: m_previewMeshs) {
@ -480,33 +480,33 @@ private:
std::vector<std::pair<float, MeshLoader *>> m_previewMeshs; std::vector<std::pair<float, MeshLoader *>> m_previewMeshs;
}; };
class SkeletonMaterialMap class MaterialMap
{ {
public: public:
TextureType forWhat; TextureType forWhat;
QUuid imageId; QUuid imageId;
}; };
class SkeletonMaterialLayer class MaterialLayer
{ {
public: public:
std::vector<SkeletonMaterialMap> maps; std::vector<MaterialMap> maps;
}; };
class SkeletonMaterial class Material
{ {
public: public:
SkeletonMaterial() Material()
{ {
} }
~SkeletonMaterial() ~Material()
{ {
delete m_previewMesh; delete m_previewMesh;
} }
QUuid id; QUuid id;
QString name; QString name;
bool dirty = true; bool dirty = true;
std::vector<SkeletonMaterialLayer> layers; std::vector<MaterialLayer> layers;
void updatePreviewMesh(MeshLoader *previewMesh) void updatePreviewMesh(MeshLoader *previewMesh)
{ {
delete m_previewMesh; delete m_previewMesh;
@ -519,11 +519,11 @@ public:
return new MeshLoader(*m_previewMesh); return new MeshLoader(*m_previewMesh);
} }
private: private:
Q_DISABLE_COPY(SkeletonMaterial); Q_DISABLE_COPY(Material);
MeshLoader *m_previewMesh = nullptr; MeshLoader *m_previewMesh = nullptr;
}; };
enum class SkeletonDocumentToSnapshotFor enum class DocumentToSnapshotFor
{ {
Document = 0, Document = 0,
Nodes, Nodes,
@ -532,7 +532,7 @@ enum class SkeletonDocumentToSnapshotFor
Motions Motions
}; };
class SkeletonDocument : public QObject class Document : public QObject
{ {
Q_OBJECT Q_OBJECT
signals: signals:
@ -623,7 +623,7 @@ public: // need initialize
float originX; float originX;
float originY; float originY;
float originZ; float originZ;
SkeletonDocumentEditMode editMode; DocumentEditMode editMode;
bool xlocked; bool xlocked;
bool ylocked; bool ylocked;
bool zlocked; bool zlocked;
@ -636,38 +636,38 @@ public: // need initialize
RigType rigType; RigType rigType;
bool weldEnabled; bool weldEnabled;
public: public:
SkeletonDocument(); Document();
~SkeletonDocument(); ~Document();
std::map<QUuid, SkeletonPart> partMap; std::map<QUuid, Part> partMap;
std::map<QUuid, SkeletonNode> nodeMap; std::map<QUuid, Node> nodeMap;
std::map<QUuid, SkeletonEdge> edgeMap; std::map<QUuid, Edge> edgeMap;
std::map<QUuid, SkeletonComponent> componentMap; std::map<QUuid, Component> componentMap;
std::map<QUuid, SkeletonMaterial> materialMap; std::map<QUuid, Material> materialMap;
std::vector<QUuid> materialIdList; std::vector<QUuid> materialIdList;
std::map<QUuid, SkeletonPose> poseMap; std::map<QUuid, Pose> poseMap;
std::vector<QUuid> poseIdList; std::vector<QUuid> poseIdList;
std::map<QUuid, SkeletonMotion> motionMap; std::map<QUuid, Motion> motionMap;
std::vector<QUuid> motionIdList; std::vector<QUuid> motionIdList;
SkeletonComponent rootComponent; Component rootComponent;
QImage turnaround; QImage turnaround;
QImage preview; QImage preview;
void toSnapshot(SkeletonSnapshot *snapshot, const std::set<QUuid> &limitNodeIds=std::set<QUuid>(), void toSnapshot(Snapshot *snapshot, const std::set<QUuid> &limitNodeIds=std::set<QUuid>(),
SkeletonDocumentToSnapshotFor forWhat=SkeletonDocumentToSnapshotFor::Document, DocumentToSnapshotFor forWhat=DocumentToSnapshotFor::Document,
const std::set<QUuid> &limitPoseIds=std::set<QUuid>(), const std::set<QUuid> &limitPoseIds=std::set<QUuid>(),
const std::set<QUuid> &limitMotionIds=std::set<QUuid>(), const std::set<QUuid> &limitMotionIds=std::set<QUuid>(),
const std::set<QUuid> &limitMaterialIds=std::set<QUuid>()) const; const std::set<QUuid> &limitMaterialIds=std::set<QUuid>()) const;
void fromSnapshot(const SkeletonSnapshot &snapshot); void fromSnapshot(const Snapshot &snapshot);
void addFromSnapshot(const SkeletonSnapshot &snapshot, bool fromPaste=true); void addFromSnapshot(const Snapshot &snapshot, bool fromPaste=true);
const SkeletonNode *findNode(QUuid nodeId) const; const Node *findNode(QUuid nodeId) const;
const SkeletonEdge *findEdge(QUuid edgeId) const; const Edge *findEdge(QUuid edgeId) const;
const SkeletonPart *findPart(QUuid partId) const; const Part *findPart(QUuid partId) const;
const SkeletonEdge *findEdgeByNodes(QUuid firstNodeId, QUuid secondNodeId) const; const Edge *findEdgeByNodes(QUuid firstNodeId, QUuid secondNodeId) const;
const SkeletonComponent *findComponent(QUuid componentId) const; const Component *findComponent(QUuid componentId) const;
const SkeletonComponent *findComponentParent(QUuid componentId) const; const Component *findComponentParent(QUuid componentId) const;
QUuid findComponentParentId(QUuid componentId) const; QUuid findComponentParentId(QUuid componentId) const;
const SkeletonMaterial *findMaterial(QUuid materialId) const; const Material *findMaterial(QUuid materialId) const;
const SkeletonPose *findPose(QUuid poseId) const; const Pose *findPose(QUuid poseId) const;
const SkeletonMotion *findMotion(QUuid motionId) const; const Motion *findMotion(QUuid motionId) const;
MeshLoader *takeResultMesh(); MeshLoader *takeResultMesh();
MeshLoader *takeResultTextureMesh(); MeshLoader *takeResultTextureMesh();
MeshLoader *takeResultRigWeightMesh(); MeshLoader *takeResultRigWeightMesh();
@ -684,7 +684,7 @@ public:
bool isNodeEditable(QUuid nodeId) const; bool isNodeEditable(QUuid nodeId) const;
bool isEdgeEditable(QUuid edgeId) const; bool isEdgeEditable(QUuid edgeId) const;
bool originSettled() const; bool originSettled() const;
const MeshResultContext &currentPostProcessedResultContext() const; const Outcome &currentPostProcessedResultContext() const;
bool isExportReady() const; bool isExportReady() const;
bool isPostProcessResultObsolete() const; bool isPostProcessResultObsolete() const;
void findAllNeighbors(QUuid nodeId, std::set<QUuid> &neighbors) const; void findAllNeighbors(QUuid nodeId, std::set<QUuid> &neighbors) const;
@ -692,7 +692,7 @@ public:
void collectComponentDescendantComponents(QUuid componentId, std::vector<QUuid> &componentIds) const; void collectComponentDescendantComponents(QUuid componentId, std::vector<QUuid> &componentIds) const;
const std::vector<QString> &resultRigMissingMarkNames() const; const std::vector<QString> &resultRigMissingMarkNames() const;
const std::vector<QString> &resultRigErrorMarkNames() const; const std::vector<QString> &resultRigErrorMarkNames() const;
const MeshResultContext &currentRiggedResultContext() const; const Outcome &currentRiggedResultContext() const;
bool currentRigSucceed() const; bool currentRigSucceed() const;
bool isMeshGenerating() const; bool isMeshGenerating() const;
public slots: public slots:
@ -704,11 +704,11 @@ public slots:
void moveNodeBy(QUuid nodeId, float x, float y, float z); void moveNodeBy(QUuid nodeId, float x, float y, float z);
void setNodeOrigin(QUuid nodeId, float x, float y, float z); void setNodeOrigin(QUuid nodeId, float x, float y, float z);
void setNodeRadius(QUuid nodeId, float radius); void setNodeRadius(QUuid nodeId, float radius);
void setNodeBoneMark(QUuid nodeId, SkeletonBoneMark mark); void setNodeBoneMark(QUuid nodeId, BoneMark mark);
void switchNodeXZ(QUuid nodeId); void switchNodeXZ(QUuid nodeId);
void moveOriginBy(float x, float y, float z); void moveOriginBy(float x, float y, float z);
void addEdge(QUuid fromNodeId, QUuid toNodeId); void addEdge(QUuid fromNodeId, QUuid toNodeId);
void setEditMode(SkeletonDocumentEditMode mode); void setEditMode(DocumentEditMode mode);
void uiReady(); void uiReady();
void generateMesh(); void generateMesh();
void regenerateMesh(); void regenerateMesh();
@ -787,13 +787,13 @@ public slots:
void removePose(QUuid poseId); void removePose(QUuid poseId);
void setPoseParameters(QUuid poseId, std::map<QString, std::map<QString, QString>> parameters); void setPoseParameters(QUuid poseId, std::map<QString, std::map<QString, QString>> parameters);
void renamePose(QUuid poseId, QString name); void renamePose(QUuid poseId, QString name);
void addMotion(QString name, std::vector<SkeletonMotionClip> clips); void addMotion(QString name, std::vector<MotionClip> clips);
void removeMotion(QUuid motionId); void removeMotion(QUuid motionId);
void setMotionClips(QUuid motionId, std::vector<SkeletonMotionClip> clips); void setMotionClips(QUuid motionId, std::vector<MotionClip> clips);
void renameMotion(QUuid motionId, QString name); void renameMotion(QUuid motionId, QString name);
void addMaterial(QString name, std::vector<SkeletonMaterialLayer>); void addMaterial(QString name, std::vector<MaterialLayer>);
void removeMaterial(QUuid materialId); void removeMaterial(QUuid materialId);
void setMaterialLayers(QUuid materialId, std::vector<SkeletonMaterialLayer> layers); void setMaterialLayers(QUuid materialId, std::vector<MaterialLayer> layers);
void renameMaterial(QUuid materialId, QString name); void renameMaterial(QUuid materialId, QString name);
private: private:
void splitPartByNode(std::vector<std::vector<QUuid>> *groups, QUuid nodeId); void splitPartByNode(std::vector<std::vector<QUuid>> *groups, QUuid nodeId);
@ -815,12 +815,12 @@ private: // need initialize
MeshGenerator *m_meshGenerator; MeshGenerator *m_meshGenerator;
MeshLoader *m_resultMesh; MeshLoader *m_resultMesh;
int m_batchChangeRefCount; int m_batchChangeRefCount;
MeshResultContext *m_currentMeshResultContext; Outcome *m_currentMeshResultContext;
bool m_isTextureObsolete; bool m_isTextureObsolete;
TextureGenerator *m_textureGenerator; TextureGenerator *m_textureGenerator;
bool m_isPostProcessResultObsolete; bool m_isPostProcessResultObsolete;
MeshResultPostProcessor *m_postProcessor; MeshResultPostProcessor *m_postProcessor;
MeshResultContext *m_postProcessedResultContext; Outcome *m_postProcessedResultContext;
MeshLoader *m_resultTextureMesh; MeshLoader *m_resultTextureMesh;
unsigned long long m_textureImageUpdateVersion; unsigned long long m_textureImageUpdateVersion;
AmbientOcclusionBaker *m_ambientOcclusionBaker; AmbientOcclusionBaker *m_ambientOcclusionBaker;
@ -834,15 +834,15 @@ private: // need initialize
std::vector<AutoRiggerBone> *m_resultRigBones; std::vector<AutoRiggerBone> *m_resultRigBones;
std::map<int, AutoRiggerVertexWeights> *m_resultRigWeights; std::map<int, AutoRiggerVertexWeights> *m_resultRigWeights;
bool m_isRigObsolete; bool m_isRigObsolete;
MeshResultContext *m_riggedResultContext; Outcome *m_riggedResultContext;
PosePreviewsGenerator *m_posePreviewsGenerator; PosePreviewsGenerator *m_posePreviewsGenerator;
bool m_currentRigSucceed; bool m_currentRigSucceed;
MaterialPreviewsGenerator *m_materialPreviewsGenerator; MaterialPreviewsGenerator *m_materialPreviewsGenerator;
MotionsGenerator *m_motionsGenerator; MotionsGenerator *m_motionsGenerator;
private: private:
static unsigned long m_maxSnapshot; static unsigned long m_maxSnapshot;
std::deque<SkeletonHistoryItem> m_undoItems; std::deque<HistoryItem> m_undoItems;
std::deque<SkeletonHistoryItem> m_redoItems; std::deque<HistoryItem> m_redoItems;
GeneratedCacheContext m_generatedCacheContext; GeneratedCacheContext m_generatedCacheContext;
std::vector<QString> m_resultRigMissingMarkNames; std::vector<QString> m_resultRigMissingMarkNames;
std::vector<QString> m_resultRigErrorMarkNames; std::vector<QString> m_resultRigErrorMarkNames;

View File

@ -15,19 +15,19 @@
#include <set> #include <set>
#include <QDesktopServices> #include <QDesktopServices>
#include <QDockWidget> #include <QDockWidget>
#include "skeletondocumentwindow.h" #include "documentwindow.h"
#include "skeletongraphicswidget.h" #include "skeletongraphicswidget.h"
#include "theme.h" #include "theme.h"
#include "ds3file.h" #include "ds3file.h"
#include "skeletonsnapshot.h" #include "snapshot.h"
#include "skeletonxml.h" #include "snapshotxml.h"
#include "logbrowser.h" #include "logbrowser.h"
#include "dust3dutil.h" #include "util.h"
#include "aboutwidget.h" #include "aboutwidget.h"
#include "version.h" #include "version.h"
#include "gltffile.h" #include "gltffile.h"
#include "graphicscontainerwidget.h" #include "graphicscontainerwidget.h"
#include "skeletonparttreewidget.h" #include "parttreewidget.h"
#include "rigwidget.h" #include "rigwidget.h"
#include "markiconcreator.h" #include "markiconcreator.h"
#include "motionmanagewidget.h" #include "motionmanagewidget.h"
@ -113,7 +113,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
g_documentWindows.insert(this); g_documentWindows.insert(this);
m_document = new SkeletonDocument; m_document = new Document;
QVBoxLayout *toolButtonLayout = new QVBoxLayout; QVBoxLayout *toolButtonLayout = new QVBoxLayout;
toolButtonLayout->setSpacing(0); toolButtonLayout->setSpacing(0);
@ -158,19 +158,19 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
SpinnableAwesomeButton *regenerateButton = new SpinnableAwesomeButton(); SpinnableAwesomeButton *regenerateButton = new SpinnableAwesomeButton();
regenerateButton->setAwesomeIcon(QChar(fa::recycle)); regenerateButton->setAwesomeIcon(QChar(fa::recycle));
connect(m_document, &SkeletonDocument::meshGenerating, this, [=]() { connect(m_document, &Document::meshGenerating, this, [=]() {
regenerateButton->showSpinner(true); regenerateButton->showSpinner(true);
}); });
connect(m_document, &SkeletonDocument::postProcessing, this, [=]() { connect(m_document, &Document::postProcessing, this, [=]() {
regenerateButton->showSpinner(true); regenerateButton->showSpinner(true);
}); });
connect(m_document, &SkeletonDocument::textureGenerating, this, [=]() { connect(m_document, &Document::textureGenerating, this, [=]() {
regenerateButton->showSpinner(true); regenerateButton->showSpinner(true);
}); });
connect(m_document, &SkeletonDocument::resultTextureChanged, this, [=]() { connect(m_document, &Document::resultTextureChanged, this, [=]() {
regenerateButton->showSpinner(false); regenerateButton->showSpinner(false);
}); });
connect(regenerateButton->button(), &QPushButton::clicked, m_document, &SkeletonDocument::regenerateMesh); connect(regenerateButton->button(), &QPushButton::clicked, m_document, &Document::regenerateMesh);
toolButtonLayout->addWidget(addButton); toolButtonLayout->addWidget(addButton);
toolButtonLayout->addWidget(selectButton); toolButtonLayout->addWidget(selectButton);
@ -231,7 +231,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
QDockWidget *partTreeDocker = new QDockWidget(tr("Parts"), this); QDockWidget *partTreeDocker = new QDockWidget(tr("Parts"), this);
partTreeDocker->setAllowedAreas(Qt::RightDockWidgetArea); partTreeDocker->setAllowedAreas(Qt::RightDockWidgetArea);
SkeletonPartTreeWidget *partTreeWidget = new SkeletonPartTreeWidget(m_document, partTreeDocker); PartTreeWidget *partTreeWidget = new PartTreeWidget(m_document, partTreeDocker);
partTreeDocker->setWidget(partTreeWidget); partTreeDocker->setWidget(partTreeWidget);
addDockWidget(Qt::RightDockWidgetArea, partTreeDocker); addDockWidget(Qt::RightDockWidgetArea, partTreeDocker);
connect(partTreeDocker, &QDockWidget::topLevelChanged, [=](bool topLevel) { connect(partTreeDocker, &QDockWidget::topLevelChanged, [=](bool topLevel) {
@ -369,16 +369,16 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
m_addAction = new QAction(tr("Add..."), this); m_addAction = new QAction(tr("Add..."), this);
connect(m_addAction, &QAction::triggered, [=]() { connect(m_addAction, &QAction::triggered, [=]() {
m_document->setEditMode(SkeletonDocumentEditMode::Add); m_document->setEditMode(DocumentEditMode::Add);
}); });
m_editMenu->addAction(m_addAction); m_editMenu->addAction(m_addAction);
m_undoAction = new QAction(tr("Undo"), this); m_undoAction = new QAction(tr("Undo"), this);
connect(m_undoAction, &QAction::triggered, m_document, &SkeletonDocument::undo); connect(m_undoAction, &QAction::triggered, m_document, &Document::undo);
m_editMenu->addAction(m_undoAction); m_editMenu->addAction(m_undoAction);
m_redoAction = new QAction(tr("Redo"), this); m_redoAction = new QAction(tr("Redo"), this);
connect(m_redoAction, &QAction::triggered, m_document, &SkeletonDocument::redo); connect(m_redoAction, &QAction::triggered, m_document, &Document::redo);
m_editMenu->addAction(m_redoAction); m_editMenu->addAction(m_redoAction);
m_deleteAction = new QAction(tr("Delete"), this); m_deleteAction = new QAction(tr("Delete"), this);
@ -402,7 +402,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
m_editMenu->addAction(m_copyAction); m_editMenu->addAction(m_copyAction);
m_pasteAction = new QAction(tr("Paste"), this); m_pasteAction = new QAction(tr("Paste"), this);
connect(m_pasteAction, &QAction::triggered, m_document, &SkeletonDocument::paste); connect(m_pasteAction, &QAction::triggered, m_document, &Document::paste);
m_editMenu->addAction(m_pasteAction); m_editMenu->addAction(m_pasteAction);
m_flipHorizontallyAction = new QAction(tr("H Flip"), this); m_flipHorizontallyAction = new QAction(tr("H Flip"), this);
@ -463,15 +463,15 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
m_markAsNoneAction = new QAction(tr("None"), this); m_markAsNoneAction = new QAction(tr("None"), this);
connect(m_markAsNoneAction, &QAction::triggered, [=]() { connect(m_markAsNoneAction, &QAction::triggered, [=]() {
m_graphicsWidget->setSelectedNodesBoneMark(SkeletonBoneMark::None); m_graphicsWidget->setSelectedNodesBoneMark(BoneMark::None);
}); });
m_markAsMenu->addAction(m_markAsNoneAction); m_markAsMenu->addAction(m_markAsNoneAction);
m_markAsMenu->addSeparator(); m_markAsMenu->addSeparator();
for (int i = 0; i < (int)SkeletonBoneMark::Count - 1; i++) { for (int i = 0; i < (int)BoneMark::Count - 1; i++) {
SkeletonBoneMark boneMark = (SkeletonBoneMark)(i + 1); BoneMark boneMark = (BoneMark)(i + 1);
m_markAsActions[i] = new QAction(MarkIconCreator::createIcon(boneMark), SkeletonBoneMarkToDispName(boneMark), this); m_markAsActions[i] = new QAction(MarkIconCreator::createIcon(boneMark), BoneMarkToDispName(boneMark), this);
connect(m_markAsActions[i], &QAction::triggered, [=]() { connect(m_markAsActions[i], &QAction::triggered, [=]() {
m_graphicsWidget->setSelectedNodesBoneMark(boneMark); m_graphicsWidget->setSelectedNodesBoneMark(boneMark);
}); });
@ -648,30 +648,30 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
connect(containerWidget, &GraphicsContainerWidget::containerSizeChanged, connect(containerWidget, &GraphicsContainerWidget::containerSizeChanged,
graphicsWidget, &SkeletonGraphicsWidget::canvasResized); graphicsWidget, &SkeletonGraphicsWidget::canvasResized);
connect(m_document, &SkeletonDocument::turnaroundChanged, connect(m_document, &Document::turnaroundChanged,
graphicsWidget, &SkeletonGraphicsWidget::turnaroundChanged); graphicsWidget, &SkeletonGraphicsWidget::turnaroundChanged);
connect(rotateCounterclockwiseButton, &QPushButton::clicked, graphicsWidget, &SkeletonGraphicsWidget::rotateAllMainProfileCounterclockwise90DegreeAlongOrigin); connect(rotateCounterclockwiseButton, &QPushButton::clicked, graphicsWidget, &SkeletonGraphicsWidget::rotateAllMainProfileCounterclockwise90DegreeAlongOrigin);
connect(rotateClockwiseButton, &QPushButton::clicked, graphicsWidget, &SkeletonGraphicsWidget::rotateAllMainProfileClockwise90DegreeAlongOrigin); connect(rotateClockwiseButton, &QPushButton::clicked, graphicsWidget, &SkeletonGraphicsWidget::rotateAllMainProfileClockwise90DegreeAlongOrigin);
connect(addButton, &QPushButton::clicked, [=]() { connect(addButton, &QPushButton::clicked, [=]() {
m_document->setEditMode(SkeletonDocumentEditMode::Add); m_document->setEditMode(DocumentEditMode::Add);
}); });
connect(selectButton, &QPushButton::clicked, [=]() { connect(selectButton, &QPushButton::clicked, [=]() {
m_document->setEditMode(SkeletonDocumentEditMode::Select); m_document->setEditMode(DocumentEditMode::Select);
}); });
connect(dragButton, &QPushButton::clicked, [=]() { connect(dragButton, &QPushButton::clicked, [=]() {
m_document->setEditMode(SkeletonDocumentEditMode::Drag); m_document->setEditMode(DocumentEditMode::Drag);
}); });
connect(zoomInButton, &QPushButton::clicked, [=]() { connect(zoomInButton, &QPushButton::clicked, [=]() {
m_document->setEditMode(SkeletonDocumentEditMode::ZoomIn); m_document->setEditMode(DocumentEditMode::ZoomIn);
}); });
connect(zoomOutButton, &QPushButton::clicked, [=]() { connect(zoomOutButton, &QPushButton::clicked, [=]() {
m_document->setEditMode(SkeletonDocumentEditMode::ZoomOut); m_document->setEditMode(DocumentEditMode::ZoomOut);
}); });
connect(m_xlockButton, &QPushButton::clicked, [=]() { connect(m_xlockButton, &QPushButton::clicked, [=]() {
@ -687,7 +687,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
m_document->setRadiusLockState(!m_document->radiusLocked); m_document->setRadiusLockState(!m_document->radiusLocked);
}); });
m_partListDockerVisibleSwitchConnection = connect(m_document, &SkeletonDocument::skeletonChanged, [=]() { m_partListDockerVisibleSwitchConnection = connect(m_document, &Document::skeletonChanged, [=]() {
if (m_graphicsWidget->hasItems()) { if (m_graphicsWidget->hasItems()) {
if (partTreeDocker->isHidden()) if (partTreeDocker->isHidden())
partTreeDocker->show(); partTreeDocker->show();
@ -695,123 +695,123 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
} }
}); });
connect(m_document, &SkeletonDocument::editModeChanged, graphicsWidget, &SkeletonGraphicsWidget::editModeChanged); connect(m_document, &Document::editModeChanged, graphicsWidget, &SkeletonGraphicsWidget::editModeChanged);
connect(graphicsWidget, &SkeletonGraphicsWidget::zoomRenderedModelBy, m_modelRenderWidget, &ModelWidget::zoom); connect(graphicsWidget, &SkeletonGraphicsWidget::zoomRenderedModelBy, m_modelRenderWidget, &ModelWidget::zoom);
connect(graphicsWidget, &SkeletonGraphicsWidget::addNode, m_document, &SkeletonDocument::addNode); connect(graphicsWidget, &SkeletonGraphicsWidget::addNode, m_document, &Document::addNode);
connect(graphicsWidget, &SkeletonGraphicsWidget::scaleNodeByAddRadius, m_document, &SkeletonDocument::scaleNodeByAddRadius); connect(graphicsWidget, &SkeletonGraphicsWidget::scaleNodeByAddRadius, m_document, &Document::scaleNodeByAddRadius);
connect(graphicsWidget, &SkeletonGraphicsWidget::moveNodeBy, m_document, &SkeletonDocument::moveNodeBy); connect(graphicsWidget, &SkeletonGraphicsWidget::moveNodeBy, m_document, &Document::moveNodeBy);
connect(graphicsWidget, &SkeletonGraphicsWidget::setNodeOrigin, m_document, &SkeletonDocument::setNodeOrigin); connect(graphicsWidget, &SkeletonGraphicsWidget::setNodeOrigin, m_document, &Document::setNodeOrigin);
connect(graphicsWidget, &SkeletonGraphicsWidget::setNodeBoneMark, m_document, &SkeletonDocument::setNodeBoneMark); connect(graphicsWidget, &SkeletonGraphicsWidget::setNodeBoneMark, m_document, &Document::setNodeBoneMark);
connect(graphicsWidget, &SkeletonGraphicsWidget::removeNode, m_document, &SkeletonDocument::removeNode); connect(graphicsWidget, &SkeletonGraphicsWidget::removeNode, m_document, &Document::removeNode);
connect(graphicsWidget, &SkeletonGraphicsWidget::setEditMode, m_document, &SkeletonDocument::setEditMode); connect(graphicsWidget, &SkeletonGraphicsWidget::setEditMode, m_document, &Document::setEditMode);
connect(graphicsWidget, &SkeletonGraphicsWidget::removeEdge, m_document, &SkeletonDocument::removeEdge); connect(graphicsWidget, &SkeletonGraphicsWidget::removeEdge, m_document, &Document::removeEdge);
connect(graphicsWidget, &SkeletonGraphicsWidget::addEdge, m_document, &SkeletonDocument::addEdge); connect(graphicsWidget, &SkeletonGraphicsWidget::addEdge, m_document, &Document::addEdge);
connect(graphicsWidget, &SkeletonGraphicsWidget::groupOperationAdded, m_document, &SkeletonDocument::saveSnapshot); connect(graphicsWidget, &SkeletonGraphicsWidget::groupOperationAdded, m_document, &Document::saveSnapshot);
connect(graphicsWidget, &SkeletonGraphicsWidget::undo, m_document, &SkeletonDocument::undo); connect(graphicsWidget, &SkeletonGraphicsWidget::undo, m_document, &Document::undo);
connect(graphicsWidget, &SkeletonGraphicsWidget::redo, m_document, &SkeletonDocument::redo); connect(graphicsWidget, &SkeletonGraphicsWidget::redo, m_document, &Document::redo);
connect(graphicsWidget, &SkeletonGraphicsWidget::paste, m_document, &SkeletonDocument::paste); connect(graphicsWidget, &SkeletonGraphicsWidget::paste, m_document, &Document::paste);
connect(graphicsWidget, &SkeletonGraphicsWidget::batchChangeBegin, m_document, &SkeletonDocument::batchChangeBegin); connect(graphicsWidget, &SkeletonGraphicsWidget::batchChangeBegin, m_document, &Document::batchChangeBegin);
connect(graphicsWidget, &SkeletonGraphicsWidget::batchChangeEnd, m_document, &SkeletonDocument::batchChangeEnd); connect(graphicsWidget, &SkeletonGraphicsWidget::batchChangeEnd, m_document, &Document::batchChangeEnd);
connect(graphicsWidget, &SkeletonGraphicsWidget::breakEdge, m_document, &SkeletonDocument::breakEdge); connect(graphicsWidget, &SkeletonGraphicsWidget::breakEdge, m_document, &Document::breakEdge);
connect(graphicsWidget, &SkeletonGraphicsWidget::moveOriginBy, m_document, &SkeletonDocument::moveOriginBy); connect(graphicsWidget, &SkeletonGraphicsWidget::moveOriginBy, m_document, &Document::moveOriginBy);
connect(graphicsWidget, &SkeletonGraphicsWidget::partChecked, m_document, &SkeletonDocument::partChecked); connect(graphicsWidget, &SkeletonGraphicsWidget::partChecked, m_document, &Document::partChecked);
connect(graphicsWidget, &SkeletonGraphicsWidget::partUnchecked, m_document, &SkeletonDocument::partUnchecked); connect(graphicsWidget, &SkeletonGraphicsWidget::partUnchecked, m_document, &Document::partUnchecked);
connect(graphicsWidget, &SkeletonGraphicsWidget::switchNodeXZ, m_document, &SkeletonDocument::switchNodeXZ); connect(graphicsWidget, &SkeletonGraphicsWidget::switchNodeXZ, m_document, &Document::switchNodeXZ);
connect(graphicsWidget, &SkeletonGraphicsWidget::setPartLockState, m_document, &SkeletonDocument::setPartLockState); connect(graphicsWidget, &SkeletonGraphicsWidget::setPartLockState, m_document, &Document::setPartLockState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setPartVisibleState, m_document, &SkeletonDocument::setPartVisibleState); connect(graphicsWidget, &SkeletonGraphicsWidget::setPartVisibleState, m_document, &Document::setPartVisibleState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setPartSubdivState, m_document, &SkeletonDocument::setPartSubdivState); connect(graphicsWidget, &SkeletonGraphicsWidget::setPartSubdivState, m_document, &Document::setPartSubdivState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setPartDisableState, m_document, &SkeletonDocument::setPartDisableState); connect(graphicsWidget, &SkeletonGraphicsWidget::setPartDisableState, m_document, &Document::setPartDisableState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setPartXmirrorState, m_document, &SkeletonDocument::setPartXmirrorState); connect(graphicsWidget, &SkeletonGraphicsWidget::setPartXmirrorState, m_document, &Document::setPartXmirrorState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setPartRoundState, m_document, &SkeletonDocument::setPartRoundState); connect(graphicsWidget, &SkeletonGraphicsWidget::setPartRoundState, m_document, &Document::setPartRoundState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setPartWrapState, m_document, &SkeletonDocument::setPartWrapState); connect(graphicsWidget, &SkeletonGraphicsWidget::setPartWrapState, m_document, &Document::setPartWrapState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setXlockState, m_document, &SkeletonDocument::setXlockState); connect(graphicsWidget, &SkeletonGraphicsWidget::setXlockState, m_document, &Document::setXlockState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setYlockState, m_document, &SkeletonDocument::setYlockState); connect(graphicsWidget, &SkeletonGraphicsWidget::setYlockState, m_document, &Document::setYlockState);
connect(graphicsWidget, &SkeletonGraphicsWidget::setZlockState, m_document, &SkeletonDocument::setZlockState); connect(graphicsWidget, &SkeletonGraphicsWidget::setZlockState, m_document, &Document::setZlockState);
connect(graphicsWidget, &SkeletonGraphicsWidget::enableAllPositionRelatedLocks, m_document, &SkeletonDocument::enableAllPositionRelatedLocks); connect(graphicsWidget, &SkeletonGraphicsWidget::enableAllPositionRelatedLocks, m_document, &Document::enableAllPositionRelatedLocks);
connect(graphicsWidget, &SkeletonGraphicsWidget::disableAllPositionRelatedLocks, m_document, &SkeletonDocument::disableAllPositionRelatedLocks); connect(graphicsWidget, &SkeletonGraphicsWidget::disableAllPositionRelatedLocks, m_document, &Document::disableAllPositionRelatedLocks);
connect(graphicsWidget, &SkeletonGraphicsWidget::changeTurnaround, this, &SkeletonDocumentWindow::changeTurnaround); connect(graphicsWidget, &SkeletonGraphicsWidget::changeTurnaround, this, &SkeletonDocumentWindow::changeTurnaround);
connect(graphicsWidget, &SkeletonGraphicsWidget::save, this, &SkeletonDocumentWindow::save); connect(graphicsWidget, &SkeletonGraphicsWidget::save, this, &SkeletonDocumentWindow::save);
connect(graphicsWidget, &SkeletonGraphicsWidget::open, this, &SkeletonDocumentWindow::open); connect(graphicsWidget, &SkeletonGraphicsWidget::open, this, &SkeletonDocumentWindow::open);
connect(m_document, &SkeletonDocument::nodeAdded, graphicsWidget, &SkeletonGraphicsWidget::nodeAdded); connect(m_document, &Document::nodeAdded, graphicsWidget, &SkeletonGraphicsWidget::nodeAdded);
connect(m_document, &SkeletonDocument::nodeRemoved, graphicsWidget, &SkeletonGraphicsWidget::nodeRemoved); connect(m_document, &Document::nodeRemoved, graphicsWidget, &SkeletonGraphicsWidget::nodeRemoved);
connect(m_document, &SkeletonDocument::edgeAdded, graphicsWidget, &SkeletonGraphicsWidget::edgeAdded); connect(m_document, &Document::edgeAdded, graphicsWidget, &SkeletonGraphicsWidget::edgeAdded);
connect(m_document, &SkeletonDocument::edgeRemoved, graphicsWidget, &SkeletonGraphicsWidget::edgeRemoved); connect(m_document, &Document::edgeRemoved, graphicsWidget, &SkeletonGraphicsWidget::edgeRemoved);
connect(m_document, &SkeletonDocument::nodeRadiusChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeRadiusChanged); connect(m_document, &Document::nodeRadiusChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeRadiusChanged);
connect(m_document, &SkeletonDocument::nodeBoneMarkChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeBoneMarkChanged); connect(m_document, &Document::nodeBoneMarkChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeBoneMarkChanged);
connect(m_document, &SkeletonDocument::nodeOriginChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeOriginChanged); connect(m_document, &Document::nodeOriginChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeOriginChanged);
connect(m_document, &SkeletonDocument::partVisibleStateChanged, graphicsWidget, &SkeletonGraphicsWidget::partVisibleStateChanged); connect(m_document, &Document::partVisibleStateChanged, graphicsWidget, &SkeletonGraphicsWidget::partVisibleStateChanged);
connect(m_document, &SkeletonDocument::partDisableStateChanged, graphicsWidget, &SkeletonGraphicsWidget::partVisibleStateChanged); connect(m_document, &Document::partDisableStateChanged, graphicsWidget, &SkeletonGraphicsWidget::partVisibleStateChanged);
connect(m_document, &SkeletonDocument::cleanup, graphicsWidget, &SkeletonGraphicsWidget::removeAllContent); connect(m_document, &Document::cleanup, graphicsWidget, &SkeletonGraphicsWidget::removeAllContent);
connect(m_document, &SkeletonDocument::originChanged, graphicsWidget, &SkeletonGraphicsWidget::originChanged); connect(m_document, &Document::originChanged, graphicsWidget, &SkeletonGraphicsWidget::originChanged);
connect(m_document, &SkeletonDocument::checkPart, graphicsWidget, &SkeletonGraphicsWidget::selectPartAllById); connect(m_document, &Document::checkPart, graphicsWidget, &SkeletonGraphicsWidget::selectPartAllById);
connect(m_document, &SkeletonDocument::enableBackgroundBlur, graphicsWidget, &SkeletonGraphicsWidget::enableBackgroundBlur); connect(m_document, &Document::enableBackgroundBlur, graphicsWidget, &SkeletonGraphicsWidget::enableBackgroundBlur);
connect(m_document, &SkeletonDocument::disableBackgroundBlur, graphicsWidget, &SkeletonGraphicsWidget::disableBackgroundBlur); connect(m_document, &Document::disableBackgroundBlur, graphicsWidget, &SkeletonGraphicsWidget::disableBackgroundBlur);
connect(m_document, &SkeletonDocument::uncheckAll, graphicsWidget, &SkeletonGraphicsWidget::unselectAll); connect(m_document, &Document::uncheckAll, graphicsWidget, &SkeletonGraphicsWidget::unselectAll);
connect(m_document, &SkeletonDocument::checkNode, graphicsWidget, &SkeletonGraphicsWidget::addSelectNode); connect(m_document, &Document::checkNode, graphicsWidget, &SkeletonGraphicsWidget::addSelectNode);
connect(m_document, &SkeletonDocument::checkEdge, graphicsWidget, &SkeletonGraphicsWidget::addSelectEdge); connect(m_document, &Document::checkEdge, graphicsWidget, &SkeletonGraphicsWidget::addSelectEdge);
connect(partTreeWidget, &SkeletonPartTreeWidget::currentComponentChanged, m_document, &SkeletonDocument::setCurrentCanvasComponentId); connect(partTreeWidget, &PartTreeWidget::currentComponentChanged, m_document, &Document::setCurrentCanvasComponentId);
connect(partTreeWidget, &SkeletonPartTreeWidget::moveComponentUp, m_document, &SkeletonDocument::moveComponentUp); connect(partTreeWidget, &PartTreeWidget::moveComponentUp, m_document, &Document::moveComponentUp);
connect(partTreeWidget, &SkeletonPartTreeWidget::moveComponentDown, m_document, &SkeletonDocument::moveComponentDown); connect(partTreeWidget, &PartTreeWidget::moveComponentDown, m_document, &Document::moveComponentDown);
connect(partTreeWidget, &SkeletonPartTreeWidget::moveComponentToTop, m_document, &SkeletonDocument::moveComponentToTop); connect(partTreeWidget, &PartTreeWidget::moveComponentToTop, m_document, &Document::moveComponentToTop);
connect(partTreeWidget, &SkeletonPartTreeWidget::moveComponentToBottom, m_document, &SkeletonDocument::moveComponentToBottom); connect(partTreeWidget, &PartTreeWidget::moveComponentToBottom, m_document, &Document::moveComponentToBottom);
connect(partTreeWidget, &SkeletonPartTreeWidget::checkPart, m_document, &SkeletonDocument::checkPart); connect(partTreeWidget, &PartTreeWidget::checkPart, m_document, &Document::checkPart);
connect(partTreeWidget, &SkeletonPartTreeWidget::createNewComponentAndMoveThisIn, m_document, &SkeletonDocument::createNewComponentAndMoveThisIn); connect(partTreeWidget, &PartTreeWidget::createNewComponentAndMoveThisIn, m_document, &Document::createNewComponentAndMoveThisIn);
connect(partTreeWidget, &SkeletonPartTreeWidget::createNewChildComponent, m_document, &SkeletonDocument::createNewChildComponent); connect(partTreeWidget, &PartTreeWidget::createNewChildComponent, m_document, &Document::createNewChildComponent);
connect(partTreeWidget, &SkeletonPartTreeWidget::renameComponent, m_document, &SkeletonDocument::renameComponent); connect(partTreeWidget, &PartTreeWidget::renameComponent, m_document, &Document::renameComponent);
connect(partTreeWidget, &SkeletonPartTreeWidget::setComponentExpandState, m_document, &SkeletonDocument::setComponentExpandState); connect(partTreeWidget, &PartTreeWidget::setComponentExpandState, m_document, &Document::setComponentExpandState);
connect(partTreeWidget, &SkeletonPartTreeWidget::setComponentSmoothAll, m_document, &SkeletonDocument::setComponentSmoothAll); connect(partTreeWidget, &PartTreeWidget::setComponentSmoothAll, m_document, &Document::setComponentSmoothAll);
connect(partTreeWidget, &SkeletonPartTreeWidget::setComponentSmoothSeam, m_document, &SkeletonDocument::setComponentSmoothSeam); connect(partTreeWidget, &PartTreeWidget::setComponentSmoothSeam, m_document, &Document::setComponentSmoothSeam);
connect(partTreeWidget, &SkeletonPartTreeWidget::moveComponent, m_document, &SkeletonDocument::moveComponent); connect(partTreeWidget, &PartTreeWidget::moveComponent, m_document, &Document::moveComponent);
connect(partTreeWidget, &SkeletonPartTreeWidget::removeComponent, m_document, &SkeletonDocument::removeComponent); connect(partTreeWidget, &PartTreeWidget::removeComponent, m_document, &Document::removeComponent);
connect(partTreeWidget, &SkeletonPartTreeWidget::hideOtherComponents, m_document, &SkeletonDocument::hideOtherComponents); connect(partTreeWidget, &PartTreeWidget::hideOtherComponents, m_document, &Document::hideOtherComponents);
connect(partTreeWidget, &SkeletonPartTreeWidget::lockOtherComponents, m_document, &SkeletonDocument::lockOtherComponents); connect(partTreeWidget, &PartTreeWidget::lockOtherComponents, m_document, &Document::lockOtherComponents);
connect(partTreeWidget, &SkeletonPartTreeWidget::hideAllComponents, m_document, &SkeletonDocument::hideAllComponents); connect(partTreeWidget, &PartTreeWidget::hideAllComponents, m_document, &Document::hideAllComponents);
connect(partTreeWidget, &SkeletonPartTreeWidget::showAllComponents, m_document, &SkeletonDocument::showAllComponents); connect(partTreeWidget, &PartTreeWidget::showAllComponents, m_document, &Document::showAllComponents);
connect(partTreeWidget, &SkeletonPartTreeWidget::collapseAllComponents, m_document, &SkeletonDocument::collapseAllComponents); connect(partTreeWidget, &PartTreeWidget::collapseAllComponents, m_document, &Document::collapseAllComponents);
connect(partTreeWidget, &SkeletonPartTreeWidget::expandAllComponents, m_document, &SkeletonDocument::expandAllComponents); connect(partTreeWidget, &PartTreeWidget::expandAllComponents, m_document, &Document::expandAllComponents);
connect(partTreeWidget, &SkeletonPartTreeWidget::lockAllComponents, m_document, &SkeletonDocument::lockAllComponents); connect(partTreeWidget, &PartTreeWidget::lockAllComponents, m_document, &Document::lockAllComponents);
connect(partTreeWidget, &SkeletonPartTreeWidget::unlockAllComponents, m_document, &SkeletonDocument::unlockAllComponents); connect(partTreeWidget, &PartTreeWidget::unlockAllComponents, m_document, &Document::unlockAllComponents);
connect(partTreeWidget, &SkeletonPartTreeWidget::setPartLockState, m_document, &SkeletonDocument::setPartLockState); connect(partTreeWidget, &PartTreeWidget::setPartLockState, m_document, &Document::setPartLockState);
connect(partTreeWidget, &SkeletonPartTreeWidget::setPartVisibleState, m_document, &SkeletonDocument::setPartVisibleState); connect(partTreeWidget, &PartTreeWidget::setPartVisibleState, m_document, &Document::setPartVisibleState);
connect(partTreeWidget, &SkeletonPartTreeWidget::setComponentInverseState, m_document, &SkeletonDocument::setComponentInverseState); connect(partTreeWidget, &PartTreeWidget::setComponentInverseState, m_document, &Document::setComponentInverseState);
connect(partTreeWidget, &SkeletonPartTreeWidget::hideDescendantComponents, m_document, &SkeletonDocument::hideDescendantComponents); connect(partTreeWidget, &PartTreeWidget::hideDescendantComponents, m_document, &Document::hideDescendantComponents);
connect(partTreeWidget, &SkeletonPartTreeWidget::showDescendantComponents, m_document, &SkeletonDocument::showDescendantComponents); connect(partTreeWidget, &PartTreeWidget::showDescendantComponents, m_document, &Document::showDescendantComponents);
connect(partTreeWidget, &SkeletonPartTreeWidget::lockDescendantComponents, m_document, &SkeletonDocument::lockDescendantComponents); connect(partTreeWidget, &PartTreeWidget::lockDescendantComponents, m_document, &Document::lockDescendantComponents);
connect(partTreeWidget, &SkeletonPartTreeWidget::unlockDescendantComponents, m_document, &SkeletonDocument::unlockDescendantComponents); connect(partTreeWidget, &PartTreeWidget::unlockDescendantComponents, m_document, &Document::unlockDescendantComponents);
connect(partTreeWidget, &SkeletonPartTreeWidget::addPartToSelection, graphicsWidget, &SkeletonGraphicsWidget::addPartToSelection); connect(partTreeWidget, &PartTreeWidget::addPartToSelection, graphicsWidget, &SkeletonGraphicsWidget::addPartToSelection);
connect(m_document, &SkeletonDocument::componentNameChanged, partTreeWidget, &SkeletonPartTreeWidget::componentNameChanged); connect(m_document, &Document::componentNameChanged, partTreeWidget, &PartTreeWidget::componentNameChanged);
connect(m_document, &SkeletonDocument::componentChildrenChanged, partTreeWidget, &SkeletonPartTreeWidget::componentChildrenChanged); connect(m_document, &Document::componentChildrenChanged, partTreeWidget, &PartTreeWidget::componentChildrenChanged);
connect(m_document, &SkeletonDocument::componentRemoved, partTreeWidget, &SkeletonPartTreeWidget::componentRemoved); connect(m_document, &Document::componentRemoved, partTreeWidget, &PartTreeWidget::componentRemoved);
connect(m_document, &SkeletonDocument::componentAdded, partTreeWidget, &SkeletonPartTreeWidget::componentAdded); connect(m_document, &Document::componentAdded, partTreeWidget, &PartTreeWidget::componentAdded);
connect(m_document, &SkeletonDocument::componentExpandStateChanged, partTreeWidget, &SkeletonPartTreeWidget::componentExpandStateChanged); connect(m_document, &Document::componentExpandStateChanged, partTreeWidget, &PartTreeWidget::componentExpandStateChanged);
connect(m_document, &SkeletonDocument::partPreviewChanged, partTreeWidget, &SkeletonPartTreeWidget::partPreviewChanged); connect(m_document, &Document::partPreviewChanged, partTreeWidget, &PartTreeWidget::partPreviewChanged);
connect(m_document, &SkeletonDocument::partLockStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partLockStateChanged); connect(m_document, &Document::partLockStateChanged, partTreeWidget, &PartTreeWidget::partLockStateChanged);
connect(m_document, &SkeletonDocument::partVisibleStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partVisibleStateChanged); connect(m_document, &Document::partVisibleStateChanged, partTreeWidget, &PartTreeWidget::partVisibleStateChanged);
connect(m_document, &SkeletonDocument::partSubdivStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partSubdivStateChanged); connect(m_document, &Document::partSubdivStateChanged, partTreeWidget, &PartTreeWidget::partSubdivStateChanged);
connect(m_document, &SkeletonDocument::partDisableStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partDisableStateChanged); connect(m_document, &Document::partDisableStateChanged, partTreeWidget, &PartTreeWidget::partDisableStateChanged);
connect(m_document, &SkeletonDocument::partXmirrorStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partXmirrorStateChanged); connect(m_document, &Document::partXmirrorStateChanged, partTreeWidget, &PartTreeWidget::partXmirrorStateChanged);
connect(m_document, &SkeletonDocument::partDeformThicknessChanged, partTreeWidget, &SkeletonPartTreeWidget::partDeformChanged); connect(m_document, &Document::partDeformThicknessChanged, partTreeWidget, &PartTreeWidget::partDeformChanged);
connect(m_document, &SkeletonDocument::partDeformWidthChanged, partTreeWidget, &SkeletonPartTreeWidget::partDeformChanged); connect(m_document, &Document::partDeformWidthChanged, partTreeWidget, &PartTreeWidget::partDeformChanged);
connect(m_document, &SkeletonDocument::partRoundStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partRoundStateChanged); connect(m_document, &Document::partRoundStateChanged, partTreeWidget, &PartTreeWidget::partRoundStateChanged);
connect(m_document, &SkeletonDocument::partWrapStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partWrapStateChanged); connect(m_document, &Document::partWrapStateChanged, partTreeWidget, &PartTreeWidget::partWrapStateChanged);
connect(m_document, &SkeletonDocument::partColorStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partColorStateChanged); connect(m_document, &Document::partColorStateChanged, partTreeWidget, &PartTreeWidget::partColorStateChanged);
connect(m_document, &SkeletonDocument::partMaterialIdChanged, partTreeWidget, &SkeletonPartTreeWidget::partMaterialIdChanged); connect(m_document, &Document::partMaterialIdChanged, partTreeWidget, &PartTreeWidget::partMaterialIdChanged);
connect(m_document, &SkeletonDocument::partRemoved, partTreeWidget, &SkeletonPartTreeWidget::partRemoved); connect(m_document, &Document::partRemoved, partTreeWidget, &PartTreeWidget::partRemoved);
connect(m_document, &SkeletonDocument::cleanup, partTreeWidget, &SkeletonPartTreeWidget::removeAllContent); connect(m_document, &Document::cleanup, partTreeWidget, &PartTreeWidget::removeAllContent);
connect(m_document, &SkeletonDocument::partChecked, partTreeWidget, &SkeletonPartTreeWidget::partChecked); connect(m_document, &Document::partChecked, partTreeWidget, &PartTreeWidget::partChecked);
connect(m_document, &SkeletonDocument::partUnchecked, partTreeWidget, &SkeletonPartTreeWidget::partUnchecked); connect(m_document, &Document::partUnchecked, partTreeWidget, &PartTreeWidget::partUnchecked);
connect(m_document, &SkeletonDocument::skeletonChanged, m_document, &SkeletonDocument::generateMesh); connect(m_document, &Document::skeletonChanged, m_document, &Document::generateMesh);
//connect(m_document, &SkeletonDocument::resultMeshChanged, [=]() { //connect(m_document, &SkeletonDocument::resultMeshChanged, [=]() {
// if ((m_exportPreviewWidget && m_exportPreviewWidget->isVisible())) { // if ((m_exportPreviewWidget && m_exportPreviewWidget->isVisible())) {
// m_document->postProcess(); // m_document->postProcess();
@ -822,76 +822,76 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
// m_document->generateTexture(); // m_document->generateTexture();
// } // }
//}); //});
connect(m_document, &SkeletonDocument::textureChanged, m_document, &SkeletonDocument::generateTexture); connect(m_document, &Document::textureChanged, m_document, &Document::generateTexture);
connect(m_document, &SkeletonDocument::resultMeshChanged, m_document, &SkeletonDocument::postProcess); connect(m_document, &Document::resultMeshChanged, m_document, &Document::postProcess);
connect(m_document, &SkeletonDocument::resultMeshChanged, m_document, &SkeletonDocument::generateRig); connect(m_document, &Document::resultMeshChanged, m_document, &Document::generateRig);
connect(m_document, &SkeletonDocument::rigChanged, m_document, &SkeletonDocument::generateRig); connect(m_document, &Document::rigChanged, m_document, &Document::generateRig);
connect(m_document, &SkeletonDocument::postProcessedResultChanged, m_document, &SkeletonDocument::generateTexture); connect(m_document, &Document::postProcessedResultChanged, m_document, &Document::generateTexture);
//connect(m_document, &SkeletonDocument::resultTextureChanged, m_document, &SkeletonDocument::bakeAmbientOcclusionTexture); //connect(m_document, &SkeletonDocument::resultTextureChanged, m_document, &SkeletonDocument::bakeAmbientOcclusionTexture);
connect(m_document, &SkeletonDocument::resultTextureChanged, [=]() { connect(m_document, &Document::resultTextureChanged, [=]() {
if (m_document->isMeshGenerating()) if (m_document->isMeshGenerating())
return; return;
m_modelRenderWidget->updateMesh(m_document->takeResultTextureMesh()); m_modelRenderWidget->updateMesh(m_document->takeResultTextureMesh());
}); });
connect(m_document, &SkeletonDocument::resultMeshChanged, [=]() { connect(m_document, &Document::resultMeshChanged, [=]() {
m_modelRenderWidget->updateMesh(m_document->takeResultMesh()); m_modelRenderWidget->updateMesh(m_document->takeResultMesh());
}); });
connect(m_document, &SkeletonDocument::posesChanged, m_document, &SkeletonDocument::generateMotions); connect(m_document, &Document::posesChanged, m_document, &Document::generateMotions);
connect(m_document, &SkeletonDocument::motionsChanged, m_document, &SkeletonDocument::generateMotions); connect(m_document, &Document::motionsChanged, m_document, &Document::generateMotions);
connect(graphicsWidget, &SkeletonGraphicsWidget::cursorChanged, [=]() { connect(graphicsWidget, &SkeletonGraphicsWidget::cursorChanged, [=]() {
m_modelRenderWidget->setCursor(graphicsWidget->cursor()); m_modelRenderWidget->setCursor(graphicsWidget->cursor());
//m_skeletonRenderWidget->setCursor(graphicsWidget->cursor()); //m_skeletonRenderWidget->setCursor(graphicsWidget->cursor());
}); });
connect(m_document, &SkeletonDocument::skeletonChanged, this, &SkeletonDocumentWindow::documentChanged); connect(m_document, &Document::skeletonChanged, this, &SkeletonDocumentWindow::documentChanged);
connect(m_document, &SkeletonDocument::turnaroundChanged, this, &SkeletonDocumentWindow::documentChanged); connect(m_document, &Document::turnaroundChanged, this, &SkeletonDocumentWindow::documentChanged);
connect(m_document, &SkeletonDocument::optionsChanged, this, &SkeletonDocumentWindow::documentChanged); connect(m_document, &Document::optionsChanged, this, &SkeletonDocumentWindow::documentChanged);
connect(m_document, &SkeletonDocument::rigChanged, this, &SkeletonDocumentWindow::documentChanged); connect(m_document, &Document::rigChanged, this, &SkeletonDocumentWindow::documentChanged);
connect(m_modelRenderWidget, &ModelWidget::customContextMenuRequested, [=](const QPoint &pos) { connect(m_modelRenderWidget, &ModelWidget::customContextMenuRequested, [=](const QPoint &pos) {
graphicsWidget->showContextMenu(graphicsWidget->mapFromGlobal(m_modelRenderWidget->mapToGlobal(pos))); graphicsWidget->showContextMenu(graphicsWidget->mapFromGlobal(m_modelRenderWidget->mapToGlobal(pos)));
}); });
connect(m_document, &SkeletonDocument::xlockStateChanged, this, &SkeletonDocumentWindow::updateXlockButtonState); connect(m_document, &Document::xlockStateChanged, this, &SkeletonDocumentWindow::updateXlockButtonState);
connect(m_document, &SkeletonDocument::ylockStateChanged, this, &SkeletonDocumentWindow::updateYlockButtonState); connect(m_document, &Document::ylockStateChanged, this, &SkeletonDocumentWindow::updateYlockButtonState);
connect(m_document, &SkeletonDocument::zlockStateChanged, this, &SkeletonDocumentWindow::updateZlockButtonState); connect(m_document, &Document::zlockStateChanged, this, &SkeletonDocumentWindow::updateZlockButtonState);
connect(m_document, &SkeletonDocument::radiusLockStateChanged, this, &SkeletonDocumentWindow::updateRadiusLockButtonState); connect(m_document, &Document::radiusLockStateChanged, this, &SkeletonDocumentWindow::updateRadiusLockButtonState);
connect(m_rigWidget, &RigWidget::setRigType, m_document, &SkeletonDocument::setRigType); connect(m_rigWidget, &RigWidget::setRigType, m_document, &Document::setRigType);
connect(m_document, &SkeletonDocument::rigTypeChanged, m_rigWidget, &RigWidget::rigTypeChanged); connect(m_document, &Document::rigTypeChanged, m_rigWidget, &RigWidget::rigTypeChanged);
connect(m_document, &SkeletonDocument::resultRigChanged, m_rigWidget, &RigWidget::updateResultInfo); connect(m_document, &Document::resultRigChanged, m_rigWidget, &RigWidget::updateResultInfo);
connect(m_document, &SkeletonDocument::resultRigChanged, this, &SkeletonDocumentWindow::updateRigWeightRenderWidget); connect(m_document, &Document::resultRigChanged, this, &SkeletonDocumentWindow::updateRigWeightRenderWidget);
//connect(m_document, &SkeletonDocument::resultRigChanged, tetrapodPoseEditWidget, &TetrapodPoseEditWidget::updatePreview); //connect(m_document, &SkeletonDocument::resultRigChanged, tetrapodPoseEditWidget, &TetrapodPoseEditWidget::updatePreview);
connect(m_document, &SkeletonDocument::poseAdded, this, [=](QUuid poseId) { connect(m_document, &Document::poseAdded, this, [=](QUuid poseId) {
Q_UNUSED(poseId); Q_UNUSED(poseId);
m_document->generatePosePreviews(); m_document->generatePosePreviews();
}); });
connect(m_document, &SkeletonDocument::poseParametersChanged, this, [=](QUuid poseId) { connect(m_document, &Document::poseParametersChanged, this, [=](QUuid poseId) {
Q_UNUSED(poseId); Q_UNUSED(poseId);
m_document->generatePosePreviews(); m_document->generatePosePreviews();
}); });
connect(m_document, &SkeletonDocument::resultRigChanged, m_document, &SkeletonDocument::generatePosePreviews); connect(m_document, &Document::resultRigChanged, m_document, &Document::generatePosePreviews);
connect(m_document, &SkeletonDocument::resultRigChanged, m_document, &SkeletonDocument::generateMotions); connect(m_document, &Document::resultRigChanged, m_document, &Document::generateMotions);
connect(m_document, &SkeletonDocument::materialAdded, this, [=](QUuid materialId) { connect(m_document, &Document::materialAdded, this, [=](QUuid materialId) {
Q_UNUSED(materialId); Q_UNUSED(materialId);
m_document->generateMaterialPreviews(); m_document->generateMaterialPreviews();
}); });
connect(m_document, &SkeletonDocument::materialLayersChanged, this, [=](QUuid materialId) { connect(m_document, &Document::materialLayersChanged, this, [=](QUuid materialId) {
Q_UNUSED(materialId); Q_UNUSED(materialId);
m_document->generateMaterialPreviews(); m_document->generateMaterialPreviews();
}); });
initShortCuts(this, m_graphicsWidget); initShortCuts(this, m_graphicsWidget);
connect(this, &SkeletonDocumentWindow::initialized, m_document, &SkeletonDocument::uiReady); connect(this, &SkeletonDocumentWindow::initialized, m_document, &Document::uiReady);
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
timer->setInterval(250); timer->setInterval(250);
@ -1092,7 +1092,7 @@ void SkeletonDocumentWindow::saveTo(const QString &saveAsFilename)
QByteArray modelXml; QByteArray modelXml;
QXmlStreamWriter stream(&modelXml); QXmlStreamWriter stream(&modelXml);
SkeletonSnapshot snapshot; Snapshot snapshot;
m_document->toSnapshot(&snapshot); m_document->toSnapshot(&snapshot);
saveSkeletonToXmlStream(&snapshot, &stream); saveSkeletonToXmlStream(&snapshot, &stream);
if (modelXml.size() > 0) if (modelXml.size() > 0)
@ -1176,7 +1176,7 @@ void SkeletonDocumentWindow::open()
QByteArray data; QByteArray data;
ds3Reader.loadItem(item.name, &data); ds3Reader.loadItem(item.name, &data);
QXmlStreamReader stream(data); QXmlStreamReader stream(data);
SkeletonSnapshot snapshot; Snapshot snapshot;
loadSkeletonFromXmlStream(&snapshot, stream); loadSkeletonFromXmlStream(&snapshot, stream);
m_document->fromSnapshot(snapshot); m_document->fromSnapshot(snapshot);
m_document->saveSnapshot(); m_document->saveSnapshot();
@ -1223,13 +1223,13 @@ void SkeletonDocumentWindow::showExportPreview()
{ {
if (nullptr == m_exportPreviewWidget) { if (nullptr == m_exportPreviewWidget) {
m_exportPreviewWidget = new ExportPreviewWidget(m_document, this); m_exportPreviewWidget = new ExportPreviewWidget(m_document, this);
connect(m_exportPreviewWidget, &ExportPreviewWidget::regenerate, m_document, &SkeletonDocument::regenerateMesh); connect(m_exportPreviewWidget, &ExportPreviewWidget::regenerate, m_document, &Document::regenerateMesh);
connect(m_exportPreviewWidget, &ExportPreviewWidget::saveAsGltf, this, &SkeletonDocumentWindow::exportGltfResult); connect(m_exportPreviewWidget, &ExportPreviewWidget::saveAsGltf, this, &SkeletonDocumentWindow::exportGltfResult);
connect(m_exportPreviewWidget, &ExportPreviewWidget::saveAsFbx, this, &SkeletonDocumentWindow::exportFbxResult); connect(m_exportPreviewWidget, &ExportPreviewWidget::saveAsFbx, this, &SkeletonDocumentWindow::exportFbxResult);
connect(m_document, &SkeletonDocument::resultMeshChanged, m_exportPreviewWidget, &ExportPreviewWidget::checkSpinner); connect(m_document, &Document::resultMeshChanged, m_exportPreviewWidget, &ExportPreviewWidget::checkSpinner);
connect(m_document, &SkeletonDocument::exportReady, m_exportPreviewWidget, &ExportPreviewWidget::checkSpinner); connect(m_document, &Document::exportReady, m_exportPreviewWidget, &ExportPreviewWidget::checkSpinner);
connect(m_document, &SkeletonDocument::resultTextureChanged, m_exportPreviewWidget, &ExportPreviewWidget::updateTexturePreview); connect(m_document, &Document::resultTextureChanged, m_exportPreviewWidget, &ExportPreviewWidget::updateTexturePreview);
connect(m_document, &SkeletonDocument::resultBakedTextureChanged, m_exportPreviewWidget, &ExportPreviewWidget::updateTexturePreview); connect(m_document, &Document::resultBakedTextureChanged, m_exportPreviewWidget, &ExportPreviewWidget::updateTexturePreview);
registerDialog(m_exportPreviewWidget); registerDialog(m_exportPreviewWidget);
} }
m_exportPreviewWidget->show(); m_exportPreviewWidget->show();
@ -1248,7 +1248,7 @@ void SkeletonDocumentWindow::exportFbxResult()
return; return;
} }
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
MeshResultContext skeletonResult = m_document->currentPostProcessedResultContext(); Outcome skeletonResult = m_document->currentPostProcessedResultContext();
FbxFileWriter fbxFileWriter(skeletonResult, m_document->resultRigBones(), m_document->resultRigWeights(), filename); FbxFileWriter fbxFileWriter(skeletonResult, m_document->resultRigBones(), m_document->resultRigWeights(), filename);
fbxFileWriter.save(); fbxFileWriter.save();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
@ -1266,7 +1266,7 @@ void SkeletonDocumentWindow::exportGltfResult()
return; return;
} }
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
MeshResultContext skeletonResult = m_document->currentPostProcessedResultContext(); Outcome skeletonResult = m_document->currentPostProcessedResultContext();
GltfFileWriter gltfFileWriter(skeletonResult, m_document->resultRigBones(), m_document->resultRigWeights(), filename); GltfFileWriter gltfFileWriter(skeletonResult, m_document->resultRigBones(), m_document->resultRigWeights(), filename);
gltfFileWriter.save(); gltfFileWriter.save();
if (m_document->textureImage) if (m_document->textureImage)

View File

@ -1,5 +1,5 @@
#ifndef SKELETON_DOCUMENT_WINDOW_H #ifndef DUST3D_DOCUMENT_WINDOW_H
#define SKELETON_DOCUMENT_WINDOW_H #define DUST3D_DOCUMENT_WINDOW_H
#include <QMainWindow> #include <QMainWindow>
#include <QShowEvent> #include <QShowEvent>
#include <QPushButton> #include <QPushButton>
@ -7,11 +7,11 @@
#include <QMenu> #include <QMenu>
#include <QAction> #include <QAction>
#include <QTextBrowser> #include <QTextBrowser>
#include "skeletondocument.h" #include "document.h"
#include "modelwidget.h" #include "modelwidget.h"
#include "exportpreviewwidget.h" #include "exportpreviewwidget.h"
#include "rigwidget.h" #include "rigwidget.h"
#include "skeletonbonemark.h" #include "bonemark.h"
#include "posemanagewidget.h" #include "posemanagewidget.h"
#include "advancesettingwidget.h" #include "advancesettingwidget.h"
@ -66,7 +66,7 @@ private:
void setCurrentFilename(const QString &filename); void setCurrentFilename(const QString &filename);
void updateTitle(); void updateTitle();
private: private:
SkeletonDocument *m_document; Document *m_document;
bool m_firstShow; bool m_firstShow;
bool m_documentSaved; bool m_documentSaved;
ExportPreviewWidget *m_exportPreviewWidget; ExportPreviewWidget *m_exportPreviewWidget;
@ -124,7 +124,7 @@ private:
QMenu *m_markAsMenu; QMenu *m_markAsMenu;
QAction *m_markAsNoneAction; QAction *m_markAsNoneAction;
QAction *m_markAsActions[(int)SkeletonBoneMark::Count - 1]; QAction *m_markAsActions[(int)BoneMark::Count - 1];
QMenu *m_viewMenu; QMenu *m_viewMenu;
QAction *m_resetModelWidgetPosAction; QAction *m_resetModelWidgetPosAction;

View File

@ -1,5 +1,5 @@
#ifndef DS3_FILE_H #ifndef DUST3D_DS3_FILE_H
#define DS3_FILE_H #define DUST3D_DS3_FILE_H
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QByteArray> #include <QByteArray>

View File

@ -7,9 +7,9 @@
#include "aboutwidget.h" #include "aboutwidget.h"
#include "version.h" #include "version.h"
#include "theme.h" #include "theme.h"
#include "dust3dutil.h" #include "util.h"
ExportPreviewWidget::ExportPreviewWidget(SkeletonDocument *document, QWidget *parent) : ExportPreviewWidget::ExportPreviewWidget(Document *document, QWidget *parent) :
QDialog(parent), QDialog(parent),
m_document(document), m_document(document),
m_previewLabel(nullptr), m_previewLabel(nullptr),

View File

@ -1,5 +1,5 @@
#ifndef EXPORT_PREVIEW_WIDGET_H #ifndef DUST3D_EXPORT_PREVIEW_WIDGET_H
#define EXPORT_PREVIEW_WIDGET_H #define DUST3D_EXPORT_PREVIEW_WIDGET_H
#include <QDialog> #include <QDialog>
#include <QImage> #include <QImage>
#include <QLabel> #include <QLabel>
@ -7,7 +7,7 @@
#include <QShowEvent> #include <QShowEvent>
#include "modelwidget.h" #include "modelwidget.h"
#include "waitingspinnerwidget.h" #include "waitingspinnerwidget.h"
#include "skeletondocument.h" #include "document.h"
class ExportPreviewWidget : public QDialog class ExportPreviewWidget : public QDialog
{ {
@ -17,7 +17,7 @@ signals:
void saveAsGltf(); void saveAsGltf();
void saveAsFbx(); void saveAsFbx();
public: public:
ExportPreviewWidget(SkeletonDocument *document, QWidget *parent=nullptr); ExportPreviewWidget(Document *document, QWidget *parent=nullptr);
public slots: public slots:
void checkSpinner(); void checkSpinner();
void updateTexturePreview(); void updateTexturePreview();
@ -29,7 +29,7 @@ private:
void initAwesomeButton(QPushButton *button); void initAwesomeButton(QPushButton *button);
void updateTexturePreviewImage(const QImage &image); void updateTexturePreviewImage(const QImage &image);
private: private:
SkeletonDocument *m_document; Document *m_document;
QLabel *m_previewLabel; QLabel *m_previewLabel;
QImage m_previewImage; QImage m_previewImage;
ModelWidget *m_textureRenderWidget; ModelWidget *m_textureRenderWidget;

View File

@ -1470,7 +1470,7 @@ void FbxFileWriter::createDefinitions(size_t deformerCount)
m_fbxDocument.nodes.push_back(definitions); m_fbxDocument.nodes.push_back(definitions);
} }
FbxFileWriter::FbxFileWriter(MeshResultContext &resultContext, FbxFileWriter::FbxFileWriter(Outcome &outcome,
const std::vector<AutoRiggerBone> *resultRigBones, const std::vector<AutoRiggerBone> *resultRigBones,
const std::map<int, AutoRiggerVertexWeights> *resultRigWeights, const std::map<int, AutoRiggerVertexWeights> *resultRigWeights,
const QString &filename) : const QString &filename) :
@ -1495,13 +1495,13 @@ FbxFileWriter::FbxFileWriter(MeshResultContext &resultContext,
geometry.addProperty(std::vector<uint8_t>({'u','n','a','m','e','d','m','e','s','h',0,1,'G','e','o','m','e','t','r','y'}), 'S'); geometry.addProperty(std::vector<uint8_t>({'u','n','a','m','e','d','m','e','s','h',0,1,'G','e','o','m','e','t','r','y'}), 'S');
geometry.addProperty("Mesh"); geometry.addProperty("Mesh");
std::vector<double> positions; std::vector<double> positions;
for (const auto &vertex: resultContext.vertices) { for (const auto &vertex: outcome.vertices) {
positions.push_back((double)vertex.position.x()); positions.push_back((double)vertex.position.x());
positions.push_back((double)vertex.position.y()); positions.push_back((double)vertex.position.y());
positions.push_back((double)vertex.position.z()); positions.push_back((double)vertex.position.z());
} }
std::vector<int32_t> indicies; std::vector<int32_t> indicies;
for (const auto &triangle: resultContext.triangles) { for (const auto &triangle: outcome.triangles) {
indicies.push_back(triangle.indicies[0]); indicies.push_back(triangle.indicies[0]);
indicies.push_back(triangle.indicies[1]); indicies.push_back(triangle.indicies[1]);
indicies.push_back(triangle.indicies[2] ^ -1); indicies.push_back(triangle.indicies[2] ^ -1);
@ -1513,7 +1513,7 @@ FbxFileWriter::FbxFileWriter(MeshResultContext &resultContext,
layerElementNormal.addPropertyNode("MappingInformationType", "ByPolygonVertex"); layerElementNormal.addPropertyNode("MappingInformationType", "ByPolygonVertex");
layerElementNormal.addPropertyNode("ReferenceInformationType", "Direct"); layerElementNormal.addPropertyNode("ReferenceInformationType", "Direct");
std::vector<double> normals; std::vector<double> normals;
const auto &triangleVertexNormals = resultContext.interpolatedTriangleVertexNormals(); const auto &triangleVertexNormals = outcome.interpolatedTriangleVertexNormals();
for (decltype(triangleVertexNormals.size()) i = 0; i < triangleVertexNormals.size(); ++i) { for (decltype(triangleVertexNormals.size()) i = 0; i < triangleVertexNormals.size(); ++i) {
const auto &n = triangleVertexNormals[i]; const auto &n = triangleVertexNormals[i];
normals.push_back((double)n.x()); normals.push_back((double)n.x());

View File

@ -1,17 +1,17 @@
#ifndef FBX_FILE_H #ifndef DUST3D_FBX_FILE_H
#define FBX_FILE_H #define DUST3D_FBX_FILE_H
#include <fbxdocument.h> #include <fbxdocument.h>
#include <map> #include <map>
#include <QString> #include <QString>
#include <QMatrix4x4> #include <QMatrix4x4>
#include "meshresultcontext.h" #include "outcome.h"
#include "skeletondocument.h" #include "document.h"
class FbxFileWriter : public QObject class FbxFileWriter : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
FbxFileWriter(MeshResultContext &resultContext, FbxFileWriter(Outcome &outcome,
const std::vector<AutoRiggerBone> *resultRigBones, const std::vector<AutoRiggerBone> *resultRigBones,
const std::map<int, AutoRiggerVertexWeights> *resultRigWeights, const std::map<int, AutoRiggerVertexWeights> *resultRigWeights,
const QString &filename); const QString &filename);

View File

@ -1,5 +1,5 @@
#ifndef FLOAT_NUMBER_WIDGET_H #ifndef DUST3D_FLOAT_NUMBER_WIDGET_H
#define FLOAT_NUMBER_WIDGET_H #define DUST3D_FLOAT_NUMBER_WIDGET_H
#include <QToolButton> #include <QToolButton>
QT_FORWARD_DECLARE_CLASS(QLabel) QT_FORWARD_DECLARE_CLASS(QLabel)

View File

@ -49,8 +49,8 @@
****************************************************************************/ ****************************************************************************/
#ifndef FLOWLAYOUT_H #ifndef DUST3D_FLOWLAYOUT_H
#define FLOWLAYOUT_H #define DUST3D_FLOWLAYOUT_H
#include <QLayout> #include <QLayout>
#include <QRect> #include <QRect>

View File

@ -6,7 +6,7 @@
#include <QDir> #include <QDir>
#include "gltffile.h" #include "gltffile.h"
#include "version.h" #include "version.h"
#include "dust3dutil.h" #include "util.h"
#include "jointnodetree.h" #include "jointnodetree.h"
#include "meshloader.h" #include "meshloader.h"
@ -21,7 +21,7 @@
bool GltfFileWriter::m_enableComment = true; bool GltfFileWriter::m_enableComment = true;
GltfFileWriter::GltfFileWriter(MeshResultContext &resultContext, GltfFileWriter::GltfFileWriter(Outcome &outcome,
const std::vector<AutoRiggerBone> *resultRigBones, const std::vector<AutoRiggerBone> *resultRigBones,
const std::map<int, AutoRiggerVertexWeights> *resultRigWeights, const std::map<int, AutoRiggerVertexWeights> *resultRigWeights,
const QString &filename) : const QString &filename) :
@ -129,12 +129,12 @@ GltfFileWriter::GltfFileWriter(MeshResultContext &resultContext,
m_json["samplers"][0]["wrapS"] = 33648; m_json["samplers"][0]["wrapS"] = 33648;
m_json["samplers"][0]["wrapT"] = 33648; m_json["samplers"][0]["wrapT"] = 33648;
const std::map<QUuid, ResultPart> *parts = &resultContext.parts(); const std::map<QUuid, ResultPart> *parts = &outcome.parts();
std::map<QUuid, ResultPart> testParts; std::map<QUuid, ResultPart> testParts;
if (m_testOutputAsWhole) { if (m_testOutputAsWhole) {
testParts[0].vertices = resultContext.vertices; testParts[0].vertices = outcome.vertices;
testParts[0].triangles = resultContext.triangles; testParts[0].triangles = outcome.triangles;
m_outputNormal = false; m_outputNormal = false;
m_outputUv = false; m_outputUv = false;

View File

@ -1,20 +1,20 @@
#ifndef GLTF_FILE_H #ifndef DUST3D_GLTF_FILE_H
#define GLTF_FILE_H #define DUST3D_GLTF_FILE_H
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QByteArray> #include <QByteArray>
#include <QMatrix4x4> #include <QMatrix4x4>
#include <vector> #include <vector>
#include <QQuaternion> #include <QQuaternion>
#include "meshresultcontext.h" #include "outcome.h"
#include "json.hpp" #include "json.hpp"
#include "skeletondocument.h" #include "document.h"
class GltfFileWriter : public QObject class GltfFileWriter : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
GltfFileWriter(MeshResultContext &resultContext, GltfFileWriter(Outcome &outcome,
const std::vector<AutoRiggerBone> *resultRigBones, const std::vector<AutoRiggerBone> *resultRigBones,
const std::map<int, AutoRiggerVertexWeights> *resultRigWeights, const std::map<int, AutoRiggerVertexWeights> *resultRigWeights,
const QString &filename); const QString &filename);

View File

@ -1,5 +1,5 @@
#ifndef GRAPHICS_CONTAINER_WIDGET_H #ifndef DUST3D_GRAPHICS_CONTAINER_WIDGET_H
#define GRAPHICS_CONTAINER_WIDGET_H #define DUST3D_GRAPHICS_CONTAINER_WIDGET_H
#include <QWidget> #include <QWidget>
#include <QResizeEvent> #include <QResizeEvent>

View File

@ -1,5 +1,5 @@
#ifndef IMAGE_FOREVER_H #ifndef DUST3D_IMAGE_FOREVER_H
#define IMAGE_FOREVER_H #define DUST3D_IMAGE_FOREVER_H
#include <QImage> #include <QImage>
#include <QUuid> #include <QUuid>

View File

@ -1,5 +1,5 @@
#ifndef INFO_LABEL_H #ifndef DUST3D_INFO_LABEL_H
#define INFO_LABEL_H #define DUST3D_INFO_LABEL_H
#include <QLabel> #include <QLabel>
#include <QIcon> #include <QIcon>
#include <QWidget> #include <QWidget>

View File

@ -1,5 +1,5 @@
#ifndef INTERPOLATION_TYPE_H #ifndef DUST3D_INTERPOLATION_TYPE_H
#define INTERPOLATION_TYPE_H #define DUST3D_INTERPOLATION_TYPE_H
#include <QString> #include <QString>
#include <QEasingCurve> #include <QEasingCurve>

View File

@ -1,5 +1,5 @@
#include "jointnodetree.h" #include "jointnodetree.h"
#include "dust3dutil.h" #include "util.h"
const std::vector<JointNode> &JointNodeTree::nodes() const const std::vector<JointNode> &JointNodeTree::nodes() const
{ {

View File

@ -1,5 +1,5 @@
#ifndef JOINT_NODE_TREE_H #ifndef DUST3D_JOINT_NODE_TREE_H
#define JOINT_NODE_TREE_H #define DUST3D_JOINT_NODE_TREE_H
#include <QMatrix4x4> #include <QMatrix4x4>
#include <vector> #include <vector>
#include <QQuaternion> #include <QQuaternion>

View File

@ -1,5 +1,5 @@
#ifndef LOG_BROWSER_H #ifndef DUST3D_LOG_BROWSER_H
#define LOG_BROWSER_H #define DUST3D_LOG_BROWSER_H
// Modified from https://wiki.qt.io/Browser_for_QDebug_output // Modified from https://wiki.qt.io/Browser_for_QDebug_output
#include <QObject> #include <QObject>

View File

@ -12,7 +12,7 @@
#include <QCloseEvent> #include <QCloseEvent>
#include <QKeyEvent> #include <QKeyEvent>
#include "version.h" #include "version.h"
#include "dust3dutil.h" #include "util.h"
LogBrowserDialog::LogBrowserDialog(QWidget *parent) : LogBrowserDialog::LogBrowserDialog(QWidget *parent) :
QDialog(parent) QDialog(parent)

View File

@ -1,5 +1,5 @@
#ifndef LOG_BROWSER_DIALOG_H #ifndef DUST3D_LOG_BROWSER_DIALOG_H
#define LOG_BROWSER_DIALOG_H #define DUST3D_LOG_BROWSER_DIALOG_H
// Modified from https://wiki.qt.io/Browser_for_QDebug_output // Modified from https://wiki.qt.io/Browser_for_QDebug_output
#include <QDialog> #include <QDialog>

View File

@ -5,7 +5,7 @@
#include <QDebug> #include <QDebug>
#include <QtGlobal> #include <QtGlobal>
#include <QSurfaceFormat> #include <QSurfaceFormat>
#include "skeletondocumentwindow.h" #include "documentwindow.h"
#include "theme.h" #include "theme.h"
#include "version.h" #include "version.h"
//#include "fbxdocument.h" //#include "fbxdocument.h"

View File

@ -3,15 +3,15 @@
#include "markiconcreator.h" #include "markiconcreator.h"
#include "theme.h" #include "theme.h"
std::map<SkeletonBoneMark, QIcon> MarkIconCreator::m_iconMap; std::map<BoneMark, QIcon> MarkIconCreator::m_iconMap;
int MarkIconCreator::m_iconSize = 40; int MarkIconCreator::m_iconSize = 40;
QIcon MarkIconCreator::createIcon(SkeletonBoneMark boneMark) QIcon MarkIconCreator::createIcon(BoneMark boneMark)
{ {
if (m_iconMap.find(boneMark) == m_iconMap.end()) { if (m_iconMap.find(boneMark) == m_iconMap.end()) {
QPixmap pixmap(MarkIconCreator::m_iconSize, MarkIconCreator::m_iconSize); QPixmap pixmap(MarkIconCreator::m_iconSize, MarkIconCreator::m_iconSize);
pixmap.fill(Qt::transparent); pixmap.fill(Qt::transparent);
QColor color = SkeletonBoneMarkToColor(boneMark); QColor color = BoneMarkToColor(boneMark);
QPainter painter(&pixmap); QPainter painter(&pixmap);
painter.setBrush(QBrush(color)); painter.setBrush(QBrush(color));
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);

View File

@ -1,15 +1,15 @@
#ifndef MARK_ICON_CREATOR_H #ifndef DUST3D_MARK_ICON_CREATOR_H
#define MARK_ICON_CREATOR_H #define DUST3D_MARK_ICON_CREATOR_H
#include <map> #include <map>
#include <QIcon> #include <QIcon>
#include "skeletondocument.h" #include "document.h"
class MarkIconCreator class MarkIconCreator
{ {
public: public:
static QIcon createIcon(SkeletonBoneMark boneMark); static QIcon createIcon(BoneMark boneMark);
private: private:
static std::map<SkeletonBoneMark, QIcon> m_iconMap; static std::map<BoneMark, QIcon> m_iconMap;
static int m_iconSize; static int m_iconSize;
}; };

View File

@ -1,8 +1,8 @@
#include "material.h" #include "material.h"
#include "imageforever.h" #include "imageforever.h"
#include "dust3dutil.h" #include "util.h"
void initializeMaterialTexturesFromSnapshot(const SkeletonSnapshot &snapshot, const QUuid &materialId, MaterialTextures &materialTextures) void initializeMaterialTexturesFromSnapshot(const Snapshot &snapshot, const QUuid &materialId, MaterialTextures &materialTextures)
{ {
QString materialIdString = materialId.toString(); QString materialIdString = materialId.toString();
for (const auto &materialItem: snapshot.materials) { for (const auto &materialItem: snapshot.materials) {

View File

@ -1,21 +1,15 @@
#ifndef MATERIAL_H #ifndef DUST3D_MATERIAL_H
#define MATERIAL_H #define DUST3D_MATERIAL_H
#include <QImage> #include <QImage>
#include <QUuid> #include <QUuid>
#include "texturetype.h" #include "texturetype.h"
#include "skeletonsnapshot.h" #include "snapshot.h"
struct Material
{
QColor color;
QUuid materialId;
};
struct MaterialTextures struct MaterialTextures
{ {
const QImage *textureImages[(int)TextureType::Count - 1] = {nullptr}; const QImage *textureImages[(int)TextureType::Count - 1] = {nullptr};
}; };
void initializeMaterialTexturesFromSnapshot(const SkeletonSnapshot &snapshot, const QUuid &materialId, MaterialTextures &materialTextures); void initializeMaterialTexturesFromSnapshot(const Snapshot &snapshot, const QUuid &materialId, MaterialTextures &materialTextures);
#endif #endif

View File

@ -14,7 +14,7 @@
#include "floatnumberwidget.h" #include "floatnumberwidget.h"
#include "version.h" #include "version.h"
#include "imageforever.h" #include "imageforever.h"
#include "dust3dutil.h" #include "util.h"
QPushButton *MaterialEditWidget::createMapButton() QPushButton *MaterialEditWidget::createMapButton()
{ {
@ -38,7 +38,7 @@ QImage *MaterialEditWidget::pickImage()
return image; return image;
} }
MaterialEditWidget::MaterialEditWidget(const SkeletonDocument *document, QWidget *parent) : MaterialEditWidget::MaterialEditWidget(const Document *document, QWidget *parent) :
QDialog(parent), QDialog(parent),
m_document(document) m_document(document)
{ {
@ -60,7 +60,7 @@ MaterialEditWidget::MaterialEditWidget(const SkeletonDocument *document, QWidget
for (int i = 1; i < (int)TextureType::Count; i++) { for (int i = 1; i < (int)TextureType::Count; i++) {
QVBoxLayout *textureManageLayout = new QVBoxLayout; QVBoxLayout *textureManageLayout = new QVBoxLayout;
SkeletonMaterialMap item; MaterialMap item;
item.forWhat = (TextureType)i; item.forWhat = (TextureType)i;
m_layers[0].maps.push_back(item); m_layers[0].maps.push_back(item);
@ -141,9 +141,9 @@ MaterialEditWidget::MaterialEditWidget(const SkeletonDocument *document, QWidget
m_unsaved = true; m_unsaved = true;
updateTitle(); updateTitle();
}); });
connect(this, &MaterialEditWidget::addMaterial, document, &SkeletonDocument::addMaterial); connect(this, &MaterialEditWidget::addMaterial, document, &Document::addMaterial);
connect(this, &MaterialEditWidget::renameMaterial, document, &SkeletonDocument::renameMaterial); connect(this, &MaterialEditWidget::renameMaterial, document, &Document::renameMaterial);
connect(this, &MaterialEditWidget::setMaterialLayers, document, &SkeletonDocument::setMaterialLayers); connect(this, &MaterialEditWidget::setMaterialLayers, document, &Document::setMaterialLayers);
updatePreview(); updatePreview();
updateTitle(); updateTitle();
@ -253,7 +253,7 @@ void MaterialEditWidget::updateTitle()
setWindowTitle(unifiedWindowTitle(tr("New") + (m_unsaved ? "*" : ""))); setWindowTitle(unifiedWindowTitle(tr("New") + (m_unsaved ? "*" : "")));
return; return;
} }
const SkeletonMaterial *material = m_document->findMaterial(m_materialId); const Material *material = m_document->findMaterial(m_materialId);
if (nullptr == material) { if (nullptr == material) {
qDebug() << "Find material failed:" << m_materialId; qDebug() << "Find material failed:" << m_materialId;
return; return;
@ -267,7 +267,7 @@ void MaterialEditWidget::setEditMaterialName(QString name)
updateTitle(); updateTitle();
} }
void MaterialEditWidget::setEditMaterialLayers(std::vector<SkeletonMaterialLayer> layers) void MaterialEditWidget::setEditMaterialLayers(std::vector<MaterialLayer> layers)
{ {
for (int i = 1; i < (int)TextureType::Count; i++) { for (int i = 1; i < (int)TextureType::Count; i++) {
m_layers[0].maps[i - 1].imageId = QUuid(); m_layers[0].maps[i - 1].imageId = QUuid();

View File

@ -1,10 +1,10 @@
#ifndef MATERIAL_EDIT_WIDGET_H #ifndef DUST3D_MATERIAL_EDIT_WIDGET_H
#define MATERIAL_EDIT_WIDGET_H #define DUST3D_MATERIAL_EDIT_WIDGET_H
#include <QDialog> #include <QDialog>
#include <map> #include <map>
#include <QCloseEvent> #include <QCloseEvent>
#include <QLineEdit> #include <QLineEdit>
#include "skeletondocument.h" #include "document.h"
#include "modelwidget.h" #include "modelwidget.h"
#include "materialpreviewsgenerator.h" #include "materialpreviewsgenerator.h"
@ -18,19 +18,19 @@ class MaterialEditWidget : public QDialog
{ {
Q_OBJECT Q_OBJECT
signals: signals:
void addMaterial(QString name, std::vector<SkeletonMaterialLayer> layers); void addMaterial(QString name, std::vector<MaterialLayer> layers);
void removeMaterial(QUuid materialId); void removeMaterial(QUuid materialId);
void setMaterialLayers(QUuid materialId, std::vector<SkeletonMaterialLayer> layers); void setMaterialLayers(QUuid materialId, std::vector<MaterialLayer> layers);
void renameMaterial(QUuid materialId, QString name); void renameMaterial(QUuid materialId, QString name);
void layersAdjusted(); void layersAdjusted();
public: public:
MaterialEditWidget(const SkeletonDocument *document, QWidget *parent=nullptr); MaterialEditWidget(const Document *document, QWidget *parent=nullptr);
~MaterialEditWidget(); ~MaterialEditWidget();
public slots: public slots:
void updatePreview(); void updatePreview();
void setEditMaterialId(QUuid materialId); void setEditMaterialId(QUuid materialId);
void setEditMaterialName(QString name); void setEditMaterialName(QString name);
void setEditMaterialLayers(std::vector<SkeletonMaterialLayer> layers); void setEditMaterialLayers(std::vector<MaterialLayer> layers);
void updateTitle(); void updateTitle();
void save(); void save();
void clearUnsaveState(); void clearUnsaveState();
@ -43,7 +43,7 @@ private:
void updateMapButtonBackground(QPushButton *button, const QImage *image); void updateMapButtonBackground(QPushButton *button, const QImage *image);
QPushButton *createMapButton(); QPushButton *createMapButton();
QImage *pickImage(); QImage *pickImage();
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
MaterialPreviewsGenerator *m_materialPreviewsGenerator = nullptr; MaterialPreviewsGenerator *m_materialPreviewsGenerator = nullptr;
ModelWidget *m_previewWidget = nullptr; ModelWidget *m_previewWidget = nullptr;
bool m_isPreviewDirty = false; bool m_isPreviewDirty = false;
@ -51,7 +51,7 @@ private:
QUuid m_materialId; QUuid m_materialId;
bool m_unsaved = false; bool m_unsaved = false;
QLineEdit *m_nameEdit = nullptr; QLineEdit *m_nameEdit = nullptr;
std::vector<SkeletonMaterialLayer> m_layers; std::vector<MaterialLayer> m_layers;
QPushButton *m_textureMapButtons[(int)TextureType::Count - 1] = {nullptr}; QPushButton *m_textureMapButtons[(int)TextureType::Count - 1] = {nullptr};
}; };

View File

@ -3,10 +3,10 @@
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
#include <QClipboard> #include <QClipboard>
#include <QApplication> #include <QApplication>
#include "skeletonxml.h" #include "snapshotxml.h"
#include "materiallistwidget.h" #include "materiallistwidget.h"
MaterialListWidget::MaterialListWidget(const SkeletonDocument *document, QWidget *parent) : MaterialListWidget::MaterialListWidget(const Document *document, QWidget *parent) :
QTreeWidget(parent), QTreeWidget(parent),
m_document(document) m_document(document)
{ {
@ -27,10 +27,10 @@ MaterialListWidget::MaterialListWidget(const SkeletonDocument *document, QWidget
setContentsMargins(0, 0, 0, 0); setContentsMargins(0, 0, 0, 0);
connect(document, &SkeletonDocument::materialListChanged, this, &MaterialListWidget::reload); connect(document, &Document::materialListChanged, this, &MaterialListWidget::reload);
connect(document, &SkeletonDocument::cleanup, this, &MaterialListWidget::removeAllContent); connect(document, &Document::cleanup, this, &MaterialListWidget::removeAllContent);
connect(this, &MaterialListWidget::removeMaterial, document, &SkeletonDocument::removeMaterial); connect(this, &MaterialListWidget::removeMaterial, document, &Document::removeMaterial);
setContextMenuPolicy(Qt::CustomContextMenu); setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &QTreeWidget::customContextMenuRequested, this, &MaterialListWidget::showContextMenu); connect(this, &QTreeWidget::customContextMenuRequested, this, &MaterialListWidget::showContextMenu);
@ -200,7 +200,7 @@ void MaterialListWidget::showContextMenu(const QPoint &pos)
QAction pasteAction(tr("Paste"), this); QAction pasteAction(tr("Paste"), this);
if (m_document->hasPastableMaterialsInClipboard()) { if (m_document->hasPastableMaterialsInClipboard()) {
connect(&pasteAction, &QAction::triggered, m_document, &SkeletonDocument::paste); connect(&pasteAction, &QAction::triggered, m_document, &Document::paste);
contextMenu.addAction(&pasteAction); contextMenu.addAction(&pasteAction);
} }
@ -297,8 +297,8 @@ void MaterialListWidget::copy()
std::set<QUuid> emptySet; std::set<QUuid> emptySet;
SkeletonSnapshot snapshot; Snapshot snapshot;
m_document->toSnapshot(&snapshot, emptySet, SkeletonDocumentToSnapshotFor::Materials, m_document->toSnapshot(&snapshot, emptySet, DocumentToSnapshotFor::Materials,
emptySet, emptySet, limitMaterialIds); emptySet, emptySet, limitMaterialIds);
QString snapshotXml; QString snapshotXml;
QXmlStreamWriter xmlStreamWriter(&snapshotXml); QXmlStreamWriter xmlStreamWriter(&snapshotXml);

View File

@ -1,9 +1,9 @@
#ifndef MATERIAL_LIST_WIDGET_H #ifndef DUST3D_MATERIAL_LIST_WIDGET_H
#define MATERIAL_LIST_WIDGET_H #define DUST3D_MATERIAL_LIST_WIDGET_H
#include <QTreeWidget> #include <QTreeWidget>
#include <map> #include <map>
#include <QMouseEvent> #include <QMouseEvent>
#include "skeletondocument.h" #include "document.h"
#include "materialwidget.h" #include "materialwidget.h"
class MaterialListWidget : public QTreeWidget class MaterialListWidget : public QTreeWidget
@ -15,7 +15,7 @@ signals:
void cornerButtonClicked(QUuid materialId); void cornerButtonClicked(QUuid materialId);
void currentSelectedMaterialChanged(QUuid materialId); void currentSelectedMaterialChanged(QUuid materialId);
public: public:
MaterialListWidget(const SkeletonDocument *document, QWidget *parent=nullptr); MaterialListWidget(const Document *document, QWidget *parent=nullptr);
bool isMaterialSelected(QUuid materialId); bool isMaterialSelected(QUuid materialId);
void enableMultipleSelection(bool enabled); void enableMultipleSelection(bool enabled);
public slots: public slots:
@ -33,7 +33,7 @@ protected:
private: private:
int calculateColumnCount(); int calculateColumnCount();
void updateMaterialSelectState(QUuid materialId, bool selected); void updateMaterialSelectState(QUuid materialId, bool selected);
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
std::map<QUuid, std::pair<QTreeWidgetItem *, int>> m_itemMap; std::map<QUuid, std::pair<QTreeWidgetItem *, int>> m_itemMap;
std::set<QUuid> m_selectedMaterialIds; std::set<QUuid> m_selectedMaterialIds;
QUuid m_currentSelectedMaterialId; QUuid m_currentSelectedMaterialId;

View File

@ -6,7 +6,7 @@
#include "materialeditwidget.h" #include "materialeditwidget.h"
#include "infolabel.h" #include "infolabel.h"
MaterialManageWidget::MaterialManageWidget(const SkeletonDocument *document, QWidget *parent) : MaterialManageWidget::MaterialManageWidget(const Document *document, QWidget *parent) :
QWidget(parent), QWidget(parent),
m_document(document) m_document(document)
{ {
@ -47,7 +47,7 @@ void MaterialManageWidget::showMaterialDialog(QUuid materialId)
MaterialEditWidget *materialEditWidget = new MaterialEditWidget(m_document); MaterialEditWidget *materialEditWidget = new MaterialEditWidget(m_document);
materialEditWidget->setAttribute(Qt::WA_DeleteOnClose); materialEditWidget->setAttribute(Qt::WA_DeleteOnClose);
if (!materialId.isNull()) { if (!materialId.isNull()) {
const SkeletonMaterial *material = m_document->findMaterial(materialId); const Material *material = m_document->findMaterial(materialId);
if (nullptr != material) { if (nullptr != material) {
materialEditWidget->setEditMaterialId(materialId); materialEditWidget->setEditMaterialId(materialId);
materialEditWidget->setEditMaterialName(material->name); materialEditWidget->setEditMaterialName(material->name);

View File

@ -1,7 +1,7 @@
#ifndef MATERIAL_MANAGE_WIDGET_H #ifndef DUST3D_MATERIAL_MANAGE_WIDGET_H
#define MATERIAL_MANAGE_WIDGET_H #define DUST3D_MATERIAL_MANAGE_WIDGET_H
#include <QWidget> #include <QWidget>
#include "skeletondocument.h" #include "document.h"
#include "materiallistwidget.h" #include "materiallistwidget.h"
class MaterialManageWidget : public QWidget class MaterialManageWidget : public QWidget
@ -11,7 +11,7 @@ signals:
void registerDialog(QWidget *widget); void registerDialog(QWidget *widget);
void unregisterDialog(QWidget *widget); void unregisterDialog(QWidget *widget);
public: public:
MaterialManageWidget(const SkeletonDocument *document, QWidget *parent=nullptr); MaterialManageWidget(const Document *document, QWidget *parent=nullptr);
MaterialListWidget *materialListWidget(); MaterialListWidget *materialListWidget();
protected: protected:
virtual QSize sizeHint() const; virtual QSize sizeHint() const;
@ -19,7 +19,7 @@ public slots:
void showAddMaterialDialog(); void showAddMaterialDialog();
void showMaterialDialog(QUuid materialId); void showMaterialDialog(QUuid materialId);
private: private:
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
MaterialListWidget *m_materialListWidget = nullptr; MaterialListWidget *m_materialListWidget = nullptr;
}; };

View File

@ -2,7 +2,7 @@
#include <QElapsedTimer> #include <QElapsedTimer>
#include "materialpreviewsgenerator.h" #include "materialpreviewsgenerator.h"
#include "meshgenerator.h" #include "meshgenerator.h"
#include "skeletonxml.h" #include "snapshotxml.h"
#include "ds3file.h" #include "ds3file.h"
#include "texturegenerator.h" #include "texturegenerator.h"
#include "imageforever.h" #include "imageforever.h"
@ -18,7 +18,7 @@ MaterialPreviewsGenerator::~MaterialPreviewsGenerator()
} }
} }
void MaterialPreviewsGenerator::addMaterial(QUuid materialId, const std::vector<SkeletonMaterialLayer> &layers) void MaterialPreviewsGenerator::addMaterial(QUuid materialId, const std::vector<MaterialLayer> &layers)
{ {
m_materials.push_back({materialId, layers}); m_materials.push_back({materialId, layers});
} }
@ -37,7 +37,7 @@ MeshLoader *MaterialPreviewsGenerator::takePreview(QUuid materialId)
void MaterialPreviewsGenerator::generate() void MaterialPreviewsGenerator::generate()
{ {
SkeletonSnapshot *snapshot = new SkeletonSnapshot; Snapshot *snapshot = new Snapshot;
std::vector<QUuid> partIds; std::vector<QUuid> partIds;
Ds3FileReader ds3Reader(":/resources/material-demo-model.ds3"); Ds3FileReader ds3Reader(":/resources/material-demo-model.ds3");
@ -65,12 +65,12 @@ void MaterialPreviewsGenerator::generate()
partIds.push_back(QUuid(mirror.first)); partIds.push_back(QUuid(mirror.first));
} }
MeshResultContext *meshResultContext = meshGenerator->takeMeshResultContext(); Outcome *outcome = meshGenerator->takeMeshResultContext();
MeshLoader *resultMesh = meshGenerator->takeResultMesh(); MeshLoader *resultMesh = meshGenerator->takeResultMesh();
for (const auto &material: m_materials) { for (const auto &material: m_materials) {
TextureGenerator *textureGenerator = new TextureGenerator(*meshResultContext); TextureGenerator *textureGenerator = new TextureGenerator(*outcome);
for (const auto &layer: material.second) { for (const auto &layer: material.second) {
for (const auto &mapItem: layer.maps) { for (const auto &mapItem: layer.maps) {
const QImage *image = ImageForever::get(mapItem.imageId); const QImage *image = ImageForever::get(mapItem.imageId);
@ -102,7 +102,7 @@ void MaterialPreviewsGenerator::generate()
delete resultMesh; delete resultMesh;
delete meshResultContext; delete outcome;
delete meshGenerator; delete meshGenerator;
delete cacheContext; delete cacheContext;

View File

@ -1,11 +1,11 @@
#ifndef MATERIAL_PREVIEWS_GENERATOR_H #ifndef DUST3D_MATERIAL_PREVIEWS_GENERATOR_H
#define MATERIAL_PREVIEWS_GENERATOR_H #define DUST3D_MATERIAL_PREVIEWS_GENERATOR_H
#include <QObject> #include <QObject>
#include <map> #include <map>
#include <QUuid> #include <QUuid>
#include <vector> #include <vector>
#include "meshloader.h" #include "meshloader.h"
#include "skeletondocument.h" #include "document.h"
class MaterialPreviewsGenerator : public QObject class MaterialPreviewsGenerator : public QObject
{ {
@ -13,7 +13,7 @@ class MaterialPreviewsGenerator : public QObject
public: public:
MaterialPreviewsGenerator(); MaterialPreviewsGenerator();
~MaterialPreviewsGenerator(); ~MaterialPreviewsGenerator();
void addMaterial(QUuid materialId, const std::vector<SkeletonMaterialLayer> &layers); void addMaterial(QUuid materialId, const std::vector<MaterialLayer> &layers);
const std::set<QUuid> &generatedPreviewMaterialIds(); const std::set<QUuid> &generatedPreviewMaterialIds();
MeshLoader *takePreview(QUuid materialId); MeshLoader *takePreview(QUuid materialId);
void generate(); void generate();
@ -22,7 +22,7 @@ signals:
public slots: public slots:
void process(); void process();
private: private:
std::vector<std::pair<QUuid, std::vector<SkeletonMaterialLayer>>> m_materials; std::vector<std::pair<QUuid, std::vector<MaterialLayer>>> m_materials;
std::map<QUuid, MeshLoader *> m_previews; std::map<QUuid, MeshLoader *> m_previews;
std::set<QUuid> m_generatedMaterialIds; std::set<QUuid> m_generatedMaterialIds;
}; };

View File

@ -1,7 +1,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include "materialwidget.h" #include "materialwidget.h"
MaterialWidget::MaterialWidget(const SkeletonDocument *document, QUuid materialId) : MaterialWidget::MaterialWidget(const Document *document, QUuid materialId) :
m_materialId(materialId), m_materialId(materialId),
m_document(document) m_document(document)
{ {
@ -31,8 +31,8 @@ MaterialWidget::MaterialWidget(const SkeletonDocument *document, QUuid materialI
setFixedSize(Theme::materialPreviewImageSize, MaterialWidget::preferredHeight()); setFixedSize(Theme::materialPreviewImageSize, MaterialWidget::preferredHeight());
connect(document, &SkeletonDocument::materialNameChanged, this, &MaterialWidget::updateName); connect(document, &Document::materialNameChanged, this, &MaterialWidget::updateName);
connect(document, &SkeletonDocument::materialPreviewChanged, this, &MaterialWidget::updatePreview); connect(document, &Document::materialPreviewChanged, this, &MaterialWidget::updatePreview);
} }
void MaterialWidget::setCornerButtonVisible(bool visible) void MaterialWidget::setCornerButtonVisible(bool visible)
@ -68,7 +68,7 @@ void MaterialWidget::reload()
void MaterialWidget::updatePreview() void MaterialWidget::updatePreview()
{ {
const SkeletonMaterial *material = m_document->findMaterial(m_materialId); const Material *material = m_document->findMaterial(m_materialId);
if (!material) { if (!material) {
qDebug() << "Material not found:" << m_materialId; qDebug() << "Material not found:" << m_materialId;
return; return;
@ -79,7 +79,7 @@ void MaterialWidget::updatePreview()
void MaterialWidget::updateName() void MaterialWidget::updateName()
{ {
const SkeletonMaterial *material = m_document->findMaterial(m_materialId); const Material *material = m_document->findMaterial(m_materialId);
if (!material) { if (!material) {
qDebug() << "Material not found:" << m_materialId; qDebug() << "Material not found:" << m_materialId;
return; return;

View File

@ -1,9 +1,9 @@
#ifndef MATERIAL_WIDGET_H #ifndef DUST3D_MATERIAL_WIDGET_H
#define MATERIAL_WIDGET_H #define DUST3D_MATERIAL_WIDGET_H
#include <QFrame> #include <QFrame>
#include <QLabel> #include <QLabel>
#include <QIcon> #include <QIcon>
#include "skeletondocument.h" #include "document.h"
#include "modelwidget.h" #include "modelwidget.h"
class MaterialWidget : public QFrame class MaterialWidget : public QFrame
@ -13,7 +13,7 @@ signals:
void modifyMaterial(QUuid materialId); void modifyMaterial(QUuid materialId);
void cornerButtonClicked(QUuid materialId); void cornerButtonClicked(QUuid materialId);
public: public:
MaterialWidget(const SkeletonDocument *document, QUuid materialId); MaterialWidget(const Document *document, QUuid materialId);
static int preferredHeight(); static int preferredHeight();
ModelWidget *previewWidget(); ModelWidget *previewWidget();
protected: protected:
@ -27,7 +27,7 @@ public slots:
void setCornerButtonVisible(bool visible); void setCornerButtonVisible(bool visible);
private: private:
QUuid m_materialId; QUuid m_materialId;
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
ModelWidget *m_previewWidget = nullptr; ModelWidget *m_previewWidget = nullptr;
QLabel *m_nameLabel = nullptr; QLabel *m_nameLabel = nullptr;
QPushButton *m_cornerButton = nullptr; QPushButton *m_cornerButton = nullptr;

View File

@ -3,8 +3,8 @@
#include <QElapsedTimer> #include <QElapsedTimer>
#include <unordered_set> #include <unordered_set>
#include "meshgenerator.h" #include "meshgenerator.h"
#include "dust3dutil.h" #include "util.h"
#include "skeletondocument.h" #include "document.h"
#include "meshlite.h" #include "meshlite.h"
#include "meshutil.h" #include "meshutil.h"
#include "theme.h" #include "theme.h"
@ -32,10 +32,10 @@ void GeneratedCacheContext::updateComponentCombinableMesh(QString componentId, v
cache = cloneCombinableMesh(mesh); cache = cloneCombinableMesh(mesh);
} }
MeshGenerator::MeshGenerator(SkeletonSnapshot *snapshot) : MeshGenerator::MeshGenerator(Snapshot *snapshot) :
m_snapshot(snapshot), m_snapshot(snapshot),
m_mesh(nullptr), m_mesh(nullptr),
m_meshResultContext(nullptr), m_outcome(nullptr),
m_sharedContextWidget(nullptr), m_sharedContextWidget(nullptr),
m_cacheContext(nullptr), m_cacheContext(nullptr),
m_smoothNormal(true), m_smoothNormal(true),
@ -50,7 +50,7 @@ MeshGenerator::~MeshGenerator()
for (const auto &partPreviewMeshIt: m_partPreviewMeshMap) { for (const auto &partPreviewMeshIt: m_partPreviewMeshMap) {
delete partPreviewMeshIt.second; delete partPreviewMeshIt.second;
} }
delete m_meshResultContext; delete m_outcome;
} }
void MeshGenerator::setSmoothNormal(bool smoothNormal) void MeshGenerator::setSmoothNormal(bool smoothNormal)
@ -103,14 +103,14 @@ const std::set<QUuid> &MeshGenerator::generatedPreviewPartIds()
return m_generatedPreviewPartIds; return m_generatedPreviewPartIds;
} }
MeshResultContext *MeshGenerator::takeMeshResultContext() Outcome *MeshGenerator::takeMeshResultContext()
{ {
MeshResultContext *meshResultContext = m_meshResultContext; Outcome *outcome = m_outcome;
m_meshResultContext = nullptr; m_outcome = nullptr;
return meshResultContext; return outcome;
} }
void MeshGenerator::loadVertexSources(void *meshliteContext, int meshId, QUuid partId, const std::map<int, QUuid> &bmeshToNodeIdMap, std::vector<BmeshVertex> &bmeshVertices, void MeshGenerator::loadVertexSources(void *meshliteContext, int meshId, QUuid partId, const std::map<int, QUuid> &bmeshToNodeIdMap, std::vector<OutcomeNodeVertex> &bmeshVertices,
std::vector<std::tuple<PositionMapKey, PositionMapKey, PositionMapKey, PositionMapKey>> &bmeshQuads) std::vector<std::tuple<PositionMapKey, PositionMapKey, PositionMapKey, PositionMapKey>> &bmeshQuads)
{ {
int vertexCount = meshlite_get_vertex_count(meshliteContext, meshId); int vertexCount = meshlite_get_vertex_count(meshliteContext, meshId);
@ -122,7 +122,7 @@ void MeshGenerator::loadVertexSources(void *meshliteContext, int meshId, QUuid p
Q_ASSERT(positionCount == sourceCount); Q_ASSERT(positionCount == sourceCount);
std::vector<QVector3D> verticesPositions; std::vector<QVector3D> verticesPositions;
for (int i = 0, positionIndex = 0; i < positionCount; i++, positionIndex+=3) { for (int i = 0, positionIndex = 0; i < positionCount; i++, positionIndex+=3) {
BmeshVertex vertex; OutcomeNodeVertex vertex;
vertex.partId = partId; vertex.partId = partId;
auto findNodeId = bmeshToNodeIdMap.find(sourceBuffer[i]); auto findNodeId = bmeshToNodeIdMap.find(sourceBuffer[i]);
if (findNodeId != bmeshToNodeIdMap.end()) if (findNodeId != bmeshToNodeIdMap.end())
@ -168,10 +168,10 @@ void MeshGenerator::loadGeneratedPositionsToMeshResultContext(void *meshliteCont
int positionCount = meshlite_get_vertex_position_array(meshliteContext, triangulatedMeshId, positionBuffer, positionBufferLen) / 3; int positionCount = meshlite_get_vertex_position_array(meshliteContext, triangulatedMeshId, positionBuffer, positionBufferLen) / 3;
std::map<int, int> verticesMap; std::map<int, int> verticesMap;
for (int i = 0, positionIndex = 0; i < positionCount; i++, positionIndex+=3) { for (int i = 0, positionIndex = 0; i < positionCount; i++, positionIndex+=3) {
ResultVertex vertex; OutcomeVertex vertex;
vertex.position = QVector3D(positionBuffer[positionIndex + 0], positionBuffer[positionIndex + 1], positionBuffer[positionIndex + 2]); vertex.position = QVector3D(positionBuffer[positionIndex + 0], positionBuffer[positionIndex + 1], positionBuffer[positionIndex + 2]);
verticesMap[i] = m_meshResultContext->vertices.size(); verticesMap[i] = m_outcome->vertices.size();
m_meshResultContext->vertices.push_back(vertex); m_outcome->vertices.push_back(vertex);
} }
int faceCount = meshlite_get_face_count(meshliteContext, triangulatedMeshId); int faceCount = meshlite_get_face_count(meshliteContext, triangulatedMeshId);
int triangleIndexBufferLen = faceCount * 3; int triangleIndexBufferLen = faceCount * 3;
@ -182,12 +182,12 @@ void MeshGenerator::loadGeneratedPositionsToMeshResultContext(void *meshliteCont
int normalCount = meshlite_get_triangle_normal_array(meshliteContext, triangulatedMeshId, normalBuffer, triangleNormalBufferLen) / 3; int normalCount = meshlite_get_triangle_normal_array(meshliteContext, triangulatedMeshId, normalBuffer, triangleNormalBufferLen) / 3;
Q_ASSERT(triangleCount == normalCount); Q_ASSERT(triangleCount == normalCount);
for (int i = 0, triangleVertIndex = 0, normalIndex=0; i < triangleCount; i++, triangleVertIndex+=3, normalIndex += 3) { for (int i = 0, triangleVertIndex = 0, normalIndex=0; i < triangleCount; i++, triangleVertIndex+=3, normalIndex += 3) {
ResultTriangle triangle; OutcomeTriangle triangle;
triangle.indicies[0] = verticesMap[triangleIndexBuffer[triangleVertIndex + 0]]; triangle.indicies[0] = verticesMap[triangleIndexBuffer[triangleVertIndex + 0]];
triangle.indicies[1] = verticesMap[triangleIndexBuffer[triangleVertIndex + 1]]; triangle.indicies[1] = verticesMap[triangleIndexBuffer[triangleVertIndex + 1]];
triangle.indicies[2] = verticesMap[triangleIndexBuffer[triangleVertIndex + 2]]; triangle.indicies[2] = verticesMap[triangleIndexBuffer[triangleVertIndex + 2]];
triangle.normal = QVector3D(normalBuffer[normalIndex + 0], normalBuffer[normalIndex + 1], normalBuffer[normalIndex + 2]); triangle.normal = QVector3D(normalBuffer[normalIndex + 0], normalBuffer[normalIndex + 1], normalBuffer[normalIndex + 2]);
m_meshResultContext->triangles.push_back(triangle); m_outcome->triangles.push_back(triangle);
} }
delete[] positionBuffer; delete[] positionBuffer;
delete[] triangleIndexBuffer; delete[] triangleIndexBuffer;
@ -257,7 +257,7 @@ void *MeshGenerator::combinePartMesh(QString partId)
if (!materialIdString.isEmpty()) if (!materialIdString.isEmpty())
materialId = QUuid(materialIdString); materialId = QUuid(materialIdString);
Material partMaterial; OutcomeMaterial partMaterial;
partMaterial.color = partColor; partMaterial.color = partColor;
partMaterial.materialId = materialId; partMaterial.materialId = materialId;
@ -291,12 +291,12 @@ void *MeshGenerator::combinePartMesh(QString partId)
float z = (m_sideProfileMiddleX - valueOfKeyInMapOrEmpty(node, "z").toFloat()); float z = (m_sideProfileMiddleX - valueOfKeyInMapOrEmpty(node, "z").toFloat());
int bmeshNodeId = meshlite_bmesh_add_node(m_meshliteContext, bmeshId, x, y, z, radius); int bmeshNodeId = meshlite_bmesh_add_node(m_meshliteContext, bmeshId, x, y, z, radius);
SkeletonBoneMark boneMark = SkeletonBoneMarkFromString(valueOfKeyInMapOrEmpty(node, "boneMark").toUtf8().constData()); BoneMark boneMark = BoneMarkFromString(valueOfKeyInMapOrEmpty(node, "boneMark").toUtf8().constData());
nodeToBmeshIdMap[nodeId] = bmeshNodeId; nodeToBmeshIdMap[nodeId] = bmeshNodeId;
bmeshToNodeIdMap[bmeshNodeId] = nodeId; bmeshToNodeIdMap[bmeshNodeId] = nodeId;
BmeshNode bmeshNode; OutcomeNode bmeshNode;
bmeshNode.partId = QUuid(partId); bmeshNode.partId = QUuid(partId);
bmeshNode.origin = QVector3D(x, y, z); bmeshNode.origin = QVector3D(x, y, z);
bmeshNode.radius = radius; bmeshNode.radius = radius;
@ -305,7 +305,7 @@ void *MeshGenerator::combinePartMesh(QString partId)
bmeshNode.material.color = partColor; bmeshNode.material.color = partColor;
bmeshNode.boneMark = boneMark; bmeshNode.boneMark = boneMark;
//if (SkeletonBoneMark::None != boneMark) //if (SkeletonBoneMark::None != boneMark)
// bmeshNode.color = SkeletonBoneMarkToColor(boneMark); // bmeshNode.color = BoneMarkToColor(boneMark);
cacheBmeshNodes.push_back(bmeshNode); cacheBmeshNodes.push_back(bmeshNode);
if (xMirrored) { if (xMirrored) {
bmeshNode.partId = mirroredPartId; bmeshNode.partId = mirroredPartId;
@ -560,7 +560,7 @@ void *MeshGenerator::combineComponentMesh(QString componentId, bool *inverse)
for (size_t vertexIndex = 0; vertexIndex < positionsBeforeSmooth.size(); vertexIndex++) { for (size_t vertexIndex = 0; vertexIndex < positionsBeforeSmooth.size(); vertexIndex++) {
const auto &oldPosition = positionsBeforeSmooth[vertexIndex]; const auto &oldPosition = positionsBeforeSmooth[vertexIndex];
const auto &smoothedPosition = positionsAfterSmooth[vertexIndex]; const auto &smoothedPosition = positionsAfterSmooth[vertexIndex];
BmeshVertex source; OutcomeNodeVertex source;
if (verticesSources.findPosition(oldPosition.x(), oldPosition.y(), oldPosition.z(), &source)) { if (verticesSources.findPosition(oldPosition.x(), oldPosition.y(), oldPosition.z(), &source)) {
verticesSources.removePosition(oldPosition.x(), oldPosition.y(), oldPosition.z()); verticesSources.removePosition(oldPosition.x(), oldPosition.y(), oldPosition.z());
source.position = smoothedPosition; source.position = smoothedPosition;
@ -591,7 +591,7 @@ void MeshGenerator::generate()
m_meshliteContext = meshlite_create_context(); m_meshliteContext = meshlite_create_context();
initMeshUtils(); initMeshUtils();
m_meshResultContext = new MeshResultContext; m_outcome = new Outcome;
bool needDeleteCacheContext = false; bool needDeleteCacheContext = false;
if (nullptr == m_cacheContext) { if (nullptr == m_cacheContext) {
@ -670,11 +670,11 @@ void MeshGenerator::generate()
} }
for (const auto &verticesSourcesIt: m_cacheContext->componentVerticesSources[QUuid().toString()].map()) { for (const auto &verticesSourcesIt: m_cacheContext->componentVerticesSources[QUuid().toString()].map()) {
m_meshResultContext->bmeshVertices.push_back(verticesSourcesIt.second); m_outcome->bmeshVertices.push_back(verticesSourcesIt.second);
} }
for (const auto &bmeshNodes: m_cacheContext->partBmeshNodes) { for (const auto &bmeshNodes: m_cacheContext->partBmeshNodes) {
m_meshResultContext->bmeshNodes.insert(m_meshResultContext->bmeshNodes.end(), m_outcome->bmeshNodes.insert(m_outcome->bmeshNodes.end(),
bmeshNodes.second.begin(), bmeshNodes.second.end()); bmeshNodes.second.begin(), bmeshNodes.second.end());
} }
@ -714,7 +714,7 @@ void MeshGenerator::generate()
if (resultMeshId > 0) { if (resultMeshId > 0) {
loadGeneratedPositionsToMeshResultContext(m_meshliteContext, triangulatedFinalMeshId); loadGeneratedPositionsToMeshResultContext(m_meshliteContext, triangulatedFinalMeshId);
m_mesh = new MeshLoader(m_meshliteContext, resultMeshId, triangulatedFinalMeshId, Theme::white, &m_meshResultContext->triangleMaterials(), m_smoothNormal); m_mesh = new MeshLoader(m_meshliteContext, resultMeshId, triangulatedFinalMeshId, Theme::white, &m_outcome->triangleMaterials(), m_smoothNormal);
} }
if (needDeleteCacheContext) { if (needDeleteCacheContext) {

View File

@ -1,5 +1,5 @@
#ifndef MESH_GENERATOR_H #ifndef DUST3D_MESH_GENERATOR_H
#define MESH_GENERATOR_H #define DUST3D_MESH_GENERATOR_H
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QImage> #include <QImage>
@ -7,21 +7,21 @@
#include <set> #include <set>
#include <QThread> #include <QThread>
#include <QOpenGLWidget> #include <QOpenGLWidget>
#include "skeletonsnapshot.h" #include "snapshot.h"
#include "meshloader.h" #include "meshloader.h"
#include "meshresultcontext.h" #include "outcome.h"
#include "positionmap.h" #include "positionmap.h"
class GeneratedCacheContext class GeneratedCacheContext
{ {
public: public:
~GeneratedCacheContext(); ~GeneratedCacheContext();
std::map<QString, std::vector<BmeshVertex>> partBmeshVertices; std::map<QString, std::vector<OutcomeNodeVertex>> partBmeshVertices;
std::map<QString, std::vector<BmeshNode>> partBmeshNodes; std::map<QString, std::vector<OutcomeNode>> partBmeshNodes;
std::map<QString, std::vector<std::tuple<PositionMapKey, PositionMapKey, PositionMapKey, PositionMapKey>>> partBmeshQuads; std::map<QString, std::vector<std::tuple<PositionMapKey, PositionMapKey, PositionMapKey, PositionMapKey>>> partBmeshQuads;
std::map<QString, void *> componentCombinableMeshs; std::map<QString, void *> componentCombinableMeshs;
std::map<QString, std::vector<QVector3D>> componentPositions; std::map<QString, std::vector<QVector3D>> componentPositions;
std::map<QString, PositionMap<BmeshVertex>> componentVerticesSources; std::map<QString, PositionMap<OutcomeNodeVertex>> componentVerticesSources;
std::map<QString, QString> partMirrorIdMap; std::map<QString, QString> partMirrorIdMap;
void updateComponentCombinableMesh(QString componentId, void *mesh); void updateComponentCombinableMesh(QString componentId, void *mesh);
}; };
@ -30,7 +30,7 @@ class MeshGenerator : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
MeshGenerator(SkeletonSnapshot *snapshot); MeshGenerator(Snapshot *snapshot);
~MeshGenerator(); ~MeshGenerator();
void setSharedContextWidget(QOpenGLWidget *widget); void setSharedContextWidget(QOpenGLWidget *widget);
void addPartPreviewRequirement(const QUuid &partId); void addPartPreviewRequirement(const QUuid &partId);
@ -41,20 +41,20 @@ public:
MeshLoader *takePartPreviewMesh(const QUuid &partId); MeshLoader *takePartPreviewMesh(const QUuid &partId);
const std::set<QUuid> &requirePreviewPartIds(); const std::set<QUuid> &requirePreviewPartIds();
const std::set<QUuid> &generatedPreviewPartIds(); const std::set<QUuid> &generatedPreviewPartIds();
MeshResultContext *takeMeshResultContext(); Outcome *takeMeshResultContext();
void generate(); void generate();
signals: signals:
void finished(); void finished();
public slots: public slots:
void process(); void process();
private: private:
SkeletonSnapshot *m_snapshot; Snapshot *m_snapshot;
MeshLoader *m_mesh; MeshLoader *m_mesh;
std::map<QUuid, MeshLoader *> m_partPreviewMeshMap; std::map<QUuid, MeshLoader *> m_partPreviewMeshMap;
std::set<QUuid> m_requirePreviewPartIds; std::set<QUuid> m_requirePreviewPartIds;
std::set<QUuid> m_generatedPreviewPartIds; std::set<QUuid> m_generatedPreviewPartIds;
QThread *m_thread; QThread *m_thread;
MeshResultContext *m_meshResultContext; Outcome *m_outcome;
QOpenGLWidget *m_sharedContextWidget; QOpenGLWidget *m_sharedContextWidget;
void *m_meshliteContext; void *m_meshliteContext;
GeneratedCacheContext *m_cacheContext; GeneratedCacheContext *m_cacheContext;
@ -71,7 +71,7 @@ private:
static bool m_enableDebug; static bool m_enableDebug;
static PositionMap<int> *m_forMakePositionKey; static PositionMap<int> *m_forMakePositionKey;
private: private:
void loadVertexSources(void *meshliteContext, int meshId, QUuid partId, const std::map<int, QUuid> &bmeshToNodeIdMap, std::vector<BmeshVertex> &bmeshVertices, void loadVertexSources(void *meshliteContext, int meshId, QUuid partId, const std::map<int, QUuid> &bmeshToNodeIdMap, std::vector<OutcomeNodeVertex> &bmeshVertices,
std::vector<std::tuple<PositionMapKey, PositionMapKey, PositionMapKey, PositionMapKey>> &bmeshQuads); std::vector<std::tuple<PositionMapKey, PositionMapKey, PositionMapKey, PositionMapKey>> &bmeshQuads);
void loadGeneratedPositionsToMeshResultContext(void *meshliteContext, int triangulatedMeshId); void loadGeneratedPositionsToMeshResultContext(void *meshliteContext, int triangulatedMeshId);
void collectParts(); void collectParts();

View File

@ -14,7 +14,7 @@
float MeshLoader::m_defaultMetalness = 0.0; float MeshLoader::m_defaultMetalness = 0.0;
float MeshLoader::m_defaultRoughness = 1.0; float MeshLoader::m_defaultRoughness = 1.0;
MeshLoader::MeshLoader(void *meshlite, int meshId, int triangulatedMeshId, QColor defaultColor, const std::vector<Material> *triangleMaterials, bool smoothNormal) : MeshLoader::MeshLoader(void *meshlite, int meshId, int triangulatedMeshId, QColor defaultColor, const std::vector<OutcomeMaterial> *triangleMaterials, bool smoothNormal) :
m_triangleVertices(nullptr), m_triangleVertices(nullptr),
m_triangleVertexCount(0), m_triangleVertexCount(0),
m_edgeVertices(nullptr), m_edgeVertices(nullptr),
@ -233,26 +233,26 @@ MeshLoader::MeshLoader(Vertex *triangleVertices, int vertexNum) :
{ {
} }
MeshLoader::MeshLoader(MeshResultContext &resultContext) : MeshLoader::MeshLoader(Outcome &outcome) :
m_triangleVertices(nullptr), m_triangleVertices(nullptr),
m_triangleVertexCount(0), m_triangleVertexCount(0),
m_edgeVertices(nullptr), m_edgeVertices(nullptr),
m_edgeVertexCount(0), m_edgeVertexCount(0),
m_textureImage(nullptr) m_textureImage(nullptr)
{ {
for (const auto &part: resultContext.parts()) { for (const auto &part: outcome.parts()) {
m_triangleVertexCount += part.second.triangles.size() * 3; m_triangleVertexCount += part.second.triangles.size() * 3;
} }
m_triangleVertices = new Vertex[m_triangleVertexCount]; m_triangleVertices = new Vertex[m_triangleVertexCount];
int destIndex = 0; int destIndex = 0;
for (const auto &part: resultContext.parts()) { for (const auto &part: outcome.parts()) {
for (int x = 0; x < (int)part.second.triangles.size(); x++) { for (int x = 0; x < (int)part.second.triangles.size(); x++) {
const auto &it = part.second.triangles[x]; const auto &it = part.second.triangles[x];
for (auto i = 0; i < 3; i++) { for (auto i = 0; i < 3; i++) {
int vertexIndex = it.indicies[i]; int vertexIndex = it.indicies[i];
const ResultVertex *srcVert = &part.second.vertices[vertexIndex]; const OutcomeVertex *srcVert = &part.second.vertices[vertexIndex];
const QVector3D *srcNormal = &part.second.interpolatedTriangleVertexNormals[x * 3 + i]; const QVector3D *srcNormal = &part.second.interpolatedTriangleVertexNormals[x * 3 + i];
const ResultVertexUv *srcUv = &part.second.vertexUvs[vertexIndex]; const OutcomeVertexUv *srcUv = &part.second.vertexUvs[vertexIndex];
//const Material *srcMaterial = &part.second.material; //const Material *srcMaterial = &part.second.material;
const QVector3D *srcTangent = &part.second.triangleTangents[x]; const QVector3D *srcTangent = &part.second.triangleTangents[x];
Vertex *dest = &m_triangleVertices[destIndex]; Vertex *dest = &m_triangleVertices[destIndex];

View File

@ -1,5 +1,5 @@
#ifndef MESH_LOADER_H #ifndef DUST3D_MESH_LOADER_H
#define MESH_LOADER_H #define DUST3D_MESH_LOADER_H
#include <QObject> #include <QObject>
#include <QOpenGLFunctions> #include <QOpenGLFunctions>
#include <vector> #include <vector>
@ -9,7 +9,7 @@
#include "positionmap.h" #include "positionmap.h"
#include "theme.h" #include "theme.h"
#include "qtlightmapper.h" #include "qtlightmapper.h"
#include "meshresultcontext.h" #include "outcome.h"
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
@ -43,8 +43,8 @@ struct TriangulatedFace
class MeshLoader class MeshLoader
{ {
public: public:
MeshLoader(void *meshlite, int meshId, int triangulatedMeshId=-1, QColor defaultColor=Theme::white, const std::vector<Material> *triangleMaterials=nullptr, bool smoothNormal=true); MeshLoader(void *meshlite, int meshId, int triangulatedMeshId=-1, QColor defaultColor=Theme::white, const std::vector<OutcomeMaterial> *triangleMaterials=nullptr, bool smoothNormal=true);
MeshLoader(MeshResultContext &resultContext); MeshLoader(Outcome &outcome);
MeshLoader(Vertex *triangleVertices, int vertexNum); MeshLoader(Vertex *triangleVertices, int vertexNum);
MeshLoader(const MeshLoader &mesh); MeshLoader(const MeshLoader &mesh);
MeshLoader(); MeshLoader();

View File

@ -1,5 +1,5 @@
#ifndef MESH_QUADIFY_H #ifndef DUST3D_MESH_QUADIFY_H
#define MESH_QUADIFY_H #define DUST3D_MESH_QUADIFY_H
#include <set> #include <set>
#include "meshutil.h" #include "meshutil.h"
#include "positionmap.h" #include "positionmap.h"

View File

@ -1,29 +1,29 @@
#include <QGuiApplication> #include <QGuiApplication>
#include "meshresultpostprocessor.h" #include "meshresultpostprocessor.h"
MeshResultPostProcessor::MeshResultPostProcessor(const MeshResultContext &meshResultContext) MeshResultPostProcessor::MeshResultPostProcessor(const Outcome &outcome)
{ {
m_meshResultContext = new MeshResultContext; m_outcome = new Outcome;
*m_meshResultContext = meshResultContext; *m_outcome = outcome;
} }
MeshResultPostProcessor::~MeshResultPostProcessor() MeshResultPostProcessor::~MeshResultPostProcessor()
{ {
delete m_meshResultContext; delete m_outcome;
} }
MeshResultContext *MeshResultPostProcessor::takePostProcessedResultContext() Outcome *MeshResultPostProcessor::takePostProcessedResultContext()
{ {
MeshResultContext *resultContext = m_meshResultContext; Outcome *outcome = m_outcome;
m_meshResultContext = nullptr; m_outcome = nullptr;
return resultContext; return outcome;
} }
void MeshResultPostProcessor::process() void MeshResultPostProcessor::process()
{ {
if (!m_meshResultContext->bmeshNodes.empty()) { if (!m_outcome->bmeshNodes.empty()) {
(void)m_meshResultContext->triangleTangents(); (void)m_outcome->triangleTangents();
(void)m_meshResultContext->parts(); (void)m_outcome->parts();
} }
this->moveToThread(QGuiApplication::instance()->thread()); this->moveToThread(QGuiApplication::instance()->thread());

View File

@ -1,21 +1,21 @@
#ifndef MESH_RESULT_POST_PROCESSOR_H #ifndef DUST3D_MESH_RESULT_POST_PROCESSOR_H
#define MESH_RESULT_POST_PROCESSOR_H #define DUST3D_MESH_RESULT_POST_PROCESSOR_H
#include <QObject> #include <QObject>
#include "meshresultcontext.h" #include "outcome.h"
class MeshResultPostProcessor : public QObject class MeshResultPostProcessor : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
MeshResultPostProcessor(const MeshResultContext &meshResultContext); MeshResultPostProcessor(const Outcome &outcome);
~MeshResultPostProcessor(); ~MeshResultPostProcessor();
MeshResultContext *takePostProcessedResultContext(); Outcome *takePostProcessedResultContext();
signals: signals:
void finished(); void finished();
public slots: public slots:
void process(); void process();
private: private:
MeshResultContext *m_meshResultContext = nullptr; Outcome *m_outcome = nullptr;
}; };
#endif #endif

View File

@ -1,5 +1,5 @@
#ifndef MESH_SPLITTER_H #ifndef DUST3D_MESH_SPLITTER_H
#define MESH_SPLITTER_H #define DUST3D_MESH_SPLITTER_H
#include <set> #include <set>
class MeshSplitterTriangle class MeshSplitterTriangle

View File

@ -1,5 +1,5 @@
#ifndef MESH_UTIL_H #ifndef DUST3D_MESH_UTIL_H
#define MESH_UTIL_H #define DUST3D_MESH_UTIL_H
#include <vector> #include <vector>
#include <set> #include <set>
#include <QVector3D> #include <QVector3D>

View File

@ -1,5 +1,5 @@
#ifndef MESH_WELD_SEAM_H #ifndef DUST3D_MESH_WELD_SEAM_H
#define MESH_WELD_SEAM_H #define DUST3D_MESH_WELD_SEAM_H
#include "meshlite.h" #include "meshlite.h"
#include "positionmap.h" #include "positionmap.h"
#include <unordered_set> #include <unordered_set>

View File

@ -1,5 +1,5 @@
#ifndef MODEL_MESH_BINDER_H #ifndef DUST3D_MODEL_MESH_BINDER_H
#define MODEL_MESH_BINDER_H #define DUST3D_MODEL_MESH_BINDER_H
#include <QOpenGLVertexArrayObject> #include <QOpenGLVertexArrayObject>
#include <QMutex> #include <QMutex>
#include <QOpenGLBuffer> #include <QOpenGLBuffer>

View File

@ -1,5 +1,5 @@
#ifndef MODEL_SHADER_PROGRAM_H #ifndef DUST3D_MODEL_SHADER_PROGRAM_H
#define MODEL_SHADER_PROGRAM_H #define DUST3D_MODEL_SHADER_PROGRAM_H
#include <QOpenGLShaderProgram> #include <QOpenGLShaderProgram>
#include <QString> #include <QString>

View File

@ -4,7 +4,7 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <math.h> #include <math.h>
#include "modelwidget.h" #include "modelwidget.h"
#include "dust3dutil.h" #include "util.h"
// Modifed from http://doc.qt.io/qt-5/qtopengl-hellogl2-glwidget-cpp.html // Modifed from http://doc.qt.io/qt-5/qtopengl-hellogl2-glwidget-cpp.html

View File

@ -1,5 +1,5 @@
#ifndef MODEL_WIDGET_H #ifndef DUST3D_MODEL_WIDGET_H
#define MODEL_WIDGET_H #define DUST3D_MODEL_WIDGET_H
#include <QOpenGLWidget> #include <QOpenGLWidget>
#include <QOpenGLFunctions> #include <QOpenGLFunctions>
#include <QOpenGLVertexArrayObject> #include <QOpenGLVertexArrayObject>

View File

@ -6,7 +6,7 @@
#include "posewidget.h" #include "posewidget.h"
#include "motionwidget.h" #include "motionwidget.h"
MotionClipWidget::MotionClipWidget(const SkeletonDocument *document, QWidget *parent) : MotionClipWidget::MotionClipWidget(const Document *document, QWidget *parent) :
QFrame(parent), QFrame(parent),
m_document(document) m_document(document)
{ {
@ -17,13 +17,13 @@ QSize MotionClipWidget::preferredSize()
{ {
int preferredWidth = 0; int preferredWidth = 0;
switch (m_clip.clipType) { switch (m_clip.clipType) {
case SkeletonMotionClipType::Motion: case MotionClipType::Motion:
preferredWidth = Theme::motionPreviewImageSize; preferredWidth = Theme::motionPreviewImageSize;
break; break;
case SkeletonMotionClipType::Pose: case MotionClipType::Pose:
preferredWidth = Theme::posePreviewImageSize; preferredWidth = Theme::posePreviewImageSize;
break; break;
case SkeletonMotionClipType::Interpolation: case MotionClipType::Interpolation:
preferredWidth = Theme::normalButtonSize; preferredWidth = Theme::normalButtonSize;
break; break;
default: default:
@ -39,7 +39,7 @@ QSize MotionClipWidget::maxSize()
return QSize(maxWidth, maxHeight); return QSize(maxWidth, maxHeight);
} }
void MotionClipWidget::setClip(SkeletonMotionClip clip) void MotionClipWidget::setClip(MotionClip clip)
{ {
m_clip = clip; m_clip = clip;
reload(); reload();
@ -60,21 +60,21 @@ void MotionClipWidget::reload()
layout->addStretch(); layout->addStretch();
switch (m_clip.clipType) { switch (m_clip.clipType) {
case SkeletonMotionClipType::Motion: case MotionClipType::Motion:
{ {
MotionWidget *motionWidget = new MotionWidget(m_document, m_clip.linkToId); MotionWidget *motionWidget = new MotionWidget(m_document, m_clip.linkToId);
motionWidget->reload(); motionWidget->reload();
layout->addWidget(motionWidget); layout->addWidget(motionWidget);
} }
break; break;
case SkeletonMotionClipType::Pose: case MotionClipType::Pose:
{ {
PoseWidget *poseWidget = new PoseWidget(m_document, m_clip.linkToId); PoseWidget *poseWidget = new PoseWidget(m_document, m_clip.linkToId);
poseWidget->reload(); poseWidget->reload();
layout->addWidget(poseWidget); layout->addWidget(poseWidget);
} }
break; break;
case SkeletonMotionClipType::Interpolation: case MotionClipType::Interpolation:
{ {
QHBoxLayout *interpolationButtonLayout = new QHBoxLayout; QHBoxLayout *interpolationButtonLayout = new QHBoxLayout;
QPushButton *interpolationButton = new QPushButton(QChar(fa::arrowsh)); QPushButton *interpolationButton = new QPushButton(QChar(fa::arrowsh));

View File

@ -1,7 +1,7 @@
#ifndef MOTION_CLIP_WIDGET_H #ifndef DUST3D_MOTION_CLIP_WIDGET_H
#define MOTION_CLIP_WIDGET_H #define DUST3D_MOTION_CLIP_WIDGET_H
#include <QFrame> #include <QFrame>
#include "skeletondocument.h" #include "document.h"
class MotionClipWidget : public QFrame class MotionClipWidget : public QFrame
{ {
@ -10,18 +10,18 @@ signals:
void modifyInterpolation(); void modifyInterpolation();
public: public:
MotionClipWidget(const SkeletonDocument *document, QWidget *parent=nullptr); MotionClipWidget(const Document *document, QWidget *parent=nullptr);
QSize preferredSize(); QSize preferredSize();
static QSize maxSize(); static QSize maxSize();
public slots: public slots:
void setClip(SkeletonMotionClip clip); void setClip(MotionClip clip);
void reload(); void reload();
void updateCheckedState(bool checked); void updateCheckedState(bool checked);
private: private:
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
SkeletonMotionClip m_clip; MotionClip m_clip;
QWidget *m_reloadToWidget = nullptr; QWidget *m_reloadToWidget = nullptr;
}; };

View File

@ -6,13 +6,13 @@
#include <QDebug> #include <QDebug>
#include <QStackedWidget> #include <QStackedWidget>
#include "motioneditwidget.h" #include "motioneditwidget.h"
#include "dust3dutil.h" #include "util.h"
#include "poselistwidget.h" #include "poselistwidget.h"
#include "motionlistwidget.h" #include "motionlistwidget.h"
#include "version.h" #include "version.h"
#include "tabwidget.h" #include "tabwidget.h"
MotionEditWidget::MotionEditWidget(const SkeletonDocument *document, QWidget *parent) : MotionEditWidget::MotionEditWidget(const Document *document, QWidget *parent) :
QDialog(parent), QDialog(parent),
m_document(document) m_document(document)
{ {
@ -130,9 +130,9 @@ MotionEditWidget::MotionEditWidget(const SkeletonDocument *document, QWidget *pa
setLayout(mainLayout); setLayout(mainLayout);
connect(this, &MotionEditWidget::addMotion, m_document, &SkeletonDocument::addMotion); connect(this, &MotionEditWidget::addMotion, m_document, &Document::addMotion);
connect(this, &MotionEditWidget::renameMotion, m_document, &SkeletonDocument::renameMotion); connect(this, &MotionEditWidget::renameMotion, m_document, &Document::renameMotion);
connect(this, &MotionEditWidget::setMotionClips, m_document, &SkeletonDocument::setMotionClips); connect(this, &MotionEditWidget::setMotionClips, m_document, &Document::setMotionClips);
updateTitle(); updateTitle();
} }
@ -218,7 +218,7 @@ void MotionEditWidget::updateTitle()
setWindowTitle(unifiedWindowTitle(tr("New") + (m_unsaved ? "*" : ""))); setWindowTitle(unifiedWindowTitle(tr("New") + (m_unsaved ? "*" : "")));
return; return;
} }
const SkeletonMotion *motion = m_document->findMotion(m_motionId); const Motion *motion = m_document->findMotion(m_motionId);
if (nullptr == motion) { if (nullptr == motion) {
qDebug() << "Find motion failed:" << m_motionId; qDebug() << "Find motion failed:" << m_motionId;
return; return;
@ -226,7 +226,7 @@ void MotionEditWidget::updateTitle()
setWindowTitle(unifiedWindowTitle(motion->name + (m_unsaved ? "*" : ""))); setWindowTitle(unifiedWindowTitle(motion->name + (m_unsaved ? "*" : "")));
} }
void MotionEditWidget::setEditMotionClips(std::vector<SkeletonMotionClip> clips) void MotionEditWidget::setEditMotionClips(std::vector<MotionClip> clips)
{ {
m_timelineWidget->setClips(clips); m_timelineWidget->setClips(clips);
} }

View File

@ -1,9 +1,9 @@
#ifndef MOTION_EDIT_WIDGET_H #ifndef DUST3D_MOTION_EDIT_WIDGET_H
#define MOTION_EDIT_WIDGET_H #define DUST3D_MOTION_EDIT_WIDGET_H
#include <QDialog> #include <QDialog>
#include <QLineEdit> #include <QLineEdit>
#include <QCloseEvent> #include <QCloseEvent>
#include "skeletondocument.h" #include "document.h"
#include "motiontimelinewidget.h" #include "motiontimelinewidget.h"
#include "modelwidget.h" #include "modelwidget.h"
#include "motionsgenerator.h" #include "motionsgenerator.h"
@ -13,11 +13,11 @@ class MotionEditWidget : public QDialog
{ {
Q_OBJECT Q_OBJECT
signals: signals:
void addMotion(QString name, std::vector<SkeletonMotionClip> clips); void addMotion(QString name, std::vector<MotionClip> clips);
void setMotionClips(QUuid motionId, std::vector<SkeletonMotionClip> clips); void setMotionClips(QUuid motionId, std::vector<MotionClip> clips);
void renameMotion(QUuid motionId, QString name); void renameMotion(QUuid motionId, QString name);
public: public:
MotionEditWidget(const SkeletonDocument *document, QWidget *parent=nullptr); MotionEditWidget(const Document *document, QWidget *parent=nullptr);
~MotionEditWidget(); ~MotionEditWidget();
protected: protected:
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
@ -29,12 +29,12 @@ public slots:
void clearUnsaveState(); void clearUnsaveState();
void setEditMotionId(QUuid poseId); void setEditMotionId(QUuid poseId);
void setEditMotionName(QString name); void setEditMotionName(QString name);
void setEditMotionClips(std::vector<SkeletonMotionClip> clips); void setEditMotionClips(std::vector<MotionClip> clips);
void setUnsavedState(); void setUnsavedState();
void generatePreviews(); void generatePreviews();
void previewsReady(); void previewsReady();
private: private:
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
MotionTimelineWidget *m_timelineWidget = nullptr; MotionTimelineWidget *m_timelineWidget = nullptr;
ModelWidget *m_previewWidget = nullptr; ModelWidget *m_previewWidget = nullptr;
QUuid m_motionId; QUuid m_motionId;

View File

@ -3,10 +3,10 @@
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
#include <QClipboard> #include <QClipboard>
#include <QApplication> #include <QApplication>
#include "skeletonxml.h" #include "snapshotxml.h"
#include "motionlistwidget.h" #include "motionlistwidget.h"
MotionListWidget::MotionListWidget(const SkeletonDocument *document, QWidget *parent) : MotionListWidget::MotionListWidget(const Document *document, QWidget *parent) :
QTreeWidget(parent), QTreeWidget(parent),
m_document(document) m_document(document)
{ {
@ -27,10 +27,10 @@ MotionListWidget::MotionListWidget(const SkeletonDocument *document, QWidget *pa
setContentsMargins(0, 0, 0, 0); setContentsMargins(0, 0, 0, 0);
connect(document, &SkeletonDocument::motionListChanged, this, &MotionListWidget::reload); connect(document, &Document::motionListChanged, this, &MotionListWidget::reload);
connect(document, &SkeletonDocument::cleanup, this, &MotionListWidget::removeAllContent); connect(document, &Document::cleanup, this, &MotionListWidget::removeAllContent);
connect(this, &MotionListWidget::removeMotion, document, &SkeletonDocument::removeMotion); connect(this, &MotionListWidget::removeMotion, document, &Document::removeMotion);
setContextMenuPolicy(Qt::CustomContextMenu); setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &QTreeWidget::customContextMenuRequested, this, &MotionListWidget::showContextMenu); connect(this, &QTreeWidget::customContextMenuRequested, this, &MotionListWidget::showContextMenu);
@ -190,7 +190,7 @@ void MotionListWidget::showContextMenu(const QPoint &pos)
QAction pasteAction(tr("Paste"), this); QAction pasteAction(tr("Paste"), this);
if (m_document->hasPastableMotionsInClipboard()) { if (m_document->hasPastableMotionsInClipboard()) {
connect(&pasteAction, &QAction::triggered, m_document, &SkeletonDocument::paste); connect(&pasteAction, &QAction::triggered, m_document, &Document::paste);
contextMenu.addAction(&pasteAction); contextMenu.addAction(&pasteAction);
} }
@ -287,8 +287,8 @@ void MotionListWidget::copy()
std::set<QUuid> emptySet; std::set<QUuid> emptySet;
SkeletonSnapshot snapshot; Snapshot snapshot;
m_document->toSnapshot(&snapshot, emptySet, SkeletonDocumentToSnapshotFor::Motions, m_document->toSnapshot(&snapshot, emptySet, DocumentToSnapshotFor::Motions,
emptySet, limitMotionIds); emptySet, limitMotionIds);
QString snapshotXml; QString snapshotXml;
QXmlStreamWriter xmlStreamWriter(&snapshotXml); QXmlStreamWriter xmlStreamWriter(&snapshotXml);

View File

@ -1,9 +1,9 @@
#ifndef MOTION_LIST_WIDGET_H #ifndef DUST3D_MOTION_LIST_WIDGET_H
#define MOTION_LIST_WIDGET_H #define DUST3D_MOTION_LIST_WIDGET_H
#include <QTreeWidget> #include <QTreeWidget>
#include <map> #include <map>
#include <QMouseEvent> #include <QMouseEvent>
#include "skeletondocument.h" #include "document.h"
#include "motionwidget.h" #include "motionwidget.h"
class MotionListWidget : public QTreeWidget class MotionListWidget : public QTreeWidget
@ -14,7 +14,7 @@ signals:
void modifyMotion(QUuid motionId); void modifyMotion(QUuid motionId);
void cornerButtonClicked(QUuid motionId); void cornerButtonClicked(QUuid motionId);
public: public:
MotionListWidget(const SkeletonDocument *document, QWidget *parent=nullptr); MotionListWidget(const Document *document, QWidget *parent=nullptr);
bool isMotionSelected(QUuid motionId); bool isMotionSelected(QUuid motionId);
public slots: public slots:
void reload(); void reload();
@ -31,7 +31,7 @@ protected:
private: private:
int calculateColumnCount(); int calculateColumnCount();
void updateMotionSelectState(QUuid motionId, bool selected); void updateMotionSelectState(QUuid motionId, bool selected);
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
std::map<QUuid, std::pair<QTreeWidgetItem *, int>> m_itemMap; std::map<QUuid, std::pair<QTreeWidgetItem *, int>> m_itemMap;
std::set<QUuid> m_selectedMotionIds; std::set<QUuid> m_selectedMotionIds;
QUuid m_currentSelectedMotionId; QUuid m_currentSelectedMotionId;

View File

@ -6,7 +6,7 @@
#include "theme.h" #include "theme.h"
#include "infolabel.h" #include "infolabel.h"
MotionManageWidget::MotionManageWidget(const SkeletonDocument *document, QWidget *parent) : MotionManageWidget::MotionManageWidget(const Document *document, QWidget *parent) :
QWidget(parent), QWidget(parent),
m_document(document) m_document(document)
{ {
@ -35,8 +35,8 @@ MotionManageWidget::MotionManageWidget(const SkeletonDocument *document, QWidget
} }
}; };
connect(m_document, &SkeletonDocument::resultRigChanged, this, refreshInfoLabel); connect(m_document, &Document::resultRigChanged, this, refreshInfoLabel);
connect(m_document, &SkeletonDocument::cleanup, this, refreshInfoLabel); connect(m_document, &Document::cleanup, this, refreshInfoLabel);
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(infoLabel); mainLayout->addWidget(infoLabel);
@ -61,7 +61,7 @@ void MotionManageWidget::showMotionDialog(QUuid motionId)
MotionEditWidget *motionEditWidget = new MotionEditWidget(m_document); MotionEditWidget *motionEditWidget = new MotionEditWidget(m_document);
motionEditWidget->setAttribute(Qt::WA_DeleteOnClose); motionEditWidget->setAttribute(Qt::WA_DeleteOnClose);
if (!motionId.isNull()) { if (!motionId.isNull()) {
const SkeletonMotion *motion = m_document->findMotion(motionId); const Motion *motion = m_document->findMotion(motionId);
if (nullptr != motion) { if (nullptr != motion) {
motionEditWidget->setEditMotionId(motionId); motionEditWidget->setEditMotionId(motionId);
motionEditWidget->setEditMotionName(motion->name); motionEditWidget->setEditMotionName(motion->name);

View File

@ -1,7 +1,7 @@
#ifndef MOTION_MANAGE_WIDGET_H #ifndef DUST3D_MOTION_MANAGE_WIDGET_H
#define MOTION_MANAGE_WIDGET_H #define DUST3D_MOTION_MANAGE_WIDGET_H
#include <QWidget> #include <QWidget>
#include "skeletondocument.h" #include "document.h"
#include "motionlistwidget.h" #include "motionlistwidget.h"
class MotionManageWidget : public QWidget class MotionManageWidget : public QWidget
@ -11,14 +11,14 @@ signals:
void registerDialog(QWidget *widget); void registerDialog(QWidget *widget);
void unregisterDialog(QWidget *widget); void unregisterDialog(QWidget *widget);
public: public:
MotionManageWidget(const SkeletonDocument *document, QWidget *parent=nullptr); MotionManageWidget(const Document *document, QWidget *parent=nullptr);
protected: protected:
virtual QSize sizeHint() const; virtual QSize sizeHint() const;
public slots: public slots:
void showAddMotionDialog(); void showAddMotionDialog();
void showMotionDialog(QUuid motionId); void showMotionDialog(QUuid motionId);
private: private:
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
MotionListWidget *m_motionListWidget = nullptr; MotionListWidget *m_motionListWidget = nullptr;
}; };

View File

@ -7,10 +7,10 @@
MotionsGenerator::MotionsGenerator(const std::vector<AutoRiggerBone> *rigBones, MotionsGenerator::MotionsGenerator(const std::vector<AutoRiggerBone> *rigBones,
const std::map<int, AutoRiggerVertexWeights> *rigWeights, const std::map<int, AutoRiggerVertexWeights> *rigWeights,
const MeshResultContext &meshResultContext) : const Outcome &outcome) :
m_rigBones(*rigBones), m_rigBones(*rigBones),
m_rigWeights(*rigWeights), m_rigWeights(*rigWeights),
m_meshResultContext(meshResultContext) m_outcome(outcome)
{ {
} }
@ -29,7 +29,7 @@ void MotionsGenerator::addPoseToLibrary(const QUuid &poseId, const std::map<QStr
m_poses[poseId] = parameters; m_poses[poseId] = parameters;
} }
void MotionsGenerator::addMotionToLibrary(const QUuid &motionId, const std::vector<SkeletonMotionClip> &clips) void MotionsGenerator::addMotionToLibrary(const QUuid &motionId, const std::vector<MotionClip> &clips)
{ {
m_motions[motionId] = clips; m_motions[motionId] = clips;
} }
@ -49,19 +49,19 @@ const std::set<QUuid> &MotionsGenerator::generatedMotionIds()
return m_generatedMotionIds; return m_generatedMotionIds;
} }
std::vector<SkeletonMotionClip> *MotionsGenerator::findMotionClips(const QUuid &motionId) std::vector<MotionClip> *MotionsGenerator::findMotionClips(const QUuid &motionId)
{ {
auto findMotionResult = m_motions.find(motionId); auto findMotionResult = m_motions.find(motionId);
if (findMotionResult == m_motions.end()) if (findMotionResult == m_motions.end())
return nullptr; return nullptr;
std::vector<SkeletonMotionClip> &clips = findMotionResult->second; std::vector<MotionClip> &clips = findMotionResult->second;
return &clips; return &clips;
} }
void MotionsGenerator::generatePreviewsForOutcomes(const std::vector<std::pair<float, JointNodeTree>> &outcomes, std::vector<std::pair<float, MeshLoader *>> &previews) void MotionsGenerator::generatePreviewsForOutcomes(const std::vector<std::pair<float, JointNodeTree>> &outcomes, std::vector<std::pair<float, MeshLoader *>> &previews)
{ {
for (const auto &item: outcomes) { for (const auto &item: outcomes) {
PoseMeshCreator *poseMeshCreator = new PoseMeshCreator(item.second.nodes(), m_meshResultContext, m_rigWeights); PoseMeshCreator *poseMeshCreator = new PoseMeshCreator(item.second.nodes(), m_outcome, m_rigWeights);
poseMeshCreator->createMesh(); poseMeshCreator->createMesh();
previews.push_back({item.first, poseMeshCreator->takeResultMesh()}); previews.push_back({item.first, poseMeshCreator->takeResultMesh()});
delete poseMeshCreator; delete poseMeshCreator;
@ -70,7 +70,7 @@ void MotionsGenerator::generatePreviewsForOutcomes(const std::vector<std::pair<f
float MotionsGenerator::calculateMotionDuration(const QUuid &motionId, std::set<QUuid> &visited) float MotionsGenerator::calculateMotionDuration(const QUuid &motionId, std::set<QUuid> &visited)
{ {
const std::vector<SkeletonMotionClip> *motionClips = findMotionClips(motionId); const std::vector<MotionClip> *motionClips = findMotionClips(motionId);
if (!motionClips || motionClips->empty()) if (!motionClips || motionClips->empty())
return 0; return 0;
if (visited.find(motionId) != visited.end()) { if (visited.find(motionId) != visited.end()) {
@ -80,11 +80,11 @@ float MotionsGenerator::calculateMotionDuration(const QUuid &motionId, std::set<
float totalDuration = 0; float totalDuration = 0;
visited.insert(motionId); visited.insert(motionId);
for (const auto &clip: *motionClips) { for (const auto &clip: *motionClips) {
if (clip.clipType == SkeletonMotionClipType::Interpolation) if (clip.clipType == MotionClipType::Interpolation)
totalDuration += clip.duration; totalDuration += clip.duration;
else if (clip.clipType == SkeletonMotionClipType::Pose) else if (clip.clipType == MotionClipType::Pose)
totalDuration += clip.duration; totalDuration += clip.duration;
else if (clip.clipType == SkeletonMotionClipType::Motion) else if (clip.clipType == MotionClipType::Motion)
totalDuration += calculateMotionDuration(clip.linkToId, visited); totalDuration += calculateMotionDuration(clip.linkToId, visited);
} }
return totalDuration; return totalDuration;
@ -99,14 +99,14 @@ void MotionsGenerator::generateMotion(const QUuid &motionId, std::set<QUuid> &vi
visited.insert(motionId); visited.insert(motionId);
std::vector<SkeletonMotionClip> *motionClips = findMotionClips(motionId); std::vector<MotionClip> *motionClips = findMotionClips(motionId);
if (!motionClips || motionClips->empty()) if (!motionClips || motionClips->empty())
return; return;
std::vector<float> timePoints; std::vector<float> timePoints;
float totalDuration = 0; float totalDuration = 0;
for (auto &clip: *motionClips) { for (auto &clip: *motionClips) {
if (clip.clipType == SkeletonMotionClipType::Motion) { if (clip.clipType == MotionClipType::Motion) {
std::set<QUuid> subVisited; std::set<QUuid> subVisited;
clip.duration = calculateMotionDuration(clip.linkToId, subVisited); clip.duration = calculateMotionDuration(clip.linkToId, subVisited);
} }
@ -131,8 +131,8 @@ void MotionsGenerator::generateMotion(const QUuid &motionId, std::set<QUuid> &vi
break; break;
} }
float clipLocalProgress = progress - timePoints[clipIndex]; float clipLocalProgress = progress - timePoints[clipIndex];
const SkeletonMotionClip &progressClip = (*motionClips)[clipIndex]; const MotionClip &progressClip = (*motionClips)[clipIndex];
if (SkeletonMotionClipType::Interpolation == progressClip.clipType) { if (MotionClipType::Interpolation == progressClip.clipType) {
if (clipIndex <= 0) { if (clipIndex <= 0) {
qDebug() << "Clip type is interpolation, but clip sit at begin"; qDebug() << "Clip type is interpolation, but clip sit at begin";
break; break;
@ -156,7 +156,7 @@ void MotionsGenerator::generateMotion(const QUuid &motionId, std::set<QUuid> &vi
lastProgress = progress; lastProgress = progress;
progress += interval; progress += interval;
continue; continue;
} else if (SkeletonMotionClipType::Pose == progressClip.clipType) { } else if (MotionClipType::Pose == progressClip.clipType) {
const JointNodeTree *beginJointNodeTree = findClipBeginJointNodeTree((*motionClips)[clipIndex]); const JointNodeTree *beginJointNodeTree = findClipBeginJointNodeTree((*motionClips)[clipIndex]);
if (nullptr == beginJointNodeTree) { if (nullptr == beginJointNodeTree) {
qDebug() << "findClipBeginJointNodeTree failed"; qDebug() << "findClipBeginJointNodeTree failed";
@ -166,7 +166,7 @@ void MotionsGenerator::generateMotion(const QUuid &motionId, std::set<QUuid> &vi
lastProgress = progress; lastProgress = progress;
progress += interval; progress += interval;
continue; continue;
} else if (SkeletonMotionClipType::Motion == progressClip.clipType) { } else if (MotionClipType::Motion == progressClip.clipType) {
generateMotion(progressClip.linkToId, visited, outcomes); generateMotion(progressClip.linkToId, visited, outcomes);
progress += progressClip.duration; progress += progressClip.duration;
continue; continue;
@ -193,13 +193,13 @@ const JointNodeTree &MotionsGenerator::poseJointNodeTree(const QUuid &poseId)
return insertResult.first->second; return insertResult.first->second;
} }
const JointNodeTree *MotionsGenerator::findClipBeginJointNodeTree(const SkeletonMotionClip &clip) const JointNodeTree *MotionsGenerator::findClipBeginJointNodeTree(const MotionClip &clip)
{ {
if (SkeletonMotionClipType::Pose == clip.clipType) { if (MotionClipType::Pose == clip.clipType) {
const JointNodeTree &jointNodeTree = poseJointNodeTree(clip.linkToId); const JointNodeTree &jointNodeTree = poseJointNodeTree(clip.linkToId);
return &jointNodeTree; return &jointNodeTree;
} else if (SkeletonMotionClipType::Motion == clip.clipType) { } else if (MotionClipType::Motion == clip.clipType) {
const std::vector<SkeletonMotionClip> *motionClips = findMotionClips(clip.linkToId); const std::vector<MotionClip> *motionClips = findMotionClips(clip.linkToId);
if (nullptr != motionClips && !motionClips->empty()) { if (nullptr != motionClips && !motionClips->empty()) {
return findClipBeginJointNodeTree((*motionClips)[0]); return findClipBeginJointNodeTree((*motionClips)[0]);
} }
@ -208,13 +208,13 @@ const JointNodeTree *MotionsGenerator::findClipBeginJointNodeTree(const Skeleton
return nullptr; return nullptr;
} }
const JointNodeTree *MotionsGenerator::findClipEndJointNodeTree(const SkeletonMotionClip &clip) const JointNodeTree *MotionsGenerator::findClipEndJointNodeTree(const MotionClip &clip)
{ {
if (SkeletonMotionClipType::Pose == clip.clipType) { if (MotionClipType::Pose == clip.clipType) {
const JointNodeTree &jointNodeTree = poseJointNodeTree(clip.linkToId); const JointNodeTree &jointNodeTree = poseJointNodeTree(clip.linkToId);
return &jointNodeTree; return &jointNodeTree;
} else if (SkeletonMotionClipType::Motion == clip.clipType) { } else if (MotionClipType::Motion == clip.clipType) {
const std::vector<SkeletonMotionClip> *motionClips = findMotionClips(clip.linkToId); const std::vector<MotionClip> *motionClips = findMotionClips(clip.linkToId);
if (nullptr != motionClips && !motionClips->empty()) { if (nullptr != motionClips && !motionClips->empty()) {
return findClipEndJointNodeTree((*motionClips)[motionClips->size() - 1]); return findClipEndJointNodeTree((*motionClips)[motionClips->size() - 1]);
} }

View File

@ -1,5 +1,5 @@
#ifndef MOTIONS_GENERATOR_H #ifndef DUST3D_MOTIONS_GENERATOR_H
#define MOTIONS_GENERATOR_H #define DUST3D_MOTIONS_GENERATOR_H
#include <QObject> #include <QObject>
#include <vector> #include <vector>
#include <map> #include <map>
@ -7,7 +7,7 @@
#include "meshloader.h" #include "meshloader.h"
#include "autorigger.h" #include "autorigger.h"
#include "jointnodetree.h" #include "jointnodetree.h"
#include "skeletondocument.h" #include "document.h"
#include "tetrapodposer.h" #include "tetrapodposer.h"
class MotionsGenerator : public QObject class MotionsGenerator : public QObject
@ -16,10 +16,10 @@ class MotionsGenerator : public QObject
public: public:
MotionsGenerator(const std::vector<AutoRiggerBone> *rigBones, MotionsGenerator(const std::vector<AutoRiggerBone> *rigBones,
const std::map<int, AutoRiggerVertexWeights> *rigWeights, const std::map<int, AutoRiggerVertexWeights> *rigWeights,
const MeshResultContext &meshResultContext); const Outcome &outcome);
~MotionsGenerator(); ~MotionsGenerator();
void addPoseToLibrary(const QUuid &poseId, const std::map<QString, std::map<QString, QString>> &parameters); void addPoseToLibrary(const QUuid &poseId, const std::map<QString, std::map<QString, QString>> &parameters);
void addMotionToLibrary(const QUuid &motionId, const std::vector<SkeletonMotionClip> &clips); void addMotionToLibrary(const QUuid &motionId, const std::vector<MotionClip> &clips);
void addRequirement(const QUuid &motionId); void addRequirement(const QUuid &motionId);
std::vector<std::pair<float, MeshLoader *>> takeResultPreviewMeshs(const QUuid &motionId); std::vector<std::pair<float, MeshLoader *>> takeResultPreviewMeshs(const QUuid &motionId);
std::vector<std::pair<float, JointNodeTree>> takeResultJointNodeTrees(const QUuid &motionId); std::vector<std::pair<float, JointNodeTree>> takeResultJointNodeTrees(const QUuid &motionId);
@ -36,17 +36,17 @@ private:
void generateMotion(const QUuid &motionId, std::set<QUuid> &visited, std::vector<std::pair<float, JointNodeTree>> &outcomes); void generateMotion(const QUuid &motionId, std::set<QUuid> &visited, std::vector<std::pair<float, JointNodeTree>> &outcomes);
const JointNodeTree &poseJointNodeTree(const QUuid &poseId); const JointNodeTree &poseJointNodeTree(const QUuid &poseId);
JointNodeTree generateInterpolation(InterpolationType interpolationType, const JointNodeTree &first, const JointNodeTree &second, float progress); JointNodeTree generateInterpolation(InterpolationType interpolationType, const JointNodeTree &first, const JointNodeTree &second, float progress);
const JointNodeTree *findClipBeginJointNodeTree(const SkeletonMotionClip &clip); const JointNodeTree *findClipBeginJointNodeTree(const MotionClip &clip);
const JointNodeTree *findClipEndJointNodeTree(const SkeletonMotionClip &clip); const JointNodeTree *findClipEndJointNodeTree(const MotionClip &clip);
std::vector<SkeletonMotionClip> *findMotionClips(const QUuid &motionId); std::vector<MotionClip> *findMotionClips(const QUuid &motionId);
void generatePreviewsForOutcomes(const std::vector<std::pair<float, JointNodeTree>> &outcomes, std::vector<std::pair<float, MeshLoader *>> &previews); void generatePreviewsForOutcomes(const std::vector<std::pair<float, JointNodeTree>> &outcomes, std::vector<std::pair<float, MeshLoader *>> &previews);
float calculateMotionDuration(const QUuid &motionId, std::set<QUuid> &visited); float calculateMotionDuration(const QUuid &motionId, std::set<QUuid> &visited);
std::vector<AutoRiggerBone> m_rigBones; std::vector<AutoRiggerBone> m_rigBones;
std::map<int, AutoRiggerVertexWeights> m_rigWeights; std::map<int, AutoRiggerVertexWeights> m_rigWeights;
MeshResultContext m_meshResultContext; Outcome m_outcome;
std::map<QUuid, std::map<QString, std::map<QString, QString>>> m_poses; std::map<QUuid, std::map<QString, std::map<QString, QString>>> m_poses;
std::map<QUuid, std::vector<SkeletonMotionClip>> m_motions; std::map<QUuid, std::vector<MotionClip>> m_motions;
std::set<QUuid> m_requiredMotionIds; std::set<QUuid> m_requiredMotionIds;
std::set<QUuid> m_generatedMotionIds; std::set<QUuid> m_generatedMotionIds;
std::map<QUuid, std::vector<std::pair<float, MeshLoader *>>> m_resultPreviewMeshs; std::map<QUuid, std::vector<std::pair<float, MeshLoader *>>> m_resultPreviewMeshs;

View File

@ -11,7 +11,7 @@
#include "posewidget.h" #include "posewidget.h"
#include "motionwidget.h" #include "motionwidget.h"
MotionTimelineWidget::MotionTimelineWidget(const SkeletonDocument *document, QWidget *parent) : MotionTimelineWidget::MotionTimelineWidget(const Document *document, QWidget *parent) :
QListWidget(parent), QListWidget(parent),
m_document(document) m_document(document)
{ {
@ -39,12 +39,12 @@ QSize MotionTimelineWidget::sizeHint() const
return QSize(0, MotionClipWidget::maxSize().height() + 4); return QSize(0, MotionClipWidget::maxSize().height() + 4);
} }
const std::vector<SkeletonMotionClip> &MotionTimelineWidget::clips() const std::vector<MotionClip> &MotionTimelineWidget::clips()
{ {
return m_clips; return m_clips;
} }
void MotionTimelineWidget::setClips(std::vector<SkeletonMotionClip> clips) void MotionTimelineWidget::setClips(std::vector<MotionClip> clips)
{ {
m_clips = clips; m_clips = clips;
if (m_currentSelectedIndex >= (int)m_clips.size()) if (m_currentSelectedIndex >= (int)m_clips.size())
@ -54,38 +54,38 @@ void MotionTimelineWidget::setClips(std::vector<SkeletonMotionClip> clips)
void MotionTimelineWidget::addPose(QUuid poseId) void MotionTimelineWidget::addPose(QUuid poseId)
{ {
SkeletonMotionClip clip; MotionClip clip;
clip.linkToId = poseId; clip.linkToId = poseId;
clip.clipType = SkeletonMotionClipType::Pose; clip.clipType = MotionClipType::Pose;
clip.duration = 0; clip.duration = 0;
addClipAfterCurrentIndex(clip); addClipAfterCurrentIndex(clip);
emit clipsChanged(); emit clipsChanged();
reload(); reload();
} }
void MotionTimelineWidget::addClipAfterCurrentIndex(const SkeletonMotionClip &clip) void MotionTimelineWidget::addClipAfterCurrentIndex(const MotionClip &clip)
{ {
SkeletonMotionClip interpolationClip; MotionClip interpolationClip;
bool needPrependInterpolationClip = false; bool needPrependInterpolationClip = false;
int afterIndex = m_currentSelectedIndex; int afterIndex = m_currentSelectedIndex;
if (-1 == afterIndex) if (-1 == afterIndex)
afterIndex = m_clips.size() - 1; afterIndex = m_clips.size() - 1;
if (-1 != afterIndex) { if (-1 != afterIndex) {
if (m_clips[afterIndex].clipType == SkeletonMotionClipType::Interpolation) { if (m_clips[afterIndex].clipType == MotionClipType::Interpolation) {
--afterIndex; --afterIndex;
} }
} }
if (clip.clipType == SkeletonMotionClipType::Interpolation) { if (clip.clipType == MotionClipType::Interpolation) {
if (m_clips.empty()) if (m_clips.empty())
return; return;
if (m_clips[m_clips.size() - 1].clipType == SkeletonMotionClipType::Interpolation) if (m_clips[m_clips.size() - 1].clipType == MotionClipType::Interpolation)
return; return;
} else { } else {
if (!m_clips.empty() && m_clips[m_clips.size() - 1].clipType != SkeletonMotionClipType::Interpolation) { if (!m_clips.empty() && m_clips[m_clips.size() - 1].clipType != MotionClipType::Interpolation) {
interpolationClip.interpolationType = InterpolationType::EaseInOutCubic; interpolationClip.interpolationType = InterpolationType::EaseInOutCubic;
interpolationClip.clipType = SkeletonMotionClipType::Interpolation; interpolationClip.clipType = MotionClipType::Interpolation;
interpolationClip.duration = 1.0; interpolationClip.duration = 1.0;
needPrependInterpolationClip = true; needPrependInterpolationClip = true;
} }
@ -104,9 +104,9 @@ void MotionTimelineWidget::addClipAfterCurrentIndex(const SkeletonMotionClip &cl
void MotionTimelineWidget::addMotion(QUuid motionId) void MotionTimelineWidget::addMotion(QUuid motionId)
{ {
SkeletonMotionClip clip; MotionClip clip;
clip.linkToId = motionId; clip.linkToId = motionId;
clip.clipType = SkeletonMotionClipType::Motion; clip.clipType = MotionClipType::Motion;
clip.duration = 0; clip.duration = 0;
addClipAfterCurrentIndex(clip); addClipAfterCurrentIndex(clip);
emit clipsChanged(); emit clipsChanged();
@ -118,7 +118,7 @@ void MotionTimelineWidget::setClipInterpolationType(int index, InterpolationType
if (index >= (int)m_clips.size()) if (index >= (int)m_clips.size())
return; return;
if (m_clips[index].clipType != SkeletonMotionClipType::Interpolation) if (m_clips[index].clipType != MotionClipType::Interpolation)
return; return;
m_clips[index].interpolationType = type; m_clips[index].interpolationType = type;
@ -130,7 +130,7 @@ void MotionTimelineWidget::setClipDuration(int index, float duration)
if (index >= (int)m_clips.size()) if (index >= (int)m_clips.size())
return; return;
if (m_clips[index].clipType == SkeletonMotionClipType::Motion) if (m_clips[index].clipType == MotionClipType::Motion)
return; return;
m_clips[index].duration = duration; m_clips[index].duration = duration;
@ -284,7 +284,7 @@ void MotionTimelineWidget::showContextMenu(const QPoint &pos)
QAction doubleDurationAction(tr("Double Duration"), this); QAction doubleDurationAction(tr("Double Duration"), this);
if (-1 != m_currentSelectedIndex) { if (-1 != m_currentSelectedIndex) {
if (m_clips[m_currentSelectedIndex].clipType == SkeletonMotionClipType::Interpolation) { if (m_clips[m_currentSelectedIndex].clipType == MotionClipType::Interpolation) {
connect(&doubleDurationAction, &QAction::triggered, [=]() { connect(&doubleDurationAction, &QAction::triggered, [=]() {
setClipDuration(m_currentSelectedIndex, m_clips[m_currentSelectedIndex].duration * 2); setClipDuration(m_currentSelectedIndex, m_clips[m_currentSelectedIndex].duration * 2);
}); });
@ -294,7 +294,7 @@ void MotionTimelineWidget::showContextMenu(const QPoint &pos)
QAction halveDurationAction(tr("Halve Duration"), this); QAction halveDurationAction(tr("Halve Duration"), this);
if (-1 != m_currentSelectedIndex) { if (-1 != m_currentSelectedIndex) {
if (m_clips[m_currentSelectedIndex].clipType == SkeletonMotionClipType::Interpolation) { if (m_clips[m_currentSelectedIndex].clipType == MotionClipType::Interpolation) {
connect(&halveDurationAction, &QAction::triggered, [=]() { connect(&halveDurationAction, &QAction::triggered, [=]() {
setClipDuration(m_currentSelectedIndex, m_clips[m_currentSelectedIndex].duration / 2); setClipDuration(m_currentSelectedIndex, m_clips[m_currentSelectedIndex].duration / 2);
}); });
@ -304,7 +304,7 @@ void MotionTimelineWidget::showContextMenu(const QPoint &pos)
QAction deleteAction(tr("Delete"), this); QAction deleteAction(tr("Delete"), this);
if (-1 != m_currentSelectedIndex) { if (-1 != m_currentSelectedIndex) {
if (m_clips[m_currentSelectedIndex].clipType != SkeletonMotionClipType::Interpolation) { if (m_clips[m_currentSelectedIndex].clipType != MotionClipType::Interpolation) {
connect(&deleteAction, &QAction::triggered, [=]() { connect(&deleteAction, &QAction::triggered, [=]() {
removeClip(m_currentSelectedIndex); removeClip(m_currentSelectedIndex);
}); });

View File

@ -1,9 +1,9 @@
#ifndef MOTION_TIMELINE_WIDGET_H #ifndef DUST3D_MOTION_TIMELINE_WIDGET_H
#define MOTION_TIMELINE_WIDGET_H #define DUST3D_MOTION_TIMELINE_WIDGET_H
#include <QListWidget> #include <QListWidget>
#include <QUuid> #include <QUuid>
#include <QMouseEvent> #include <QMouseEvent>
#include "skeletondocument.h" #include "document.h"
#include "interpolationtype.h" #include "interpolationtype.h"
class MotionTimelineWidget : public QListWidget class MotionTimelineWidget : public QListWidget
@ -12,11 +12,11 @@ class MotionTimelineWidget : public QListWidget
signals: signals:
void clipsChanged(); void clipsChanged();
public: public:
MotionTimelineWidget(const SkeletonDocument *document, QWidget *parent=nullptr); MotionTimelineWidget(const Document *document, QWidget *parent=nullptr);
const std::vector<SkeletonMotionClip> &clips(); const std::vector<MotionClip> &clips();
public slots: public slots:
void setClips(std::vector<SkeletonMotionClip> clips); void setClips(std::vector<MotionClip> clips);
void addPose(QUuid poseId); void addPose(QUuid poseId);
void addMotion(QUuid motionId); void addMotion(QUuid motionId);
void reload(); void reload();
@ -32,10 +32,10 @@ protected:
QSize sizeHint() const override; QSize sizeHint() const override;
private: private:
void addClipAfterCurrentIndex(const SkeletonMotionClip &clip); void addClipAfterCurrentIndex(const MotionClip &clip);
std::vector<SkeletonMotionClip> m_clips; std::vector<MotionClip> m_clips;
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
int m_currentSelectedIndex = -1; int m_currentSelectedIndex = -1;
}; };

View File

@ -1,7 +1,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include "motionwidget.h" #include "motionwidget.h"
MotionWidget::MotionWidget(const SkeletonDocument *document, QUuid motionId) : MotionWidget::MotionWidget(const Document *document, QUuid motionId) :
m_motionId(motionId), m_motionId(motionId),
m_document(document) m_document(document)
{ {
@ -31,12 +31,12 @@ MotionWidget::MotionWidget(const SkeletonDocument *document, QUuid motionId) :
setFixedSize(Theme::motionPreviewImageSize, MotionWidget::preferredHeight()); setFixedSize(Theme::motionPreviewImageSize, MotionWidget::preferredHeight());
connect(document, &SkeletonDocument::motionNameChanged, this, [=](QUuid motionId) { connect(document, &Document::motionNameChanged, this, [=](QUuid motionId) {
if (motionId != m_motionId) if (motionId != m_motionId)
return; return;
updateName(); updateName();
}); });
connect(document, &SkeletonDocument::motionPreviewChanged, this, [=](QUuid motionId) { connect(document, &Document::motionPreviewChanged, this, [=](QUuid motionId) {
if (motionId != m_motionId) if (motionId != m_motionId)
return; return;
updatePreview(); updatePreview();
@ -76,7 +76,7 @@ void MotionWidget::reload()
void MotionWidget::updatePreview() void MotionWidget::updatePreview()
{ {
const SkeletonMotion *motion = m_document->findMotion(m_motionId); const Motion *motion = m_document->findMotion(m_motionId);
if (!motion) { if (!motion) {
qDebug() << "Motion not found:" << m_motionId; qDebug() << "Motion not found:" << m_motionId;
return; return;
@ -87,7 +87,7 @@ void MotionWidget::updatePreview()
void MotionWidget::updateName() void MotionWidget::updateName()
{ {
const SkeletonMotion *motion = m_document->findMotion(m_motionId); const Motion *motion = m_document->findMotion(m_motionId);
if (!motion) { if (!motion) {
qDebug() << "Motion not found:" << m_motionId; qDebug() << "Motion not found:" << m_motionId;
return; return;

View File

@ -1,9 +1,9 @@
#ifndef MOTION_WIDGET_H #ifndef DUST3D_MOTION_WIDGET_H
#define MOTION_WIDGET_H #define DUST3D_MOTION_WIDGET_H
#include <QFrame> #include <QFrame>
#include <QLabel> #include <QLabel>
#include <QIcon> #include <QIcon>
#include "skeletondocument.h" #include "document.h"
#include "modelwidget.h" #include "modelwidget.h"
class MotionWidget : public QFrame class MotionWidget : public QFrame
@ -13,7 +13,7 @@ signals:
void modifyMotion(QUuid motionId); void modifyMotion(QUuid motionId);
void cornerButtonClicked(QUuid motionId); void cornerButtonClicked(QUuid motionId);
public: public:
MotionWidget(const SkeletonDocument *document, QUuid motionId); MotionWidget(const Document *document, QUuid motionId);
static int preferredHeight(); static int preferredHeight();
ModelWidget *previewWidget(); ModelWidget *previewWidget();
protected: protected:
@ -27,7 +27,7 @@ public slots:
void setCornerButtonVisible(bool visible); void setCornerButtonVisible(bool visible);
private: private:
QUuid m_motionId; QUuid m_motionId;
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
ModelWidget *m_previewWidget = nullptr; ModelWidget *m_previewWidget = nullptr;
QLabel *m_nameLabel = nullptr; QLabel *m_nameLabel = nullptr;
QPushButton *m_cornerButton = nullptr; QPushButton *m_cornerButton = nullptr;

View File

@ -7,7 +7,7 @@
#include <simpleuv/uvunwrapper.h> #include <simpleuv/uvunwrapper.h>
#include "texturegenerator.h" #include "texturegenerator.h"
#include "theme.h" #include "theme.h"
#include "meshresultcontext.h" #include "outcome.h"
#include "positionmap.h" #include "positionmap.h"
#include "anglesmooth.h" #include "anglesmooth.h"
@ -26,7 +26,7 @@ struct CandidateEdge
float length; float length;
}; };
MeshResultContext::MeshResultContext() : Outcome::Outcome() :
m_triangleSourceResolved(false), m_triangleSourceResolved(false),
m_triangleMaterialResolved(false), m_triangleMaterialResolved(false),
m_triangleEdgeSourceMapResolved(false), m_triangleEdgeSourceMapResolved(false),
@ -38,7 +38,7 @@ MeshResultContext::MeshResultContext() :
{ {
} }
const std::vector<std::pair<QUuid, QUuid>> &MeshResultContext::triangleSourceNodes() const std::vector<std::pair<QUuid, QUuid>> &Outcome::triangleSourceNodes()
{ {
if (!m_triangleSourceResolved) { if (!m_triangleSourceResolved) {
m_triangleSourceResolved = true; m_triangleSourceResolved = true;
@ -48,7 +48,7 @@ const std::vector<std::pair<QUuid, QUuid>> &MeshResultContext::triangleSourceNod
return m_triangleSourceNodes; return m_triangleSourceNodes;
} }
const std::map<int, std::pair<QUuid, QUuid>> &MeshResultContext::vertexSourceMap() const std::map<int, std::pair<QUuid, QUuid>> &Outcome::vertexSourceMap()
{ {
if (!m_triangleSourceResolved) { if (!m_triangleSourceResolved) {
m_triangleSourceResolved = true; m_triangleSourceResolved = true;
@ -58,7 +58,7 @@ const std::map<int, std::pair<QUuid, QUuid>> &MeshResultContext::vertexSourceMap
return m_vertexSourceMap; return m_vertexSourceMap;
} }
const std::vector<Material> &MeshResultContext::triangleMaterials() const std::vector<OutcomeMaterial> &Outcome::triangleMaterials()
{ {
if (!m_triangleMaterialResolved) { if (!m_triangleMaterialResolved) {
calculateTriangleMaterials(m_triangleMaterials); calculateTriangleMaterials(m_triangleMaterials);
@ -67,7 +67,7 @@ const std::vector<Material> &MeshResultContext::triangleMaterials()
return m_triangleMaterials; return m_triangleMaterials;
} }
const std::map<std::pair<int, int>, std::pair<QUuid, QUuid>> &MeshResultContext::triangleEdgeSourceMap() const std::map<std::pair<int, int>, std::pair<QUuid, QUuid>> &Outcome::triangleEdgeSourceMap()
{ {
if (!m_triangleEdgeSourceMapResolved) { if (!m_triangleEdgeSourceMapResolved) {
calculateTriangleEdgeSourceMap(m_triangleEdgeSourceMap); calculateTriangleEdgeSourceMap(m_triangleEdgeSourceMap);
@ -76,7 +76,7 @@ const std::map<std::pair<int, int>, std::pair<QUuid, QUuid>> &MeshResultContext:
return m_triangleEdgeSourceMap; return m_triangleEdgeSourceMap;
} }
const std::map<std::pair<QUuid, QUuid>, BmeshNode *> &MeshResultContext::bmeshNodeMap() const std::map<std::pair<QUuid, QUuid>, OutcomeNode *> &Outcome::bmeshNodeMap()
{ {
if (!m_bmeshNodeMapResolved) { if (!m_bmeshNodeMapResolved) {
calculateBmeshNodeMap(m_bmeshNodeMap); calculateBmeshNodeMap(m_bmeshNodeMap);
@ -85,7 +85,7 @@ const std::map<std::pair<QUuid, QUuid>, BmeshNode *> &MeshResultContext::bmeshNo
return m_bmeshNodeMap; return m_bmeshNodeMap;
} }
void MeshResultContext::calculateTriangleSourceNodes(std::vector<std::pair<QUuid, QUuid>> &triangleSourceNodes, std::map<int, std::pair<QUuid, QUuid>> &vertexSourceMap) void Outcome::calculateTriangleSourceNodes(std::vector<std::pair<QUuid, QUuid>> &triangleSourceNodes, std::map<int, std::pair<QUuid, QUuid>> &vertexSourceMap)
{ {
PositionMap<std::pair<QUuid, QUuid>> positionMap; PositionMap<std::pair<QUuid, QUuid>> positionMap;
std::map<std::pair<int, int>, HalfColorEdge> halfColorEdgeMap; std::map<std::pair<int, int>, HalfColorEdge> halfColorEdgeMap;
@ -95,7 +95,7 @@ void MeshResultContext::calculateTriangleSourceNodes(std::vector<std::pair<QUuid
std::make_pair(it.partId, it.nodeId)); std::make_pair(it.partId, it.nodeId));
} }
for (auto x = 0u; x < vertices.size(); x++) { for (auto x = 0u; x < vertices.size(); x++) {
ResultVertex *resultVertex = &vertices[x]; OutcomeVertex *resultVertex = &vertices[x];
std::pair<QUuid, QUuid> source; std::pair<QUuid, QUuid> source;
if (positionMap.findPosition(resultVertex->position.x(), resultVertex->position.y(), resultVertex->position.z(), &source)) { if (positionMap.findPosition(resultVertex->position.x(), resultVertex->position.y(), resultVertex->position.z(), &source)) {
vertexSourceMap[x] = source; vertexSourceMap[x] = source;
@ -228,7 +228,7 @@ void MeshResultContext::calculateTriangleSourceNodes(std::vector<std::pair<QUuid
} }
} }
void MeshResultContext::calculateRemainingVertexSourceNodesAfterTriangleSourceNodesSolved(std::map<int, std::pair<QUuid, QUuid>> &vertexSourceMap) void Outcome::calculateRemainingVertexSourceNodesAfterTriangleSourceNodesSolved(std::map<int, std::pair<QUuid, QUuid>> &vertexSourceMap)
{ {
std::map<int, std::set<std::pair<QUuid, QUuid>>> remainings; std::map<int, std::set<std::pair<QUuid, QUuid>>> remainings;
for (auto x = 0u; x < triangles.size(); x++) { for (auto x = 0u; x < triangles.size(); x++) {
@ -259,9 +259,9 @@ void MeshResultContext::calculateRemainingVertexSourceNodesAfterTriangleSourceNo
} }
} }
void MeshResultContext::calculateTriangleMaterials(std::vector<Material> &triangleMaterials) void Outcome::calculateTriangleMaterials(std::vector<OutcomeMaterial> &triangleMaterials)
{ {
std::map<std::pair<QUuid, QUuid>, Material> nodeMaterialMap; std::map<std::pair<QUuid, QUuid>, OutcomeMaterial> nodeMaterialMap;
for (const auto &it: bmeshNodes) { for (const auto &it: bmeshNodes) {
nodeMaterialMap[std::make_pair(it.partId, it.nodeId)] = it.material; nodeMaterialMap[std::make_pair(it.partId, it.nodeId)] = it.material;
} }
@ -271,7 +271,7 @@ void MeshResultContext::calculateTriangleMaterials(std::vector<Material> &triang
} }
} }
void MeshResultContext::calculateTriangleEdgeSourceMap(std::map<std::pair<int, int>, std::pair<QUuid, QUuid>> &triangleEdgeSourceMap) void Outcome::calculateTriangleEdgeSourceMap(std::map<std::pair<int, int>, std::pair<QUuid, QUuid>> &triangleEdgeSourceMap)
{ {
const std::vector<std::pair<QUuid, QUuid>> sourceNodes = triangleSourceNodes(); const std::vector<std::pair<QUuid, QUuid>> sourceNodes = triangleSourceNodes();
for (auto x = 0u; x < triangles.size(); x++) { for (auto x = 0u; x < triangles.size(); x++) {
@ -284,20 +284,20 @@ void MeshResultContext::calculateTriangleEdgeSourceMap(std::map<std::pair<int, i
} }
} }
void MeshResultContext::calculateBmeshNodeMap(std::map<std::pair<QUuid, QUuid>, BmeshNode *> &bmeshNodeMap) { void Outcome::calculateBmeshNodeMap(std::map<std::pair<QUuid, QUuid>, OutcomeNode *> &bmeshNodeMap) {
for (auto i = 0u; i < bmeshNodes.size(); i++) { for (auto i = 0u; i < bmeshNodes.size(); i++) {
BmeshNode *bmeshNode = &bmeshNodes[i]; OutcomeNode *bmeshNode = &bmeshNodes[i];
bmeshNodeMap[std::make_pair(bmeshNode->partId, bmeshNode->nodeId)] = bmeshNode; bmeshNodeMap[std::make_pair(bmeshNode->partId, bmeshNode->nodeId)] = bmeshNode;
} }
} }
struct BmeshNodeDistWithWorldCenter struct BmeshNodeDistWithWorldCenter
{ {
BmeshNode *bmeshNode; OutcomeNode *bmeshNode;
float dist2; float dist2;
}; };
const std::map<QUuid, ResultPart> &MeshResultContext::parts() const std::map<QUuid, ResultPart> &Outcome::parts()
{ {
if (!m_resultPartsResolved) { if (!m_resultPartsResolved) {
calculateResultParts(m_resultParts); calculateResultParts(m_resultParts);
@ -306,7 +306,7 @@ const std::map<QUuid, ResultPart> &MeshResultContext::parts()
return m_resultParts; return m_resultParts;
} }
const std::vector<ResultTriangleUv> &MeshResultContext::triangleUvs() const std::vector<OutcomeTriangleUv> &Outcome::triangleUvs()
{ {
if (!m_resultTriangleUvsResolved) { if (!m_resultTriangleUvsResolved) {
calculateResultTriangleUvs(m_resultTriangleUvs, m_seamVertices); calculateResultTriangleUvs(m_resultTriangleUvs, m_seamVertices);
@ -315,7 +315,7 @@ const std::vector<ResultTriangleUv> &MeshResultContext::triangleUvs()
return m_resultTriangleUvs; return m_resultTriangleUvs;
} }
void MeshResultContext::calculateResultParts(std::map<QUuid, ResultPart> &parts) void Outcome::calculateResultParts(std::map<QUuid, ResultPart> &parts)
{ {
std::map<std::pair<QUuid, int>, int> oldVertexToNewMap; std::map<std::pair<QUuid, int>, int> oldVertexToNewMap;
for (auto x = 0u; x < triangles.size(); x++) { for (auto x = 0u; x < triangles.size(); x++) {
@ -329,7 +329,7 @@ void MeshResultContext::calculateResultParts(std::map<QUuid, ResultPart> &parts)
parts.insert(std::make_pair(sourceNode.first, newPart)); parts.insert(std::make_pair(sourceNode.first, newPart));
} }
auto &resultPart = parts[sourceNode.first]; auto &resultPart = parts[sourceNode.first];
ResultTriangle newTriangle; OutcomeTriangle newTriangle;
newTriangle.normal = triangle.normal; newTriangle.normal = triangle.normal;
for (auto i = 0u; i < 3; i++) { for (auto i = 0u; i < 3; i++) {
const auto &normal = interpolatedTriangleVertexNormals()[normalIndex++]; const auto &normal = interpolatedTriangleVertexNormals()[normalIndex++];
@ -341,7 +341,7 @@ void MeshResultContext::calculateResultParts(std::map<QUuid, ResultPart> &parts)
int newIndex = resultPart.vertices.size(); int newIndex = resultPart.vertices.size();
resultPart.verticesOldIndicies.push_back(triangle.indicies[i]); resultPart.verticesOldIndicies.push_back(triangle.indicies[i]);
resultPart.vertices.push_back(vertices[triangle.indicies[i]]); resultPart.vertices.push_back(vertices[triangle.indicies[i]]);
ResultVertexUv vertexUv; OutcomeVertexUv vertexUv;
vertexUv.uv[0] = triangleUvs()[x].uv[i][0]; vertexUv.uv[0] = triangleUvs()[x].uv[i][0];
vertexUv.uv[1] = triangleUvs()[x].uv[i][1]; vertexUv.uv[1] = triangleUvs()[x].uv[i][1];
resultPart.vertexUvs.push_back(vertexUv); resultPart.vertexUvs.push_back(vertexUv);
@ -359,7 +359,7 @@ void MeshResultContext::calculateResultParts(std::map<QUuid, ResultPart> &parts)
} }
} }
void MeshResultContext::calculateResultTriangleUvs(std::vector<ResultTriangleUv> &uvs, std::set<int> &seamVertices) void Outcome::calculateResultTriangleUvs(std::vector<OutcomeTriangleUv> &uvs, std::set<int> &seamVertices)
{ {
simpleuv::Mesh inputMesh; simpleuv::Mesh inputMesh;
const auto &choosenVertices = vertices; const auto &choosenVertices = vertices;
@ -420,7 +420,7 @@ void MeshResultContext::calculateResultTriangleUvs(std::vector<ResultTriangleUv>
} }
} }
void MeshResultContext::interpolateTriangleVertexNormals(std::vector<QVector3D> &resultNormals) void Outcome::interpolateTriangleVertexNormals(std::vector<QVector3D> &resultNormals)
{ {
std::vector<QVector3D> inputVerticies; std::vector<QVector3D> inputVerticies;
std::vector<std::tuple<size_t, size_t, size_t>> inputTriangles; std::vector<std::tuple<size_t, size_t, size_t>> inputTriangles;
@ -435,7 +435,7 @@ void MeshResultContext::interpolateTriangleVertexNormals(std::vector<QVector3D>
angleSmooth(inputVerticies, inputTriangles, inputNormals, thresholdAngleDegrees, resultNormals); angleSmooth(inputVerticies, inputTriangles, inputNormals, thresholdAngleDegrees, resultNormals);
} }
const std::vector<QVector3D> &MeshResultContext::interpolatedTriangleVertexNormals() const std::vector<QVector3D> &Outcome::interpolatedTriangleVertexNormals()
{ {
if (!m_triangleVertexNormalsInterpolated) { if (!m_triangleVertexNormalsInterpolated) {
m_triangleVertexNormalsInterpolated = true; m_triangleVertexNormalsInterpolated = true;
@ -444,7 +444,7 @@ const std::vector<QVector3D> &MeshResultContext::interpolatedTriangleVertexNorma
return m_interpolatedTriangleVertexNormals; return m_interpolatedTriangleVertexNormals;
} }
const std::vector<QVector3D> &MeshResultContext::triangleTangents() const std::vector<QVector3D> &Outcome::triangleTangents()
{ {
if (!m_triangleTangentsResolved) { if (!m_triangleTangentsResolved) {
m_triangleTangentsResolved = true; m_triangleTangentsResolved = true;
@ -453,7 +453,7 @@ const std::vector<QVector3D> &MeshResultContext::triangleTangents()
return m_triangleTangents; return m_triangleTangents;
} }
void MeshResultContext::calculateTriangleTangents(std::vector<QVector3D> &tangents) void Outcome::calculateTriangleTangents(std::vector<QVector3D> &tangents)
{ {
tangents.resize(triangles.size()); tangents.resize(triangles.size());

View File

@ -1,84 +1,90 @@
#ifndef MESH_RESULT_CONTEXT_H #ifndef DUST3D_OUTCOME_H
#define MESH_RESULT_CONTEXT_H #define DUST3D_OUTCOME_H
#include <vector> #include <vector>
#include <set> #include <set>
#include <QVector3D> #include <QVector3D>
#include <QUuid> #include <QUuid>
#include <QColor> #include <QColor>
#include "positionmap.h" #include "positionmap.h"
#include "skeletonbonemark.h" #include "bonemark.h"
#include "texturetype.h" #include "texturetype.h"
#include "material.h" #include "material.h"
#define MAX_WEIGHT_NUM 4 #define MAX_WEIGHT_NUM 4
struct BmeshNode struct OutcomeMaterial
{
QColor color;
QUuid materialId;
};
struct OutcomeNode
{ {
QUuid partId; QUuid partId;
QUuid nodeId; QUuid nodeId;
QVector3D origin; QVector3D origin;
float radius = 0; float radius = 0;
Material material; OutcomeMaterial material;
QUuid mirrorFromPartId; QUuid mirrorFromPartId;
SkeletonBoneMark boneMark; BoneMark boneMark;
}; };
struct BmeshVertex struct OutcomeNodeVertex
{ {
QVector3D position; QVector3D position;
QUuid partId; QUuid partId;
QUuid nodeId; QUuid nodeId;
}; };
struct ResultVertex struct OutcomeVertex
{ {
QVector3D position; QVector3D position;
}; };
struct ResultTriangle struct OutcomeTriangle
{ {
int indicies[3] = {0, 0, 0}; int indicies[3] = {0, 0, 0};
QVector3D normal; QVector3D normal;
}; };
struct ResultTriangleUv struct OutcomeTriangleUv
{ {
float uv[3][2] = {{0, 0}, {0, 0}, {0, 0}}; float uv[3][2] = {{0, 0}, {0, 0}, {0, 0}};
bool resolved = false; bool resolved = false;
}; };
struct ResultVertexUv struct OutcomeVertexUv
{ {
float uv[2] = {0, 0}; float uv[2] = {0, 0};
}; };
struct ResultPart struct ResultPart
{ {
Material material; OutcomeMaterial material;
std::vector<ResultVertex> vertices; std::vector<OutcomeVertex> vertices;
std::vector<int> verticesOldIndicies; std::vector<int> verticesOldIndicies;
std::vector<QVector3D> interpolatedTriangleVertexNormals; std::vector<QVector3D> interpolatedTriangleVertexNormals;
std::vector<ResultTriangle> triangles; std::vector<OutcomeTriangle> triangles;
std::vector<ResultTriangleUv> uvs; std::vector<OutcomeTriangleUv> uvs;
std::vector<ResultVertexUv> vertexUvs; std::vector<OutcomeVertexUv> vertexUvs;
std::vector<QVector3D> triangleTangents; std::vector<QVector3D> triangleTangents;
}; };
class MeshResultContext class Outcome
{ {
public: public:
std::vector<BmeshNode> bmeshNodes; std::vector<OutcomeNode> bmeshNodes;
std::vector<BmeshVertex> bmeshVertices; std::vector<OutcomeNodeVertex> bmeshVertices;
std::vector<ResultVertex> vertices; std::vector<OutcomeVertex> vertices;
std::vector<ResultTriangle> triangles; std::vector<OutcomeTriangle> triangles;
MeshResultContext(); Outcome();
public: public:
const std::vector<std::pair<QUuid, QUuid>> &triangleSourceNodes(); const std::vector<std::pair<QUuid, QUuid>> &triangleSourceNodes();
const std::vector<Material> &triangleMaterials(); const std::vector<OutcomeMaterial> &triangleMaterials();
const std::map<std::pair<int, int>, std::pair<QUuid, QUuid>> &triangleEdgeSourceMap(); const std::map<std::pair<int, int>, std::pair<QUuid, QUuid>> &triangleEdgeSourceMap();
const std::map<std::pair<QUuid, QUuid>, BmeshNode *> &bmeshNodeMap(); const std::map<std::pair<QUuid, QUuid>, OutcomeNode *> &bmeshNodeMap();
const std::map<QUuid, ResultPart> &parts(); const std::map<QUuid, ResultPart> &parts();
const std::vector<ResultTriangleUv> &triangleUvs(); const std::vector<OutcomeTriangleUv> &triangleUvs();
const std::map<int, std::pair<QUuid, QUuid>> &vertexSourceMap(); const std::map<int, std::pair<QUuid, QUuid>> &vertexSourceMap();
const std::vector<QVector3D> &interpolatedTriangleVertexNormals(); const std::vector<QVector3D> &interpolatedTriangleVertexNormals();
const std::vector<QVector3D> &triangleTangents(); const std::vector<QVector3D> &triangleTangents();
@ -93,11 +99,11 @@ private:
bool m_triangleTangentsResolved; bool m_triangleTangentsResolved;
private: private:
std::vector<std::pair<QUuid, QUuid>> m_triangleSourceNodes; std::vector<std::pair<QUuid, QUuid>> m_triangleSourceNodes;
std::vector<Material> m_triangleMaterials; std::vector<OutcomeMaterial> m_triangleMaterials;
std::map<std::pair<int, int>, std::pair<QUuid, QUuid>> m_triangleEdgeSourceMap; std::map<std::pair<int, int>, std::pair<QUuid, QUuid>> m_triangleEdgeSourceMap;
std::map<std::pair<QUuid, QUuid>, BmeshNode *> m_bmeshNodeMap; std::map<std::pair<QUuid, QUuid>, OutcomeNode *> m_bmeshNodeMap;
std::map<QUuid, ResultPart> m_resultParts; std::map<QUuid, ResultPart> m_resultParts;
std::vector<ResultTriangleUv> m_resultTriangleUvs; std::vector<OutcomeTriangleUv> m_resultTriangleUvs;
std::set<int> m_seamVertices; std::set<int> m_seamVertices;
std::map<int, std::pair<QUuid, QUuid>> m_vertexSourceMap; std::map<int, std::pair<QUuid, QUuid>> m_vertexSourceMap;
std::map<int, int> m_rearrangedVerticesToOldIndexMap; std::map<int, int> m_rearrangedVerticesToOldIndexMap;
@ -106,11 +112,11 @@ private:
private: private:
void calculateTriangleSourceNodes(std::vector<std::pair<QUuid, QUuid>> &triangleSourceNodes, std::map<int, std::pair<QUuid, QUuid>> &vertexSourceMap); void calculateTriangleSourceNodes(std::vector<std::pair<QUuid, QUuid>> &triangleSourceNodes, std::map<int, std::pair<QUuid, QUuid>> &vertexSourceMap);
void calculateRemainingVertexSourceNodesAfterTriangleSourceNodesSolved(std::map<int, std::pair<QUuid, QUuid>> &vertexSourceMap); void calculateRemainingVertexSourceNodesAfterTriangleSourceNodesSolved(std::map<int, std::pair<QUuid, QUuid>> &vertexSourceMap);
void calculateTriangleMaterials(std::vector<Material> &triangleMaterials); void calculateTriangleMaterials(std::vector<OutcomeMaterial> &triangleMaterials);
void calculateTriangleEdgeSourceMap(std::map<std::pair<int, int>, std::pair<QUuid, QUuid>> &triangleEdgeSourceMap); void calculateTriangleEdgeSourceMap(std::map<std::pair<int, int>, std::pair<QUuid, QUuid>> &triangleEdgeSourceMap);
void calculateBmeshNodeMap(std::map<std::pair<QUuid, QUuid>, BmeshNode *> &bmeshNodeMap); void calculateBmeshNodeMap(std::map<std::pair<QUuid, QUuid>, OutcomeNode *> &bmeshNodeMap);
void calculateResultParts(std::map<QUuid, ResultPart> &parts); void calculateResultParts(std::map<QUuid, ResultPart> &parts);
void calculateResultTriangleUvs(std::vector<ResultTriangleUv> &uvs, std::set<int> &seamVertices); void calculateResultTriangleUvs(std::vector<OutcomeTriangleUv> &uvs, std::set<int> &seamVertices);
void interpolateTriangleVertexNormals(std::vector<QVector3D> &resultNormals); void interpolateTriangleVertexNormals(std::vector<QVector3D> &resultNormals);
void calculateTriangleTangents(std::vector<QVector3D> &tangents); void calculateTriangleTangents(std::vector<QVector3D> &tangents);
}; };

View File

@ -6,12 +6,12 @@
#include <QRadialGradient> #include <QRadialGradient>
#include <QBrush> #include <QBrush>
#include <QGuiApplication> #include <QGuiApplication>
#include "skeletonparttreewidget.h" #include "parttreewidget.h"
#include "skeletonpartwidget.h" #include "partwidget.h"
#include "skeletongraphicswidget.h" #include "skeletongraphicswidget.h"
#include "floatnumberwidget.h" #include "floatnumberwidget.h"
SkeletonPartTreeWidget::SkeletonPartTreeWidget(const SkeletonDocument *document, QWidget *parent) : PartTreeWidget::PartTreeWidget(const Document *document, QWidget *parent) :
QTreeWidget(parent), QTreeWidget(parent),
m_document(document) m_document(document)
{ {
@ -56,13 +56,13 @@ SkeletonPartTreeWidget::SkeletonPartTreeWidget(const SkeletonDocument *document,
gradient.setColorAt(1, Qt::transparent); gradient.setColorAt(1, Qt::transparent);
m_hightlightedPartBackground = QBrush(gradient); m_hightlightedPartBackground = QBrush(gradient);
connect(this, &QTreeWidget::customContextMenuRequested, this, &SkeletonPartTreeWidget::showContextMenu); connect(this, &QTreeWidget::customContextMenuRequested, this, &PartTreeWidget::showContextMenu);
connect(this, &QTreeWidget::itemChanged, this, &SkeletonPartTreeWidget::groupChanged); connect(this, &QTreeWidget::itemChanged, this, &PartTreeWidget::groupChanged);
connect(this, &QTreeWidget::itemExpanded, this, &SkeletonPartTreeWidget::groupExpanded); connect(this, &QTreeWidget::itemExpanded, this, &PartTreeWidget::groupExpanded);
connect(this, &QTreeWidget::itemCollapsed, this, &SkeletonPartTreeWidget::groupCollapsed); connect(this, &QTreeWidget::itemCollapsed, this, &PartTreeWidget::groupCollapsed);
} }
void SkeletonPartTreeWidget::selectComponent(QUuid componentId, bool multiple) void PartTreeWidget::selectComponent(QUuid componentId, bool multiple)
{ {
if (multiple) { if (multiple) {
if (!m_currentSelectedComponentId.isNull()) { if (!m_currentSelectedComponentId.isNull()) {
@ -103,9 +103,9 @@ void SkeletonPartTreeWidget::selectComponent(QUuid componentId, bool multiple)
} }
} }
void SkeletonPartTreeWidget::updateComponentSelectState(QUuid componentId, bool selected) void PartTreeWidget::updateComponentSelectState(QUuid componentId, bool selected)
{ {
const SkeletonComponent *component = m_document->findComponent(componentId); const Component *component = m_document->findComponent(componentId);
if (nullptr == component) { if (nullptr == component) {
qDebug() << "Component not found:" << componentId; qDebug() << "Component not found:" << componentId;
return; return;
@ -113,7 +113,7 @@ void SkeletonPartTreeWidget::updateComponentSelectState(QUuid componentId, bool
if (!component->linkToPartId.isNull()) { if (!component->linkToPartId.isNull()) {
auto item = m_partItemMap.find(component->linkToPartId); auto item = m_partItemMap.find(component->linkToPartId);
if (item != m_componentItemMap.end()) { if (item != m_componentItemMap.end()) {
SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
widget->updateCheckedState(selected); widget->updateCheckedState(selected);
} }
return; return;
@ -130,7 +130,7 @@ void SkeletonPartTreeWidget::updateComponentSelectState(QUuid componentId, bool
} }
} }
void SkeletonPartTreeWidget::mousePressEvent(QMouseEvent *event) void PartTreeWidget::mousePressEvent(QMouseEvent *event)
{ {
QModelIndex itemIndex = indexAt(event->pos()); QModelIndex itemIndex = indexAt(event->pos());
QTreeView::mousePressEvent(event); QTreeView::mousePressEvent(event);
@ -141,7 +141,7 @@ void SkeletonPartTreeWidget::mousePressEvent(QMouseEvent *event)
auto componentId = QUuid(item->data(0, Qt::UserRole).toString()); auto componentId = QUuid(item->data(0, Qt::UserRole).toString());
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) { if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) {
if (!m_shiftStartComponentId.isNull()) { if (!m_shiftStartComponentId.isNull()) {
const SkeletonComponent *parent = m_document->findComponentParent(m_shiftStartComponentId); const Component *parent = m_document->findComponentParent(m_shiftStartComponentId);
if (parent) { if (parent) {
if (!parent->childrenIds.empty()) { if (!parent->childrenIds.empty()) {
bool startAdd = false; bool startAdd = false;
@ -190,11 +190,11 @@ void SkeletonPartTreeWidget::mousePressEvent(QMouseEvent *event)
} }
} }
void SkeletonPartTreeWidget::showContextMenu(const QPoint &pos) void PartTreeWidget::showContextMenu(const QPoint &pos)
{ {
const SkeletonComponent *component = nullptr; const Component *component = nullptr;
const SkeletonPart *part = nullptr; const Part *part = nullptr;
SkeletonPartWidget *partWidget = nullptr; PartWidget *partWidget = nullptr;
std::set<QUuid> unorderedComponentIds = m_selectedComponentIds; std::set<QUuid> unorderedComponentIds = m_selectedComponentIds;
if (!m_currentSelectedComponentId.isNull()) if (!m_currentSelectedComponentId.isNull())
@ -238,7 +238,7 @@ void SkeletonPartTreeWidget::showContextMenu(const QPoint &pos)
if (nullptr != part) { if (nullptr != part) {
auto findItem = m_partItemMap.find(part->id); auto findItem = m_partItemMap.find(part->id);
if (findItem != m_partItemMap.end()) { if (findItem != m_partItemMap.end()) {
partWidget = (SkeletonPartWidget *)itemWidget(findItem->second, 0); partWidget = (PartWidget *)itemWidget(findItem->second, 0);
} }
} }
if (nullptr != part && nullptr != partWidget) { if (nullptr != part && nullptr != partWidget) {
@ -500,7 +500,7 @@ void SkeletonPartTreeWidget::showContextMenu(const QPoint &pos)
}); });
addChildGroupsFunc = [this, &groupsActions, &addChildGroupsFunc, &moveToMenu, &componentIds](QUuid currentId, int tabs) -> void { addChildGroupsFunc = [this, &groupsActions, &addChildGroupsFunc, &moveToMenu, &componentIds](QUuid currentId, int tabs) -> void {
const SkeletonComponent *current = m_document->findComponent(currentId); const Component *current = m_document->findComponent(currentId);
if (nullptr == current) if (nullptr == current)
return; return;
if (!current->id.isNull() && current->linkDataType().isEmpty()) { if (!current->id.isNull() && current->linkDataType().isEmpty()) {
@ -535,11 +535,11 @@ void SkeletonPartTreeWidget::showContextMenu(const QPoint &pos)
} }
} }
QWidget *SkeletonPartTreeWidget::createSmoothMenuWidget(QUuid componentId) QWidget *PartTreeWidget::createSmoothMenuWidget(QUuid componentId)
{ {
QWidget *popup = new QWidget; QWidget *popup = new QWidget;
const SkeletonComponent *component = m_document->findComponent(componentId); const Component *component = m_document->findComponent(componentId);
if (!component) { if (!component) {
qDebug() << "Find component failed:" << componentId; qDebug() << "Find component failed:" << componentId;
return popup; return popup;
@ -607,7 +607,7 @@ QWidget *SkeletonPartTreeWidget::createSmoothMenuWidget(QUuid componentId)
return popup; return popup;
} }
QTreeWidgetItem *SkeletonPartTreeWidget::findComponentItem(QUuid componentId) QTreeWidgetItem *PartTreeWidget::findComponentItem(QUuid componentId)
{ {
auto findResult = m_componentItemMap.find(componentId); auto findResult = m_componentItemMap.find(componentId);
if (findResult == m_componentItemMap.end()) if (findResult == m_componentItemMap.end())
@ -616,7 +616,7 @@ QTreeWidgetItem *SkeletonPartTreeWidget::findComponentItem(QUuid componentId)
return findResult->second; return findResult->second;
} }
void SkeletonPartTreeWidget::componentNameChanged(QUuid componentId) void PartTreeWidget::componentNameChanged(QUuid componentId)
{ {
auto componentItem = m_componentItemMap.find(componentId); auto componentItem = m_componentItemMap.find(componentId);
if (componentItem == m_componentItemMap.end()) { if (componentItem == m_componentItemMap.end()) {
@ -624,7 +624,7 @@ void SkeletonPartTreeWidget::componentNameChanged(QUuid componentId)
return; return;
} }
const SkeletonComponent *component = m_document->findComponent(componentId); const Component *component = m_document->findComponent(componentId);
if (nullptr == component) { if (nullptr == component) {
qDebug() << "Find component failed:" << componentId; qDebug() << "Find component failed:" << componentId;
return; return;
@ -633,7 +633,7 @@ void SkeletonPartTreeWidget::componentNameChanged(QUuid componentId)
componentItem->second->setText(0, component->name); componentItem->second->setText(0, component->name);
} }
void SkeletonPartTreeWidget::componentExpandStateChanged(QUuid componentId) void PartTreeWidget::componentExpandStateChanged(QUuid componentId)
{ {
auto componentItem = m_componentItemMap.find(componentId); auto componentItem = m_componentItemMap.find(componentId);
if (componentItem == m_componentItemMap.end()) { if (componentItem == m_componentItemMap.end()) {
@ -641,7 +641,7 @@ void SkeletonPartTreeWidget::componentExpandStateChanged(QUuid componentId)
return; return;
} }
const SkeletonComponent *component = m_document->findComponent(componentId); const Component *component = m_document->findComponent(componentId);
if (nullptr == component) { if (nullptr == component) {
qDebug() << "Find component failed:" << componentId; qDebug() << "Find component failed:" << componentId;
return; return;
@ -650,14 +650,14 @@ void SkeletonPartTreeWidget::componentExpandStateChanged(QUuid componentId)
componentItem->second->setExpanded(component->expanded); componentItem->second->setExpanded(component->expanded);
} }
void SkeletonPartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTreeWidgetItem *parentItem) void PartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTreeWidgetItem *parentItem)
{ {
const SkeletonComponent *parentComponent = m_document->findComponent(componentId); const Component *parentComponent = m_document->findComponent(componentId);
if (nullptr == parentComponent) if (nullptr == parentComponent)
return; return;
for (const auto &childId: parentComponent->childrenIds) { for (const auto &childId: parentComponent->childrenIds) {
const SkeletonComponent *component = m_document->findComponent(childId); const Component *component = m_document->findComponent(childId);
if (nullptr == component) if (nullptr == component)
continue; continue;
if (!component->linkToPartId.isNull()) { if (!component->linkToPartId.isNull()) {
@ -666,8 +666,8 @@ void SkeletonPartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTree
item->setData(0, Qt::UserRole, QVariant(component->id.toString())); item->setData(0, Qt::UserRole, QVariant(component->id.toString()));
item->setFlags(item->flags() & ~(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable)); item->setFlags(item->flags() & ~(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable));
QUuid partId = component->linkToPartId; QUuid partId = component->linkToPartId;
SkeletonPartWidget *widget = new SkeletonPartWidget(m_document, partId); PartWidget *widget = new PartWidget(m_document, partId);
item->setSizeHint(0, SkeletonPartWidget::preferredSize()); item->setSizeHint(0, PartWidget::preferredSize());
setItemWidget(item, 0, widget); setItemWidget(item, 0, widget);
widget->reload(); widget->reload();
m_partItemMap[partId] = item; m_partItemMap[partId] = item;
@ -685,13 +685,13 @@ void SkeletonPartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTree
} }
} }
void SkeletonPartTreeWidget::deleteItemChildren(QTreeWidgetItem *item) void PartTreeWidget::deleteItemChildren(QTreeWidgetItem *item)
{ {
auto children = item->takeChildren(); auto children = item->takeChildren();
while (!children.isEmpty()) { while (!children.isEmpty()) {
auto first = children.takeFirst(); auto first = children.takeFirst();
auto componentId = QUuid(first->data(0, Qt::UserRole).toString()); auto componentId = QUuid(first->data(0, Qt::UserRole).toString());
const SkeletonComponent *component = m_document->findComponent(componentId); const Component *component = m_document->findComponent(componentId);
if (nullptr != component) { if (nullptr != component) {
m_componentItemMap.erase(componentId); m_componentItemMap.erase(componentId);
if (!component->linkToPartId.isNull()) { if (!component->linkToPartId.isNull()) {
@ -703,7 +703,7 @@ void SkeletonPartTreeWidget::deleteItemChildren(QTreeWidgetItem *item)
} }
} }
void SkeletonPartTreeWidget::componentChildrenChanged(QUuid componentId) void PartTreeWidget::componentChildrenChanged(QUuid componentId)
{ {
QTreeWidgetItem *parentItem = findComponentItem(componentId); QTreeWidgetItem *parentItem = findComponentItem(componentId);
if (nullptr == parentItem) { if (nullptr == parentItem) {
@ -723,7 +723,7 @@ void SkeletonPartTreeWidget::componentChildrenChanged(QUuid componentId)
} }
} }
void SkeletonPartTreeWidget::removeAllContent() void PartTreeWidget::removeAllContent()
{ {
qDeleteAll(invisibleRootItem()->takeChildren()); qDeleteAll(invisibleRootItem()->takeChildren());
m_partItemMap.clear(); m_partItemMap.clear();
@ -731,7 +731,7 @@ void SkeletonPartTreeWidget::removeAllContent()
m_componentItemMap[QUuid()] = invisibleRootItem(); m_componentItemMap[QUuid()] = invisibleRootItem();
} }
void SkeletonPartTreeWidget::componentRemoved(QUuid componentId) void PartTreeWidget::componentRemoved(QUuid componentId)
{ {
auto componentItem = m_componentItemMap.find(componentId); auto componentItem = m_componentItemMap.find(componentId);
if (componentItem == m_componentItemMap.end()) if (componentItem == m_componentItemMap.end())
@ -742,12 +742,12 @@ void SkeletonPartTreeWidget::componentRemoved(QUuid componentId)
m_componentItemMap.erase(componentId); m_componentItemMap.erase(componentId);
} }
void SkeletonPartTreeWidget::componentAdded(QUuid componentId) void PartTreeWidget::componentAdded(QUuid componentId)
{ {
// ignore // ignore
} }
void SkeletonPartTreeWidget::partRemoved(QUuid partId) void PartTreeWidget::partRemoved(QUuid partId)
{ {
auto partItem = m_partItemMap.find(partId); auto partItem = m_partItemMap.find(partId);
if (partItem == m_partItemMap.end()) if (partItem == m_partItemMap.end())
@ -756,14 +756,14 @@ void SkeletonPartTreeWidget::partRemoved(QUuid partId)
m_partItemMap.erase(partItem); m_partItemMap.erase(partItem);
} }
void SkeletonPartTreeWidget::groupChanged(QTreeWidgetItem *item, int column) void PartTreeWidget::groupChanged(QTreeWidgetItem *item, int column)
{ {
if (0 != column) if (0 != column)
return; return;
auto componentId = QUuid(item->data(0, Qt::UserRole).toString()); auto componentId = QUuid(item->data(0, Qt::UserRole).toString());
const SkeletonComponent *component = m_document->findComponent(componentId); const Component *component = m_document->findComponent(componentId);
if (nullptr == component) { if (nullptr == component) {
qDebug() << "Find component failed:" << componentId; qDebug() << "Find component failed:" << componentId;
return; return;
@ -773,140 +773,140 @@ void SkeletonPartTreeWidget::groupChanged(QTreeWidgetItem *item, int column)
emit renameComponent(componentId, item->text(0)); emit renameComponent(componentId, item->text(0));
} }
void SkeletonPartTreeWidget::groupExpanded(QTreeWidgetItem *item) void PartTreeWidget::groupExpanded(QTreeWidgetItem *item)
{ {
QUuid componentId = QUuid(item->data(0, Qt::UserRole).toString()); QUuid componentId = QUuid(item->data(0, Qt::UserRole).toString());
emit setComponentExpandState(componentId, true); emit setComponentExpandState(componentId, true);
} }
void SkeletonPartTreeWidget::groupCollapsed(QTreeWidgetItem *item) void PartTreeWidget::groupCollapsed(QTreeWidgetItem *item)
{ {
QUuid componentId = QUuid(item->data(0, Qt::UserRole).toString()); QUuid componentId = QUuid(item->data(0, Qt::UserRole).toString());
emit setComponentExpandState(componentId, false); emit setComponentExpandState(componentId, false);
} }
void SkeletonPartTreeWidget::partPreviewChanged(QUuid partId) void PartTreeWidget::partPreviewChanged(QUuid partId)
{ {
auto item = m_partItemMap.find(partId); auto item = m_partItemMap.find(partId);
if (item == m_partItemMap.end()) { if (item == m_partItemMap.end()) {
qDebug() << "Part item not found:" << partId; qDebug() << "Part item not found:" << partId;
return; return;
} }
SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
widget->updatePreview(); widget->updatePreview();
} }
void SkeletonPartTreeWidget::partLockStateChanged(QUuid partId) void PartTreeWidget::partLockStateChanged(QUuid partId)
{ {
auto item = m_partItemMap.find(partId); auto item = m_partItemMap.find(partId);
if (item == m_partItemMap.end()) { if (item == m_partItemMap.end()) {
qDebug() << "Part item not found:" << partId; qDebug() << "Part item not found:" << partId;
return; return;
} }
SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
widget->updateLockButton(); widget->updateLockButton();
} }
void SkeletonPartTreeWidget::partVisibleStateChanged(QUuid partId) void PartTreeWidget::partVisibleStateChanged(QUuid partId)
{ {
auto item = m_partItemMap.find(partId); auto item = m_partItemMap.find(partId);
if (item == m_partItemMap.end()) { if (item == m_partItemMap.end()) {
qDebug() << "Part item not found:" << partId; qDebug() << "Part item not found:" << partId;
return; return;
} }
SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
widget->updateVisibleButton(); widget->updateVisibleButton();
} }
void SkeletonPartTreeWidget::partSubdivStateChanged(QUuid partId) void PartTreeWidget::partSubdivStateChanged(QUuid partId)
{ {
auto item = m_partItemMap.find(partId); auto item = m_partItemMap.find(partId);
if (item == m_partItemMap.end()) { if (item == m_partItemMap.end()) {
qDebug() << "Part item not found:" << partId; qDebug() << "Part item not found:" << partId;
return; return;
} }
SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
widget->updateSubdivButton(); widget->updateSubdivButton();
} }
void SkeletonPartTreeWidget::partDisableStateChanged(QUuid partId) void PartTreeWidget::partDisableStateChanged(QUuid partId)
{ {
auto item = m_partItemMap.find(partId); auto item = m_partItemMap.find(partId);
if (item == m_partItemMap.end()) { if (item == m_partItemMap.end()) {
qDebug() << "Part item not found:" << partId; qDebug() << "Part item not found:" << partId;
return; return;
} }
SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
widget->updateDisableButton(); widget->updateDisableButton();
} }
void SkeletonPartTreeWidget::partXmirrorStateChanged(QUuid partId) void PartTreeWidget::partXmirrorStateChanged(QUuid partId)
{ {
auto item = m_partItemMap.find(partId); auto item = m_partItemMap.find(partId);
if (item == m_partItemMap.end()) { if (item == m_partItemMap.end()) {
qDebug() << "Part item not found:" << partId; qDebug() << "Part item not found:" << partId;
return; return;
} }
SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
widget->updateXmirrorButton(); widget->updateXmirrorButton();
} }
void SkeletonPartTreeWidget::partDeformChanged(QUuid partId) void PartTreeWidget::partDeformChanged(QUuid partId)
{ {
auto item = m_partItemMap.find(partId); auto item = m_partItemMap.find(partId);
if (item == m_partItemMap.end()) { if (item == m_partItemMap.end()) {
qDebug() << "Part item not found:" << partId; qDebug() << "Part item not found:" << partId;
return; return;
} }
SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
widget->updateDeformButton(); widget->updateDeformButton();
} }
void SkeletonPartTreeWidget::partRoundStateChanged(QUuid partId) void PartTreeWidget::partRoundStateChanged(QUuid partId)
{ {
auto item = m_partItemMap.find(partId); auto item = m_partItemMap.find(partId);
if (item == m_partItemMap.end()) { if (item == m_partItemMap.end()) {
qDebug() << "Part item not found:" << partId; qDebug() << "Part item not found:" << partId;
return; return;
} }
SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
widget->updateRoundButton(); widget->updateRoundButton();
} }
void SkeletonPartTreeWidget::partWrapStateChanged(QUuid partId) void PartTreeWidget::partWrapStateChanged(QUuid partId)
{ {
auto item = m_partItemMap.find(partId); auto item = m_partItemMap.find(partId);
if (item == m_partItemMap.end()) { if (item == m_partItemMap.end()) {
qDebug() << "Part item not found:" << partId; qDebug() << "Part item not found:" << partId;
return; return;
} }
SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
widget->updateWrapButton(); widget->updateWrapButton();
} }
void SkeletonPartTreeWidget::partColorStateChanged(QUuid partId) void PartTreeWidget::partColorStateChanged(QUuid partId)
{ {
auto item = m_partItemMap.find(partId); auto item = m_partItemMap.find(partId);
if (item == m_partItemMap.end()) { if (item == m_partItemMap.end()) {
qDebug() << "Part item not found:" << partId; qDebug() << "Part item not found:" << partId;
return; return;
} }
SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
widget->updateColorButton(); widget->updateColorButton();
} }
void SkeletonPartTreeWidget::partMaterialIdChanged(QUuid partId) void PartTreeWidget::partMaterialIdChanged(QUuid partId)
{ {
auto item = m_partItemMap.find(partId); auto item = m_partItemMap.find(partId);
if (item == m_partItemMap.end()) { if (item == m_partItemMap.end()) {
qDebug() << "Part item not found:" << partId; qDebug() << "Part item not found:" << partId;
return; return;
} }
SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); PartWidget *widget = (PartWidget *)itemWidget(item->second, 0);
widget->updateColorButton(); widget->updateColorButton();
} }
void SkeletonPartTreeWidget::partChecked(QUuid partId) void PartTreeWidget::partChecked(QUuid partId)
{ {
auto item = m_partItemMap.find(partId); auto item = m_partItemMap.find(partId);
if (item == m_partItemMap.end()) { if (item == m_partItemMap.end()) {
@ -916,7 +916,7 @@ void SkeletonPartTreeWidget::partChecked(QUuid partId)
item->second->setBackground(0, m_hightlightedPartBackground); item->second->setBackground(0, m_hightlightedPartBackground);
} }
void SkeletonPartTreeWidget::partUnchecked(QUuid partId) void PartTreeWidget::partUnchecked(QUuid partId)
{ {
auto item = m_partItemMap.find(partId); auto item = m_partItemMap.find(partId);
if (item == m_partItemMap.end()) { if (item == m_partItemMap.end()) {
@ -926,13 +926,13 @@ void SkeletonPartTreeWidget::partUnchecked(QUuid partId)
item->second->setBackground(0, QBrush(Qt::transparent)); item->second->setBackground(0, QBrush(Qt::transparent));
} }
QSize SkeletonPartTreeWidget::sizeHint() const QSize PartTreeWidget::sizeHint() const
{ {
QSize size = SkeletonPartWidget::preferredSize(); QSize size = PartWidget::preferredSize();
return QSize(size.width() * 1.35, size.height() * 5.5); return QSize(size.width() * 1.35, size.height() * 5.5);
} }
bool SkeletonPartTreeWidget::isComponentSelected(QUuid componentId) bool PartTreeWidget::isComponentSelected(QUuid componentId)
{ {
return (m_currentSelectedComponentId == componentId || return (m_currentSelectedComponentId == componentId ||
m_selectedComponentIds.find(componentId) != m_selectedComponentIds.end()); m_selectedComponentIds.find(componentId) != m_selectedComponentIds.end());

View File

@ -1,11 +1,11 @@
#ifndef SKELETON_PART_TREE_WIDGET_H #ifndef DUST3D_PART_TREE_WIDGET_H
#define SKELETON_PART_TREE_WIDGET_H #define DUST3D_PART_TREE_WIDGET_H
#include <QTreeWidget> #include <QTreeWidget>
#include <QUuid> #include <QUuid>
#include <QMouseEvent> #include <QMouseEvent>
#include "skeletondocument.h" #include "document.h"
class SkeletonPartTreeWidget : public QTreeWidget class PartTreeWidget : public QTreeWidget
{ {
Q_OBJECT Q_OBJECT
signals: signals:
@ -41,7 +41,7 @@ signals:
void addPartToSelection(QUuid partId); void addPartToSelection(QUuid partId);
void groupOperationAdded(); void groupOperationAdded();
public: public:
SkeletonPartTreeWidget(const SkeletonDocument *document, QWidget *parent); PartTreeWidget(const Document *document, QWidget *parent);
QTreeWidgetItem *findComponentItem(QUuid componentId); QTreeWidgetItem *findComponentItem(QUuid componentId);
public slots: public slots:
void componentNameChanged(QUuid componentId); void componentNameChanged(QUuid componentId);
@ -79,7 +79,7 @@ private:
void updateComponentSelectState(QUuid componentId, bool selected); void updateComponentSelectState(QUuid componentId, bool selected);
bool isComponentSelected(QUuid componentId); bool isComponentSelected(QUuid componentId);
private: private:
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
std::map<QUuid, QTreeWidgetItem *> m_partItemMap; std::map<QUuid, QTreeWidgetItem *> m_partItemMap;
std::map<QUuid, QTreeWidgetItem *> m_componentItemMap; std::map<QUuid, QTreeWidgetItem *> m_componentItemMap;
QFont m_normalFont; QFont m_normalFont;

View File

@ -6,13 +6,13 @@
#include <QColorDialog> #include <QColorDialog>
#include <QSizePolicy> #include <QSizePolicy>
#include <QFileDialog> #include <QFileDialog>
#include "skeletonpartwidget.h" #include "partwidget.h"
#include "theme.h" #include "theme.h"
#include "floatnumberwidget.h" #include "floatnumberwidget.h"
#include "materiallistwidget.h" #include "materiallistwidget.h"
#include "infolabel.h" #include "infolabel.h"
SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid partId) : PartWidget::PartWidget(const Document *document, QUuid partId) :
m_document(document), m_document(document),
m_partId(partId) m_partId(partId)
{ {
@ -124,25 +124,25 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
setLayout(mainLayout); setLayout(mainLayout);
connect(this, &SkeletonPartWidget::setPartLockState, m_document, &SkeletonDocument::setPartLockState); connect(this, &PartWidget::setPartLockState, m_document, &Document::setPartLockState);
connect(this, &SkeletonPartWidget::setPartVisibleState, m_document, &SkeletonDocument::setPartVisibleState); connect(this, &PartWidget::setPartVisibleState, m_document, &Document::setPartVisibleState);
connect(this, &SkeletonPartWidget::setPartSubdivState, m_document, &SkeletonDocument::setPartSubdivState); connect(this, &PartWidget::setPartSubdivState, m_document, &Document::setPartSubdivState);
connect(this, &SkeletonPartWidget::setPartDisableState, m_document, &SkeletonDocument::setPartDisableState); connect(this, &PartWidget::setPartDisableState, m_document, &Document::setPartDisableState);
connect(this, &SkeletonPartWidget::setPartXmirrorState, m_document, &SkeletonDocument::setPartXmirrorState); connect(this, &PartWidget::setPartXmirrorState, m_document, &Document::setPartXmirrorState);
connect(this, &SkeletonPartWidget::setPartDeformThickness, m_document, &SkeletonDocument::setPartDeformThickness); connect(this, &PartWidget::setPartDeformThickness, m_document, &Document::setPartDeformThickness);
connect(this, &SkeletonPartWidget::setPartDeformWidth, m_document, &SkeletonDocument::setPartDeformWidth); connect(this, &PartWidget::setPartDeformWidth, m_document, &Document::setPartDeformWidth);
connect(this, &SkeletonPartWidget::setPartRoundState, m_document, &SkeletonDocument::setPartRoundState); connect(this, &PartWidget::setPartRoundState, m_document, &Document::setPartRoundState);
connect(this, &SkeletonPartWidget::setPartWrapState, m_document, &SkeletonDocument::setPartWrapState); connect(this, &PartWidget::setPartWrapState, m_document, &Document::setPartWrapState);
connect(this, &SkeletonPartWidget::setPartColorState, m_document, &SkeletonDocument::setPartColorState); connect(this, &PartWidget::setPartColorState, m_document, &Document::setPartColorState);
connect(this, &SkeletonPartWidget::setPartMaterialId, m_document, &SkeletonDocument::setPartMaterialId); connect(this, &PartWidget::setPartMaterialId, m_document, &Document::setPartMaterialId);
connect(this, &SkeletonPartWidget::checkPart, m_document, &SkeletonDocument::checkPart); connect(this, &PartWidget::checkPart, m_document, &Document::checkPart);
connect(this, &SkeletonPartWidget::enableBackgroundBlur, m_document, &SkeletonDocument::enableBackgroundBlur); connect(this, &PartWidget::enableBackgroundBlur, m_document, &Document::enableBackgroundBlur);
connect(this, &SkeletonPartWidget::disableBackgroundBlur, m_document, &SkeletonDocument::disableBackgroundBlur); connect(this, &PartWidget::disableBackgroundBlur, m_document, &Document::disableBackgroundBlur);
connect(this, &SkeletonPartWidget::groupOperationAdded, m_document, &SkeletonDocument::saveSnapshot); connect(this, &PartWidget::groupOperationAdded, m_document, &Document::saveSnapshot);
connect(m_lockButton, &QPushButton::clicked, [=]() { connect(m_lockButton, &QPushButton::clicked, [=]() {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -152,7 +152,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
}); });
connect(m_visibleButton, &QPushButton::clicked, [=]() { connect(m_visibleButton, &QPushButton::clicked, [=]() {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -162,7 +162,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
}); });
connect(m_subdivButton, &QPushButton::clicked, [=]() { connect(m_subdivButton, &QPushButton::clicked, [=]() {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -172,7 +172,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
}); });
connect(m_disableButton, &QPushButton::clicked, [=]() { connect(m_disableButton, &QPushButton::clicked, [=]() {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -182,7 +182,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
}); });
connect(m_xMirrorButton, &QPushButton::clicked, [=]() { connect(m_xMirrorButton, &QPushButton::clicked, [=]() {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -192,7 +192,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
}); });
connect(m_deformButton, &QPushButton::clicked, [=]() { connect(m_deformButton, &QPushButton::clicked, [=]() {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -201,7 +201,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
}); });
connect(m_roundButton, &QPushButton::clicked, [=]() { connect(m_roundButton, &QPushButton::clicked, [=]() {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -211,7 +211,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
}); });
connect(m_colorButton, &QPushButton::clicked, [=]() { connect(m_colorButton, &QPushButton::clicked, [=]() {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -220,7 +220,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
}); });
connect(m_wrapButton, &QPushButton::clicked, [=]() { connect(m_wrapButton, &QPushButton::clicked, [=]() {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -235,17 +235,17 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
updateAllButtons(); updateAllButtons();
} }
ModelWidget *SkeletonPartWidget::previewWidget() ModelWidget *PartWidget::previewWidget()
{ {
return m_previewWidget; return m_previewWidget;
} }
QSize SkeletonPartWidget::preferredSize() QSize PartWidget::preferredSize()
{ {
return QSize(Theme::miniIconSize + Theme::partPreviewImageSize + Theme::miniIconSize * 4 + 5 + 2, Theme::partPreviewImageSize + 6); return QSize(Theme::miniIconSize + Theme::partPreviewImageSize + Theme::miniIconSize * 4 + 5 + 2, Theme::partPreviewImageSize + 6);
} }
void SkeletonPartWidget::updateAllButtons() void PartWidget::updateAllButtons()
{ {
updateVisibleButton(); updateVisibleButton();
updateLockButton(); updateLockButton();
@ -258,7 +258,7 @@ void SkeletonPartWidget::updateAllButtons()
updateWrapButton(); updateWrapButton();
} }
void SkeletonPartWidget::updateCheckedState(bool checked) void PartWidget::updateCheckedState(bool checked)
{ {
if (checked) if (checked)
m_backgroundWidget->setStyleSheet("QWidget#background {border: 1px solid " + Theme::red.name() + ";}"); m_backgroundWidget->setStyleSheet("QWidget#background {border: 1px solid " + Theme::red.name() + ";}");
@ -266,27 +266,27 @@ void SkeletonPartWidget::updateCheckedState(bool checked)
m_backgroundWidget->setStyleSheet("QWidget#background {border: 1px solid transparent;}"); m_backgroundWidget->setStyleSheet("QWidget#background {border: 1px solid transparent;}");
} }
void SkeletonPartWidget::mouseDoubleClickEvent(QMouseEvent *event) void PartWidget::mouseDoubleClickEvent(QMouseEvent *event)
{ {
QWidget::mouseDoubleClickEvent(event); QWidget::mouseDoubleClickEvent(event);
emit checkPart(m_partId); emit checkPart(m_partId);
} }
void SkeletonPartWidget::initToolButtonWithoutFont(QPushButton *button) void PartWidget::initToolButtonWithoutFont(QPushButton *button)
{ {
Theme::initAwesomeToolButtonWithoutFont(button); Theme::initAwesomeToolButtonWithoutFont(button);
} }
void SkeletonPartWidget::initToolButton(QPushButton *button) void PartWidget::initToolButton(QPushButton *button)
{ {
Theme::initAwesomeToolButton(button); Theme::initAwesomeToolButton(button);
} }
void SkeletonPartWidget::showColorSettingPopup(const QPoint &pos) void PartWidget::showColorSettingPopup(const QPoint &pos)
{ {
QMenu popupMenu; QMenu popupMenu;
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Find part failed:" << m_partId; qDebug() << "Find part failed:" << m_partId;
return; return;
@ -353,11 +353,11 @@ void SkeletonPartWidget::showColorSettingPopup(const QPoint &pos)
popupMenu.exec(mapToGlobal(pos)); popupMenu.exec(mapToGlobal(pos));
} }
void SkeletonPartWidget::showDeformSettingPopup(const QPoint &pos) void PartWidget::showDeformSettingPopup(const QPoint &pos)
{ {
QMenu popupMenu; QMenu popupMenu;
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Find part failed:" << m_partId; qDebug() << "Find part failed:" << m_partId;
return; return;
@ -421,19 +421,19 @@ void SkeletonPartWidget::showDeformSettingPopup(const QPoint &pos)
popupMenu.exec(mapToGlobal(pos)); popupMenu.exec(mapToGlobal(pos));
} }
void SkeletonPartWidget::initButton(QPushButton *button) void PartWidget::initButton(QPushButton *button)
{ {
Theme::initAwesomeMiniButton(button); Theme::initAwesomeMiniButton(button);
} }
void SkeletonPartWidget::updateButton(QPushButton *button, QChar icon, bool highlighted) void PartWidget::updateButton(QPushButton *button, QChar icon, bool highlighted)
{ {
Theme::updateAwesomeMiniButton(button, icon, highlighted); Theme::updateAwesomeMiniButton(button, icon, highlighted);
} }
void SkeletonPartWidget::updatePreview() void PartWidget::updatePreview()
{ {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -443,9 +443,9 @@ void SkeletonPartWidget::updatePreview()
m_previewWidget->updateMesh(previewMesh); m_previewWidget->updateMesh(previewMesh);
} }
void SkeletonPartWidget::updateLockButton() void PartWidget::updateLockButton()
{ {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -456,9 +456,9 @@ void SkeletonPartWidget::updateLockButton()
updateButton(m_lockButton, QChar(fa::unlock), false); updateButton(m_lockButton, QChar(fa::unlock), false);
} }
void SkeletonPartWidget::updateVisibleButton() void PartWidget::updateVisibleButton()
{ {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -469,9 +469,9 @@ void SkeletonPartWidget::updateVisibleButton()
updateButton(m_visibleButton, QChar(fa::eyeslash), true); updateButton(m_visibleButton, QChar(fa::eyeslash), true);
} }
void SkeletonPartWidget::updateSubdivButton() void PartWidget::updateSubdivButton()
{ {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -482,9 +482,9 @@ void SkeletonPartWidget::updateSubdivButton()
updateButton(m_subdivButton, QChar(fa::squareo), false); updateButton(m_subdivButton, QChar(fa::squareo), false);
} }
void SkeletonPartWidget::updateDisableButton() void PartWidget::updateDisableButton()
{ {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -495,9 +495,9 @@ void SkeletonPartWidget::updateDisableButton()
updateButton(m_disableButton, QChar(fa::link), false); updateButton(m_disableButton, QChar(fa::link), false);
} }
void SkeletonPartWidget::updateXmirrorButton() void PartWidget::updateXmirrorButton()
{ {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -508,9 +508,9 @@ void SkeletonPartWidget::updateXmirrorButton()
updateButton(m_xMirrorButton, QChar(fa::balancescale), false); updateButton(m_xMirrorButton, QChar(fa::balancescale), false);
} }
void SkeletonPartWidget::updateDeformButton() void PartWidget::updateDeformButton()
{ {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -521,9 +521,9 @@ void SkeletonPartWidget::updateDeformButton()
updateButton(m_deformButton, QChar(fa::handlizardo), false); updateButton(m_deformButton, QChar(fa::handlizardo), false);
} }
void SkeletonPartWidget::updateRoundButton() void PartWidget::updateRoundButton()
{ {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -534,9 +534,9 @@ void SkeletonPartWidget::updateRoundButton()
updateButton(m_roundButton, QChar(fa::magnet), false); updateButton(m_roundButton, QChar(fa::magnet), false);
} }
void SkeletonPartWidget::updateColorButton() void PartWidget::updateColorButton()
{ {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -547,9 +547,9 @@ void SkeletonPartWidget::updateColorButton()
updateButton(m_colorButton, QChar(fa::eyedropper), false); updateButton(m_colorButton, QChar(fa::eyedropper), false);
} }
void SkeletonPartWidget::updateWrapButton() void PartWidget::updateWrapButton()
{ {
const SkeletonPart *part = m_document->findPart(m_partId); const Part *part = m_document->findPart(m_partId);
if (!part) { if (!part) {
qDebug() << "Part not found:" << m_partId; qDebug() << "Part not found:" << m_partId;
return; return;
@ -560,7 +560,7 @@ void SkeletonPartWidget::updateWrapButton()
updateButton(m_wrapButton, QChar(fa::cube), false); updateButton(m_wrapButton, QChar(fa::cube), false);
} }
void SkeletonPartWidget::reload() void PartWidget::reload()
{ {
updatePreview(); updatePreview();
updateAllButtons(); updateAllButtons();

View File

@ -1,12 +1,12 @@
#ifndef SKELETON_PART_WIDGET_H #ifndef DUST3D_PART_WIDGET_H
#define SKELETON_PART_WIDGET_H #define DUST3D_PART_WIDGET_H
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
#include <QMouseEvent> #include <QMouseEvent>
#include "skeletondocument.h" #include "document.h"
#include "modelwidget.h" #include "modelwidget.h"
class SkeletonPartWidget : public QWidget class PartWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
signals: signals:
@ -31,7 +31,7 @@ signals:
void enableBackgroundBlur(); void enableBackgroundBlur();
void disableBackgroundBlur(); void disableBackgroundBlur();
public: public:
SkeletonPartWidget(const SkeletonDocument *document, QUuid partId); PartWidget(const Document *document, QUuid partId);
void reload(); void reload();
void updatePreview(); void updatePreview();
void updateLockButton(); void updateLockButton();
@ -53,7 +53,7 @@ public slots:
void showDeformSettingPopup(const QPoint &pos); void showDeformSettingPopup(const QPoint &pos);
void showColorSettingPopup(const QPoint &pos); void showColorSettingPopup(const QPoint &pos);
private: // need initialize private: // need initialize
const SkeletonDocument *m_document; const Document *m_document;
QUuid m_partId; QUuid m_partId;
private: private:
ModelWidget *m_previewWidget; ModelWidget *m_previewWidget;

View File

@ -11,7 +11,7 @@
#include "floatnumberwidget.h" #include "floatnumberwidget.h"
#include "version.h" #include "version.h"
PoseEditWidget::PoseEditWidget(const SkeletonDocument *document, QWidget *parent) : PoseEditWidget::PoseEditWidget(const Document *document, QWidget *parent) :
QDialog(parent), QDialog(parent),
m_document(document) m_document(document)
{ {
@ -125,15 +125,15 @@ PoseEditWidget::PoseEditWidget(const SkeletonDocument *document, QWidget *parent
setLayout(mainLayout); setLayout(mainLayout);
connect(m_document, &SkeletonDocument::resultRigChanged, this, &PoseEditWidget::updatePreview); connect(m_document, &Document::resultRigChanged, this, &PoseEditWidget::updatePreview);
connect(this, &PoseEditWidget::parametersAdjusted, this, &PoseEditWidget::updatePreview); connect(this, &PoseEditWidget::parametersAdjusted, this, &PoseEditWidget::updatePreview);
connect(this, &PoseEditWidget::parametersAdjusted, [=]() { connect(this, &PoseEditWidget::parametersAdjusted, [=]() {
m_unsaved = true; m_unsaved = true;
updateTitle(); updateTitle();
}); });
connect(this, &PoseEditWidget::addPose, m_document, &SkeletonDocument::addPose); connect(this, &PoseEditWidget::addPose, m_document, &Document::addPose);
connect(this, &PoseEditWidget::renamePose, m_document, &SkeletonDocument::renamePose); connect(this, &PoseEditWidget::renamePose, m_document, &Document::renamePose);
connect(this, &PoseEditWidget::setPoseParameters, m_document, &SkeletonDocument::setPoseParameters); connect(this, &PoseEditWidget::setPoseParameters, m_document, &Document::setPoseParameters);
updatePreview(); updatePreview();
updateTitle(); updateTitle();
@ -220,7 +220,7 @@ void PoseEditWidget::updateTitle()
setWindowTitle(unifiedWindowTitle(tr("New") + (m_unsaved ? "*" : ""))); setWindowTitle(unifiedWindowTitle(tr("New") + (m_unsaved ? "*" : "")));
return; return;
} }
const SkeletonPose *pose = m_document->findPose(m_poseId); const Pose *pose = m_document->findPose(m_poseId);
if (nullptr == pose) { if (nullptr == pose) {
qDebug() << "Find pose failed:" << m_poseId; qDebug() << "Find pose failed:" << m_poseId;
return; return;

View File

@ -1,12 +1,12 @@
#ifndef POSE_EDIT_WIDGET_H #ifndef DUST3D_POSE_EDIT_WIDGET_H
#define POSE_EDIT_WIDGET_H #define DUST3D_POSE_EDIT_WIDGET_H
#include <QDialog> #include <QDialog>
#include <map> #include <map>
#include <QCloseEvent> #include <QCloseEvent>
#include <QLineEdit> #include <QLineEdit>
#include "posepreviewmanager.h" #include "posepreviewmanager.h"
#include "tetrapodposer.h" #include "tetrapodposer.h"
#include "skeletondocument.h" #include "document.h"
#include "modelwidget.h" #include "modelwidget.h"
enum class PopupWidgetType enum class PopupWidgetType
@ -25,7 +25,7 @@ signals:
void renamePose(QUuid poseId, QString name); void renamePose(QUuid poseId, QString name);
void parametersAdjusted(); void parametersAdjusted();
public: public:
PoseEditWidget(const SkeletonDocument *document, QWidget *parent=nullptr); PoseEditWidget(const Document *document, QWidget *parent=nullptr);
~PoseEditWidget(); ~PoseEditWidget();
public slots: public slots:
void updatePreview(); void updatePreview();
@ -41,7 +41,7 @@ protected:
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
void reject() override; void reject() override;
private: private:
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
PosePreviewManager *m_posePreviewManager = nullptr; PosePreviewManager *m_posePreviewManager = nullptr;
ModelWidget *m_previewWidget = nullptr; ModelWidget *m_previewWidget = nullptr;
bool m_isPreviewDirty = false; bool m_isPreviewDirty = false;

View File

@ -3,10 +3,10 @@
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
#include <QClipboard> #include <QClipboard>
#include <QApplication> #include <QApplication>
#include "skeletonxml.h" #include "snapshotxml.h"
#include "poselistwidget.h" #include "poselistwidget.h"
PoseListWidget::PoseListWidget(const SkeletonDocument *document, QWidget *parent) : PoseListWidget::PoseListWidget(const Document *document, QWidget *parent) :
QTreeWidget(parent), QTreeWidget(parent),
m_document(document) m_document(document)
{ {
@ -27,10 +27,10 @@ PoseListWidget::PoseListWidget(const SkeletonDocument *document, QWidget *parent
setContentsMargins(0, 0, 0, 0); setContentsMargins(0, 0, 0, 0);
connect(document, &SkeletonDocument::poseListChanged, this, &PoseListWidget::reload); connect(document, &Document::poseListChanged, this, &PoseListWidget::reload);
connect(document, &SkeletonDocument::cleanup, this, &PoseListWidget::removeAllContent); connect(document, &Document::cleanup, this, &PoseListWidget::removeAllContent);
connect(this, &PoseListWidget::removePose, document, &SkeletonDocument::removePose); connect(this, &PoseListWidget::removePose, document, &Document::removePose);
setContextMenuPolicy(Qt::CustomContextMenu); setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &QTreeWidget::customContextMenuRequested, this, &PoseListWidget::showContextMenu); connect(this, &QTreeWidget::customContextMenuRequested, this, &PoseListWidget::showContextMenu);
@ -190,7 +190,7 @@ void PoseListWidget::showContextMenu(const QPoint &pos)
QAction pasteAction(tr("Paste"), this); QAction pasteAction(tr("Paste"), this);
if (m_document->hasPastablePosesInClipboard()) { if (m_document->hasPastablePosesInClipboard()) {
connect(&pasteAction, &QAction::triggered, m_document, &SkeletonDocument::paste); connect(&pasteAction, &QAction::triggered, m_document, &Document::paste);
contextMenu.addAction(&pasteAction); contextMenu.addAction(&pasteAction);
} }
@ -287,8 +287,8 @@ void PoseListWidget::copy()
std::set<QUuid> emptySet; std::set<QUuid> emptySet;
SkeletonSnapshot snapshot; Snapshot snapshot;
m_document->toSnapshot(&snapshot, emptySet, SkeletonDocumentToSnapshotFor::Poses, m_document->toSnapshot(&snapshot, emptySet, DocumentToSnapshotFor::Poses,
limitPoseIds); limitPoseIds);
QString snapshotXml; QString snapshotXml;
QXmlStreamWriter xmlStreamWriter(&snapshotXml); QXmlStreamWriter xmlStreamWriter(&snapshotXml);

View File

@ -1,9 +1,9 @@
#ifndef POSE_LIST_WIDGET_H #ifndef DUST3D_POSE_LIST_WIDGET_H
#define POSE_LIST_WIDGET_H #define DUST3D_POSE_LIST_WIDGET_H
#include <QTreeWidget> #include <QTreeWidget>
#include <map> #include <map>
#include <QMouseEvent> #include <QMouseEvent>
#include "skeletondocument.h" #include "document.h"
#include "posewidget.h" #include "posewidget.h"
class PoseListWidget : public QTreeWidget class PoseListWidget : public QTreeWidget
@ -14,7 +14,7 @@ signals:
void modifyPose(QUuid poseId); void modifyPose(QUuid poseId);
void cornerButtonClicked(QUuid poseId); void cornerButtonClicked(QUuid poseId);
public: public:
PoseListWidget(const SkeletonDocument *document, QWidget *parent=nullptr); PoseListWidget(const Document *document, QWidget *parent=nullptr);
bool isPoseSelected(QUuid poseId); bool isPoseSelected(QUuid poseId);
public slots: public slots:
void reload(); void reload();
@ -31,7 +31,7 @@ protected:
private: private:
int calculateColumnCount(); int calculateColumnCount();
void updatePoseSelectState(QUuid poseId, bool selected); void updatePoseSelectState(QUuid poseId, bool selected);
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
std::map<QUuid, std::pair<QTreeWidgetItem *, int>> m_itemMap; std::map<QUuid, std::pair<QTreeWidgetItem *, int>> m_itemMap;
std::set<QUuid> m_selectedPoseIds; std::set<QUuid> m_selectedPoseIds;
QUuid m_currentSelectedPoseId; QUuid m_currentSelectedPoseId;

View File

@ -6,7 +6,7 @@
#include "poseeditwidget.h" #include "poseeditwidget.h"
#include "infolabel.h" #include "infolabel.h"
PoseManageWidget::PoseManageWidget(const SkeletonDocument *document, QWidget *parent) : PoseManageWidget::PoseManageWidget(const Document *document, QWidget *parent) :
QWidget(parent), QWidget(parent),
m_document(document) m_document(document)
{ {
@ -35,8 +35,8 @@ PoseManageWidget::PoseManageWidget(const SkeletonDocument *document, QWidget *pa
} }
}; };
connect(m_document, &SkeletonDocument::resultRigChanged, this, refreshInfoLabel); connect(m_document, &Document::resultRigChanged, this, refreshInfoLabel);
connect(m_document, &SkeletonDocument::cleanup, this, refreshInfoLabel); connect(m_document, &Document::cleanup, this, refreshInfoLabel);
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(infoLabel); mainLayout->addWidget(infoLabel);
@ -66,7 +66,7 @@ void PoseManageWidget::showPoseDialog(QUuid poseId)
PoseEditWidget *poseEditWidget = new PoseEditWidget(m_document); PoseEditWidget *poseEditWidget = new PoseEditWidget(m_document);
poseEditWidget->setAttribute(Qt::WA_DeleteOnClose); poseEditWidget->setAttribute(Qt::WA_DeleteOnClose);
if (!poseId.isNull()) { if (!poseId.isNull()) {
const SkeletonPose *pose = m_document->findPose(poseId); const Pose *pose = m_document->findPose(poseId);
if (nullptr != pose) { if (nullptr != pose) {
poseEditWidget->setEditPoseId(poseId); poseEditWidget->setEditPoseId(poseId);
poseEditWidget->setEditPoseName(pose->name); poseEditWidget->setEditPoseName(pose->name);

View File

@ -1,7 +1,7 @@
#ifndef POSE_MANAGE_WIDGET_H #ifndef DUST3D_POSE_MANAGE_WIDGET_H
#define POSE_MANAGE_WIDGET_H #define DUST3D_POSE_MANAGE_WIDGET_H
#include <QWidget> #include <QWidget>
#include "skeletondocument.h" #include "document.h"
#include "poselistwidget.h" #include "poselistwidget.h"
class PoseManageWidget : public QWidget class PoseManageWidget : public QWidget
@ -11,7 +11,7 @@ signals:
void registerDialog(QWidget *widget); void registerDialog(QWidget *widget);
void unregisterDialog(QWidget *widget); void unregisterDialog(QWidget *widget);
public: public:
PoseManageWidget(const SkeletonDocument *document, QWidget *parent=nullptr); PoseManageWidget(const Document *document, QWidget *parent=nullptr);
PoseListWidget *poseListWidget(); PoseListWidget *poseListWidget();
protected: protected:
virtual QSize sizeHint() const; virtual QSize sizeHint() const;
@ -19,7 +19,7 @@ public slots:
void showAddPoseDialog(); void showAddPoseDialog();
void showPoseDialog(QUuid poseId); void showPoseDialog(QUuid poseId);
private: private:
const SkeletonDocument *m_document = nullptr; const Document *m_document = nullptr;
PoseListWidget *m_poseListWidget = nullptr; PoseListWidget *m_poseListWidget = nullptr;
}; };

View File

@ -3,10 +3,10 @@
#include "skinnedmeshcreator.h" #include "skinnedmeshcreator.h"
PoseMeshCreator::PoseMeshCreator(const std::vector<JointNode> &resultNodes, PoseMeshCreator::PoseMeshCreator(const std::vector<JointNode> &resultNodes,
const MeshResultContext &meshResultContext, const Outcome &outcome,
const std::map<int, AutoRiggerVertexWeights> &resultWeights) : const std::map<int, AutoRiggerVertexWeights> &resultWeights) :
m_resultNodes(resultNodes), m_resultNodes(resultNodes),
m_meshResultContext(meshResultContext), m_outcome(outcome),
m_resultWeights(resultWeights) m_resultWeights(resultWeights)
{ {
} }
@ -25,7 +25,7 @@ MeshLoader *PoseMeshCreator::takeResultMesh()
void PoseMeshCreator::createMesh() void PoseMeshCreator::createMesh()
{ {
SkinnedMeshCreator skinnedMeshCreator(m_meshResultContext, m_resultWeights); SkinnedMeshCreator skinnedMeshCreator(m_outcome, m_resultWeights);
std::vector<QMatrix4x4> matricies; std::vector<QMatrix4x4> matricies;
matricies.resize(m_resultNodes.size()); matricies.resize(m_resultNodes.size());

View File

@ -1,9 +1,9 @@
#ifndef POSE_MESH_CREATOR_H #ifndef DUST3D_POSE_MESH_CREATOR_H
#define POSE_MESH_CREATOR_H #define DUST3D_POSE_MESH_CREATOR_H
#include <QObject> #include <QObject>
#include "meshloader.h" #include "meshloader.h"
#include "jointnodetree.h" #include "jointnodetree.h"
#include "meshresultcontext.h" #include "outcome.h"
class PoseMeshCreator : public QObject class PoseMeshCreator : public QObject
{ {
@ -12,7 +12,7 @@ signals:
void finished(); void finished();
public: public:
PoseMeshCreator(const std::vector<JointNode> &resultNodes, PoseMeshCreator(const std::vector<JointNode> &resultNodes,
const MeshResultContext &meshResultContext, const Outcome &outcome,
const std::map<int, AutoRiggerVertexWeights> &resultWeights); const std::map<int, AutoRiggerVertexWeights> &resultWeights);
~PoseMeshCreator(); ~PoseMeshCreator();
void createMesh(); void createMesh();
@ -21,7 +21,7 @@ public slots:
void process(); void process();
private: private:
std::vector<JointNode> m_resultNodes; std::vector<JointNode> m_resultNodes;
MeshResultContext m_meshResultContext; Outcome m_outcome;
std::map<int, AutoRiggerVertexWeights> m_resultWeights; std::map<int, AutoRiggerVertexWeights> m_resultWeights;
MeshLoader *m_resultMesh = nullptr; MeshLoader *m_resultMesh = nullptr;
}; };

View File

@ -17,7 +17,7 @@ bool PosePreviewManager::isRendering()
} }
bool PosePreviewManager::postUpdate(const Poser &poser, bool PosePreviewManager::postUpdate(const Poser &poser,
const MeshResultContext &meshResultContext, const Outcome &outcome,
const std::map<int, AutoRiggerVertexWeights> &resultWeights) const std::map<int, AutoRiggerVertexWeights> &resultWeights)
{ {
if (nullptr != m_poseMeshCreator) if (nullptr != m_poseMeshCreator)
@ -26,7 +26,7 @@ bool PosePreviewManager::postUpdate(const Poser &poser,
qDebug() << "Pose mesh generating.."; qDebug() << "Pose mesh generating..";
QThread *thread = new QThread; QThread *thread = new QThread;
m_poseMeshCreator = new PoseMeshCreator(poser.resultNodes(), meshResultContext, resultWeights); m_poseMeshCreator = new PoseMeshCreator(poser.resultNodes(), outcome, resultWeights);
m_poseMeshCreator->moveToThread(thread); m_poseMeshCreator->moveToThread(thread);
connect(thread, &QThread::started, m_poseMeshCreator, &PoseMeshCreator::process); connect(thread, &QThread::started, m_poseMeshCreator, &PoseMeshCreator::process);
connect(m_poseMeshCreator, &PoseMeshCreator::finished, this, &PosePreviewManager::poseMeshReady); connect(m_poseMeshCreator, &PoseMeshCreator::finished, this, &PosePreviewManager::poseMeshReady);

View File

@ -1,7 +1,7 @@
#ifndef POSE_PREVIEW_MANAGER_H #ifndef DUST3D_POSE_PREVIEW_MANAGER_H
#define POSE_PREVIEW_MANAGER_H #define DUST3D_POSE_PREVIEW_MANAGER_H
#include <QWidget> #include <QWidget>
#include "skeletondocument.h" #include "document.h"
#include "poser.h" #include "poser.h"
#include "posemeshcreator.h" #include "posemeshcreator.h"
#include "meshloader.h" #include "meshloader.h"
@ -14,7 +14,7 @@ public:
~PosePreviewManager(); ~PosePreviewManager();
bool isRendering(); bool isRendering();
bool postUpdate(const Poser &poser, bool postUpdate(const Poser &poser,
const MeshResultContext &meshResultContext, const Outcome &outcome,
const std::map<int, AutoRiggerVertexWeights> &resultWeights); const std::map<int, AutoRiggerVertexWeights> &resultWeights);
MeshLoader *takeResultPreviewMesh(); MeshLoader *takeResultPreviewMesh();
private slots: private slots:

View File

@ -6,10 +6,10 @@
PosePreviewsGenerator::PosePreviewsGenerator(const std::vector<AutoRiggerBone> *rigBones, PosePreviewsGenerator::PosePreviewsGenerator(const std::vector<AutoRiggerBone> *rigBones,
const std::map<int, AutoRiggerVertexWeights> *rigWeights, const std::map<int, AutoRiggerVertexWeights> *rigWeights,
const MeshResultContext &meshResultContext) : const Outcome &outcome) :
m_rigBones(*rigBones), m_rigBones(*rigBones),
m_rigWeights(*rigWeights), m_rigWeights(*rigWeights),
m_meshResultContext(new MeshResultContext(meshResultContext)) m_outcome(new Outcome(outcome))
{ {
} }
@ -18,7 +18,7 @@ PosePreviewsGenerator::~PosePreviewsGenerator()
for (auto &item: m_previews) { for (auto &item: m_previews) {
delete item.second; delete item.second;
} }
delete m_meshResultContext; delete m_outcome;
} }
void PosePreviewsGenerator::addPose(QUuid poseId, const std::map<QString, std::map<QString, QString>> &pose) void PosePreviewsGenerator::addPose(QUuid poseId, const std::map<QString, std::map<QString, QString>> &pose)
@ -48,7 +48,7 @@ void PosePreviewsGenerator::process()
poser->parameters() = pose.second; poser->parameters() = pose.second;
poser->commit(); poser->commit();
PoseMeshCreator *poseMeshCreator = new PoseMeshCreator(poser->resultNodes(), *m_meshResultContext, m_rigWeights); PoseMeshCreator *poseMeshCreator = new PoseMeshCreator(poser->resultNodes(), *m_outcome, m_rigWeights);
poseMeshCreator->createMesh(); poseMeshCreator->createMesh();
m_previews[pose.first] = poseMeshCreator->takeResultMesh(); m_previews[pose.first] = poseMeshCreator->takeResultMesh();
delete poseMeshCreator; delete poseMeshCreator;

View File

@ -1,12 +1,12 @@
#ifndef POSE_PREVIEWS_GENERATOR_H #ifndef DUST3D_POSE_PREVIEWS_GENERATOR_H
#define POSE_PREVIEWS_GENERATOR_H #define DUST3D_POSE_PREVIEWS_GENERATOR_H
#include <QObject> #include <QObject>
#include <map> #include <map>
#include <QUuid> #include <QUuid>
#include <vector> #include <vector>
#include "meshloader.h" #include "meshloader.h"
#include "autorigger.h" #include "autorigger.h"
#include "meshresultcontext.h" #include "outcome.h"
class PosePreviewsGenerator : public QObject class PosePreviewsGenerator : public QObject
{ {
@ -14,7 +14,7 @@ class PosePreviewsGenerator : public QObject
public: public:
PosePreviewsGenerator(const std::vector<AutoRiggerBone> *rigBones, PosePreviewsGenerator(const std::vector<AutoRiggerBone> *rigBones,
const std::map<int, AutoRiggerVertexWeights> *rigWeights, const std::map<int, AutoRiggerVertexWeights> *rigWeights,
const MeshResultContext &meshResultContext); const Outcome &outcome);
~PosePreviewsGenerator(); ~PosePreviewsGenerator();
void addPose(QUuid poseId, const std::map<QString, std::map<QString, QString>> &pose); void addPose(QUuid poseId, const std::map<QString, std::map<QString, QString>> &pose);
const std::set<QUuid> &generatedPreviewPoseIds(); const std::set<QUuid> &generatedPreviewPoseIds();
@ -26,7 +26,7 @@ public slots:
private: private:
std::vector<AutoRiggerBone> m_rigBones; std::vector<AutoRiggerBone> m_rigBones;
std::map<int, AutoRiggerVertexWeights> m_rigWeights; std::map<int, AutoRiggerVertexWeights> m_rigWeights;
MeshResultContext *m_meshResultContext = nullptr; Outcome *m_outcome = nullptr;
std::vector<std::pair<QUuid, std::map<QString, std::map<QString, QString>>>> m_poses; std::vector<std::pair<QUuid, std::map<QString, std::map<QString, QString>>>> m_poses;
std::map<QUuid, MeshLoader *> m_previews; std::map<QUuid, MeshLoader *> m_previews;
std::set<QUuid> m_generatedPoseIds; std::set<QUuid> m_generatedPoseIds;

View File

@ -1,9 +1,9 @@
#ifndef POSER_H #ifndef DUST3D_POSER_H
#define POSER_H #define DUST3D_POSER_H
#include <QObject> #include <QObject>
#include "autorigger.h" #include "autorigger.h"
#include "jointnodetree.h" #include "jointnodetree.h"
#include "dust3dutil.h" #include "util.h"
class Poser : public QObject class Poser : public QObject
{ {

Some files were not shown because too many files have changed in this diff Show More