Forward declare Document

master
huxingyi 2020-12-19 11:59:24 +09:30
parent 1e7057bd90
commit aae9d3fca5
46 changed files with 157 additions and 229 deletions

View File

@ -502,6 +502,9 @@ HEADERS += src/silhouetteimagegenerator.h
SOURCES += src/bonedocument.cpp SOURCES += src/bonedocument.cpp
HEADERS += src/bonedocument.h HEADERS += src/bonedocument.h
SOURCES += src/materiallayer.cpp
HEADERS += src/materiallayer.h
SOURCES += src/main.cpp SOURCES += src/main.cpp
HEADERS += src/version.h HEADERS += src/version.h

View File

@ -9,6 +9,7 @@
#include "autosaver.h" #include "autosaver.h"
#include "documentsaver.h" #include "documentsaver.h"
#include "snapshotxml.h" #include "snapshotxml.h"
#include "document.h"
AutoSaver::AutoSaver(Document *document) : AutoSaver::AutoSaver(Document *document) :
m_document(document) m_document(document)

View File

@ -2,8 +2,8 @@
#define DUST3D_AUTO_SAVER_H #define DUST3D_AUTO_SAVER_H
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include "document.h"
class Document;
class DocumentSaver; class DocumentSaver;
class AutoSaver : public QObject class AutoSaver : public QObject

View File

@ -60,3 +60,44 @@ void BoneDocument::updateTurnaround(const QImage &image)
turnaround = image; turnaround = image;
emit turnaroundChanged(); emit turnaroundChanged();
} }
void BoneDocument::setEditMode(SkeletonDocumentEditMode mode)
{
if (editMode == mode)
return;
editMode = mode;
emit editModeChanged();
}
void BoneDocument::setXlockState(bool locked)
{
if (xlocked == locked)
return;
xlocked = locked;
emit xlockStateChanged();
}
void BoneDocument::setYlockState(bool locked)
{
if (ylocked == locked)
return;
ylocked = locked;
emit ylockStateChanged();
}
void BoneDocument::setZlockState(bool locked)
{
if (zlocked == locked)
return;
zlocked = locked;
emit zlockStateChanged();
}
void BoneDocument::setRadiusLockState(bool locked)
{
if (radiusLocked == locked)
return;
radiusLocked = locked;
emit radiusLockStateChanged();
}

View File

@ -7,6 +7,11 @@ class BoneDocument : public SkeletonDocument
Q_OBJECT Q_OBJECT
signals: signals:
void turnaroundChanged(); void turnaroundChanged();
void editModeChanged();
void xlockStateChanged();
void ylockStateChanged();
void zlockStateChanged();
void radiusLockStateChanged();
public: public:
BoneDocument(); BoneDocument();
bool undoable(void) const; bool undoable(void) const;
@ -16,10 +21,16 @@ public:
bool isNodeEditable(QUuid) const; bool isNodeEditable(QUuid) const;
bool isEdgeEditable(QUuid) const; bool isEdgeEditable(QUuid) const;
void copyNodes(std::set<QUuid> nodeIdSet) const; void copyNodes(std::set<QUuid> nodeIdSet) const;
public slots:
void undo(void); void undo(void);
void redo(void); void redo(void);
void paste(void); void paste(void);
void updateTurnaround(const QImage &image); void updateTurnaround(const QImage &image);
void setEditMode(SkeletonDocumentEditMode mode);
void setXlockState(bool locked);
void setYlockState(bool locked);
void setZlockState(bool locked);
void setRadiusLockState(bool locked);
}; };
#endif #endif

View File

