From a945612718c0389a3fdeb7d24b17cad8aa450e8c Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Tue, 25 Jun 2019 21:07:17 +0930 Subject: [PATCH] Fix part mesh generation variation Before this commit, the node id and edge id changed when reload from file, then caused the uuid changing and affected the node processing order during mesh generation. --- src/document.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/document.cpp b/src/document.cpp index 42ec479a..eadd4455 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1250,8 +1250,9 @@ void Document::addFromSnapshot(const Snapshot &snapshot, bool fromPaste) nodeKv.second.find("z") == nodeKv.second.end() || nodeKv.second.find("partId") == nodeKv.second.end()) continue; - SkeletonNode node; - oldNewIdMap[QUuid(nodeKv.first)] = node.id; + QUuid oldNodeId = QUuid(nodeKv.first); + SkeletonNode node(nodeMap.find(oldNodeId) == nodeMap.end() ? oldNodeId : QUuid::createUuid()); + oldNewIdMap[oldNodeId] = node.id; node.name = valueOfKeyInMapOrEmpty(nodeKv.second, "name"); node.radius = valueOfKeyInMapOrEmpty(nodeKv.second, "radius").toFloat(); node.x = valueOfKeyInMapOrEmpty(nodeKv.second, "x").toFloat(); @@ -1267,8 +1268,9 @@ void Document::addFromSnapshot(const Snapshot &snapshot, bool fromPaste) edgeKv.second.find("to") == edgeKv.second.end() || edgeKv.second.find("partId") == edgeKv.second.end()) continue; - SkeletonEdge edge; - oldNewIdMap[QUuid(edgeKv.first)] = edge.id; + QUuid oldEdgeId = QUuid(edgeKv.first); + SkeletonEdge edge(edgeMap.find(oldEdgeId) == edgeMap.end() ? oldEdgeId : QUuid::createUuid()); + oldNewIdMap[oldEdgeId] = edge.id; edge.name = valueOfKeyInMapOrEmpty(edgeKv.second, "name"); edge.partId = oldNewIdMap[QUuid(valueOfKeyInMapOrEmpty(edgeKv.second, "partId"))]; QString fromNodeId = valueOfKeyInMapOrEmpty(edgeKv.second, "from");