1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-28 15:56:51 +00:00

[headers 6] collision_check functions and structs (#2148)

* [headers 6] collision_check functions and structs

* bss
This commit is contained in:
Dragorn421 2024-09-07 08:29:50 +02:00 committed by GitHub
parent e7b0daa2ec
commit 87c304afcb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 133 additions and 127 deletions

View file

@ -647,99 +647,7 @@ void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* d
UNK_TYPE arg6);
s32 func_8005B198(void);
s16 Camera_SetFinishedFlag(Camera* camera);
DamageTable* DamageTable_Get(s32 index);
void DamageTable_Clear(DamageTable* table);
#if OOT_DEBUG
void Collider_DrawRedPoly(GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC);
void Collider_DrawPoly(GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC, u8 r, u8 g, u8 b);
#endif
s32 Collider_InitJntSph(PlayState* play, ColliderJntSph* jntSph);
s32 Collider_FreeJntSph(PlayState* play, ColliderJntSph* jntSph);
s32 Collider_DestroyJntSph(PlayState* play, ColliderJntSph* jntSph);
s32 Collider_SetJntSphToActor(PlayState* play, ColliderJntSph* dest, ColliderJntSphInitToActor* src);
s32 Collider_SetJntSphAllocType1(PlayState* play, ColliderJntSph* dest, Actor* actor,
ColliderJntSphInitType1* src);
s32 Collider_SetJntSphAlloc(PlayState* play, ColliderJntSph* dest, Actor* actor, ColliderJntSphInit* src);
s32 Collider_SetJntSph(PlayState* play, ColliderJntSph* dest, Actor* actor, ColliderJntSphInit* src,
ColliderJntSphElement* jntSphElements);
s32 Collider_ResetJntSphAT(PlayState* play, Collider* col);
s32 Collider_ResetJntSphAC(PlayState* play, Collider* col);
s32 Collider_ResetJntSphOC(PlayState* play, Collider* col);
s32 Collider_InitCylinder(PlayState* play, ColliderCylinder* cyl);
s32 Collider_DestroyCylinder(PlayState* play, ColliderCylinder* cyl);
s32 Collider_SetCylinderToActor(PlayState* play, ColliderCylinder* dest, ColliderCylinderInitToActor* src);
s32 Collider_SetCylinderType1(PlayState* play, ColliderCylinder* dest, Actor* actor, ColliderCylinderInitType1* src);
s32 Collider_SetCylinder(PlayState* play, ColliderCylinder* dest, Actor* actor, ColliderCylinderInit* src);
s32 Collider_ResetCylinderAT(PlayState* play, Collider* col);
s32 Collider_ResetCylinderAC(PlayState* play, Collider* col);
s32 Collider_ResetCylinderOC(PlayState* play, Collider* col);
s32 Collider_InitTris(PlayState* play, ColliderTris* tris);
s32 Collider_FreeTris(PlayState* play, ColliderTris* tris);
s32 Collider_DestroyTris(PlayState* play, ColliderTris* tris);
s32 Collider_SetTrisAllocType1(PlayState* play, ColliderTris* dest, Actor* actor, ColliderTrisInitType1* src);
s32 Collider_SetTrisAlloc(PlayState* play, ColliderTris* dest, Actor* actor, ColliderTrisInit* src);
s32 Collider_SetTris(PlayState* play, ColliderTris* dest, Actor* actor, ColliderTrisInit* src,
ColliderTrisElement* trisElements);
s32 Collider_ResetTrisAT(PlayState* play, Collider* col);
s32 Collider_ResetTrisAC(PlayState* play, Collider* col);
s32 Collider_ResetTrisOC(PlayState* play, Collider* col);
s32 Collider_InitQuad(PlayState* play, ColliderQuad* quad);
s32 Collider_DestroyQuad(PlayState* play, ColliderQuad* quad);
s32 Collider_SetQuadType1(PlayState* play, ColliderQuad* dest, Actor* actor, ColliderQuadInitType1* src);
s32 Collider_SetQuad(PlayState* play, ColliderQuad* dest, Actor* actor, ColliderQuadInit* src);
s32 Collider_ResetQuadAT(PlayState* play, Collider* col);
s32 Collider_ResetQuadAC(PlayState* play, Collider* col);
s32 Collider_ResetQuadOC(PlayState* play, Collider* col);
s32 Collider_InitLine(PlayState* play, OcLine* line);
s32 Collider_DestroyLine(PlayState* play, OcLine* line);
s32 Collider_SetLinePoints(PlayState* play, OcLine* ocLine, Vec3f* a, Vec3f* b);
s32 Collider_SetLine(PlayState* play, OcLine* dest, OcLine* src);
s32 Collider_ResetLineOC(PlayState* play, OcLine* line);
void CollisionCheck_InitContext(PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_DestroyContext(PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_ClearContext(PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_EnableSAC(PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_DisableSAC(PlayState* play, CollisionCheckContext* colChkCtx);
#if OOT_DEBUG
void Collider_Draw(PlayState* play, Collider* col);
void CollisionCheck_DrawCollision(PlayState* play, CollisionCheckContext* colChkCtx);
#endif
s32 CollisionCheck_SetAT(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider);
s32 CollisionCheck_SetAT_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index);
s32 CollisionCheck_SetAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider);
s32 CollisionCheck_SetAC_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index);
s32 CollisionCheck_SetOC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider);
s32 CollisionCheck_SetOC_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index);
s32 CollisionCheck_SetOCLine(PlayState* play, CollisionCheckContext* colChkCtx, OcLine* collider);
void CollisionCheck_BlueBlood(PlayState* play, Collider* collider, Vec3f* v);
void CollisionCheck_AT(PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_OC(PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_InitInfo(CollisionCheckInfo* info);
void CollisionCheck_ResetDamage(CollisionCheckInfo* info);
void CollisionCheck_SetInfoNoDamageTable(CollisionCheckInfo* info, CollisionCheckInfoInit* init);
void CollisionCheck_SetInfo(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit* init);
void CollisionCheck_SetInfo2(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit2* init);
void CollisionCheck_SetInfoGetDamageTable(CollisionCheckInfo* info, s32 index, CollisionCheckInfoInit2* init);
void CollisionCheck_Damage(PlayState* play, CollisionCheckContext* colChkCtx);
s32 CollisionCheck_LineOCCheckAll(PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b);
s32 CollisionCheck_LineOCCheck(PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b,
Actor** exclusions, s32 numExclusions);
void Collider_UpdateCylinder(Actor* actor, ColliderCylinder* cyl);
void Collider_SetCylinderPosition(ColliderCylinder* cyl, Vec3s* pos);
void Collider_SetQuadVertices(ColliderQuad* quad, Vec3f* a, Vec3f* b, Vec3f* c, Vec3f* d);
void Collider_SetTrisVertices(ColliderTris* tris, s32 elemIndex, Vec3f* a, Vec3f* b, Vec3f* c);
void Collider_SetTrisDim(PlayState* play, ColliderTris* tris, s32 elemIndex, ColliderTrisElementDimInit* src);
void Collider_UpdateSpheres(s32 limb, ColliderJntSph* jntSph);
void CollisionCheck_SpawnRedBlood(PlayState* play, Vec3f* v);
void CollisionCheck_SpawnWaterDroplets(PlayState* play, Vec3f* v);
void CollisionCheck_SpawnShieldParticles(PlayState* play, Vec3f* v);
void CollisionCheck_SpawnShieldParticlesMetal(PlayState* play, Vec3f* v);
void CollisionCheck_SpawnShieldParticlesMetalSfx(PlayState* play, Vec3f* v, Vec3f* pos);
void CollisionCheck_SpawnShieldParticlesMetal2(PlayState* play, Vec3f* v);
void CollisionCheck_SpawnShieldParticlesWood(PlayState* play, Vec3f* v, Vec3f* actorPos);
s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* actorPos, Vec3f* itemPos,
Vec3f* itemProjPos, Vec3f* out1, Vec3f* out2);
u8 CollisionCheck_GetSwordDamage(s32 dmgFlags);
void SaveContext_Init(void);
s32 func_800635D0(s32);
void Regs_Init(void);

View file

@ -96,39 +96,6 @@ typedef struct ActorOverlay {
/* 0x1E */ s8 numLoaded; // original name: "clients"
} ActorOverlay; // size = 0x20
typedef struct DamageTable {
u8 table[32];
} DamageTable;
typedef struct CollisionCheckInfoInit {
/* 0x00 */ u8 health;
/* 0x02 */ s16 cylRadius;
/* 0x04 */ s16 cylHeight;
/* 0x06 */ u8 mass;
} CollisionCheckInfoInit;
typedef struct CollisionCheckInfoInit2 {
/* 0x00 */ u8 health;
/* 0x02 */ s16 cylRadius;
/* 0x04 */ s16 cylHeight;
/* 0x06 */ s16 cylYShift;
/* 0x08 */ u8 mass;
} CollisionCheckInfoInit2;
typedef struct CollisionCheckInfo {
/* 0x00 */ DamageTable* damageTable;
/* 0x04 */ Vec3f displacement; // Amount to correct actor velocity by when colliding into a body
/* 0x10 */ s16 cylRadius; // Used for various purposes
/* 0x12 */ s16 cylHeight; // Used for various purposes
/* 0x14 */ s16 cylYShift; // Unused. Purpose inferred from Cylinder16 and CollisionCheck_CylSideVsLineSeg
/* 0x16 */ u8 mass; // Used to compute displacement for OC collisions
/* 0x17 */ u8 health; // Note: some actors may use their own health variable instead of this one
/* 0x18 */ u8 damage; // Amount to decrement health by
/* 0x19 */ u8 damageEffect; // Stores what effect should occur when hit by a weapon
/* 0x1A */ u8 atHitEffect; // Stores what effect should occur when AT connects with an AC
/* 0x1B */ u8 acHitEffect; // Stores what effect should occur when AC is touched by an AT
} CollisionCheckInfo; // size = 0x1C
typedef struct ActorShape {
/* 0x00 */ Vec3s rot; // Current actor shape rotation
/* 0x06 */ s16 face; // Used to index eyes and mouth textures. Only used by player

View file

@ -1,12 +1,17 @@
#ifndef Z64COLLISION_CHECK_H
#define Z64COLLISION_CHECK_H
#include "ultra64.h"
#include "z64math.h"
#define COLLISION_CHECK_AT_MAX 50
#define COLLISION_CHECK_AC_MAX 60
#define COLLISION_CHECK_OC_MAX 50
#define COLLISION_CHECK_OC_LINE_MAX 3
struct Actor;
struct GraphicsContext;
struct PlayState;
/*
* Bases for all shapes of colliders
@ -437,4 +442,131 @@ typedef struct CollisionCheckContext {
#define DMG_RANGED (DMG_ARROW | DMG_HOOKSHOT | DMG_SLINGSHOT)
#define DMG_DEFAULT ~(DMG_SHIELD | DMG_MIR_RAY)
typedef struct DamageTable {
u8 table[32];
} DamageTable;
typedef struct CollisionCheckInfoInit {
/* 0x00 */ u8 health;
/* 0x02 */ s16 cylRadius;
/* 0x04 */ s16 cylHeight;
/* 0x06 */ u8 mass;
} CollisionCheckInfoInit;
typedef struct CollisionCheckInfoInit2 {
/* 0x00 */ u8 health;
/* 0x02 */ s16 cylRadius;
/* 0x04 */ s16 cylHeight;
/* 0x06 */ s16 cylYShift;
/* 0x08 */ u8 mass;
} CollisionCheckInfoInit2;
typedef struct CollisionCheckInfo {
/* 0x00 */ DamageTable* damageTable;
/* 0x04 */ Vec3f displacement; // Amount to correct actor velocity by when colliding into a body
/* 0x10 */ s16 cylRadius; // Used for various purposes
/* 0x12 */ s16 cylHeight; // Used for various purposes
/* 0x14 */ s16 cylYShift; // Unused. Purpose inferred from Cylinder16 and CollisionCheck_CylSideVsLineSeg
/* 0x16 */ u8 mass; // Used to compute displacement for OC collisions
/* 0x17 */ u8 health; // Note: some actors may use their own health variable instead of this one
/* 0x18 */ u8 damage; // Amount to decrement health by
/* 0x19 */ u8 damageEffect; // Stores what effect should occur when hit by a weapon
/* 0x1A */ u8 atHitEffect; // Stores what effect should occur when AT connects with an AC
/* 0x1B */ u8 acHitEffect; // Stores what effect should occur when AC is touched by an AT
} CollisionCheckInfo; // size = 0x1C
DamageTable* DamageTable_Get(s32 index);
void DamageTable_Clear(DamageTable* table);
#if OOT_DEBUG
void Collider_DrawRedPoly(struct GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC);
void Collider_DrawPoly(struct GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC, u8 r, u8 g, u8 b);
#endif
s32 Collider_InitJntSph(struct PlayState* play, ColliderJntSph* jntSph);
s32 Collider_FreeJntSph(struct PlayState* play, ColliderJntSph* jntSph);
s32 Collider_DestroyJntSph(struct PlayState* play, ColliderJntSph* jntSph);
s32 Collider_SetJntSphToActor(struct PlayState* play, ColliderJntSph* dest, ColliderJntSphInitToActor* src);
s32 Collider_SetJntSphAllocType1(struct PlayState* play, ColliderJntSph* dest, struct Actor* actor,
ColliderJntSphInitType1* src);
s32 Collider_SetJntSphAlloc(struct PlayState* play, ColliderJntSph* dest, struct Actor* actor, ColliderJntSphInit* src);
s32 Collider_SetJntSph(struct PlayState* play, ColliderJntSph* dest, struct Actor* actor, ColliderJntSphInit* src,
ColliderJntSphElement* jntSphElements);
s32 Collider_ResetJntSphAT(struct PlayState* play, Collider* col);
s32 Collider_ResetJntSphAC(struct PlayState* play, Collider* col);
s32 Collider_ResetJntSphOC(struct PlayState* play, Collider* col);
s32 Collider_InitCylinder(struct PlayState* play, ColliderCylinder* cyl);
s32 Collider_DestroyCylinder(struct PlayState* play, ColliderCylinder* cyl);
s32 Collider_SetCylinderToActor(struct PlayState* play, ColliderCylinder* dest, ColliderCylinderInitToActor* src);
s32 Collider_SetCylinderType1(struct PlayState* play, ColliderCylinder* dest, struct Actor* actor, ColliderCylinderInitType1* src);
s32 Collider_SetCylinder(struct PlayState* play, ColliderCylinder* dest, struct Actor* actor, ColliderCylinderInit* src);
s32 Collider_ResetCylinderAT(struct PlayState* play, Collider* col);
s32 Collider_ResetCylinderAC(struct PlayState* play, Collider* col);
s32 Collider_ResetCylinderOC(struct PlayState* play, Collider* col);
s32 Collider_InitTris(struct PlayState* play, ColliderTris* tris);
s32 Collider_FreeTris(struct PlayState* play, ColliderTris* tris);
s32 Collider_DestroyTris(struct PlayState* play, ColliderTris* tris);
s32 Collider_SetTrisAllocType1(struct PlayState* play, ColliderTris* dest, struct Actor* actor, ColliderTrisInitType1* src);
s32 Collider_SetTrisAlloc(struct PlayState* play, ColliderTris* dest, struct Actor* actor, ColliderTrisInit* src);
s32 Collider_SetTris(struct PlayState* play, ColliderTris* dest, struct Actor* actor, ColliderTrisInit* src,
ColliderTrisElement* trisElements);
s32 Collider_ResetTrisAT(struct PlayState* play, Collider* col);
s32 Collider_ResetTrisAC(struct PlayState* play, Collider* col);
s32 Collider_ResetTrisOC(struct PlayState* play, Collider* col);
s32 Collider_InitQuad(struct PlayState* play, ColliderQuad* quad);
s32 Collider_DestroyQuad(struct PlayState* play, ColliderQuad* quad);
s32 Collider_SetQuadType1(struct PlayState* play, ColliderQuad* dest, struct Actor* actor, ColliderQuadInitType1* src);
s32 Collider_SetQuad(struct PlayState* play, ColliderQuad* dest, struct Actor* actor, ColliderQuadInit* src);
s32 Collider_ResetQuadAT(struct PlayState* play, Collider* col);
s32 Collider_ResetQuadAC(struct PlayState* play, Collider* col);
s32 Collider_ResetQuadOC(struct PlayState* play, Collider* col);
s32 Collider_InitLine(struct PlayState* play, OcLine* line);
s32 Collider_DestroyLine(struct PlayState* play, OcLine* line);
s32 Collider_SetLinePoints(struct PlayState* play, OcLine* ocLine, Vec3f* a, Vec3f* b);
s32 Collider_SetLine(struct PlayState* play, OcLine* dest, OcLine* src);
s32 Collider_ResetLineOC(struct PlayState* play, OcLine* line);
void CollisionCheck_InitContext(struct PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_DestroyContext(struct PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_ClearContext(struct PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_EnableSAC(struct PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_DisableSAC(struct PlayState* play, CollisionCheckContext* colChkCtx);
#if OOT_DEBUG
void Collider_Draw(struct PlayState* play, Collider* col);
void CollisionCheck_DrawCollision(struct PlayState* play, CollisionCheckContext* colChkCtx);
#endif
s32 CollisionCheck_SetAT(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider);
s32 CollisionCheck_SetAT_SAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index);
s32 CollisionCheck_SetAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider);
s32 CollisionCheck_SetAC_SAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index);
s32 CollisionCheck_SetOC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider);
s32 CollisionCheck_SetOC_SAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index);
s32 CollisionCheck_SetOCLine(struct PlayState* play, CollisionCheckContext* colChkCtx, OcLine* collider);
void CollisionCheck_BlueBlood(struct PlayState* play, Collider* collider, Vec3f* v);
void CollisionCheck_AT(struct PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_OC(struct PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_InitInfo(CollisionCheckInfo* info);
void CollisionCheck_ResetDamage(CollisionCheckInfo* info);
void CollisionCheck_SetInfoNoDamageTable(CollisionCheckInfo* info, CollisionCheckInfoInit* init);
void CollisionCheck_SetInfo(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit* init);
void CollisionCheck_SetInfo2(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit2* init);
void CollisionCheck_SetInfoGetDamageTable(CollisionCheckInfo* info, s32 index, CollisionCheckInfoInit2* init);
void CollisionCheck_Damage(struct PlayState* play, CollisionCheckContext* colChkCtx);
s32 CollisionCheck_LineOCCheckAll(struct PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b);
s32 CollisionCheck_LineOCCheck(struct PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b,
struct Actor** exclusions, s32 numExclusions);
void Collider_UpdateCylinder(struct Actor* actor, ColliderCylinder* cyl);
void Collider_SetCylinderPosition(ColliderCylinder* cyl, Vec3s* pos);
void Collider_SetQuadVertices(ColliderQuad* quad, Vec3f* a, Vec3f* b, Vec3f* c, Vec3f* d);
void Collider_SetTrisVertices(ColliderTris* tris, s32 elemIndex, Vec3f* a, Vec3f* b, Vec3f* c);
void Collider_SetTrisDim(struct PlayState* play, ColliderTris* tris, s32 elemIndex, ColliderTrisElementDimInit* src);
void Collider_UpdateSpheres(s32 limb, ColliderJntSph* jntSph);
void CollisionCheck_SpawnRedBlood(struct PlayState* play, Vec3f* v);
void CollisionCheck_SpawnWaterDroplets(struct PlayState* play, Vec3f* v);
void CollisionCheck_SpawnShieldParticles(struct PlayState* play, Vec3f* v);
void CollisionCheck_SpawnShieldParticlesMetal(struct PlayState* play, Vec3f* v);
void CollisionCheck_SpawnShieldParticlesMetalSfx(struct PlayState* play, Vec3f* v, Vec3f* pos);
void CollisionCheck_SpawnShieldParticlesMetal2(struct PlayState* play, Vec3f* v);
void CollisionCheck_SpawnShieldParticlesWood(struct PlayState* play, Vec3f* v, Vec3f* actorPos);
s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* actorPos, Vec3f* itemPos,
Vec3f* itemProjPos, Vec3f* out1, Vec3f* out2);
u8 CollisionCheck_GetSwordDamage(s32 dmgFlags);
#endif

View file

@ -2318,7 +2318,6 @@ void CollisionCheck_ATQuadVsACCyl(PlayState* play, CollisionCheckContext* colChk
static s8 sBssDummy3;
static s8 sBssDummy4;
static s8 sBssDummy5;
static s8 sBssDummy6;
#endif
void CollisionCheck_ATTrisVsACTris(PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol,