From a778521c2f5cff7eb21c8f2153166753c328167c Mon Sep 17 00:00:00 2001 From: Andrew Clinton Date: Thu, 12 Sep 2013 16:36:45 -0400 Subject: [PATCH] Improve numerical stability of catmark subdivision This change sums the vertex point last, since it's normally the largest value. There may be other numerical stability issues in this code that I haven't discovered. --- opensubdiv/hbr/catmark.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/opensubdiv/hbr/catmark.h b/opensubdiv/hbr/catmark.h index bde83759..47f446b5 100644 --- a/opensubdiv/hbr/catmark.h +++ b/opensubdiv/hbr/catmark.h @@ -1063,8 +1063,6 @@ HbrCatmarkSubdivision::Subdivide(HbrMesh* mesh, HbrVertex* vertex) { switch (masks[i]) { case HbrVertex::k_Smooth: case HbrVertex::k_Dart: { - // Compute n-2/n of the old vertex value - data.AddWithWeight(vertex->GetData(), weights[i] * invvalencesquared * valence * (valence - 2)); // Add 1 / n^2 * surrounding edge vertices and surrounding face // subdivided vertices HbrSubdivision::AddSurroundingVerticesWithWeight( @@ -1078,16 +1076,18 @@ HbrCatmarkSubdivision::Subdivide(HbrMesh* mesh, HbrVertex* vertex) { edge = vertex->GetNextEdge(edge); if (edge == start) break; } + // Compute n-2/n of the old vertex value + data.AddWithWeight(vertex->GetData(), weights[i] * invvalencesquared * valence * (valence - 2)); break; } case HbrVertex::k_Crease: { - // Compute 3/4 of old vertex value - data.AddWithWeight(vertex->GetData(), weights[i] * 0.75f); - // Add 0.125f of the (hopefully only two!) neighbouring // sharp edges HbrSubdivision::AddCreaseEdgesWithWeight( mesh, vertex, i == 1, weights[i] * 0.125f, &data); + + // Compute 3/4 of old vertex value + data.AddWithWeight(vertex->GetData(), weights[i] * 0.75f); break; } case HbrVertex::k_Corner: