Skip to main content

Module optimize

Module optimize 

Source
Expand description

Mesh and asset optimization for low-budget targets (Raspberry Pi, sprites).

  • cluster_collapse: polygon reduction by vertex clustering (snap to a grid, merge, drop degenerate/duplicate triangles). Robust on any mesh; stylized results, no topology bookkeeping needed.
  • decimate_to_ratio: pick the cluster cell automatically to hit a target fraction of the original triangles.
  • merge_materials: merge near-identical materials so a scene shares fewer PBR states (WorldBuilder has no bitmap textures, so this is the equivalent of “texture reduction”; UV channels can be dropped entirely with remove_uvs).

Functions§

cluster_collapse
Snap all vertices onto a grid of cell meters, merge each cluster to its centroid and rebuild the triangle list. Degenerate (collapsed) and duplicate triangles are dropped; UVs are averaged per cluster; skin data is removed (callers should refuse skinned meshes explicitly).
decimate_mesh
Decimate one mesh asset. Terrain grids are resampled (clean lattice); everything else goes through clustering. Skinned meshes are refused: vertex weights would point at merged vertices. Returns (before, after).
decimate_node
Decimate the mesh instance under node. See decimate_mesh.
decimate_to_ratio
Cluster with a cell size chosen so the result is close to ratio of the original triangle count (bisection search). Returns (before, after).
merge_materials
remove_uvs
Drop the UV channel (unused without bitmap textures; saves memory). Returns whether anything was removed.
remove_uvs_mesh
Remove the UV channel of one mesh asset; true when it had one.