@ -44,7 +44,6 @@ Document::Document() :
m_meshGenerator(nullptr), m_meshGenerator(nullptr),
m_resultMesh(nullptr), m_resultMesh(nullptr),
m_paintedMesh(nullptr), m_paintedMesh(nullptr),
//m_resultMeshCutFaceTransforms(nullptr),
m_resultMeshNodesCutFaces(nullptr), m_resultMeshNodesCutFaces(nullptr),
m_isMeshGenerationSucceed(true), m_isMeshGenerationSucceed(true),
m_batchChangeRefCount(0), m_batchChangeRefCount(0),
@ -109,7 +108,6 @@ Document::~Document()
{ {
delete m_resultMesh; delete m_resultMesh;
delete m_paintedMesh; delete m_paintedMesh;
//delete m_resultMeshCutFaceTransforms;
delete m_resultMeshNodesCutFaces; delete m_resultMeshNodesCutFaces;
delete m_postProcessedObject; delete m_postProcessedObject;
delete textureImage; delete textureImage;
@ -292,10 +290,6 @@ void Document::removeEdge(QUuid edgeId)
updateLinkedPart(oldPartId, newPartNodeNumMap[0].first); updateLinkedPart(oldPartId, newPartNodeNumMap[0].first);
} }
for (const auto &partId: newPartIds) {
checkPartGrid(partId);
}
emit skeletonChanged(); emit skeletonChanged();
} }
@ -375,10 +369,6 @@ void Document::removeNode(QUuid nodeId)
updateLinkedPart(oldPartId, newPartNodeNumMap[0].first); updateLinkedPart(oldPartId, newPartNodeNumMap[0].first);
} }
for (const auto &partId: newPartIds) {
checkPartGrid(partId);
}
emit skeletonChanged(); emit skeletonChanged();
} }
@ -444,7 +434,6 @@ QUuid Document::createNode(QUuid nodeId, float x, float y, float z, float radius
if (newPartAdded) if (newPartAdded)
addPartToComponent(partId, m_currentCanvasComponentId); addPartToComponent(partId, m_currentCanvasComponentId);
checkPartGrid(partId);
emit skeletonChanged(); emit skeletonChanged();
return node.id; return node.id;
@ -594,36 +583,9 @@ void Document::addEdge(QUuid fromNodeId, QUuid toNodeId)
removePart(toPartId); removePart(toPartId);
} }
checkPartGrid(fromNode->partId);
emit skeletonChanged(); emit skeletonChanged();
} }
void Document::checkPartGrid(QUuid partId)
{
return;
/*
SkeletonPart *part = (SkeletonPart *)findPart(partId);
if (nullptr == part)
return;
bool isGrid = false;
for (const auto &nodeId: part->nodeIds) {
const SkeletonNode *node = findNode(nodeId);
if (nullptr == node)
continue;
if (node->edgeIds.size() >= 3) {
isGrid = true;
break;
}
}
if (part->gridded == isGrid)
return;
part->gridded = isGrid;
part->dirty = true;
emit partGridStateChanged(partId);
*/
}
void Document::updateLinkedPart(QUuid oldPartId, QUuid newPartId) void Document::updateLinkedPart(QUuid oldPartId, QUuid newPartId)
{ {
for (auto &partIt: partMap) { for (auto &partIt: partMap) {
@ -1221,10 +1183,6 @@ void Document::toSnapshot(Snapshot *snapshot, const std::set<QUuid> &limitNodeId
component["expanded"] = componentIt.second.expanded ? "true" : "false"; component["expanded"] = componentIt.second.expanded ? "true" : "false";
component["combineMode"] = CombineModeToString(componentIt.second.combineMode); component["combineMode"] = CombineModeToString(componentIt.second.combineMode);
component["__dirty"] = componentIt.second.dirty ? "true" : "false"; component["__dirty"] = componentIt.second.dirty ? "true" : "false";
if (componentIt.second.smoothAllAdjusted())
component["smoothAll"] = QString::number(componentIt.second.smoothAll);
if (componentIt.second.smoothSeamAdjusted())
component["smoothSeam"] = QString::number(componentIt.second.smoothSeam);
QStringList childIdList; QStringList childIdList;
for (const auto &childId: componentIt.second.childrenIds) { for (const auto &childId: componentIt.second.childrenIds) {
childIdList.append(childId.toString()); childIdList.append(childId.toString());
@ -1378,7 +1336,6 @@ void Document::createSinglePartFromEdges(const std::vector<QVector3D> &nodes,
} }
for (const auto &partIt : newAddedPartIds) { for (const auto &partIt : newAddedPartIds) {
checkPartGrid(partIt);
emit partVisibleStateChanged(partIt); emit partVisibleStateChanged(partIt);
} }
@ -1657,12 +1614,6 @@ void Document::addFromSnapshot(const Snapshot &snapshot, enum SnapshotSource sou
if (isTrueValueString(valueOfKeyInMapOrEmpty(componentKv.second, "inverse"))) if (isTrueValueString(valueOfKeyInMapOrEmpty(componentKv.second, "inverse")))
component.combineMode = CombineMode::Inversion; component.combineMode = CombineMode::Inversion;
} }
const auto &smoothAllIt = componentKv.second.find("smoothAll");
if (smoothAllIt != componentKv.second.end())
component.setSmoothAll(smoothAllIt->second.toFloat());
const auto &smoothSeamIt = componentKv.second.find("smoothSeam");
if (smoothSeamIt != componentKv.second.end())
component.setSmoothSeam(smoothSeamIt->second.toFloat());
//qDebug() << "Add component:" << component.id << " old:" << componentKv.first << "name:" << component.name; //qDebug() << "Add component:" << component.id << " old:" << componentKv.first << "name:" << component.name;
if ("partId" == linkDataType) { if ("partId" == linkDataType) {
QUuid partId = oldNewIdMap[QUuid(linkData)]; QUuid partId = oldNewIdMap[QUuid(linkData)];
@ -1731,7 +1682,6 @@ void Document::addFromSnapshot(const Snapshot &snapshot, enum SnapshotSource sou
emit skeletonChanged(); emit skeletonChanged();
for (const auto &partIt : newAddedPartIds) { for (const auto &partIt : newAddedPartIds) {
checkPartGrid(partIt);
emit partVisibleStateChanged(partIt); emit partVisibleStateChanged(partIt);
} }
@ -1872,14 +1822,9 @@ void Document::meshReady()
delete m_resultMesh; delete m_resultMesh;
m_resultMesh = resultMesh; m_resultMesh = resultMesh;
//delete m_resultMeshCutFaceTransforms;
//m_resultMeshCutFaceTransforms = m_meshGenerator->takeCutFaceTransforms();
delete m_resultMeshNodesCutFaces; delete m_resultMeshNodesCutFaces;
m_resultMeshNodesCutFaces = m_meshGenerator->takeNodesCutFaces(); m_resultMeshNodesCutFaces = m_meshGenerator->takeNodesCutFaces();
//addToolToMesh(m_resultMesh);
m_isMeshGenerationSucceed = isSuccessful; m_isMeshGenerationSucceed = isSuccessful;
delete m_currentObject; delete m_currentObject;
@ -1930,36 +1875,6 @@ void Document::meshReady()
} }
} }
//void Document::addToolToMesh(Model *mesh)
//{
// if (nullptr == mesh)
// return;
//
// if (nullptr == m_resultMeshCutFaceTransforms ||
// nullptr == m_resultMeshNodesCutFaces ||
// m_resultMeshCutFaceTransforms->empty() ||
// m_resultMeshNodesCutFaces->empty())
// return;
//
// ToolMesh toolMesh;
// for (const auto &transformIt: *m_resultMeshCutFaceTransforms) {
// const auto &nodeId = transformIt.first;
// const auto &transform = transformIt.second;
// qDebug() << "nodeId:" << nodeId;
// for (const auto &cutFaceIt: (*m_resultMeshNodesCutFaces)[nodeId]) {
// const auto &cutFaceId = cutFaceIt.first;
// const auto &cutFace2d = cutFaceIt.second;
// QVector3D position = transform.translation + transform.rotation * (transform.uFactor * cutFace2d.x() + transform.vFactor * cutFace2d.y());
// qDebug() << "cutFaceId:" << cutFaceId;
// toolMesh.addNode(nodeId.toString() + cutFaceId, position);
// }
// }
// toolMesh.generate();
// int shaderVertexCount = 0;
// ShaderVertex *shaderVertices = toolMesh.takeShaderVertices(&shaderVertexCount);
// mesh->updateTool(shaderVertices, shaderVertexCount);
//}
bool Document::isPostProcessResultObsolete() const bool Document::isPostProcessResultObsolete() const
{ {
return m_isPostProcessResultObsolete; return m_isPostProcessResultObsolete;
@ -2283,32 +2198,6 @@ void Document::setComponentCombineMode(QUuid componentId, CombineMode combineMod
emit skeletonChanged(); emit skeletonChanged();
} }
void Document::setComponentSmoothAll(QUuid componentId, float toSmoothAll)
{
auto component = componentMap.find(componentId);
if (component == componentMap.end()) {
qDebug() << "Component not found:" << componentId;
return;
}
component->second.setSmoothAll(toSmoothAll);
component->second.dirty = true;
emit componentSmoothAllChanged(componentId);
emit skeletonChanged();
}
void Document::setComponentSmoothSeam(QUuid componentId, float toSmoothSeam)
{
auto component = componentMap.find(componentId);
if (component == componentMap.end()) {
qDebug() << "Component not found:" << componentId;
return;
}
component->second.setSmoothSeam(toSmoothSeam);
component->second.dirty = true;
emit componentSmoothSeamChanged(componentId);
emit skeletonChanged();
}
void Document::setPartSubdivState(QUuid partId, bool subdived) void Document::setPartSubdivState(QUuid partId, bool subdived)
{ {
auto part = partMap.find(partId); auto part = partMap.find(partId);

View File

@ -26,6 +26,7 @@
#include "paintmode.h" #include "paintmode.h"
#include "proceduralanimation.h" #include "proceduralanimation.h"
#include "texturepainter.h" #include "texturepainter.h"
#include "materiallayer.h"
class MaterialPreviewsGenerator; class MaterialPreviewsGenerator;
class MotionsGenerator; class MotionsGenerator;
@ -218,20 +219,6 @@ private:
Model *m_previewMesh = nullptr; Model *m_previewMesh = nullptr;
}; };
class MaterialMap
{
public:
TextureType forWhat;
QUuid imageId;
};
class MaterialLayer
{
public:
std::vector<MaterialMap> maps;
float tileScale = 1.0;
};
class Material class Material
{ {
public: public:
@ -283,8 +270,6 @@ signals:
void componentRemoved(QUuid componentId); void componentRemoved(QUuid componentId);
void componentAdded(QUuid componentId); void componentAdded(QUuid componentId);
void componentExpandStateChanged(QUuid componentId); void componentExpandStateChanged(QUuid componentId);
void componentSmoothAllChanged(QUuid componentId);
void componentSmoothSeamChanged(QUuid componentId);
void componentLayerChanged(QUuid componentId); void componentLayerChanged(QUuid componentId);
void nodeRemoved(QUuid nodeId); void nodeRemoved(QUuid nodeId);
void edgeRemoved(QUuid edgeId); void edgeRemoved(QUuid edgeId);
@ -549,8 +534,6 @@ public slots:
void createNewComponentAndMoveThisIn(QUuid componentId); void createNewComponentAndMoveThisIn(QUuid componentId);
void createNewChildComponent(QUuid parentComponentId); void createNewChildComponent(QUuid parentComponentId);
void setComponentExpandState(QUuid componentId, bool expanded); void setComponentExpandState(QUuid componentId, bool expanded);
void setComponentSmoothAll(QUuid componentId, float toSmoothAll);
void setComponentSmoothSeam(QUuid componentId, float toSmoothSeam);
void hideOtherComponents(QUuid componentId); void hideOtherComponents(QUuid componentId);
void lockOtherComponents(QUuid componentId); void lockOtherComponents(QUuid componentId);
void hideAllComponents(); void hideAllComponents();
@ -622,15 +605,12 @@ private:
void markAllDirty(); void markAllDirty();
void removeRigResults(); void removeRigResults();
void updateLinkedPart(QUuid oldPartId, QUuid newPartId); void updateLinkedPart(QUuid oldPartId, QUuid newPartId);
//void addToolToMesh(Model *mesh);
bool updateDefaultVariables(const std::map<QString, std::map<QString, QString>> &defaultVariables); bool updateDefaultVariables(const std::map<QString, std::map<QString, QString>> &defaultVariables);
void checkPartGrid(QUuid partId);
private: // need initialize private: // need initialize
bool m_isResultMeshObsolete; bool m_isResultMeshObsolete;
MeshGenerator *m_meshGenerator; MeshGenerator *m_meshGenerator;
Model *m_resultMesh; Model *m_resultMesh;
Model *m_paintedMesh; Model *m_paintedMesh;
//std::map<QUuid, StrokeMeshBuilder::CutFaceTransform> *m_resultMeshCutFaceTransforms;
std::map<QUuid, std::map<QString, QVector2D>> *m_resultMeshNodesCutFaces; std::map<QUuid, std::map<QString, QVector2D>> *m_resultMeshNodesCutFaces;
bool m_isMeshGenerationSucceed; bool m_isMeshGenerationSucceed;
int m_batchChangeRefCount; int m_batchChangeRefCount;

View File

@ -55,6 +55,7 @@
#include "silhouetteimagegenerator.h" #include "silhouetteimagegenerator.h"
#include "flowlayout.h" #include "flowlayout.h"
#include "bonedocument.h" #include "bonedocument.h"
#include "document.h"
int DocumentWindow::m_autoRecovered = false; int DocumentWindow::m_autoRecovered = false;
@ -884,6 +885,22 @@ DocumentWindow::DocumentWindow() :
connect(m_document, &Document::editModeChanged, this, [=]() { connect(m_document, &Document::editModeChanged, this, [=]() {
m_modelRenderWidget->enableMousePicking(SkeletonDocumentEditMode::Paint == m_document->editMode); m_modelRenderWidget->enableMousePicking(SkeletonDocumentEditMode::Paint == m_document->editMode);
}); });
connect(m_document, &Document::editModeChanged, this, [=]() {
m_boneDocument->setEditMode(m_document->editMode);
});
connect(m_document, &Document::xlockStateChanged, this, [=]() {
m_boneDocument->setXlockState(m_document->xlocked);
});
connect(m_document, &Document::ylockStateChanged, this, [=]() {
m_boneDocument->setYlockState(m_document->ylocked);
});
connect(m_document, &Document::zlockStateChanged, this, [=]() {
m_boneDocument->setZlockState(m_document->zlocked);
});
connect(m_document, &Document::radiusLockStateChanged, this, [=]() {
m_boneDocument->setRadiusLockState(m_document->radiusLocked);
});
m_partListDockerVisibleSwitchConnection = connect(m_document, &Document::skeletonChanged, [=]() { m_partListDockerVisibleSwitchConnection = connect(m_document, &Document::skeletonChanged, [=]() {
if (m_shapeGraphicsWidget->hasItems()) { if (m_shapeGraphicsWidget->hasItems()) {
@ -894,6 +911,7 @@ DocumentWindow::DocumentWindow() :
}); });
connect(m_document, &Document::editModeChanged, shapeGraphicsWidget, &SkeletonGraphicsWidget::editModeChanged); connect(m_document, &Document::editModeChanged, shapeGraphicsWidget, &SkeletonGraphicsWidget::editModeChanged);
connect(m_boneDocument, &BoneDocument::editModeChanged, boneGraphicsWidget, &SkeletonGraphicsWidget::editModeChanged);
connect(shapeGraphicsWidget, &SkeletonGraphicsWidget::shortcutToggleWireframe, [=]() { connect(shapeGraphicsWidget, &SkeletonGraphicsWidget::shortcutToggleWireframe, [=]() {
m_modelRenderWidget->toggleWireframe(); m_modelRenderWidget->toggleWireframe();
@ -984,8 +1002,6 @@ DocumentWindow::DocumentWindow() :
connect(m_partTreeWidget, &PartTreeWidget::createNewChildComponent, m_document, &Document::createNewChildComponent); connect(m_partTreeWidget, &PartTreeWidget::createNewChildComponent, m_document, &Document::createNewChildComponent);
connect(m_partTreeWidget, &PartTreeWidget::renameComponent, m_document, &Document::renameComponent); connect(m_partTreeWidget, &PartTreeWidget::renameComponent, m_document, &Document::renameComponent);
connect(m_partTreeWidget, &PartTreeWidget::setComponentExpandState, m_document, &Document::setComponentExpandState); connect(m_partTreeWidget, &PartTreeWidget::setComponentExpandState, m_document, &Document::setComponentExpandState);
connect(m_partTreeWidget, &PartTreeWidget::setComponentSmoothAll, m_document, &Document::setComponentSmoothAll);
connect(m_partTreeWidget, &PartTreeWidget::setComponentSmoothSeam, m_document, &Document::setComponentSmoothSeam);
connect(m_partTreeWidget, &PartTreeWidget::moveComponent, m_document, &Document::moveComponent); connect(m_partTreeWidget, &PartTreeWidget::moveComponent, m_document, &Document::moveComponent);
connect(m_partTreeWidget, &PartTreeWidget::removeComponent, m_document, &Document::removeComponent); connect(m_partTreeWidget, &PartTreeWidget::removeComponent, m_document, &Document::removeComponent);
connect(m_partTreeWidget, &PartTreeWidget::hideOtherComponents, m_document, &Document::hideOtherComponents); connect(m_partTreeWidget, &PartTreeWidget::hideOtherComponents, m_document, &Document::hideOtherComponents);
@ -1177,6 +1193,7 @@ void DocumentWindow::toggleRotation()
if (nullptr == m_shapeGraphicsWidget) if (nullptr == m_shapeGraphicsWidget)
return; return;
m_shapeGraphicsWidget->setRotated(!m_shapeGraphicsWidget->rotated()); m_shapeGraphicsWidget->setRotated(!m_shapeGraphicsWidget->rotated());
m_boneGraphicsWidget->setRotated(m_shapeGraphicsWidget->rotated());
updateRotationButtonState(); updateRotationButtonState();
} }

View File

@ -10,7 +10,6 @@
#include <map> #include <map>
#include <QStringList> #include <QStringList>
#include <QLabel> #include <QLabel>
#include "document.h"
#include "modelwidget.h" #include "modelwidget.h"
#include "rigwidget.h" #include "rigwidget.h"
#include "bonemark.h" #include "bonemark.h"
@ -21,11 +20,13 @@
#include "partpreviewimagesgenerator.h" #include "partpreviewimagesgenerator.h"
#include "QtColorWidgets/ColorWheel" #include "QtColorWidgets/ColorWheel"
class Document;
class SkeletonGraphicsWidget; class SkeletonGraphicsWidget;
class PartTreeWidget; class PartTreeWidget;
class SpinnableAwesomeButton; class SpinnableAwesomeButton;
class SilhouetteImageGenerator; class SilhouetteImageGenerator;
class BoneDocument; class BoneDocument;
class Snapshot;
class DocumentWindow : public QMainWindow class DocumentWindow : public QMainWindow
{ {

View File

@ -10,6 +10,7 @@
#include "jointnodetree.h" #include "jointnodetree.h"
#include "util.h" #include "util.h"
#include "modelshaderprogram.h" #include "modelshaderprogram.h"
#include "document.h"
using namespace fbx; using namespace fbx;

View File

@ -7,7 +7,8 @@
#include <QQuaternion> #include <QQuaternion>
#include <QImage> #include <QImage>
#include "object.h" #include "object.h"
#include "document.h" #include "rig.h"
#include "jointnodetree.h"
class FbxFileWriter : public QObject class FbxFileWriter : public QObject
{ {

View File

@ -11,6 +11,7 @@
#include "documentwindow.h" #include "documentwindow.h"
#include "theme.h" #include "theme.h"
#include "version.h" #include "version.h"
#include "document.h"
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {

View File

@ -2,7 +2,7 @@
#define DUST3D_MARK_ICON_CREATOR_H #define DUST3D_MARK_ICON_CREATOR_H
#include <map> #include <map>
#include <QIcon> #include <QIcon>
#include "document.h" #include "bonemark.h"
class MarkIconCreator class MarkIconCreator
{ {

View File

@ -15,6 +15,7 @@
#include "version.h" #include "version.h"
#include "imageforever.h" #include "imageforever.h"
#include "util.h" #include "util.h"
#include "document.h"
ImagePreviewWidget *MaterialEditWidget::createMapButton() ImagePreviewWidget *MaterialEditWidget::createMapButton()
{ {

View File

@ -4,11 +4,13 @@
#include <map> #include <map>
#include <QCloseEvent> #include <QCloseEvent>
#include <QLineEdit> #include <QLineEdit>
#include "document.h"
#include "modelwidget.h" #include "modelwidget.h"
#include "materialpreviewsgenerator.h" #include "materialpreviewsgenerator.h"
#include "imagepreviewwidget.h" #include "imagepreviewwidget.h"
#include "floatnumberwidget.h" #include "floatnumberwidget.h"
#include "materiallayer.h"
class Document;
enum class PopupWidgetType enum class PopupWidgetType
{ {

1
src/materiallayer.cpp Normal file
View File

@ -0,0 +1 @@
#include "materiallayer.h"

21
src/materiallayer.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef DUST3D_MATERIAL_LAYER_H
#define DUST3D_MATERIAL_LAYER_H
#include <QUuid>
#include <vector>
#include "texturetype.h"
class MaterialMap
{
public:
TextureType forWhat;
QUuid imageId;
};
class MaterialLayer
{
public:
std::vector<MaterialMap> maps;
float tileScale = 1.0;
};
#endif

View File

@ -5,6 +5,7 @@
#include <QApplication> #include <QApplication>
#include "snapshotxml.h" #include "snapshotxml.h"
#include "materiallistwidget.h" #include "materiallistwidget.h"
#include "document.h"
MaterialListWidget::MaterialListWidget(const Document *document, QWidget *parent) : MaterialListWidget::MaterialListWidget(const Document *document, QWidget *parent) :
QTreeWidget(parent), QTreeWidget(parent),

View File

@ -3,9 +3,10 @@
#include <QTreeWidget> #include <QTreeWidget>
#include <map> #include <map>
#include <QMouseEvent> #include <QMouseEvent>
#include "document.h"
#include "materialwidget.h" #include "materialwidget.h"
class Document;
class MaterialListWidget : public QTreeWidget class MaterialListWidget : public QTreeWidget
{ {
Q_OBJECT Q_OBJECT

View File

@ -5,6 +5,7 @@
#include "theme.h" #include "theme.h"
#include "materialeditwidget.h" #include "materialeditwidget.h"
#include "infolabel.h" #include "infolabel.h"
#include "document.h"
MaterialManageWidget::MaterialManageWidget(const Document *document, QWidget *parent) : MaterialManageWidget::MaterialManageWidget(const Document *document, QWidget *parent) :
QWidget(parent), QWidget(parent),

View File

@ -1,9 +1,10 @@
#ifndef DUST3D_MATERIAL_MANAGE_WIDGET_H #ifndef DUST3D_MATERIAL_MANAGE_WIDGET_H
#define DUST3D_MATERIAL_MANAGE_WIDGET_H #define DUST3D_MATERIAL_MANAGE_WIDGET_H
#include <QWidget> #include <QWidget>
#include "document.h"
#include "materiallistwidget.h" #include "materiallistwidget.h"
class Document;
class MaterialManageWidget : public QWidget class MaterialManageWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT

View File

@ -5,7 +5,7 @@
#include <QUuid> #include <QUuid>
#include <vector> #include <vector>
#include "model.h" #include "model.h"
#include "document.h" #include "materiallayer.h"
class MaterialPreviewsGenerator : public QObject class MaterialPreviewsGenerator : public QObject
{ {

View File

@ -1,5 +1,6 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include "materialwidget.h" #include "materialwidget.h"
#include "document.h"
MaterialWidget::MaterialWidget(const Document *document, QUuid materialId) : MaterialWidget::MaterialWidget(const Document *document, QUuid materialId) :
m_materialId(materialId), m_materialId(materialId),

View File

@ -3,9 +3,11 @@
#include <QFrame> #include <QFrame>
#include <QLabel> #include <QLabel>
#include <QIcon> #include <QIcon>
#include "document.h" #include <QPushButton>
#include "modelwidget.h" #include "modelwidget.h"
class Document;
class MaterialWidget : public QFrame class MaterialWidget : public QFrame
{ {
Q_OBJECT Q_OBJECT

View File

@ -14,6 +14,7 @@
#include "util.h" #include "util.h"
#include "version.h" #include "version.h"
#include "vertebratamovemotionparameterswidget.h" #include "vertebratamovemotionparameterswidget.h"
#include "theme.h"
MotionEditWidget::~MotionEditWidget() MotionEditWidget::~MotionEditWidget()
{ {

View File

@ -5,6 +5,8 @@
#include <queue> #include <queue>
#include <QLineEdit> #include <QLineEdit>
#include <QUuid> #include <QUuid>
#include <QPushButton>
#include <QLabel>
#include "rig.h" #include "rig.h"
#include "object.h" #include "object.h"

View File

@ -5,6 +5,7 @@
#include <QApplication> #include <QApplication>
#include "snapshotxml.h" #include "snapshotxml.h"
#include "motionlistwidget.h" #include "motionlistwidget.h"
#include "document.h"
MotionListWidget::MotionListWidget(const Document *document, QWidget *parent) : MotionListWidget::MotionListWidget(const Document *document, QWidget *parent) :
QTreeWidget(parent), QTreeWidget(parent),

View File

@ -3,9 +3,10 @@
#include <QTreeWidget> #include <QTreeWidget>
#include <map> #include <map>
#include <QMouseEvent> #include <QMouseEvent>
#include "document.h"
#include "motionwidget.h" #include "motionwidget.h"
class Document;
class MotionListWidget : public QTreeWidget class MotionListWidget : public QTreeWidget
{ {
Q_OBJECT Q_OBJECT

View File

@ -5,6 +5,7 @@
#include "theme.h" #include "theme.h"
#include "infolabel.h" #include "infolabel.h"
#include "motioneditwidget.h" #include "motioneditwidget.h"
#include "document.h"
MotionManageWidget::MotionManageWidget(const Document *document, QWidget *parent) : MotionManageWidget::MotionManageWidget(const Document *document, QWidget *parent) :
QWidget(parent), QWidget(parent),

View File

@ -1,9 +1,10 @@
#ifndef DUST3D_MOTION_MANAGE_WIDGET_H #ifndef DUST3D_MOTION_MANAGE_WIDGET_H
#define DUST3D_MOTION_MANAGE_WIDGET_H #define DUST3D_MOTION_MANAGE_WIDGET_H
#include <QWidget> #include <QWidget>
#include "document.h"
#include "motionlistwidget.h" #include "motionlistwidget.h"
class Document;
class MotionManageWidget : public QWidget class MotionManageWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT

View File

@ -8,7 +8,6 @@
#include "simpleshadermesh.h" #include "simpleshadermesh.h"
#include "rig.h" #include "rig.h"
#include "jointnodetree.h" #include "jointnodetree.h"
#include "document.h"
class MotionsGenerator : public QObject class MotionsGenerator : public QObject
{ {

View File

@ -1,5 +1,6 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include "motionwidget.h" #include "motionwidget.h"
#include "document.h"
MotionWidget::MotionWidget(const Document *document, QUuid motionId) : MotionWidget::MotionWidget(const Document *document, QUuid motionId) :
m_motionId(motionId), m_motionId(motionId),

View File

@ -3,9 +3,11 @@
#include <QFrame> #include <QFrame>
#include <QLabel> #include <QLabel>
#include <QIcon> #include <QIcon>
#include "document.h" #include <QPushButton>
#include "modelwidget.h" #include "modelwidget.h"
class Document;
class MotionWidget : public QFrame class MotionWidget : public QFrame
{ {
Q_OBJECT Q_OBJECT

View File

@ -16,6 +16,7 @@
#include "skeletongraphicswidget.h" #include "skeletongraphicswidget.h"
#include "floatnumberwidget.h" #include "floatnumberwidget.h"
#include "intnumberwidget.h" #include "intnumberwidget.h"
#include "document.h"
PartTreeWidget::PartTreeWidget(const Document *document, QWidget *parent) : PartTreeWidget::PartTreeWidget(const Document *document, QWidget *parent) :
QTreeWidget(parent), QTreeWidget(parent),
@ -781,78 +782,6 @@ void PartTreeWidget::showContextMenu(const QPoint &pos, bool shorted)
} }
} }
QWidget *PartTreeWidget::createSmoothMenuWidget(QUuid componentId)
{
QWidget *popup = new QWidget;
const Component *component = m_document->findComponent(componentId);
if (!component) {
qDebug() << "Find component failed:" << componentId;
return popup;
}
bool showSeamControl = component->linkToPartId.isNull();
FloatNumberWidget *smoothAllWidget = new FloatNumberWidget;
smoothAllWidget->setItemName(tr("All"));
smoothAllWidget->setRange(0, 1);
smoothAllWidget->setValue(component->smoothAll);
connect(smoothAllWidget, &FloatNumberWidget::valueChanged, [=](float value) {
emit setComponentSmoothAll(componentId, value);
emit groupOperationAdded();
});
QPushButton *smoothAllEraser = new QPushButton(QChar(fa::eraser));
Theme::initAwesomeToolButton(smoothAllEraser);
connect(smoothAllEraser, &QPushButton::clicked, [=]() {
smoothAllWidget->setValue(0.0);
});
FloatNumberWidget *smoothSeamWidget = nullptr;
QPushButton *smoothSeamEraser = nullptr;
if (showSeamControl) {
smoothSeamWidget = new FloatNumberWidget;
smoothSeamWidget->setItemName(tr("Seam"));
smoothSeamWidget->setRange(0, 1);
smoothSeamWidget->setValue(component->smoothSeam);
connect(smoothSeamWidget, &FloatNumberWidget::valueChanged, [=](float value) {
emit setComponentSmoothSeam(componentId, value);
emit groupOperationAdded();
});
smoothSeamEraser = new QPushButton(QChar(fa::eraser));
Theme::initAwesomeToolButton(smoothSeamEraser);
connect(smoothSeamEraser, &QPushButton::clicked, [=]() {
smoothSeamWidget->setValue(0.0);
});
}
QHBoxLayout *smoothSeamLayout = nullptr;
QVBoxLayout *layout = new QVBoxLayout;
QHBoxLayout *smoothAllLayout = new QHBoxLayout;
if (showSeamControl)
smoothSeamLayout = new QHBoxLayout;
smoothAllLayout->addWidget(smoothAllEraser);
smoothAllLayout->addWidget(smoothAllWidget);
if (showSeamControl) {
smoothSeamLayout->addWidget(smoothSeamEraser);
smoothSeamLayout->addWidget(smoothSeamWidget);
}
layout->addLayout(smoothAllLayout);
if (showSeamControl)
layout->addLayout(smoothSeamLayout);
popup->setLayout(layout);
return popup;
}
QTreeWidgetItem *PartTreeWidget::findComponentItem(QUuid componentId) QTreeWidgetItem *PartTreeWidget::findComponentItem(QUuid componentId)
{ {
auto findResult = m_componentItemMap.find(componentId); auto findResult = m_componentItemMap.find(componentId);

View File

@ -5,7 +5,12 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QTimer> #include <QTimer>
#include "document.h" #include <set>
#include "parttarget.h"
#include "partbase.h"
#include "combinemode.h"
class Document;
class PartTreeWidget : public QTreeWidget class PartTreeWidget : public QTreeWidget
{ {
@ -21,8 +26,6 @@ signals:
void createNewChildComponent(QUuid parentComponentId); void createNewChildComponent(QUuid parentComponentId);
void renameComponent(QUuid componentId, QString name); void renameComponent(QUuid componentId, QString name);
void setComponentExpandState(QUuid componentId, bool expanded); void setComponentExpandState(QUuid componentId, bool expanded);
void setComponentSmoothAll(QUuid componentId, float toSmoothAll);
void setComponentSmoothSeam(QUuid componentId, float toSmoothSeam);
void setPartTarget(QUuid partId, PartTarget target); void setPartTarget(QUuid partId, PartTarget target);
void setPartBase(QUuid partId, PartBase base); void setPartBase(QUuid partId, PartBase base);
void moveComponent(QUuid componentId, QUuid toParentId); void moveComponent(QUuid componentId, QUuid toParentId);
@ -93,7 +96,6 @@ private:
void addComponentChildrenToItem(QUuid componentId, QTreeWidgetItem *parentItem); void addComponentChildrenToItem(QUuid componentId, QTreeWidgetItem *parentItem);
void deleteItemChildren(QTreeWidgetItem *item); void deleteItemChildren(QTreeWidgetItem *item);
void selectComponent(QUuid componentId, bool multiple=false); void selectComponent(QUuid componentId, bool multiple=false);
QWidget *createSmoothMenuWidget(QUuid componentId);
void updateComponentSelectState(QUuid componentId, bool selected); void updateComponentSelectState(QUuid componentId, bool selected);
void updateComponentAppearance(QUuid componentId); void updateComponentAppearance(QUuid componentId);
bool isComponentSelected(QUuid componentId); bool isComponentSelected(QUuid componentId);

View File

@ -22,6 +22,7 @@
#include "flowlayout.h" #include "flowlayout.h"
#include "imageforever.h" #include "imageforever.h"
#include "imagepreviewwidget.h" #include "imagepreviewwidget.h"
#include "document.h"
PartWidget::PartWidget(const Document *document, QUuid partId) : PartWidget::PartWidget(const Document *document, QUuid partId) :
m_document(document), m_document(document),

View File

@ -3,8 +3,10 @@
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
#include <QMouseEvent> #include <QMouseEvent>
#include "document.h"
#include "modelwidget.h" #include "modelwidget.h"
#include "cutface.h"
class Document;
class PartWidget : public QWidget class PartWidget : public QWidget
{ {

View File

@ -7,6 +7,7 @@
#include "util.h" #include "util.h"
#include "preferences.h" #include "preferences.h"
#include "theme.h" #include "theme.h"
#include "document.h"
PreferencesWidget::PreferencesWidget(const Document *document, QWidget *parent) : PreferencesWidget::PreferencesWidget(const Document *document, QWidget *parent) :
QDialog(parent), QDialog(parent),

View File

@ -1,7 +1,8 @@
#ifndef DUST3D_PREFERENCES_WIDGET_H #ifndef DUST3D_PREFERENCES_WIDGET_H
#define DUST3D_PREFERENCES_WIDGET_H #define DUST3D_PREFERENCES_WIDGET_H
#include <QDialog> #include <QDialog>
#include "document.h"
class Document;
class PreferencesWidget : public QDialog class PreferencesWidget : public QDialog
{ {

View File

@ -5,6 +5,7 @@
#include "rigtype.h" #include "rigtype.h"
#include "infolabel.h" #include "infolabel.h"
#include "theme.h" #include "theme.h"
#include "document.h"
RigWidget::RigWidget(const Document *document, QWidget *parent) : RigWidget::RigWidget(const Document *document, QWidget *parent) :
QWidget(parent), QWidget(parent),

View File

@ -3,11 +3,12 @@
#include <QWidget> #include <QWidget>
#include <QComboBox> #include <QComboBox>
#include <QPushButton> #include <QPushButton>
#include "document.h"
#include "rigtype.h" #include "rigtype.h"
#include "modelwidget.h" #include "modelwidget.h"
#include "infolabel.h" #include "infolabel.h"
class Document;
class RigWidget : public QWidget class RigWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT

View File

@ -10,6 +10,7 @@
#include "theme.h" #include "theme.h"
#include "floatnumberwidget.h" #include "floatnumberwidget.h"
#include "intnumberwidget.h" #include "intnumberwidget.h"
#include "document.h"
ScriptVariablesWidget::ScriptVariablesWidget(const Document *document, ScriptVariablesWidget::ScriptVariablesWidget(const Document *document,
QWidget *parent) : QWidget *parent) :

View File

@ -4,7 +4,8 @@
#include <QString> #include <QString>
#include <map> #include <map>
#include <QScrollArea> #include <QScrollArea>
#include "document.h"
class Document;
class ScriptVariablesWidget : public QScrollArea class ScriptVariablesWidget : public QScrollArea
{ {

View File

@ -3,6 +3,7 @@
#include "scriptwidget.h" #include "scriptwidget.h"
#include "scripteditwidget.h" #include "scripteditwidget.h"
#include "theme.h" #include "theme.h"
#include "document.h"
ScriptWidget::ScriptWidget(const Document *document, QWidget *parent) : ScriptWidget::ScriptWidget(const Document *document, QWidget *parent) :
QWidget(parent), QWidget(parent),

View File

@ -2,9 +2,10 @@
#define SCRIPT_WIDGET_H #define SCRIPT_WIDGET_H
#include <QWidget> #include <QWidget>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include "document.h"
#include "scriptvariableswidget.h" #include "scriptvariableswidget.h"
class Document;
class ScriptWidget : public QWidget class ScriptWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT

View File

@ -1,4 +1,3 @@
#ifndef DUST3D_SKELETON_DOCUMENT_H #ifndef DUST3D_SKELETON_DOCUMENT_H
#define DUST3D_SKELETON_DOCUMENT_H #define DUST3D_SKELETON_DOCUMENT_H
#include <QUuid> #include <QUuid>