1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-01-15 12:47:04 +00:00

(wip) some doc on room draw2

This commit is contained in:
Dragorn421 2022-06-16 10:19:15 +02:00
parent 030594a457
commit 72c31f9bcd
No known key found for this signature in database
GPG key ID: 32B53D2D16FC4118
3 changed files with 56 additions and 48 deletions

View file

@ -101,6 +101,10 @@
#define R_MAGIC_FILL_X XREG(51) #define R_MAGIC_FILL_X XREG(51)
#define R_ENV_LIGHT1_DIR(i) cREG(3 + i) #define R_ENV_LIGHT1_DIR(i) cREG(3 + i)
#define R_ENV_LIGHT2_DIR(i) cREG(6 + i) #define R_ENV_LIGHT2_DIR(i) cREG(6 + i)
#define R_MESH2_DEBUG_MODE iREG(86)
#define R_MESH2_NUM_ALL_ENTRIES iREG(87)
#define R_MESH2_NUM_DRAWN_ENTRIES iREG(88)
#define R_MESH2_DEBUG_DRAW_TARGET iREG(89)
#define R_B_LABEL_DD WREG(0) #define R_B_LABEL_DD WREG(0)
#define R_OW_MINIMAP_X WREG(29) #define R_OW_MINIMAP_X WREG(29)
#define R_OW_MINIMAP_Y WREG(30) #define R_OW_MINIMAP_Y WREG(30)

View file

