#ifndef DC_SIMPLIFY_H
#define DC_SIMPLIFY_H
// MCA (Multiple Choice Approach) mesh simplification using QEM.
// For each collapse step, pick K random edges, evaluate QEM error
// for each, collapse the one with minimum error. Fast and good enough
// for LOD terrain meshes.
//
// Reference: Wu & Kobbelt, "Fast Mesh Decimation by Multiple-Choice Techniques"
#include "dc_contour.h"
// Simplify mesh in-place to at most target_tri_count triangles.
// k_candidates: number of random edges to evaluate per step (default 10).
// max_error: stop early if all candidate errors exceed this threshold.
// Returns the number of collapses performed.
int dc_simplify_mca(DCMeshData& mesh, int target_tri_count,
int k_candidates = 10, float max_error = 1e6f);
// meshoptimizer-based simplification with border vertex locking.
// Produces higher-quality LOD meshes than MCA. lock_border prevents
// border vertices from moving, eliminating T-junctions between LOD levels.
void dc_simplify_meshopt(DCMeshData& mesh, int target_tri_count, bool lock_border = true);
// Optimize vertex cache ordering for GPU rendering efficiency.
// No geometry changes — just reorders indices for better cache utilization.
void dc_optimize_vertex_cache(DCMeshData& mesh);
#endif // DC_SIMPLIFY_H