Talk:Collision Layer

From the CreationKit Wiki
Jump to navigation Jump to search

Reverse engineering[edit source]

Collision layers have an internal UID stored in the BNAM subrecord, which the Creation Kit doesn't display in its UI. This UID corresponds to hardcoded layers and behaviors, and is the value used by the "Collision Layer" value on various NIF blocks related to physics.

On startup, the game creates a map, allowing to rapidly check whether any two layers collide. Layers are only stored in this map if their UIDs are less than 64, because each map entry is a 64-bit mask. (The game likewise creates 64-element arrays to track layers' debug colors and names, presumably for debugging commands that are unavailable in the retail build.) The game also uses 64-bit masks to track which layers have the "Trigger Volume" and "Sensor" flags set.

Havok processes collisions using 32-bit integers whose meanings are user-defined (i.e. Bethesda-defined in this case). The function that I call bool bhkCollisionFilter::CanFilterInfosCollide(uint32_t, uint32_t) (Address Library ID 78553 for AE) checks whether any two integers can collide.

  • For these integers, the low 7 bits are treated as the layer ID, such that layer IDs must be less than 127 to properly process collisions.
  • This function makes hardcoded references to layer UIDs 8 (L_BIEPD), 30 (L_CHARCONTROLLER), 32 (L_DEADBIP), 33 (L_BIPED_NO_CC), and 44 (not in CK, identified as L_CUSTOMPICK2).
  • Havok shapes in NIF files can specify Havok material types; these values are passed verbatim into this system.

The effect of this is that layers' BNAM subrecords cannot safely specify values above 127. The exact consequences that may occur are unknown, though I've seen extreme frame rate drops when using a trigger volume with a UID well above that value.

DavidJCobb (talk) 18:07, 12 July 2026 (EDT)

The game will overwrite the collision mask for layer UIDs 43 (L_CUSTOMPICK1), 44 (L_CUSTOMPICK2), and 45 (L_SPELLEXPLOSION) at different points during execution, to select different layers. Mods should not rely on these layers being customizable nor on the configuration shown when examining them in game files. DavidJCobb (talk) 18:50, 12 July 2026 (EDT)