mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2025-01-03 05:31:12 +00:00
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.
This commit is contained in:
parent
e34122223c
commit
a778521c2f
@ -1063,8 +1063,6 @@ HbrCatmarkSubdivision<T>::Subdivide(HbrMesh<T>* mesh, HbrVertex<T>* vertex) {
|
|||||||
switch (masks[i]) {
|
switch (masks[i]) {
|
||||||
case HbrVertex<T>::k_Smooth:
|
case HbrVertex<T>::k_Smooth:
|
||||||
case HbrVertex<T>::k_Dart: {
|
case HbrVertex<T>::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
|
// Add 1 / n^2 * surrounding edge vertices and surrounding face
|
||||||
// subdivided vertices
|
// subdivided vertices
|
||||||
HbrSubdivision<T>::AddSurroundingVerticesWithWeight(
|
HbrSubdivision<T>::AddSurroundingVerticesWithWeight(
|
||||||
@ -1078,16 +1076,18 @@ HbrCatmarkSubdivision<T>::Subdivide(HbrMesh<T>* mesh, HbrVertex<T>* vertex) {
|
|||||||
edge = vertex->GetNextEdge(edge);
|
edge = vertex->GetNextEdge(edge);
|
||||||
if (edge == start) break;
|
if (edge == start) break;
|
||||||
}
|
}
|
||||||
|
// Compute n-2/n of the old vertex value
|
||||||
|
data.AddWithWeight(vertex->GetData(), weights[i] * invvalencesquared * valence * (valence - 2));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HbrVertex<T>::k_Crease: {
|
case HbrVertex<T>::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
|
// Add 0.125f of the (hopefully only two!) neighbouring
|
||||||
// sharp edges
|
// sharp edges
|
||||||
HbrSubdivision<T>::AddCreaseEdgesWithWeight(
|
HbrSubdivision<T>::AddCreaseEdgesWithWeight(
|
||||||
mesh, vertex, i == 1, weights[i] * 0.125f, &data);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case HbrVertex<T>::k_Corner:
|
case HbrVertex<T>::k_Corner:
|
||||||
|
Loading…
Reference in New Issue
Block a user