pub fn pack_instances(visible_slots: &[u32], morphs: &[f32]) -> Vec<u8> ⓘExpand description
Pack per-instance data for the chunk MultiMesh into a byte buffer.
Each instance is 16 f32 values (64 bytes) matching Godot’s
TRANSFORM_3D + custom_data multimesh format:
floats [0..3] — transform row 0 (identity: 1 0 0 0)
floats [4..7] — transform row 1 (identity: 0 1 0 0)
floats [8..11] — transform row 2 (identity: 0 0 1 0)
float [12] — INSTANCE_CUSTOM.r = slot as f32 ← slot index here
float [13] — INSTANCE_CUSTOM.g = geomorph factor ← morph here
floats [14..15] — INSTANCE_CUSTOM.b/a = 0visible_slots and morphs are parallel arrays (one entry per drawn instance,
same order); morphs[i] is the geomorph factor for the chunk in slot
visible_slots[i] (1 = full detail, 0 = parent resolution). Pass 1.0 for
every entry to disable morphing.
The identity transform is intentional: the vertex shader reads vertex positions from the vertex-pool texture using the slot, so no CPU-side transform is needed.
§Panics
Panics (debug) if morphs.len() != visible_slots.len().