From 3c2b60a8cc9a82c80b6db8869f733bcac96f22d2 Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Thu, 11 Jul 2019 19:54:52 +0930 Subject: [PATCH] Fix mesh failure when direction of two nodes parallel to z axis --- thirdparty/nodemesh/nodemesh/builder.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/thirdparty/nodemesh/nodemesh/builder.cpp b/thirdparty/nodemesh/nodemesh/builder.cpp index 1567a332..30fefc3f 100644 --- a/thirdparty/nodemesh/nodemesh/builder.cpp +++ b/thirdparty/nodemesh/nodemesh/builder.cpp @@ -135,7 +135,18 @@ void Builder::resolveBaseNormalRecursively(size_t nodeIndex) if (searchResult.second) { resolveBaseNormalForLeavesRecursively(nodeIndex, searchResult.first); } else { - resolveBaseNormalForLeavesRecursively(nodeIndex, QVector3D {0, 0, 1}); + const std::vector axisList = { + QVector3D {0, 0, 1}, + QVector3D {0, 1, 0}, + QVector3D {1, 0, 0} + }; + for (const auto &axis: axisList) { + if (validateNormal(QVector3D::crossProduct(axis, node.traverseDirection).normalized())) { + resolveBaseNormalForLeavesRecursively(nodeIndex, axis); + return; + } + } + resolveBaseNormalForLeavesRecursively(nodeIndex, axisList[0]); } } }