assign_inverted_counters

Function assign_inverted_counters 

Source
pub fn assign_inverted_counters(root: &mut MdlNode)
Expand description

Assign inverted counter values to all mesh nodes in DFS tree order.

The inverted counter is a mesh sequence value stored at CExoArrayList offset +0xC8. It uses an “inverted” numbering scheme where values count down within each group of 100. Saber nodes consume two increments (one for each GL pool).

This function is for newly constructed models. Binary-parsed models already have their inverted_counter fields populated from the file.

Formula (from mdledit asciipostprocess.cpp:1024):

quo = mesh_counter / 100
mod = mesh_counter % 100
inverted_counter = 2^quo * 100 - mesh_counter
                 + (mod != 0 ? quo * 100 : 0)
                 + (quo != 0 ? 0 : -1)

See docs/notes/mesh_derived_fields.md §1.5 for full documentation.