Skip to content

Rewrite LOD simplification with Blender-style min-heap algorithm#317

Open
Szy-Cathay wants to merge 1 commit intodonkeyProgramming:masterfrom
Szy-Cathay:feature/blender-lod-rewrite
Open

Rewrite LOD simplification with Blender-style min-heap algorithm#317
Szy-Cathay wants to merge 1 commit intodonkeyProgramming:masterfrom
Szy-Cathay:feature/blender-lod-rewrite

Conversation

@Szy-Cathay
Copy link
Copy Markdown
Contributor

Replace the Forstmann threshold-based iterative approach with a single-pass min-heap edge collapse algorithm inspired by Blender's bmesh_decimate_collapse.cc.

Key changes in MeshDecimator:

  • New EdgeEntry struct with version-based stale detection (replaces floating-point cost comparison that was unreliable)
  • New methods: ComputeEdgeCost, PushEdgeCost, BuildEdgeCosts, UpdateNeighborCosts, IsDegenerateTopology, InitBordersAndSmartLink, InitQuadricsAndBoundaryConstraints
  • Rewritten DecimateMesh/DecimateMeshLossless for single-pass min-heap
  • Removed: CollapseCandidate, RemoveVertexPass, UpdateMesh
  • Added scalar multiply operator to SymmetricMatrix
  • Removed seamMismatch/foldoverMismatch hard blocks for more uniform simplification

Bug fixes:

  • Fix maxVertexCount mapping to int.MaxValue causing early loop exit (only 2 triangles removed per LOD level)
  • Fix DecimatorMeshOptimizer using vertex count instead of triangle count for target calculation (causing over-aggressive simplification)

Blender improvements retained:

  • Area-weighted flip detection (0.01 threshold)
  • Boundary constraint planes (100x weight)
  • Topology fallback for flat regions
  • Normal interpolation by edge-parametric factor
  • Degenerate topology check (duplicate face prevention)

Replace the Forstmann threshold-based iterative approach with a single-pass
min-heap edge collapse algorithm inspired by Blender's bmesh_decimate_collapse.cc.

Key changes in MeshDecimator:
- New EdgeEntry struct with version-based stale detection (replaces
  floating-point cost comparison that was unreliable)
- New methods: ComputeEdgeCost, PushEdgeCost, BuildEdgeCosts,
  UpdateNeighborCosts, IsDegenerateTopology, InitBordersAndSmartLink,
  InitQuadricsAndBoundaryConstraints
- Rewritten DecimateMesh/DecimateMeshLossless for single-pass min-heap
- Removed: CollapseCandidate, RemoveVertexPass, UpdateMesh
- Added scalar multiply operator to SymmetricMatrix
- Removed seamMismatch/foldoverMismatch hard blocks for more uniform simplification

Bug fixes:
- Fix maxVertexCount mapping to int.MaxValue causing early loop exit
  (only 2 triangles removed per LOD level)
- Fix DecimatorMeshOptimizer using vertex count instead of triangle
  count for target calculation (causing over-aggressive simplification)

Blender improvements retained:
- Area-weighted flip detection (0.01 threshold)
- Boundary constraint planes (100x weight)
- Topology fallback for flat regions
- Normal interpolation by edge-parametric factor
- Degenerate topology check (duplicate face prevention)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant