Fix mesh failure when direction of two nodes parallel to z axis

master
Jeremy Hu 2019-07-11 19:54:52 +09:30
parent f7b865f18b
commit 3c2b60a8cc
1 changed files with 12 additions and 1 deletions

View File

@ -135,7 +135,18 @@ void Builder::resolveBaseNormalRecursively(size_t nodeIndex)
if (searchResult.second) { if (searchResult.second) {
resolveBaseNormalForLeavesRecursively(nodeIndex, searchResult.first); resolveBaseNormalForLeavesRecursively(nodeIndex, searchResult.first);
} else { } else {
resolveBaseNormalForLeavesRecursively(nodeIndex, QVector3D {0, 0, 1}); const std::vector<QVector3D> 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]);
} }
} }
} }