be2b0fcddc
This change replicates the distance-only metric patch which is now much smaller and cleaner, as upstream simplifier already tracks distance and attribute quadrics separately - it just doesn't store both errors in the collapse structures. The old two patches were removed as they are no longer needed.
39 lines
1.5 KiB
Diff
39 lines
1.5 KiB
Diff
diff --git a/thirdparty/meshoptimizer/simplifier.cpp b/thirdparty/meshoptimizer/simplifier.cpp
|
|
index 5ba8570076..6f8b0e520e 100644
|
|
--- a/thirdparty/meshoptimizer/simplifier.cpp
|
|
+++ b/thirdparty/meshoptimizer/simplifier.cpp
|
|
@@ -476,6 +476,8 @@ struct Collapse
|
|
float error;
|
|
unsigned int errorui;
|
|
};
|
|
+
|
|
+ float distance_error;
|
|
};
|
|
|
|
static float normalize(Vector3& v)
|
|
@@ -941,6 +943,8 @@ static void rankEdgeCollapses(Collapse* collapses, size_t collapse_count, const
|
|
float ei = quadricError(vertex_quadrics[remap[i0]], vertex_positions[i1]);
|
|
float ej = quadricError(vertex_quadrics[remap[j0]], vertex_positions[j1]);
|
|
|
|
+ float dei = ei, dej = ej;
|
|
+
|
|
if (attribute_count)
|
|
{
|
|
ei += quadricError(attribute_quadrics[remap[i0]], &attribute_gradients[remap[i0] * attribute_count], attribute_count, vertex_positions[i1], &vertex_attributes[i1 * attribute_count]);
|
|
@@ -951,6 +955,7 @@ static void rankEdgeCollapses(Collapse* collapses, size_t collapse_count, const
|
|
c.v0 = ei <= ej ? i0 : j0;
|
|
c.v1 = ei <= ej ? i1 : j1;
|
|
c.error = ei <= ej ? ei : ej;
|
|
+ c.distance_error = ei <= ej ? dei : dej;
|
|
}
|
|
}
|
|
|
|
@@ -1097,7 +1102,7 @@ static size_t performEdgeCollapses(unsigned int* collapse_remap, unsigned char*
|
|
triangle_collapses += (vertex_kind[i0] == Kind_Border) ? 1 : 2;
|
|
edge_collapses++;
|
|
|
|
- result_error = result_error < c.error ? c.error : result_error;
|
|
+ result_error = result_error < c.distance_error ? c.distance_error : result_error;
|
|
}
|
|
|
|
#if TRACE
|