@ -129,11 +129,13 @@ typedef struct {
typedef struct { typedef struct {
/* 0x00 */ Vec3s pos; /* 0x00 */ Vec3s pos;
/* 0x06 */ s16 unk_06; /* 0x06 */ s16 radius;
/* 0x08 */ Gfx* opa; /* 0x08 */ Gfx* opa;
/* 0x0C */ Gfx* xlu; /* 0x0C */ Gfx* xlu;
} MeshHeader2Entry; // size = 0x10 } MeshHeader2Entry; // size = 0x10
#define MESH_HEADER2_MAX_ENTRIES 64
typedef struct { typedef struct {
/* 0x00 */ MeshHeaderBase base; /* 0x00 */ MeshHeaderBase base;
/* 0x01 */ u8 numEntries; /* 0x01 */ u8 numEntries;

View file

@ -23,9 +23,9 @@ Gfx D_801270B0[] = {
}; };
void (*sRoomDrawHandlers[MESH_HEADER_TYPE_MAX])(PlayState* play, Room* room, u32 flags) = { void (*sRoomDrawHandlers[MESH_HEADER_TYPE_MAX])(PlayState* play, Room* room, u32 flags) = {
Room_Draw0, Room_Draw0, // MESH_HEADER_TYPE_0
Room_Draw1, Room_Draw1, // MESH_HEADER_TYPE_1
Room_Draw2, Room_Draw2, // MESH_HEADER_TYPE_2
}; };
void func_80095AA0(PlayState* play, Room* room, Input* arg2, UNK_TYPE arg3) { void func_80095AA0(PlayState* play, Room* room, Input* arg2, UNK_TYPE arg3) {
@ -69,24 +69,22 @@ void Room_Draw0(PlayState* play, Room* room, u32 flags) {
CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 239); CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 239);
} }
#define SHAPE_SORT_MAX 64 typedef struct MeshHeader2EntryLinked {
/* 0x00 */ MeshHeader2Entry* meshHeader2Entry;
typedef struct struct_80095D04 { /* 0x04 */ f32 unk_04_zDiff;
/* 0x00 */ MeshHeader2Entry* unk_00; /* 0x08 */ struct MeshHeader2EntryLinked* prev;
/* 0x04 */ f32 unk_04; /* 0x0C */ struct MeshHeader2EntryLinked* next;
/* 0x08 */ struct struct_80095D04* unk_08; } MeshHeader2EntryLinked; // size = 0x10
/* 0x0C */ struct struct_80095D04* unk_0C;
} struct_80095D04; // size = 0x10
void Room_Draw2(PlayState* play, Room* room, u32 flags) { void Room_Draw2(PlayState* play, Room* room, u32 flags) {
MeshHeader2* meshHeader2; MeshHeader2* meshHeader2;
MeshHeader2Entry* meshHeader2Entry; MeshHeader2Entry* meshHeader2Entry;
struct_80095D04 spB8[SHAPE_SORT_MAX]; MeshHeader2EntryLinked linkedEntriesBuffer[MESH_HEADER2_MAX_ENTRIES];
struct_80095D04* spB4 = NULL; MeshHeader2EntryLinked* head = NULL;
struct_80095D04* spB0 = NULL; MeshHeader2EntryLinked* tail = NULL;
struct_80095D04* iter; MeshHeader2EntryLinked* iter;
s32 pad; s32 pad;
struct_80095D04* spA4; MeshHeader2EntryLinked* insert;
s32 j; s32 j;
s32 i; s32 i;
Vec3f pos; Vec3f pos;
@ -95,7 +93,7 @@ void Room_Draw2(PlayState* play, Room* room, u32 flags) {
s32 pad2; s32 pad2;
MeshHeader2Entry* meshHeader2Entries; MeshHeader2Entry* meshHeader2Entries;
MeshHeader2Entry* meshHeader2EntryIter; MeshHeader2Entry* meshHeader2EntryIter;
f32 temp_f2; f32 temp_f2_zDiff;
OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 287); OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 287);
if (flags & ROOM_DRAW_OPA) { if (flags & ROOM_DRAW_OPA) {
@ -114,9 +112,10 @@ void Room_Draw2(PlayState* play, Room* room, u32 flags) {
meshHeader2 = &room->meshHeader->meshHeader2; meshHeader2 = &room->meshHeader->meshHeader2;
meshHeader2Entry = SEGMENTED_TO_VIRTUAL(meshHeader2->entries); meshHeader2Entry = SEGMENTED_TO_VIRTUAL(meshHeader2->entries);
spA4 = spB8; insert = linkedEntriesBuffer;
ASSERT(meshHeader2->numEntries <= SHAPE_SORT_MAX, "polygon2->num <= SHAPE_SORT_MAX", "../z_room.c", 317); ASSERT(meshHeader2->numEntries <= ARRAY_COUNT(linkedEntriesBuffer), "polygon2->num <= SHAPE_SORT_MAX",
"../z_room.c", 317);
meshHeader2Entries = meshHeader2Entry; meshHeader2Entries = meshHeader2Entry;
for (i = 0; i < meshHeader2->numEntries; i++, meshHeader2Entry++) { for (i = 0; i < meshHeader2->numEntries; i++, meshHeader2Entry++) {
@ -124,59 +123,62 @@ void Room_Draw2(PlayState* play, Room* room, u32 flags) {
pos.y = meshHeader2Entry->pos.y; pos.y = meshHeader2Entry->pos.y;
pos.z = meshHeader2Entry->pos.z; pos.z = meshHeader2Entry->pos.z;
SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &projectedPos, &projectedW); SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &projectedPos, &projectedW);
if (-(f32)meshHeader2Entry->unk_06 < projectedPos.z) { if (-(f32)meshHeader2Entry->radius < projectedPos.z) {
temp_f2 = projectedPos.z - meshHeader2Entry->unk_06; temp_f2_zDiff = projectedPos.z - meshHeader2Entry->radius;
if (temp_f2 < play->lightCtx.fogFar) { if (temp_f2_zDiff < play->lightCtx.fogFar) {
spA4->unk_00 = meshHeader2Entry; insert->meshHeader2Entry = meshHeader2Entry;
spA4->unk_04 = temp_f2; insert->unk_04_zDiff = temp_f2_zDiff;
iter = spB4; iter = head;
if (iter == NULL) { if (iter == NULL) {
spB4 = spB0 = spA4; head = tail = insert;
spA4->unk_08 = spA4->unk_0C = NULL; insert->prev = insert->next = NULL;
} else { } else {
do { do {
if (spA4->unk_04 < iter->unk_04) { if (insert->unk_04_zDiff < iter->unk_04_zDiff) {
break; break;
} }
iter = iter->unk_0C; iter = iter->next;
} while (iter != NULL); } while (iter != NULL);
if (iter == NULL) { if (iter == NULL) {
spA4->unk_08 = spB0; insert->prev = tail;
spA4->unk_0C = NULL; insert->next = NULL;
spB0->unk_0C = spA4; tail->next = insert;
spB0 = spA4; tail = insert;
} else { } else {
spA4->unk_08 = iter->unk_08; insert->prev = iter->prev;
if (spA4->unk_08 == NULL) { if (insert->prev == NULL) {
spB4 = spA4; head = insert;
} else { } else {
spA4->unk_08->unk_0C = spA4; insert->prev->next = insert;
} }
iter->unk_08 = spA4; iter->prev = insert;
spA4->unk_0C = iter; insert->next = iter;
} }
} }
spA4++; insert++;
} }
} }
} }
iREG(87) = meshHeader2->numEntries & 0xFFFF & 0xFFFF & 0xFFFF; // if this is real then I might not be R_MESH2_NUM_ALL_ENTRIES = meshHeader2->numEntries & 0xFFFF & 0xFFFF & 0xFFFF; // if this is real then I might not be
for (i = 1; spB4 != NULL; spB4 = spB4->unk_0C, i++) { for (i = 1; head != NULL; head = head->next, i++) {
Gfx* displayList; Gfx* displayList;
meshHeader2Entry = spB4->unk_00; meshHeader2Entry = head->meshHeader2Entry;
if (iREG(86) != 0) { if (R_MESH2_DEBUG_MODE != 0) {
// This loop does nothing
meshHeader2EntryIter = meshHeader2Entries; meshHeader2EntryIter = meshHeader2Entries;
for (j = 0; j < meshHeader2->numEntries; j++, meshHeader2EntryIter++) { for (j = 0; j < meshHeader2->numEntries; j++, meshHeader2EntryIter++) {
if (meshHeader2Entry == meshHeader2EntryIter) { if (meshHeader2Entry == meshHeader2EntryIter) {
break; // This loop does nothing? break;
} }
} }
if (((iREG(86) == 1) && (iREG(89) >= i)) || ((iREG(86) == 2) && (iREG(89) == i))) { if (((R_MESH2_DEBUG_MODE == 1) && (R_MESH2_DEBUG_DRAW_TARGET >= i)) ||
((R_MESH2_DEBUG_MODE == 2) && (R_MESH2_DEBUG_DRAW_TARGET == i))) {
if (flags & ROOM_DRAW_OPA) { if (flags & ROOM_DRAW_OPA) {
displayList = meshHeader2Entry->opa; displayList = meshHeader2Entry->opa;
if (displayList != NULL) { if (displayList != NULL) {
@ -208,7 +210,7 @@ void Room_Draw2(PlayState* play, Room* room, u32 flags) {
} }
} }
iREG(88) = i - 1; R_MESH2_NUM_DRAWN_ENTRIES = i - 1;
CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 430); CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 430);
} }