diff --git a/dust3d.pro b/dust3d.pro
index eb9e865e..1eeef3f4 100644
--- a/dust3d.pro
+++ b/dust3d.pro
@@ -37,12 +37,9 @@ wd = $$replace(PWD, /, $$QMAKE_DIR_SEP)
# Update the .ts file from source
qtPrepareTool(LUPDATE, lupdate)
LUPDATE += src/*.cpp src/*.h -locations none
-TSFILES = $$files($$PWD/languages/dust3d_??.ts)
-for(file, TSFILES) {
- lang = $$replace(file, .*_([^/]*).ts, 1)
- v = ts-$${lang}.commands
- $$v = cd $$wd && $$LUPDATE $$SOURCES $$APP_FILES -ts $$file
- QMAKE_EXTRA_TARGETS += ts-$$lang
+for(lang, LANGUAGES) {
+ command = $$LUPDATE -ts languages/dust3d_$${lang}.ts
+ system($$command)|error("Failed to run: $$command")
}
##########################################################
diff --git a/languages/dust3d_zh_CN.ts b/languages/dust3d_zh_CN.ts
index 47c174bd..3e4fe159 100644
--- a/languages/dust3d_zh_CN.ts
+++ b/languages/dust3d_zh_CN.ts
@@ -342,6 +342,18 @@ Tips:
glb文档(.glb)
+
+
+ 旋转
+
+
+
+ 切面...
+
+
+
+ 清除切面
+
ExportPreviewWidget
@@ -1075,5 +1087,13 @@ Tips:
取消全选
+
+
+ 切面...
+
+
+
+ 清除切面
+
diff --git a/src/document.cpp b/src/document.cpp
index a659850f..e1afd4ce 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -614,6 +614,19 @@ void Document::updateLinkedPart(QUuid oldPartId, QUuid newPartId)
partIt.second.setCutFaceLinkedId(newPartId);
}
}
+ std::set dirtyPartIds;
+ for (auto &nodeIt: nodeMap) {
+ if (nodeIt.second.cutFaceLinkedId == oldPartId) {
+ dirtyPartIds.insert(nodeIt.second.partId);
+ nodeIt.second.setCutFaceLinkedId(newPartId);
+ }
+ }
+ for (const auto &partId: dirtyPartIds) {
+ SkeletonPart *part = (SkeletonPart *)findPart(partId);
+ if (nullptr == part)
+ continue;
+ part->dirty = true;
+ }
}
const Component *Document::findComponent(QUuid componentId) const
@@ -799,6 +812,75 @@ void Document::setNodeBoneMark(QUuid nodeId, BoneMark mark)
emit skeletonChanged();
}
+void Document::setNodeCutRotation(QUuid nodeId, float cutRotation)
+{
+ auto node = nodeMap.find(nodeId);
+ if (node == nodeMap.end()) {
+ qDebug() << "Node not found:" << nodeId;
+ return;
+ }
+ if (qFuzzyCompare(cutRotation, node->second.cutRotation))
+ return;
+ node->second.setCutRotation(cutRotation);
+ auto part = partMap.find(node->second.partId);
+ if (part != partMap.end())
+ part->second.dirty = true;
+ emit nodeCutRotationChanged(nodeId);
+ emit skeletonChanged();
+}
+
+void Document::setNodeCutFace(QUuid nodeId, CutFace cutFace)
+{
+ auto node = nodeMap.find(nodeId);
+ if (node == nodeMap.end()) {
+ qDebug() << "Node not found:" << nodeId;
+ return;
+ }
+ if (node->second.cutFace == cutFace)
+ return;
+ node->second.setCutFace(cutFace);
+ auto part = partMap.find(node->second.partId);
+ if (part != partMap.end())
+ part->second.dirty = true;
+ emit nodeCutFaceChanged(nodeId);
+ emit skeletonChanged();
+}
+
+void Document::setNodeCutFaceLinkedId(QUuid nodeId, QUuid linkedId)
+{
+ auto node = nodeMap.find(nodeId);
+ if (node == nodeMap.end()) {
+ qDebug() << "Node not found:" << nodeId;
+ return;
+ }
+ if (node->second.cutFace == CutFace::UserDefined &&
+ node->second.cutFaceLinkedId == linkedId)
+ return;
+ node->second.setCutFaceLinkedId(linkedId);
+ auto part = partMap.find(node->second.partId);
+ if (part != partMap.end())
+ part->second.dirty = true;
+ emit nodeCutFaceChanged(nodeId);
+ emit skeletonChanged();
+}
+
+void Document::clearNodeCutFaceSettings(QUuid nodeId)
+{
+ auto node = nodeMap.find(nodeId);
+ if (node == nodeMap.end()) {
+ qDebug() << "Node not found:" << nodeId;
+ return;
+ }
+ if (!node->second.hasCutFaceSettings)
+ return;
+ node->second.clearCutFaceSettings();
+ auto part = partMap.find(node->second.partId);
+ if (part != partMap.end())
+ part->second.dirty = true;
+ emit nodeCutFaceChanged(nodeId);
+ emit skeletonChanged();
+}
+
void Document::updateTurnaround(const QImage &image)
{
turnaround = image;
@@ -976,6 +1058,16 @@ void Document::toSnapshot(Snapshot *snapshot, const std::set &limitNodeId
node["partId"] = nodeIt.second.partId.toString();
if (nodeIt.second.boneMark != BoneMark::None)
node["boneMark"] = BoneMarkToString(nodeIt.second.boneMark);
+ if (nodeIt.second.hasCutFaceSettings) {
+ node["cutRotation"] = QString::number(nodeIt.second.cutRotation);
+ if (CutFace::UserDefined == nodeIt.second.cutFace) {
+ if (!nodeIt.second.cutFaceLinkedId.isNull()) {
+ node["cutFace"] = nodeIt.second.cutFaceLinkedId.toString();
+ }
+ } else {
+ node["cutFace"] = CutFaceToString(nodeIt.second.cutFace);
+ }
+ }
if (!nodeIt.second.name.isEmpty())
node["name"] = nodeIt.second.name;
snapshot->nodes[node["id"]] = node;
@@ -1248,7 +1340,7 @@ void Document::addFromSnapshot(const Snapshot &snapshot, bool fromPaste)
for (const auto &it: cutFaceLinkedIdModifyMap) {
SkeletonPart &part = partMap[it.first];
auto findNewLinkedId = oldNewIdMap.find(it.second);
- if (oldNewIdMap.find(it.second) == oldNewIdMap.end()) {
+ if (findNewLinkedId == oldNewIdMap.end()) {
if (partMap.find(it.second) == partMap.end()) {
part.setCutFaceLinkedId(QUuid());
}
@@ -1273,6 +1365,26 @@ void Document::addFromSnapshot(const Snapshot &snapshot, bool fromPaste)
node.z = valueOfKeyInMapOrEmpty(nodeKv.second, "z").toFloat();
node.partId = oldNewIdMap[QUuid(valueOfKeyInMapOrEmpty(nodeKv.second, "partId"))];
node.boneMark = BoneMarkFromString(valueOfKeyInMapOrEmpty(nodeKv.second, "boneMark").toUtf8().constData());
+ const auto &cutRotationIt = nodeKv.second.find("cutRotation");
+ if (cutRotationIt != nodeKv.second.end())
+ node.setCutRotation(cutRotationIt->second.toFloat());
+ const auto &cutFaceIt = nodeKv.second.find("cutFace");
+ if (cutFaceIt != nodeKv.second.end()) {
+ QUuid cutFaceLinkedId = QUuid(cutFaceIt->second);
+ if (cutFaceLinkedId.isNull()) {
+ node.setCutFace(CutFaceFromString(cutFaceIt->second.toUtf8().constData()));
+ } else {
+ node.setCutFaceLinkedId(cutFaceLinkedId);
+ auto findNewLinkedId = oldNewIdMap.find(cutFaceLinkedId);
+ if (findNewLinkedId == oldNewIdMap.end()) {
+ if (partMap.find(cutFaceLinkedId) == partMap.end()) {
+ node.setCutFaceLinkedId(QUuid());
+ }
+ } else {
+ node.setCutFaceLinkedId(findNewLinkedId->second);
+ }
+ }
+ }
nodeMap[node.id] = node;
newAddedNodeIds.insert(node.id);
}
diff --git a/src/document.h b/src/document.h
index 3cdeffd8..89fe8a66 100644
--- a/src/document.h
+++ b/src/document.h
@@ -383,6 +383,9 @@ signals:
void edgeRemoved(QUuid edgeId);
void nodeRadiusChanged(QUuid nodeId);
void nodeBoneMarkChanged(QUuid nodeId);
+ void nodeColorStateChanged(QUuid nodeId);
+ void nodeCutRotationChanged(QUuid nodeId);
+ void nodeCutFaceChanged(QUuid nodeId);
void nodeOriginChanged(QUuid nodeId);
void edgeChanged(QUuid edgeId);
void partPreviewChanged(QUuid partId);
@@ -536,6 +539,10 @@ public slots:
void setNodeOrigin(QUuid nodeId, float x, float y, float z);
void setNodeRadius(QUuid nodeId, float radius);
void setNodeBoneMark(QUuid nodeId, BoneMark mark);
+ void setNodeCutRotation(QUuid nodeId, float cutRotation);
+ void setNodeCutFace(QUuid nodeId, CutFace cutFace);
+ void setNodeCutFaceLinkedId(QUuid nodeId, QUuid linkedId);
+ void clearNodeCutFaceSettings(QUuid nodeId);
void switchNodeXZ(QUuid nodeId);
void moveOriginBy(float x, float y, float z);
void addEdge(QUuid fromNodeId, QUuid toNodeId);
diff --git a/src/documentwindow.cpp b/src/documentwindow.cpp
index 846d0906..9a6dd9dc 100644
--- a/src/documentwindow.cpp
+++ b/src/documentwindow.cpp
@@ -15,6 +15,7 @@
#include