From 63d32781c1a46a24b623ade05f2ae0237cc0f605 Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Tue, 28 May 2019 23:49:50 +0930 Subject: [PATCH] Fix branch wrapping #32 In this commit, the wrapping algorithm consider the position of neighbor's neighbor, so the cut normal of branch nodes would looks more natural. This commit also fix the radius calculation of the branch face. Thanks @KeepFenDou for pointing out this issue. --- CHANGELOGS.md | 9 +++++++++ CONTRIBUTORS | 3 ++- thirdparty/nodemesh/nodemesh/builder.cpp | 14 +++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGELOGS.md b/CHANGELOGS.md index 61e9c1dc..caebca7b 100644 --- a/CHANGELOGS.md +++ b/CHANGELOGS.md @@ -1,3 +1,12 @@ +Changes between 1.0.0-beta.16 and 1.0.0-beta.17: +-------------------------------------------------- +- Remote IO Protocol +- Uncombined Mode +- User Defined Cut Face +- Base Plane Constrain +- Color Solubility +- Crash Fix + Changes between 1.0.0-beta.15 and 1.0.0-beta.16: -------------------------------------------------- - Support onion skinning in pose editor diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 06b1cf42..52ac1905 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -26,4 +26,5 @@ boynet fornclake bvanevery Toshio Araki -Evan Gruda \ No newline at end of file +Evan Gruda +KeepFenDou \ No newline at end of file diff --git a/thirdparty/nodemesh/nodemesh/builder.cpp b/thirdparty/nodemesh/nodemesh/builder.cpp index 48af2a9c..6299d8a7 100644 --- a/thirdparty/nodemesh/nodemesh/builder.cpp +++ b/thirdparty/nodemesh/nodemesh/builder.cpp @@ -456,15 +456,23 @@ bool Builder::tryWrapMultipleBranchesForNode(size_t nodeIndex, std::vector, QVector3D>> cutsForEdges; bool directSwallowed = false; for (size_t i = 0; i < node.edges.size(); ++i) { - const QVector3D &cutNormal = node.raysToNeibors[i]; + QVector3D cutNormal = node.raysToNeibors[i]; size_t edgeIndex = node.edges[i]; size_t neighborIndex = m_edges[edgeIndex].neiborOf(nodeIndex); const auto &neighbor = m_nodes[neighborIndex]; + if (neighbor.edges.size() == 2) { + size_t anotherEdgeIndex = neighbor.anotherEdge(edgeIndex); + size_t neighborsNeighborIndex = m_edges[anotherEdgeIndex].neiborOf(neighborIndex); + const auto &neighborsNeighbor = m_nodes[neighborsNeighborIndex]; + cutNormal = ((cutNormal + (neighborsNeighbor.position - neighbor.position).normalized()) * 0.5).normalized(); + } float distance = (neighbor.position - node.position).length(); if (qFuzzyIsNull(distance)) distance = 0.0001f; - float radiusFactor = 1.0 - (node.radius / distance); - float radius = node.radius * radiusFactor + neighbor.radius * (1.0 - radiusFactor); + float radiusRate = neighbor.radius / node.radius; + float tangentTriangleLongEdgeLength = distance + (radiusRate * distance / (1.0 - radiusRate)); + float segmentLength = node.radius * (tangentTriangleLongEdgeLength - node.radius) / tangentTriangleLongEdgeLength; + float radius = segmentLength / std::sin(std::acos(node.radius / tangentTriangleLongEdgeLength)); std::vector cut; float offsetDistance = 0; offsetDistance = offsets[i] * (distance - node.radius - neighbor.radius);