Quake & Distortion Docs (Again) + Math Cleanup (Camera Prep) (#1129)

* more quake docs

* more docs

* more distortion docs

* math cleanup

* fix header

* cleanup

* only partial PR review

* PR Suggestions

* fix master merge

* reverb angle change macros

* more revert

* fix enum
This commit is contained in:
engineer124
2023-05-18 10:29:50 -04:00
committed by GitHub
parent 83ac58d739
commit 180227e7bb
62 changed files with 811 additions and 729 deletions
+10 -10
View File
@@ -739,9 +739,9 @@ s16 Actor_TestFloorInDirection(Actor* actor, PlayState* play, f32 distance, s16
s32 Actor_IsTargeted(PlayState* play, Actor* actor);
s32 Actor_OtherIsTargeted(PlayState* play, Actor* actor);
void func_800BC620(Vec3f* pos, Vec3f* scale, u8 alpha, PlayState* play);
void Actor_AddQuake(PlayState* play, s16 verticalMag, s16 countdown);
void Actor_AddQuakeWithSpeed(PlayState* play, s16 verticalMag, s16 countdown, s16 speed);
void func_800BC848(Actor* actor, PlayState* play, s16 y, s16 countdown);
void Actor_RequestQuake(PlayState* play, s16 y, s16 duration);
void Actor_RequestQuakeWithSpeed(PlayState* play, s16 y, s16 duration, s16 speed);
void Actor_RequestQuakeAndRumble(Actor* actor, PlayState* play, s16 quakeY, s16 quakeDuration);
void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type);
void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 bufFlag, u16 duration);
Hilite* func_800BCBF4(Vec3f* arg0, PlayState* play);
@@ -833,7 +833,7 @@ s16 Camera_ClearFlags(Camera* camera, s16 flags);
s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 bgCamIndex, f32 arg3, s16 timer1, s16 timer2, s16 timer3);
s32 Camera_Copy(Camera* dstCamera, Camera* srcCamera);
// UNK_TYPE4 func_800E01AC(void);
Vec3f* Camera_GetQuakeOffset(Vec3f* dst, Camera* camera);
Vec3f* Camera_GetQuakeOffset(Vec3f* quakeOffset, Camera* camera);
// void func_800E01DC(s32 param_1, u32 param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6);
// UNK_TYPE4 func_800E0228(void);
void func_800E0238(Camera* camera);
@@ -1462,17 +1462,17 @@ f32 OLib_ClampMinDist(f32 val, f32 min);
f32 OLib_ClampMaxDist(f32 val, f32 max);
Vec3f* OLib_Vec3fDistNormalize(Vec3f* dest, Vec3f* a, Vec3f* b);
Vec3f* OLib_VecSphToVec3f(Vec3f* dest, VecSph* sph);
Vec3f* OLib_VecSphGeoToVec3f(Vec3f* dest, VecSph* sph);
Vec3f* OLib_VecGeoToVec3f(Vec3f* dest, VecGeo* geo);
VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec);
VecSph* OLib_Vec3fToVecSphGeo(VecSph* dest, Vec3f* vec);
VecGeo* OLib_Vec3fToVecGeo(VecGeo* dest, Vec3f* vec);
VecSph* OLib_Vec3fDiffToVecSph(VecSph* dest, Vec3f* a, Vec3f* b);
VecSph* OLib_Vec3fDiffToVecSphGeo(VecSph* dest, Vec3f* a, Vec3f* b);
Vec3f* OLib_VecSphAddToVec3f(Vec3f* dest, Vec3f* a, VecSph* sph);
VecGeo* OLib_Vec3fDiffToVecGeo(VecGeo* dest, Vec3f* a, Vec3f* b);
Vec3f* OLib_AddVecGeoToVec3f(Vec3f* dest, Vec3f* a, VecGeo* geo);
Vec3f* OLib_Vec3fDiffRad(Vec3f* dest, Vec3f* a, Vec3f* b);
Vec3f* OLib_Vec3fDiffDegF(Vec3f* dest, Vec3f* a, Vec3f* b);
Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b);
void OLib_DbCameraVec3fDiff(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode);
void OLib_DbCameraVec3fSum(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode);
void OLib_Vec3fDiff(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode);
void OLib_Vec3fAdd(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode);
Gfx* Gfx_DrawTexRectRGBA16(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy);
Gfx* Gfx_DrawTexRectIA8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy);
+2 -2
View File
@@ -532,8 +532,8 @@ typedef enum {
#define ACTOR_FLAG_400 (1 << 10)
//
#define ACTOR_FLAG_800 (1 << 11)
//
#define ACTOR_FLAG_1000 (1 << 12)
// Actor will not shake when a quake occurs
#define ACTOR_FLAG_IGNORE_QUAKE (1 << 12)
//
#define ACTOR_FLAG_2000 (1 << 13)
//
+7 -7
View File
@@ -374,7 +374,7 @@ typedef struct {
/* 0x00 */ Vec3f pos;
/* 0x0C */ Vec3f norm;
/* 0x18 */ CollisionPoly* poly;
/* 0x1C */ VecSph sphNorm;
/* 0x1C */ VecGeo geoNorm;
/* 0x24 */ s32 bgId;
} CameraCollision; // size = 0x28
@@ -1244,8 +1244,8 @@ typedef struct {
typedef struct {
/* 0x00 */ Vec3f unk_00;
/* 0x0C */ VecSph unk_0C;
/* 0x14 */ VecSph unk_14;
/* 0x0C */ VecGeo unk_0C;
/* 0x14 */ VecGeo unk_14;
/* 0x1C */ s16 unk_1C;
} Demo1ReadWriteData; // size = 0x20
@@ -1319,7 +1319,7 @@ typedef struct {
/* 0x0C */ f32 unk_0C;
/* 0x10 */ f32 unk_10;
/* 0x14 */ f32 unk_14;
/* 0x18 */ VecSph unk_18;
/* 0x18 */ VecGeo unk_18;
/* 0x20 */ s16 unk_20;
/* 0x22 */ s16 timer;
} Demo4ReadWriteData; // size = 0x24
@@ -1345,7 +1345,7 @@ typedef struct {
/* 0x10 */ f32 unk_10;
/* 0x14 */ f32 unk_14;
/* 0x18 */ f32 unk_18;
/* 0x1C */ VecSph unk_1C;
/* 0x1C */ VecGeo unk_1C;
/* 0x24 */ s16 unk_24;
/* 0x26 */ s16 timer;
} Demo5ReadWriteData; // size = 0x28
@@ -1367,8 +1367,8 @@ typedef struct {
typedef struct {
/* 0x00 */ f32 unk_00;
/* 0x04 */ VecSph subAtToEye;
/* 0x0C */ VecSph atToEye;
/* 0x04 */ VecGeo subAtToEye;
/* 0x0C */ VecGeo atToEye;
/* 0x14 */ s16 unk_14;
/* 0x16 */ s16 unk_16;
/* 0x18 */ s16 unk_18;
+25 -5
View File
@@ -87,12 +87,32 @@ typedef struct {
/* 0x0C */ Vec3f b;
} LineSegment; // size = 0x18
// Defines a point in the spherical coordinate system
typedef struct {
/* 0x0 */ f32 r; // radius
/* 0x4 */ s16 pitch; // polar (zenith) angle
/* 0x6 */ s16 yaw; // azimuthal angle
} VecSph; // size = 0x8
/* 0x0 */ f32 r; // radius
/* 0x4 */ s16 pitch; // depends on coordinate system. See below.
/* 0x6 */ s16 yaw; // azimuthal angle
} VecSphGeo; // size = 0x8
// Defines a point in the spherical coordinate system.
// Pitch is 0 along the positive y-axis (up)
typedef VecSphGeo VecSph;
// Defines a point in the geographic coordinate system.
// Pitch is 0 along the xz-plane (horizon)
typedef VecSphGeo VecGeo;
// To be used with OLib_Vec3fAdd()
typedef enum {
/* 0 */ OLIB_ADD_COPY, // Copy `b` to dest
/* 1 */ OLIB_ADD_OFFSET, // Add `a` and `b` to dest, and also add the yaw of `a` to the dest
/* 2 */ OLIB_ADD, // Add `a` and `b` to dest
} OlibVec3fAdd;
typedef enum {
/* 0 */ OLIB_DIFF_COPY, // Copy `b` to dest
/* 1 */ OLIB_DIFF_OFFSET, // Sub `a` and `b` to dest, and also subs the yaw of `a` to the dest
/* 2 */ OLIB_DIFF, // Sub `a` and `b` to dest
} OlibVec3fDiff;
#define LERPIMP(v0, v1, t) ((v0) + (((v1) - (v0)) * (t)))
#define F32_LERP(v0, v1, t) ((1.0f - (t)) * (f32)(v0) + (t) * (f32)(v1))
+43 -47
View File
@@ -1,68 +1,64 @@
#ifndef Z64QUAKE_H
#define Z64QUAKE_H
#include "z64camera.h"
#include "z64math.h"
struct PlayState;
struct Camera;
typedef struct {
/* 0x00 */ Vec3f atOffset;
/* 0x0C */ Vec3f eyeOffset;
/* 0x18 */ s16 rollOffset;
/* 0x1A */ s16 zoom;
/* 0x1C */ f32 max; // Set to scaled max data of struct (mag for Vec3f), never used
} QuakeCamCalc; // size = 0x20
#define QUAKE_SPEED (1 << 0)
#define QUAKE_VERTICAL_MAG (1 << 1)
#define QUAKE_HORIZONTAL_MAG (1 << 2)
#define QUAKE_ZOOM (1 << 3)
#define QUAKE_ROLL_OFFSET (1 << 4)
#define QUAKE_SHAKE_PLANE_OFFSET_X (1 << 5)
#define QUAKE_SHAKE_PLANE_OFFSET_Y (1 << 6)
#define QUAKE_SHAKE_PLANE_OFFSET_Z (1 << 7)
#define QUAKE_COUNTDOWN (1 << 8)
#define QUAKE_IS_SHAKE_PERPENDICULAR (1 << 9)
/* 0x18 */ s16 upRollOffset;
/* 0x1A */ s16 fovOffset;
/* 0x1C */ f32 maxOffset; // Set to scaled max data of struct (mag for Vec3f), never used
} ShakeInfo; // size = 0x20
typedef enum {
/* 1 */ QUAKE_TYPE_1 = 1,
/* 2 */ QUAKE_TYPE_2,
/* 3 */ QUAKE_TYPE_3,
/* 4 */ QUAKE_TYPE_4,
/* 5 */ QUAKE_TYPE_5,
/* 6 */ QUAKE_TYPE_6
/* 0 */ QUAKE_TYPE_NONE,
/* 1 */ QUAKE_TYPE_1, // Periodic, sustaining, random X perturbations
/* 2 */ QUAKE_TYPE_2, // Aperiodic, sustaining, random X perturbations
/* 3 */ QUAKE_TYPE_3, // Periodic, decaying
/* 4 */ QUAKE_TYPE_4, // Aperiodic, decaying, random X perturbations
/* 5 */ QUAKE_TYPE_5, // Periodic, sustaining
/* 6 */ QUAKE_TYPE_6 // See below
} QuakeType;
u32 Quake_SetValue(s16 quakeIndex, s16 valueType, s16 value);
u32 Quake_SetSpeed(s16 quakeIndex, s16 speed);
u32 Quake_SetCountdown(s16 quakeIndex, s16 countdown);
s16 Quake_GetCountdown(s16 quakeIndex);
u32 Quake_SetQuakeValues(s16 quakeIndex, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset);
u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakePlaneOffset);
s16 Quake_Add(Camera* camera, u32 type);
s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData);
u32 Quake_Remove(s16 index);
s32 Quake_NumActiveQuakes(void);
s16 Quake_Request(Camera* camera, u32 type);
u32 Quake_SetSpeed(s16 index, s16 speed);
u32 Quake_SetPerturbations(s16 index, s16 y, s16 x, s16 fov, s16 roll);
u32 Quake_SetDuration(s16 index, s16 duration);
u32 Quake_SetOrientation(s16 index, s16 isRelativeToScreen, Vec3s orientation);
s16 Quake_GetTimeLeft(s16 index);
s32 Quake_GetNumActiveQuakes(void);
u32 Quake_RemoveRequest(s16 index);
void Quake_Init(void);
s16 Quake_Update(Camera* camera, ShakeInfo* camShake);
#define DISTORTION_TYPE_0 (1 << 0)
#define DISTORTION_TYPE_NON_ZORA_SWIMMING (1 << 2)
#define DISTORTION_TYPE_ZORA_SWIMMING (1 << 3)
#define DISTORTION_TYPE_UNDERWATER_ENTRY (1 << 4)
#define DISTORTION_TYPE_5 (1 << 5)
#define DISTORTION_TYPE_6 (1 << 6)
#define DISTORTION_TYPE_7 (1 << 7)
#define DISTORTION_TYPE_8 (1 << 8)
#define DISTORTION_TYPE_9 (1 << 9)
#define DISTORTION_TYPE_A (1 << 10)
#define DISTORTION_TYPE_B (1 << 11)
#define DISTORTION_TYPE_HOT_ROOM (1 << 0) // Hot Room
#define DISTORTION_TYPE_NON_ZORA_SWIMMING (1 << 2) // Non-Zora swimming
#define DISTORTION_TYPE_ZORA_SWIMMING (1 << 3) // Zora swimming, also used for boss warp pad part 1
void Distortion_SetCountdown(s16 countdown);
s16 Distortion_GetCountdown(void);
#define DISTORTION_TYPE_UNDERWATER_ENTRY (1 << 4) // Entering water, also used for boss warp pad part 2
#define DISTORTION_TYPE_SONG_OF_TIME (1 << 5) // Song of Time effects
#define DISTORTION_TYPE_ZORA_KICK (1 << 6) // PLAYER_MWA_ZORA_PUNCH_KICK
#define DISTORTION_TYPE_UNK_ATTACK (1 << 7) // Impossible to achieve, inferred to be another `PLAYER_MWA_`,
#define DISTORTION_TYPE_GORON_BUTT (1 << 8) // PLAYER_MWA_GORON_PUNCH_BUTT
#define DISTORTION_TYPE_MASK_TRANSFORM_1 (1 << 9) // Mask transformation part 1
#define DISTORTION_TYPE_BOSS_WARP (1 << 10) // Boss warp pad part 3
#define DISTORTION_TYPE_MASK_TRANSFORM_2 (1 << 11) // Mask transformation part 2
void Distortion_Request(s32 type);
void Distortion_SetDuration(s16 duration);
s16 Distortion_GetTimeLeft(void);
s16 Distortion_GetType(void);
void Distortion_SetType(s32 type);
void Distortion_ClearType(s32 type);
void Distortion_RemoveRequest(s32 type);
void Distortion_Init(PlayState* play);
void Distortion_Update(void);