Stage collision (stNN.dat, executable)
The characters, shots and props don’t collide with the render meshes: each stage file carries its own collision set, built at stage load (0x1402039fc) into the collision world (SYSTEMS.md §9). Decoded from the stage-load and collision code, checked on every stage file (st01–st09, st12–st17, st22–st26, st32): every record’s size matches its count, and every stored triangle normal is the unit cross product of its corners.
- Shape lists. A list is a run of records ended by a head whose first byte is 0xFF. Head (12 bytes): u8 attribute, u8 shape type, u8 flags, u8 pad, u32 data size, u32 unused; then the data. Only records with flags bit 0 join the world (all do in the shipped files: flags 3).
- Type 3, triangle mesh.
Data: bounding sphere f32[4] (centre, radius),
box f32[6], u16 triangle count at 0x28, two
unused bytes, u32 vertex record index at 0x2C (0
in every list: the list’s first type 8 record),
then 20-byte triangles from 0x30: three u16
corner indices, u16 pad, f32[3] unit normal. The
attribute is per mesh record (a stage has
250–1040 small meshes), not per triangle.
(11-14, collapse r5) collconv writes
the bounding sphere per mesh as
sphere(centre Z mirrored, radius): the pieces’ object pass needs it. Checked on st03’s object lists: the box is the vertex bounds, the deck meshes’ radius equals the farthest vertex (the pillar’s is 1.2 u larger), and the stored normal’s y sign equals the winding’s on all 770 triangles. - Type 8, vertices. f32[3] per vertex, data size / 12 of them. It joins the world with its query flag cleared (it is only the meshes’ vertex table).
- Arena: header slot
0x94 is the arena’s list (st03:
1039 meshes, 2723 triangles over 1921 vertices;
st07: 9343 triangles). The render file’s
collision-only index buffers
(
model_0_collision, “Stage bounds” below) are not part of it (only 12 of st03’s 87 lie on the decoded set); every mesh shape the stage load registers comes from the.datlists; nor is st03’s flat plane at height 0 under the pit (no decoded mesh lies at height 0). - Object kinds: header slot
0x90 points at one
0x38-byte entry per stage object kind
(count: header word 0x60). Words 0x00/0x04/0x08
are the kind’s render model per object state
(the first is kind + 8, the layout’s
model), 0x0C–0x14 and 0x24–0x2C are other per-state lists not read here, and 0x18/0x1C/0x20 are its collision lists for states 0, 1, 2 (file offsets, −1 = none). A layout prop with object id k uses kind k. The kinds’ lists are small (st03: 10–89 triangles per kind; the railing post kind, 10). The structure class (0x1401fbbc0) builds one world object per state list, moved by the object’s own matrix, and registers the current state’s (state 0 at start). - Groups. World objects carry a 15-bit group and a 15-bit “hits” mask; a pair is tested when either one’s hits meets the other’s group. Arena meshes: group 0x1000, hits 0x4. Structures: group 0x100 (0x800 for some), hits 0x44. The character’s body probe: group 0x1, hits 0x1900, so it meets the arena and every structure.
- The loader also ORs query bits into the flags by attribute: 18 → 0x10, 19 → 0x40, 31 → 0x20, every other attribute → 0x70 (which query kinds see a mesh; the readers of these bits are not mapped).
- Character passes: the body’s wall passes and floor pick skip a mesh contact whose attribute (contact byte 2 = the mesh record’s attribute byte, decoded 11-10) is 31 always, and 20 while the body’s reaction state is 5 or 7; in every other state attribute 20 is solid for the body. Shots and the ground probes skip 16, 18, 20 and 31. Full table: “Collision attributes, groups and casts”. (Corrected 11-10: the earlier text had the attribute 20 rule inverted and kept 31 solid.)
- The character’s shape: a sphere (type 1, its own attribute byte 0x22) set per tick to the body’s position and size (0x140254530; the floor routine moves it, 0x14025522b). Shape types: 1 sphere (centre, radius), 2 and 3 meshes, 4 point, 5 and 6 two-point shapes (segments), 7 a box object of 0x1A4 bytes, 8 vertices; the pair table (0x1402dc2f0, row = first type × 8 + second) has functions for types 1–6.
- Converter:
collconv.py stNN.dat <out>/stNNwritescollision.json:stageandkinds[k][state]lists of{verts, meshes: [{attr, tris}]}, game units with Z mirrored. Godot builds one trimesh body per attribute from it (PdData.add_collision_list), each on its attribute’s physics layer (PdData.attr_layer: plain attributes on layer 1, 16 / 18 / 20 / 31 on their own layers; the body, shot and sight queries mask them as in “Collision attributes, groups and casts”), the arena with the stage transform and each prop with its own; a prop whose kind has no state-0 list is not solid (only the stages inPdData.COLLISION_STAGES: st01, st03, st07; ledger row “Decoded collision per stage”). The shapes are one-sided: Godot’s face plane for the converted corner order is the game’s normal (the Z mirror flips the winding), and the floor pick only takes faces whose own normal has y > 0.1 (“Floor test”; only y > 0.643 grounds), so a down-facing lid (st03 attribute 16 at ~26 m, st01’s top) is never a floor from above; the wall passes skip a face the body centre is behind. The set has no stair steps: the render meshes’ staircases are ramps in it (st01’s walkable faces are mostly inclined, 0.643 < n.y < 0.97), so a body walks them without step-ups. Withoutcollision.jsonit falls back to the render meshes.