Fix cap UV
parent
1fc2399bf6
commit
af67dc0cd6
|
@ -81,7 +81,7 @@ void SectionRemesher::remesh()
|
|||
maxUs[i] = offsetU;
|
||||
offsetU += (m_vertices[i] - m_vertices[j]).length();
|
||||
}
|
||||
maxUs[m_ringSize] = offsetU;
|
||||
maxUs[m_ringSize] += offsetU;
|
||||
offsetU = std::max(offsetU, std::numeric_limits<double>::epsilon());
|
||||
for (auto& it : maxUs)
|
||||
it /= offsetU;
|
||||
|
@ -90,8 +90,8 @@ void SectionRemesher::remesh()
|
|||
m_generatedFaces.emplace_back(std::vector<size_t> { i, j, m_ringSize });
|
||||
m_generatedFaceUvs.emplace_back(std::vector<Vector2> {
|
||||
Vector2(maxUs[i], m_ringV),
|
||||
Vector2(maxUs[j], m_ringV),
|
||||
Vector2((maxUs[i] + maxUs[j]) * 0.5, m_centerV) });
|
||||
Vector2(maxUs[i + 1], m_ringV),
|
||||
Vector2((maxUs[i] + maxUs[i + 1]) * 0.5, m_centerV) });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -299,14 +299,12 @@ void TubeMeshBuilder::build()
|
|||
}
|
||||
}
|
||||
if (!m_isCircle) {
|
||||
addCap(cutFaceIndices.back(), vOffsetBecauseOfFrontCap + vTubeRatio, 1.0);
|
||||
auto front = cutFaceIndices.front();
|
||||
std::reverse(front.begin(), front.end());
|
||||
addCap(front, vOffsetBecauseOfFrontCap, 0.0);
|
||||
addCap(cutFaceIndices.back(), vOffsetBecauseOfFrontCap + vTubeRatio, 1.0, false);
|
||||
addCap(cutFaceIndices.front(), vOffsetBecauseOfFrontCap, 0.0, true);
|
||||
}
|
||||
}
|
||||
|
||||
void TubeMeshBuilder::addCap(const std::vector<size_t>& section, double ringV, double centerV)
|
||||
void TubeMeshBuilder::addCap(const std::vector<size_t>& section, double ringV, double centerV, bool reverseU)
|
||||
{
|
||||
std::vector<size_t> vertexIndices = section;
|
||||
std::vector<Vector3> ringVertices(vertexIndices.size());
|
||||
|
@ -325,9 +323,13 @@ void TubeMeshBuilder::addCap(const std::vector<size_t>& section, double ringV, d
|
|||
for (size_t i = 0; i < it.size(); ++i)
|
||||
newFace[i] = vertexIndices[it[i]];
|
||||
m_generatedFaces.emplace_back(newFace);
|
||||
if (reverseU)
|
||||
std::reverse(m_generatedFaces.back().begin(), m_generatedFaces.back().end());
|
||||
}
|
||||
for (const auto& it : sectionRemesher.generatedFaceUvs()) {
|
||||
m_generatedFaceUvs.emplace_back(it);
|
||||
if (reverseU)
|
||||
std::reverse(m_generatedFaceUvs.back().begin(), m_generatedFaceUvs.back().end());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ private:
|
|||
const Vector3& forwardDirection);
|
||||
void applyRoundEnd();
|
||||
void applyInterpolation();
|
||||
void addCap(const std::vector<size_t>& section, double ringV, double centerV);
|
||||
void addCap(const std::vector<size_t>& section, double ringV, double centerV, bool reverseU);
|
||||
};
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue