Skip to content

Commit 7276609

Browse files
committed
remove LinearizeTangents
1 parent 69a32c8 commit 7276609

File tree

2 files changed

+2
-44
lines changed

2 files changed

+2
-44
lines changed

src/manifold/src/impl.h

-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ struct Manifold::Impl {
182182
float minSmoothness) const;
183183
void SharpenTangent(int halfedge, float smoothness);
184184
void SetNormals(int normalIdx, float minSharpAngle);
185-
void LinearizeFlatTangents();
186185
void DistributeTangents(const Vec<bool>& fixedHalfedges);
187186
void CreateTangents(int normalIdx);
188187
void CreateTangents(std::vector<Smoothness>);

src/manifold/src/smoothing.cpp

+2-43
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,12 @@ std::vector<Smoothness> Manifold::Impl::SharpenEdges(
405405

406406
/**
407407
* Sharpen tangents that intersect an edge to sharpen that edge. The weight is
408-
* unchanged, as this has a squared effect on radius of curvature, except
409-
* in the case of zero radius, which is marked with weight = 0.
408+
* unchanged, as this has a squared effect on radius of curvature.
410409
*/
411410
void Manifold::Impl::SharpenTangent(int halfedge, float smoothness) {
412411
halfedgeTangent_[halfedge] =
413412
glm::vec4(smoothness * glm::vec3(halfedgeTangent_[halfedge]),
414-
smoothness == 0 ? 0 : halfedgeTangent_[halfedge].w);
413+
halfedgeTangent_[halfedge].w);
415414
}
416415

417416
/**
@@ -592,45 +591,6 @@ void Manifold::Impl::SetNormals(int normalIdx, float minSharpAngle) {
592591
}
593592
}
594593

595-
/**
596-
* Tangents get flattened to create sharp edges by setting their weight to zero.
597-
* This is the natural limit of reducing the weight to increase the sharpness
598-
* smoothly. This limit gives a decent shape, but it causes the parameterization
599-
* to be stretched and compresses it near the edges, which is good for resolving
600-
* tight curvature, but bad for property interpolation. This function fixes the
601-
* parameter stretch at the limit for sharp edges, since there is no curvature
602-
* to resolve. Note this also changes the overall shape - making it more evenly
603-
* curved.
604-
*/
605-
void Manifold::Impl::LinearizeFlatTangents() {
606-
const int n = halfedgeTangent_.size();
607-
for_each_n(
608-
autoPolicy(n), zip(halfedgeTangent_.begin(), countAt(0)), n,
609-
[this](thrust::tuple<glm::vec4&, int> inOut) {
610-
glm::vec4& tangent = thrust::get<0>(inOut);
611-
const int halfedge = thrust::get<1>(inOut);
612-
glm::vec4& otherTangent =
613-
halfedgeTangent_[halfedge_[halfedge].pairedHalfedge];
614-
615-
const glm::bvec2 flat(tangent.w == 0, otherTangent.w == 0);
616-
if (!halfedge_[halfedge].IsForward() || (!flat[0] && !flat[1])) {
617-
return;
618-
}
619-
620-
const glm::vec3 edgeVec = vertPos_[halfedge_[halfedge].endVert] -
621-
vertPos_[halfedge_[halfedge].startVert];
622-
623-
if (flat[0] && flat[1]) {
624-
tangent = glm::vec4(edgeVec / 3.0f, 1);
625-
otherTangent = glm::vec4(-edgeVec / 3.0f, 1);
626-
} else if (flat[0]) {
627-
tangent = glm::vec4((edgeVec + glm::vec3(otherTangent)) / 2.0f, 1);
628-
} else {
629-
otherTangent = glm::vec4((-edgeVec + glm::vec3(tangent)) / 2.0f, 1);
630-
}
631-
});
632-
}
633-
634594
/**
635595
* Redistribute the tangents around each vertex so that the angles between them
636596
* have the same ratios as the angles of the triangles between the corresponding
@@ -916,7 +876,6 @@ void Manifold::Impl::CreateTangents(std::vector<Smoothness> sharpenedEdges) {
916876
});
917877
}
918878
}
919-
LinearizeFlatTangents();
920879
}
921880

922881
void Manifold::Impl::Refine(std::function<int(glm::vec3)> edgeDivisions) {

0 commit comments

Comments
 (0)