1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-25 00:11:28 +00:00

Cleanup z_collision_check.c and structs

This commit is contained in:
Dragorn421 2022-11-10 05:49:03 +01:00
parent d8175501ad
commit 9062812a2c
No known key found for this signature in database
GPG key ID: 32B53D2D16FC4118
109 changed files with 1640 additions and 1528 deletions

View file

@ -9,90 +9,140 @@
// From z64.h
struct Actor;
/*
* Bases for all shapes of colliders
*/
typedef enum {
/* 0 */ COLTYPE_HIT0, // Blue blood, white hitmark
/* 1 */ COLTYPE_HIT1, // No blood, dust hitmark
/* 2 */ COLTYPE_HIT2, // Green blood, dust hitmark
/* 3 */ COLTYPE_HIT3, // No blood, white hitmark
/* 4 */ COLTYPE_HIT4, // Water burst, no hitmark
/* 5 */ COLTYPE_HIT5, // No blood, red hitmark
/* 6 */ COLTYPE_HIT6, // Green blood, white hitmark
/* 7 */ COLTYPE_HIT7, // Red blood, white hitmark
/* 8 */ COLTYPE_HIT8, // Blue blood, red hitmark
/* 9 */ COLTYPE_METAL,
/* 10 */ COLTYPE_NONE,
/* 11 */ COLTYPE_WOOD,
/* 12 */ COLTYPE_HARD,
/* 13 */ COLTYPE_TREE
} ColliderType;
typedef enum {
/* 0 */ COLSHAPE_JNTSPH,
/* 1 */ COLSHAPE_CYLINDER,
/* 2 */ COLSHAPE_TRIS,
/* 3 */ COLSHAPE_QUAD,
/* 4 */ COLSHAPE_MAX
} ColliderShape;
typedef struct {
/* 0x00 */ struct Actor* actor; // Attached actor
/* 0x04 */ struct Actor* at; // Actor attached to what it collided with as an AT collider.
/* 0x08 */ struct Actor* ac; // Actor attached to what it collided with as an AC collider.
/* 0x0C */ struct Actor* oc; // Actor attached to what it collided with as an OC collider.
/* 0x10 */ u8 atFlags; // Information flags for AT collisions.
/* 0x11 */ u8 acFlags; // Information flags for AC collisions.
/* 0x12 */ u8 ocFlags1; // Information flags for OC collisions.
/* 0x13 */ u8 ocFlags2; // Flags related to which colliders it can OC collide with.
/* 0x14 */ u8 colType; // Determines hitmarks and sound effects during AC collisions.
/* 0x15 */ u8 shape; // JntSph, Cylinder, Tris, or Quad
/* 0x00 */ struct Actor* self; // Actor owning this collider.
/* 0x04 */ struct Actor* otherAC; // Other actor owning the AC collider that collided with this AT collider.
/* 0x08 */ struct Actor* otherAT; // Other actor owning the AT collider that collided with this AC collider.
/* 0x0C */ struct Actor* otherOC; // Other actor owning the OC collider that collided with this OC collider.
/* 0x10 */ u8 atFlags;
/* 0x11 */ u8 acFlags;
/* 0x12 */ u8 ocFlags1;
/* 0x13 */ u8 ocFlags2; // Flags related to which colliders it can OC collide with.
/* 0x14 */ u8 colType; // Determines hitmarks and sound effects during AC collisions. See `ColliderType` enum
/* 0x15 */ u8 shape; // See `ColliderShape` enum
} Collider; // size = 0x18
typedef struct {
/* 0x00 */ u8 colType; // Determines hitmarks and sound effects during AC collisions.
/* 0x01 */ u8 atFlags; // Information flags for AT collisions.
/* 0x02 */ u8 acFlags; // Information flags for AC collisions.
/* 0x03 */ u8 ocFlags1; // Information flags for OC collisions.
/* 0x04 */ u8 ocFlags2; // Flags related to which colliders it can OC collide with.
/* 0x05 */ u8 shape; // JntSph, Cylinder, Tris, or Quad
/* 0x00 */ u8 colType;
/* 0x01 */ u8 atFlags;
/* 0x02 */ u8 acFlags;
/* 0x03 */ u8 ocFlags1;
/* 0x04 */ u8 ocFlags2;
/* 0x05 */ u8 shape;
} ColliderInit; // size = 0x06
typedef struct {
/* 0x00 */ u8 colType; // Determines hitmarks and sound effects during AC collisions.
/* 0x01 */ u8 atFlags; // Information flags for AT collisions.
/* 0x02 */ u8 acFlags; // Information flags for AC collisions.
/* 0x03 */ u8 ocFlags1; // Information flags for OC collisions.
/* 0x04 */ u8 shape; // JntSph, Cylinder, Tris, or Quad
/* 0x00 */ u8 colType;
/* 0x01 */ u8 atFlags;
/* 0x02 */ u8 acFlags;
/* 0x03 */ u8 ocFlags1;
/* 0x04 */ u8 shape;
} ColliderInitType1; // size = 0x05
typedef struct {
/* 0x00 */ struct Actor* actor;
/* 0x04 */ u8 atFlags; // Information flags for AT collisions.
/* 0x05 */ u8 acFlags; // Information flags for AC collisions.
/* 0x06 */ u8 ocFlags1; // Information flags for OC collisions.
/* 0x07 */ u8 shape; // JntSph, Cylinder, Tris, or Quad
/* 0x04 */ u8 atFlags;
/* 0x05 */ u8 acFlags;
/* 0x06 */ u8 ocFlags1;
/* 0x07 */ u8 shape;
} ColliderInitToActor; // size = 0x08
typedef struct {
/* 0x00 */ u32 dmgFlags; // Toucher damage type flags.
/* 0x04 */ u8 effect; // Damage Effect (Knockback, Fire, etc.)
/* 0x05 */ u8 damage; // Damage or Stun Timer
} ColliderTouch; // size = 0x08
} ColliderElementTouch; // size = 0x08
typedef struct {
/* 0x00 */ u32 dmgFlags; // Bumper damage type flags.
/* 0x04 */ u8 effect; // Damage Effect (Knockback, Fire, etc.)
/* 0x05 */ u8 defense; // Damage Resistance
/* 0x06 */ Vec3s hitPos; // Point of contact
} ColliderBump; // size = 0x0C
} ColliderElementBump; // size = 0x0C
typedef struct {
/* 0x00 */ u32 dmgFlags; // Bumper exclusion mask
/* 0x04 */ u8 effect; // Damage Effect (Knockback, Fire, etc.)
/* 0x05 */ u8 defense; // Damage Resistance
} ColliderBumpInit; // size = 0x08
} ColliderElementBumpInit; // size = 0x08
typedef struct ColliderInfo {
/* 0x00 */ ColliderTouch toucher; // Damage properties when acting as an AT collider
/* 0x08 */ ColliderBump bumper; // Damage properties when acting as an AC collider
/**
* Affects the sound Link's sword makes when hitting it, hookability,
* and possibly other things. It's definitely not flags, as all checks
* are == or !=. Will probably need more actors decomped to truly
* understand what this is.
*/
typedef enum {
/* 0 */ ELEMTYPE_UNK0,
/* 1 */ ELEMTYPE_UNK1,
/* 2 */ ELEMTYPE_UNK2,
/* 3 */ ELEMTYPE_UNK3,
/* 4 */ ELEMTYPE_UNK4,
/* 5 */ ELEMTYPE_UNK5,
/* 6 */ ELEMTYPE_UNK6,
/* 7 */ ELEMTYPE_UNK7
} ElementType;
typedef struct ColliderElement {
/* 0x00 */ ColliderElementTouch toucher; // Damage properties when acting as an AT collider
/* 0x08 */ ColliderElementBump bumper; // Damage properties when acting as an AC collider
/* 0x14 */ u8 elemType; // Affects sfx reaction when attacked by Link and hookability. Full purpose unknown.
/* 0x15 */ u8 toucherFlags; // Information flags for AT collisions
/* 0x16 */ u8 bumperFlags; // Information flags for AC collisions
/* 0x17 */ u8 ocElemFlags; // Information flags for OC collisions
/* 0x18 */ Collider* atHit; // object touching this element's AT collider
/* 0x1C */ Collider* acHit; // object touching this element's AC collider
/* 0x20 */ struct ColliderInfo* atHitInfo; // element that hit the AT collider
/* 0x24 */ struct ColliderInfo* acHitInfo; // element that hit the AC collider
} ColliderInfo; // size = 0x28
/* 0x20 */ struct ColliderElement* atHitInfo; // element that hit the AT collider
/* 0x24 */ struct ColliderElement* acHitInfo; // element that hit the AC collider
} ColliderElement; // size = 0x28
typedef struct {
/* 0x00 */ u8 elemType; // Affects sfx reaction when attacked by Link and hookability. Full purpose unknown.
/* 0x04 */ ColliderTouch toucher; // Damage properties when acting as an AT collider
/* 0x0C */ ColliderBumpInit bumper; // Damage properties when acting as an AC collider
/* 0x04 */ ColliderElementTouch toucher; // Damage properties when acting as an AT collider
/* 0x0C */ ColliderElementBumpInit bumper; // Damage properties when acting as an AC collider
/* 0x14 */ u8 toucherFlags; // Information flags for AT collisions
/* 0x15 */ u8 bumperFlags; // Information flags for AC collisions
/* 0x16 */ u8 ocElemFlags; // Information flags for OC collisions
} ColliderInfoInit; // size = 0x18
} ColliderElementInit; // size = 0x18
/*
* JntSph collider
*/
typedef struct {
/* 0x00 */ Sphere16 modelSphere; // model space sphere
/* 0x08 */ Sphere16 worldSphere; // world space sphere
/* 0x10 */ f32 scale; // world space sphere = model * scale * 0.01
/* 0x14 */ u8 limb; // attached limb
/* 0x10 */ f32 scale; // world space sphere = model * scale * 0.01
/* 0x14 */ u8 limb; // attached limb
} ColliderJntSphElementDim; // size = 0x18
typedef struct {
@ -102,12 +152,12 @@ typedef struct {
} ColliderJntSphElementDimInit; // size = 0x0C
typedef struct {
/* 0x00 */ ColliderInfo info;
/* 0x00 */ ColliderElement base;
/* 0x28 */ ColliderJntSphElementDim dim;
} ColliderJntSphElement; // size = 0x40
typedef struct {
/* 0x00 */ ColliderInfoInit info;
/* 0x00 */ ColliderElementInit base;
/* 0x18 */ ColliderJntSphElementDimInit dim;
} ColliderJntSphElementInit; // size = 0x24
@ -135,41 +185,49 @@ typedef struct {
/* 0x0C */ ColliderJntSphElementInit* elements;
} ColliderJntSphInitToActor; // size = 0x10
/*
* Cylinder collider
*/
typedef struct {
/* 0x00 */ Collider base;
/* 0x18 */ ColliderInfo info;
/* 0x18 */ ColliderElement elem;
/* 0x40 */ Cylinder16 dim;
} ColliderCylinder; // size = 0x4C
typedef struct {
/* 0x00 */ ColliderInit base;
/* 0x08 */ ColliderInfoInit info;
/* 0x08 */ ColliderElementInit elem;
/* 0x20 */ Cylinder16 dim;
} ColliderCylinderInit; // size = 0x2C
typedef struct {
/* 0x00 */ ColliderInitType1 base;
/* 0x08 */ ColliderInfoInit info;
/* 0x08 */ ColliderElementInit elem;
/* 0x20 */ Cylinder16 dim;
} ColliderCylinderInitType1; // size = 0x2C
typedef struct {
/* 0x00 */ ColliderInitToActor base;
/* 0x08 */ ColliderInfoInit info;
/* 0x08 */ ColliderElementInit elem;
/* 0x20 */ Cylinder16 dim;
} ColliderCylinderInitToActor; // size = 0x2C
/*
* Tris collider
*/
typedef struct {
/* 0x00 */ Vec3f vtx[3];
} ColliderTrisElementDimInit; // size = 0x24
typedef struct {
/* 0x00 */ ColliderInfo info;
/* 0x00 */ ColliderElement base;
/* 0x28 */ TriNorm dim;
} ColliderTrisElement; // size = 0x5C
typedef struct {
/* 0x00 */ ColliderInfoInit info;
/* 0x00 */ ColliderElementInit base;
/* 0x18 */ ColliderTrisElementDimInit dim;
} ColliderTrisElementInit; // size = 0x3C
@ -191,6 +249,10 @@ typedef struct {
/* 0x0C */ ColliderTrisElementInit* elements;
} ColliderTrisInitType1; // size = 0x10
/*
* Quad collider
*/
typedef struct {
/* 0x00 */ Vec3f quad[4];
/* 0x30 */ Vec3s dcMid; // midpoint of vectors d, c
@ -202,77 +264,36 @@ typedef struct {
/* 0x00 */ Vec3f quad[4];
} ColliderQuadDimInit; // size = 0x30
typedef struct {
/* 0x00 */ ColliderInfo info;
/* 0x24 */ ColliderQuadDim dim;
} ColliderQuadElement; // size = 0x68
typedef struct {
/* 0x00 */ Collider base;
/* 0x18 */ ColliderInfo info;
/* 0x18 */ ColliderElement elem;
/* 0x40 */ ColliderQuadDim dim;
} ColliderQuad; // size = 0x80
typedef struct {
/* 0x00 */ ColliderInit base;
/* 0x08 */ ColliderInfoInit info;
/* 0x08 */ ColliderElementInit elem;
/* 0x20 */ ColliderQuadDimInit dim;
} ColliderQuadInit; // size = 0x50
typedef struct {
/* 0x00 */ ColliderInitType1 base;
/* 0x08 */ ColliderInfoInit info;
/* 0x08 */ ColliderElementInit elem;
/* 0x20 */ ColliderQuadDimInit dim;
} ColliderQuadInitType1; // size = 0x50
/*
* Line collider
*/
typedef struct {
/* 0x00 */ Linef line;
/* 0x18 */ u16 ocFlags;
} OcLine; // size = 0x1C
typedef enum {
/* 0 */ COLTYPE_HIT0, // Blue blood, white hitmark
/* 1 */ COLTYPE_HIT1, // No blood, dust hitmark
/* 2 */ COLTYPE_HIT2, // Green blood, dust hitmark
/* 3 */ COLTYPE_HIT3, // No blood, white hitmark
/* 4 */ COLTYPE_HIT4, // Water burst, no hitmark
/* 5 */ COLTYPE_HIT5, // No blood, red hitmark
/* 6 */ COLTYPE_HIT6, // Green blood, white hitmark
/* 7 */ COLTYPE_HIT7, // Red blood, white hitmark
/* 8 */ COLTYPE_HIT8, // Blue blood, red hitmark
/* 9 */ COLTYPE_METAL,
/* 10 */ COLTYPE_NONE,
/* 11 */ COLTYPE_WOOD,
/* 12 */ COLTYPE_HARD,
/* 13 */ COLTYPE_TREE
} ColliderType;
typedef enum {
/* 0 */ COLSHAPE_JNTSPH,
/* 1 */ COLSHAPE_CYLINDER,
/* 2 */ COLSHAPE_TRIS,
/* 3 */ COLSHAPE_QUAD,
/* 4 */ COLSHAPE_MAX
} ColliderShape;
/**
* Affects the sound Link's sword makes when hitting it, hookability,
* and possibly other things. It's definitely not flags, as all checks
* are == or !=. Will probably need more actors decomped to truly
* understand what this is.
/*
* Collider properties, for all shapes
*/
typedef enum {
/* 0 */ ELEMTYPE_UNK0,
/* 1 */ ELEMTYPE_UNK1,
/* 2 */ ELEMTYPE_UNK2,
/* 3 */ ELEMTYPE_UNK3,
/* 4 */ ELEMTYPE_UNK4,
/* 5 */ ELEMTYPE_UNK5,
/* 6 */ ELEMTYPE_UNK6,
/* 7 */ ELEMTYPE_UNK7
} ElementType;
#define SAC_ENABLE (1 << 0)
#define AT_NONE 0 // No flags set. Cannot have AT collisions when set as AT
#define AT_ON (1 << 0) // Can have AT collisions when set as AT