Implement part deform
parent
73b3dc3941
commit
978c2bf744
|
@ -96,8 +96,16 @@ std::vector<Vector3> TubeMeshBuilder::buildCutFaceVertices(const Vector3 &origin
|
||||||
std::vector<Vector3> cutFaceVertices(m_buildParameters.cutFace.size());
|
std::vector<Vector3> cutFaceVertices(m_buildParameters.cutFace.size());
|
||||||
Vector3 u = m_generatedBaseNormal.rotated(-forwardDirection, m_buildParameters.baseNormalRotation);
|
Vector3 u = m_generatedBaseNormal.rotated(-forwardDirection, m_buildParameters.baseNormalRotation);
|
||||||
Vector3 v = Vector3::crossProduct(forwardDirection, u).normalized();
|
Vector3 v = Vector3::crossProduct(forwardDirection, u).normalized();
|
||||||
auto uFactor = u * radius;
|
auto uFactor = u * radius * m_buildParameters.deformWidth;
|
||||||
auto vFactor = v * radius;
|
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) {
|
for (size_t i = 0; i < m_buildParameters.cutFace.size(); ++i) {
|
||||||
const auto &t = m_buildParameters.cutFace[i];
|
const auto &t = m_buildParameters.cutFace[i];
|
||||||
cutFaceVertices[i] = origin + (uFactor * t.x() + vFactor * t.y());
|
cutFaceVertices[i] = origin + (uFactor * t.x() + vFactor * t.y());
|
||||||
|
@ -114,6 +122,9 @@ void TubeMeshBuilder::build()
|
||||||
|
|
||||||
buildNodePositionAndDirections();
|
buildNodePositionAndDirections();
|
||||||
|
|
||||||
|
for (const auto &it: m_nodes)
|
||||||
|
m_maxNodeRadius = std::max(m_maxNodeRadius, it.radius);
|
||||||
|
|
||||||
m_generatedBaseNormal = m_isCircle ?
|
m_generatedBaseNormal = m_isCircle ?
|
||||||
BaseNormal::calculateCircleBaseNormal(m_nodePositions) :
|
BaseNormal::calculateCircleBaseNormal(m_nodePositions) :
|
||||||
BaseNormal::calculateTubeBaseNormal(m_nodePositions);
|
BaseNormal::calculateTubeBaseNormal(m_nodePositions);
|
||||||
|
|
|
@ -57,6 +57,7 @@ private:
|
||||||
std::vector<std::vector<size_t>> m_generatedFaces;
|
std::vector<std::vector<size_t>> m_generatedFaces;
|
||||||
Vector3 m_generatedBaseNormal;
|
Vector3 m_generatedBaseNormal;
|
||||||
bool m_isCircle = false;
|
bool m_isCircle = false;
|
||||||
|
double m_maxNodeRadius = 0.0;
|
||||||
void preprocessNodes();
|
void preprocessNodes();
|
||||||
void buildNodePositionAndDirections();
|
void buildNodePositionAndDirections();
|
||||||
std::vector<Vector3> buildCutFaceVertices(const Vector3 &origin,
|
std::vector<Vector3> buildCutFaceVertices(const Vector3 &origin,
|
||||||
|
|
Loading…
Reference in New Issue