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.master
parent
7c068466e8
commit
63d32781c1
|
@ -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:
|
Changes between 1.0.0-beta.15 and 1.0.0-beta.16:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
- Support onion skinning in pose editor
|
- Support onion skinning in pose editor
|
||||||
|
|
|
@ -27,3 +27,4 @@ fornclake <https://www.reddit.com/user/fornclake>
|
||||||
bvanevery <https://www.reddit.com/user/bvanevery>
|
bvanevery <https://www.reddit.com/user/bvanevery>
|
||||||
Toshio Araki <https://github.com/Toshiwoz>
|
Toshio Araki <https://github.com/Toshiwoz>
|
||||||
Evan Gruda <evangruda@ufl.edu>
|
Evan Gruda <evangruda@ufl.edu>
|
||||||
|
KeepFenDou <https://github.com/huxingyi/dust3d/issues/32>
|
|
@ -456,15 +456,23 @@ bool Builder::tryWrapMultipleBranchesForNode(size_t nodeIndex, std::vector<float
|
||||||
std::vector<std::pair<std::vector<size_t>, QVector3D>> cutsForEdges;
|
std::vector<std::pair<std::vector<size_t>, QVector3D>> cutsForEdges;
|
||||||
bool directSwallowed = false;
|
bool directSwallowed = false;
|
||||||
for (size_t i = 0; i < node.edges.size(); ++i) {
|
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 edgeIndex = node.edges[i];
|
||||||
size_t neighborIndex = m_edges[edgeIndex].neiborOf(nodeIndex);
|
size_t neighborIndex = m_edges[edgeIndex].neiborOf(nodeIndex);
|
||||||
const auto &neighbor = m_nodes[neighborIndex];
|
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();
|
float distance = (neighbor.position - node.position).length();
|
||||||
if (qFuzzyIsNull(distance))
|
if (qFuzzyIsNull(distance))
|
||||||
distance = 0.0001f;
|
distance = 0.0001f;
|
||||||
float radiusFactor = 1.0 - (node.radius / distance);
|
float radiusRate = neighbor.radius / node.radius;
|
||||||
float radius = node.radius * radiusFactor + neighbor.radius * (1.0 - radiusFactor);
|
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<QVector3D> cut;
|
std::vector<QVector3D> cut;
|
||||||
float offsetDistance = 0;
|
float offsetDistance = 0;
|
||||||
offsetDistance = offsets[i] * (distance - node.radius - neighbor.radius);
|
offsetDistance = offsets[i] * (distance - node.radius - neighbor.radius);
|
||||||
|
|
Loading…
Reference in New Issue