mirror of
https://github.com/zeldaret/oot.git
synced 2024-12-27 07:07:09 +00:00
Document Actor_DrawDoorLock
(#1045)
This commit is contained in:
parent
ff49ace524
commit
b3d5f549e7
5 changed files with 52 additions and 38 deletions
|
@ -321,4 +321,10 @@ typedef enum {
|
|||
#undef DEFINE_ACTOR_INTERNAL
|
||||
#undef DEFINE_ACTOR_UNSET
|
||||
|
||||
typedef enum {
|
||||
DOORLOCK_NORMAL,
|
||||
DOORLOCK_BOSS,
|
||||
DOORLOCK_NORMAL_SPIRIT
|
||||
} DoorLockType;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "overlays/actors/ovl_Arms_Hook/z_arms_hook.h"
|
||||
#include "overlays/actors/ovl_En_Part/z_en_part.h"
|
||||
#include "objects/gameplay_keep/gameplay_keep.h"
|
||||
#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h"
|
||||
#include "objects/object_bdoor/object_bdoor.h"
|
||||
|
||||
static CollisionPoly* sCurCeilingPoly;
|
||||
static s32 sCurCeilingBgId;
|
||||
|
@ -3488,69 +3490,73 @@ f32 Rand_CenteredFloat(f32 f) {
|
|||
}
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ f32 unk_00;
|
||||
/* 0x04 */ f32 unk_04;
|
||||
/* 0x08 */ f32 unk_08;
|
||||
/* 0x0C */ f32 unk_0C;
|
||||
/* 0x10 */ f32 unk_10;
|
||||
/* 0x14 */ u32 unk_14;
|
||||
/* 0x18 */ u32 unk_18;
|
||||
} struct_801160DC; // size = 0x1C
|
||||
/* 0x00 */ f32 chainAngle;
|
||||
/* 0x04 */ f32 chainLength;
|
||||
/* 0x08 */ f32 yShift;
|
||||
/* 0x0C */ f32 chainsScale;
|
||||
/* 0x10 */ f32 chainsRotZInit;
|
||||
/* 0x14 */ Gfx* chainDL;
|
||||
/* 0x18 */ Gfx* lockDL;
|
||||
} DoorLockInfo; // size = 0x1C
|
||||
|
||||
static struct_801160DC D_801160DC[] = {
|
||||
{ 0.54f, 6000.0f, 5000.0f, 1.0f, 0.0f, 0x050011F0, 0x05001100 },
|
||||
{ 0.644f, 12000.0f, 8000.0f, 1.0f, 0.0f, 0x06001530, 0x06001400 },
|
||||
{ 0.64000005f, 8500.0f, 8000.0f, 1.75f, 0.1f, 0x050011F0, 0x05001100 },
|
||||
static DoorLockInfo sDoorLocksInfo[] = {
|
||||
/* DOORLOCK_NORMAL */ { 0.54f, 6000.0f, 5000.0f, 1.0f, 0.0f, gDoorChainsDL, gDoorLockDL },
|
||||
/* DOORLOCK_BOSS */ { 0.644f, 12000.0f, 8000.0f, 1.0f, 0.0f, object_bdoor_DL_001530, object_bdoor_DL_001400 },
|
||||
/* DOORLOCK_NORMAL_SPIRIT */ { 0.64000005f, 8500.0f, 8000.0f, 1.75f, 0.1f, gDoorChainsDL, gDoorLockDL },
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws chains and lock of a locked door, of the specified `type` (see `DoorLockType`).
|
||||
* `frame` can be 0 to 10, where 0 is "open" and 10 is "closed", the chains slide accordingly.
|
||||
*/
|
||||
void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) {
|
||||
struct_801160DC* entry;
|
||||
DoorLockInfo* entry;
|
||||
s32 i;
|
||||
MtxF spB0;
|
||||
f32 var;
|
||||
f32 temp1;
|
||||
f32 temp2;
|
||||
f32 temp3;
|
||||
MtxF baseMtxF;
|
||||
f32 chainRotZ;
|
||||
f32 chainsTranslateX;
|
||||
f32 chainsTranslateY;
|
||||
f32 rotZStep;
|
||||
|
||||
entry = &D_801160DC[type];
|
||||
var = entry->unk_10;
|
||||
entry = &sDoorLocksInfo[type];
|
||||
chainRotZ = entry->chainsRotZInit;
|
||||
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 8265);
|
||||
|
||||
Matrix_Translate(0.0f, entry->unk_08, 500.0f, MTXMODE_APPLY);
|
||||
Matrix_Get(&spB0);
|
||||
Matrix_Translate(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY);
|
||||
Matrix_Get(&baseMtxF);
|
||||
|
||||
temp1 = sinf(entry->unk_00 - var) * -(10 - frame) * 0.1f * entry->unk_04;
|
||||
temp2 = cosf(entry->unk_00 - var) * (10 - frame) * 0.1f * entry->unk_04;
|
||||
chainsTranslateX = sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength;
|
||||
chainsTranslateY = cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
Matrix_Put(&spB0);
|
||||
Matrix_RotateZ(var, MTXMODE_APPLY);
|
||||
Matrix_Translate(temp1, temp2, 0.0f, MTXMODE_APPLY);
|
||||
Matrix_Put(&baseMtxF);
|
||||
Matrix_RotateZ(chainRotZ, MTXMODE_APPLY);
|
||||
Matrix_Translate(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY);
|
||||
|
||||
if (entry->unk_0C != 1.0f) {
|
||||
Matrix_Scale(entry->unk_0C, entry->unk_0C, entry->unk_0C, MTXMODE_APPLY);
|
||||
if (entry->chainsScale != 1.0f) {
|
||||
Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY);
|
||||
}
|
||||
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_actor.c", 8299),
|
||||
G_MTX_MODELVIEW | G_MTX_LOAD);
|
||||
gSPDisplayList(POLY_OPA_DISP++, entry->unk_14);
|
||||
gSPDisplayList(POLY_OPA_DISP++, entry->chainDL);
|
||||
|
||||
if (i % 2) {
|
||||
temp3 = entry->unk_00 + entry->unk_00;
|
||||
rotZStep = 2.0f * entry->chainAngle;
|
||||
} else {
|
||||
temp3 = M_PI - (entry->unk_00 + entry->unk_00);
|
||||
rotZStep = M_PI - (2.0f * entry->chainAngle);
|
||||
}
|
||||
|
||||
var += temp3;
|
||||
chainRotZ += rotZStep;
|
||||
}
|
||||
|
||||
Matrix_Put(&spB0);
|
||||
Matrix_Put(&baseMtxF);
|
||||
Matrix_Scale(frame * 0.1f, frame * 0.1f, frame * 0.1f, MTXMODE_APPLY);
|
||||
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_actor.c", 8314),
|
||||
G_MTX_MODELVIEW | G_MTX_LOAD);
|
||||
gSPDisplayList(POLY_OPA_DISP++, entry->unk_18);
|
||||
gSPDisplayList(POLY_OPA_DISP++, entry->lockDL);
|
||||
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 8319);
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ void DoorGerudo_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
|||
|
||||
if (this->unk_166 != 0) {
|
||||
Matrix_Scale(0.01f, 0.01f, 0.025f, MTXMODE_APPLY);
|
||||
Actor_DrawDoorLock(globalCtx, this->unk_166, 0);
|
||||
Actor_DrawDoorLock(globalCtx, this->unk_166, DOORLOCK_NORMAL);
|
||||
}
|
||||
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_door_gerudo.c", 377);
|
||||
|
|
|
@ -749,7 +749,9 @@ void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
|||
if (this->unk_16E != 0) {
|
||||
Matrix_Scale(0.01f, 0.01f, 0.025f, MTXMODE_APPLY);
|
||||
Actor_DrawDoorLock(globalCtx, this->unk_16E,
|
||||
(this->doorType == SHUTTER_BOSS) ? 1 : ((this->unk_16C == 6) ? 2 : 0));
|
||||
(this->doorType == SHUTTER_BOSS)
|
||||
? DOORLOCK_BOSS
|
||||
: ((this->unk_16C == 6) ? DOORLOCK_NORMAL_SPIRIT : DOORLOCK_NORMAL));
|
||||
}
|
||||
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_door_shutter.c", 2135);
|
||||
|
|
|
@ -344,7 +344,7 @@ void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
|||
}
|
||||
}
|
||||
if (this->lockTimer != 0) {
|
||||
Actor_DrawDoorLock(globalCtx, this->lockTimer, 0);
|
||||
Actor_DrawDoorLock(globalCtx, this->lockTimer, DOORLOCK_NORMAL);
|
||||
}
|
||||
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_door.c", 941);
|
||||
|
|
Loading…
Reference in a new issue