diff --git a/dust3d/mesh/tube_mesh_builder.cc b/dust3d/mesh/tube_mesh_builder.cc index 64a21ee6..6411613d 100644 --- a/dust3d/mesh/tube_mesh_builder.cc +++ b/dust3d/mesh/tube_mesh_builder.cc @@ -96,8 +96,16 @@ std::vector TubeMeshBuilder::buildCutFaceVertices(const Vector3 &origin std::vector cutFaceVertices(m_buildParameters.cutFace.size()); Vector3 u = m_generatedBaseNormal.rotated(-forwardDirection, m_buildParameters.baseNormalRotation); Vector3 v = Vector3::crossProduct(forwardDirection, u).normalized(); - auto uFactor = u * radius; - auto vFactor = v * radius; + auto uFactor = u * radius * m_buildParameters.deformWidth; + auto vFactor = v * radius * m_buildParameters.deformThickness; + if (m_buildParameters.deformUnified) { + if (!Math::isEqual(m_buildParameters.deformWidth, 1.0)) { + uFactor *= m_maxNodeRadius / radius; + } + if (!Math::isEqual(m_buildParameters.deformThickness, 1.0)) { + vFactor *= m_maxNodeRadius / radius; + } + } for (size_t i = 0; i < m_buildParameters.cutFace.size(); ++i) { const auto &t = m_buildParameters.cutFace[i]; cutFaceVertices[i] = origin + (uFactor * t.x() + vFactor * t.y()); @@ -114,6 +122,9 @@ void TubeMeshBuilder::build() buildNodePositionAndDirections(); + for (const auto &it: m_nodes) + m_maxNodeRadius = std::max(m_maxNodeRadius, it.radius); + m_generatedBaseNormal = m_isCircle ? BaseNormal::calculateCircleBaseNormal(m_nodePositions) : BaseNormal::calculateTubeBaseNormal(m_nodePositions); diff --git a/dust3d/mesh/tube_mesh_builder.h b/dust3d/mesh/tube_mesh_builder.h index 8dacaf79..c5dc61ff 100644 --- a/dust3d/mesh/tube_mesh_builder.h +++ b/dust3d/mesh/tube_mesh_builder.h @@ -57,6 +57,7 @@ private: std::vector> m_generatedFaces; Vector3 m_generatedBaseNormal; bool m_isCircle = false; + double m_maxNodeRadius = 0.0; void preprocessNodes(); void buildNodePositionAndDirections(); std::vector buildCutFaceVertices(const Vector3 &origin,