From aa33833595703f6151223f1cfedbd45da797a04d Mon Sep 17 00:00:00 2001 From: Banjo Kazooie Date: Thu, 1 Dec 2022 13:27:28 -0600 Subject: [PATCH] core2/modelRender.c documentation --- include/core2/modelRender.h | 15 +- include/functions.h | 7 +- include/gc/gczoombox.h | 2 +- include/generic.h | 11 ++ src/BGS/ch/yumblie.c | 4 +- src/GV/code_1570.c | 2 +- src/GV/code_2730.c | 2 +- src/GV/code_2EE0.c | 2 +- src/MM/ch/orange.c | 2 +- src/MMM/ch/motzhand.c | 4 +- src/MMM/ch/napper.c | 4 +- src/MMM/code_47D0.c | 4 +- src/MMM/code_5000.c | 6 +- src/RBB/code_3CB0.c | 5 +- src/RBB/code_4C70.c | 2 +- src/RBB/code_5F80.c | 26 ++-- src/RBB/code_8520.c | 2 +- src/TTC/code_35D0.c | 2 +- src/core2/ch/badShad.c | 2 +- src/core2/ch/gameSelect.c | 4 +- src/core2/code_43800.c | 4 +- src/core2/code_47BD0.c | 4 +- src/core2/code_55390.c | 4 +- src/core2/code_55850.c | 4 +- src/core2/code_55BC0.c | 4 +- src/core2/code_55E70.c | 4 +- src/core2/code_560F0.c | 4 +- src/core2/code_57C70.c | 6 +- src/core2/code_581D0.c | 4 +- src/core2/code_584D0.c | 4 +- src/core2/code_59780.c | 6 +- src/core2/code_5C870.c | 4 +- src/core2/code_679A0.c | 2 +- src/core2/code_82000.c | 234 ++++++++++++++--------------- src/core2/code_94780.c | 2 +- src/core2/code_9E370.c | 17 +-- src/core2/code_AA60.c | 4 +- src/core2/code_AD5B0.c | 8 +- src/core2/code_C97F0.c | 2 +- src/core2/code_D7D10.c | 4 +- src/core2/gc/pauseMenu.c | 4 +- src/core2/gc/zoombox.c | 12 +- src/core2/modelRender.c | 292 +++++++++++++++++++----------------- 43 files changed, 385 insertions(+), 356 deletions(-) create mode 100644 include/generic.h diff --git a/include/core2/modelRender.h b/include/core2/modelRender.h index 6dc679e4..263e1f7b 100644 --- a/include/core2/modelRender.h +++ b/include/core2/modelRender.h @@ -3,6 +3,7 @@ #include #include "model.h" +#include "generic.h" enum model_render_depth_mode_e{ MODEL_RENDER_DEPTH_NONE = 0, @@ -16,9 +17,21 @@ BKTextureList *model_getTextureList(BKModelBin *arg0); void modelRender_reset(void); BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 arg3[3], f32 scale, f32*arg5, BKModelBin* model_bin); +void modelRender_preDraw(GenMethod_1 func, s32 arg); +void modelRender_postDraw(GenMethod_1 func, s32 arg); void modelRender_setDisplayList(BKGfxList *gfx_list); +void func_8033A308(f32 arg0[3]); +void modelRender_setPrimAndEnvColors(s32 env[4], s32 prim[4]); +void modelRender_setEnvColor(s32 r, s32 g, s32 b, s32 a); +void modelRender_setAlpha(s32 a); +void func_8033A444(struct58s *arg0); +void func_8033A450(s32 arg0); +void func_8033A45C(s32 arg0, s32 arg1); +void func_8033A470(s32 arg0, s32 arg1); void modelRender_setTextureList(BKTextureList *textureList); +void func_8033A494(s32 arg0); +void func_8033A4A0(enum asset_e modelId, f32 arg1, f32 arg2); void modelRender_setVertexList(BKVertexList *vertex_list); void modelRender_setDepthMode(enum model_render_depth_mode_e renderMode); - +void modelRender_defrag(void); #endif diff --git a/include/functions.h b/include/functions.h index f75bfd84..a47e666b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -18,15 +18,12 @@ #include "bs_funcs.h" #include "bsint.h" +#include "generic.h" extern f32 fabsf(f32); #pragma intrinsic (fabsf) -typedef void (* GenMethod_0)(void); -typedef void (* GenMethod_1)(s32); -typedef void (* GenMethod_2)(s32, s32); -typedef void (* GenMethod_4)(s32, s32, s32, s32); -typedef void (* GenMethod_5)(s32, s32, s32, s32, s32); + #define NOT(boolean) ((boolean) ^ 1) #define TUPLE_ASSIGN(out, a, b, c) {\ diff --git a/include/gc/gczoombox.h b/include/gc/gczoombox.h index 261f1457..f8dd39ce 100644 --- a/include/gc/gczoombox.h +++ b/include/gc/gczoombox.h @@ -120,7 +120,7 @@ typedef struct { u8 unk60[0x30]; u8 unk90[0x20]; u8 unkB0[0x40]; - BKModelBin *unkF0; + BKModelBin *model; AnimCtrl *anim_ctrl; BKSprite *unkF8; BKSpriteDisplayData *unkFC; diff --git a/include/generic.h b/include/generic.h new file mode 100644 index 00000000..2127fa89 --- /dev/null +++ b/include/generic.h @@ -0,0 +1,11 @@ +#ifndef _GENERIC_METHODS_H_ +#define _GENERIC_METHODS_H_ + +typedef void (* GenMethod_0)(void); +typedef void (* GenMethod_1)(s32); +typedef void (* GenMethod_2)(s32, s32); +typedef void (* GenMethod_3)(s32, s32, s32); +typedef void (* GenMethod_4)(s32, s32, s32, s32); +typedef void (* GenMethod_5)(s32, s32, s32, s32, s32); + +#endif diff --git a/src/BGS/ch/yumblie.c b/src/BGS/ch/yumblie.c index 8fe3d34f..746cb5af 100644 --- a/src/BGS/ch/yumblie.c +++ b/src/BGS/ch/yumblie.c @@ -109,8 +109,8 @@ Actor *chyumblie_draw(ActorMarker *this, Gfx **gfx, Mtx** mtx, Vtx **vtx){ return thisActor; } - func_8033A2D4(func_803253A0, thisActor, sp40); - func_8033A2E8(func_80325794, this); + modelRender_preDraw((GenMethod_1) func_803253A0, (s32)thisActor); + modelRender_postDraw((GenMethod_1) func_80325794, (s32)this); sp44[0] = thisActor->position_x; sp44[1] = thisActor->position_y + sp40->unk0*75.0f; sp44[2] = thisActor->position_z; diff --git a/src/GV/code_1570.c b/src/GV/code_1570.c index 50749f69..60e647c4 100644 --- a/src/GV/code_1570.c +++ b/src/GV/code_1570.c @@ -130,7 +130,7 @@ Actor *chgobi2_draw(ActorMarker *this_marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ sp3C[1] = this->yaw; sp3C[2] = this->roll; func_8033A238(func_803356A0(this->unk148)); - func_8033A2D4(func_803253A0, this); + modelRender_preDraw(func_803253A0, this); modelRender_draw(gfx, mtx, this->position, sp3C, 1.0f, NULL, func_80330B1C(this_marker)); if(this->state == 4){ diff --git a/src/GV/code_2730.c b/src/GV/code_2730.c index b9090446..dbf62d3a 100644 --- a/src/GV/code_2730.c +++ b/src/GV/code_2730.c @@ -71,7 +71,7 @@ Actor *func_80388C64(ActorMarker *this_marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ sp3C[0] = this->pitch; sp3C[1] = this->yaw; sp3C[2] = this->roll; - func_8033A2D4(func_803253A0, this); + modelRender_preDraw(func_803253A0, this); func_8033A450(func_80329934()); modelRender_draw(gfx, mtx, this->position, sp3C, 1.0f, NULL,func_80330B1C(this_marker)); func_8034A174(func_80329934(), 5, local->unk0); diff --git a/src/GV/code_2EE0.c b/src/GV/code_2EE0.c index a6dfcd59..f6a5690e 100644 --- a/src/GV/code_2EE0.c +++ b/src/GV/code_2EE0.c @@ -29,7 +29,7 @@ Actor *func_803892D0(ActorMarker *this_marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ position[1] = this->position_y; position[2] = this->position_z; position[1] += 8.0f; - func_8033A2D4(func_803253A0, this); + modelRender_preDraw(func_803253A0, this); modelRender_draw(gfx, mtx, position, rotation, this->unk1C[0], NULL, func_80330B1C(this_marker)); } return this; diff --git a/src/MM/ch/orange.c b/src/MM/ch/orange.c index a10db8ad..aac3d0d2 100644 --- a/src/MM/ch/orange.c +++ b/src/MM/ch/orange.c @@ -85,7 +85,7 @@ Actor *func_80388188(ActorMarker *this, Gfx **dl, Mtx **mptr, Vtx **vtx){ sp48[0] = actorPtr->position_x; sp48[1] = actorPtr->unk1C_y + 3.0f; sp48[2] = actorPtr->position_z; - func_8033A410( (s32) MIN(255.0f, actorPtr->unk60) ); + modelRender_setAlpha( (s32) MIN(255.0f, actorPtr->unk60) ); modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); modelRender_draw(dl, mptr, sp48, sp54, actorPtr->unk28, sp60, func_8030A428(0x18)); actorPtr->position_y -= 1.9; diff --git a/src/MMM/ch/motzhand.c b/src/MMM/ch/motzhand.c index 7ae4304f..6819b184 100644 --- a/src/MMM/ch/motzhand.c +++ b/src/MMM/ch/motzhand.c @@ -69,10 +69,10 @@ Actor *chMotzhand_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ func_8033A238(func_803356A0(this->unk148)); if(this->state == 4){ - func_8033A410((s32) (local->alpha * 255.0f)); + modelRender_setAlpha((s32) (local->alpha * 255.0f)); } else{ - func_8033A410((s32) 255); + modelRender_setAlpha((s32) 255); } sp3C[0] = sp3C[1] = sp3C[2] = 0.0f; diff --git a/src/MMM/ch/napper.c b/src/MMM/ch/napper.c index 6b8c887e..4dc7477b 100644 --- a/src/MMM/ch/napper.c +++ b/src/MMM/ch/napper.c @@ -84,10 +84,10 @@ Actor *chnapper_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ } if(this->state == 1){ //set model alpha - func_8033A410(0x80); + modelRender_setAlpha(0x80); } else{ - func_8033A410(0xdc); + modelRender_setAlpha(0xdc); } return func_80325888(marker, gfx, mtx, vtx); diff --git a/src/MMM/code_47D0.c b/src/MMM/code_47D0.c index 4c85ec83..100567e2 100644 --- a/src/MMM/code_47D0.c +++ b/src/MMM/code_47D0.c @@ -32,9 +32,9 @@ void func_8038AC40(Struct_MMM_47D0_0 *arg0, struct struct_68_s *arg1, f32 positi if (arg0->unk4 != 3) { if ((arg0->unk4 == 0) || (arg0->unk4 == 1)) { - func_8033A410(0xFF, arg0); + modelRender_setAlpha(0xFF); } else if (arg0->unk4 == 2) { - func_8033A410((s32)((1 - ((f64)arg0->unk8 * 1)) * 255.0), arg0); + modelRender_setAlpha((s32)((1 - ((f64)arg0->unk8 * 1)) * 255.0)); } modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); modelRender_draw(gfx, mtx, position, rotation, scale, NULL, model_bin); diff --git a/src/MMM/code_5000.c b/src/MMM/code_5000.c index 338355b5..3d70ff2a 100644 --- a/src/MMM/code_5000.c +++ b/src/MMM/code_5000.c @@ -25,21 +25,21 @@ void func_8038B3F0(Struct5Fs *arg0, struct struct_68_s *arg1, f32 position[3], f sp58[1] = temp_f4; sp58[2] = temp_f4; sp58[3] = 0xFF; - func_8033A334(sp58, __mmm_5000_red); + modelRender_setPrimAndEnvColors(sp58, __mmm_5000_red); } else if (arg0->unk4 > 0.0f) { temp_f6 = (s32) (((1.0f - arg0->unk4) * 223.0f) + 32.0f); sp44[0] = temp_f6; sp44[1] = temp_f6; sp44[2] = temp_f6; sp44[3] = 0xFF; - func_8033A334(sp44, __mmm_5000_green); + modelRender_setPrimAndEnvColors(sp44, __mmm_5000_green); } else if (arg0->unk0 > 0.0f) { temp_f8 = (s32) (((1.0f - arg0->unk0) * 223.0f) + 32.0f); sp30[0] = temp_f8; sp30[1] = temp_f8; sp30[2] = temp_f8; sp30[3] = 0xFF; - func_8033A334(sp30, __mmm_5000_blue); + modelRender_setPrimAndEnvColors(sp30, __mmm_5000_blue); } modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); modelRender_draw(gfx, mtx, position, rotation, scale, NULL, model_bin); diff --git a/src/RBB/code_3CB0.c b/src/RBB/code_3CB0.c index c1c0b209..cc5af769 100644 --- a/src/RBB/code_3CB0.c +++ b/src/RBB/code_3CB0.c @@ -4,7 +4,6 @@ extern void func_8028F9DC(s32); extern void func_803253A0(Actor *); -extern void func_8033A2D4(void(*)(Actor *), Actor *); /* typedefs and declarations */ typedef struct { @@ -77,7 +76,7 @@ Actor *func_8038A224(ActorMarker *marker, Gfx **gdl, Mtx **mptr, s32 arg3){ return actor; } - func_8033A2D4(func_803253A0, actor); + modelRender_preDraw(func_803253A0, actor); if(local->unk4){ modelRender_draw(gdl, mptr, &actor->position, NULL, 1.0f, NULL, local->unk4); } @@ -121,4 +120,4 @@ void func_8038A324(Actor *this){ RBB_func_8038A0A0(this, 1); } } -} \ No newline at end of file +} diff --git a/src/RBB/code_4C70.c b/src/RBB/code_4C70.c index e8a465ce..0294a792 100644 --- a/src/RBB/code_4C70.c +++ b/src/RBB/code_4C70.c @@ -111,7 +111,7 @@ Actor *func_8038B230(ActorMarker *marker, Gfx** gdl, Mtx** mptr, s32 arg3){ sp3C[0] = actor->pitch; sp3C[1] = actor->yaw; sp3C[2] = actor->roll; - func_8033A2D4(&func_803253A0, actor); + modelRender_preDraw(&func_803253A0, actor); func_8033A450(func_80329934()); modelRender_draw(gdl, mptr, &actor->position, &sp3C, actor->scale, NULL, func_80330B1C(marker)); func_8034A174(func_80329934(), 5, &local->unk4); diff --git a/src/RBB/code_5F80.c b/src/RBB/code_5F80.c index 9d19914d..595c135b 100644 --- a/src/RBB/code_5F80.c +++ b/src/RBB/code_5F80.c @@ -265,7 +265,7 @@ void RBB_func_8038CC9C(Actor *this, s32 new_state){ int i; f32 pad; f32 sp68[3]; - f32 sp64; + f32 player_position; f32 sp60; f32 sp5C; f32 sp58; @@ -404,11 +404,11 @@ void RBB_func_8038CC9C(Actor *this, s32 new_state){ if(this->state == 3 || this->state == 4 || this->state == 5){ local->unk20 = RBB_func_8038CBF0(this); if( local->unk20 == 0){ - sp64 = local->unk0->unk4*300.0f; + player_position = local->unk0->unk4*300.0f; for(i = 0; i < 10; i++){ - local->unk14[0] = local->unk8[0] + randf2(-sp64, sp64); + local->unk14[0] = local->unk8[0] + randf2(-player_position, player_position); local->unk14[1] = local->unk14[1]; - local->unk14[2] = local->unk8[2] + randf2(-sp64, sp64); + local->unk14[2] = local->unk8[2] + randf2(-player_position, player_position); func_8038CA70(this, &local->unk14); local->unk20 = RBB_func_8038CBF0(this); if(local->unk20) @@ -465,9 +465,9 @@ Actor *func_8038D638(ActorMarker *marker, Gfx **gdl, Mtx ** mptr, s32 arg3){ func_8033A45C(6, (actor->state == 4)? 2: 1); func_8033A45C(7, (actor->state == 4)? 2: 1); } - func_8033A2D4(func_803253A0, actor); - func_8033A2E8(func_80325794, marker); - modelRender_draw(gdl, mptr, &actor->position, &sp3C, actor->scale, NULL, func_80330B1C(marker)); + modelRender_preDraw( (GenMethod_1)func_803253A0, (s32)actor); + modelRender_postDraw((GenMethod_1)func_80325794, (s32)marker); + modelRender_draw(gdl, mptr, actor->position, sp3C, actor->scale, NULL, func_80330B1C(marker)); return actor; } @@ -493,7 +493,7 @@ void func_8038D7E8(ActorMarker *marker, s32 arg1){ void func_8038D8B4(Actor *actor){} void func_8038D8BC(Actor *this){ - f32 sp64[3]; + f32 player_position[3]; ActorLocal_RBB_5F80 *local = (ActorLocal_RBB_5F80 *) &this->local; f32 sp5C; f32 sp58; @@ -540,7 +540,7 @@ void func_8038D8BC(Actor *this){ return; } - player_getPosition(&sp64); + player_getPosition(player_position); if(this->state == 1){ if(func_803203FC(2)){ if(func_803203FC(3)){ @@ -548,7 +548,7 @@ void func_8038D8BC(Actor *this){ } } else{//L8038DAA8 - if(ml_vec3f_distance(&this->position, &sp64) < 1200.0f){ + if(ml_vec3f_distance(this->position, player_position) < 1200.0f){ RBB_func_8038CC9C(this, 2); } } @@ -565,7 +565,7 @@ void func_8038D8BC(Actor *this){ if(func_8033567C(this->unk148) == ASSET_147_ANIM_BOOMBOX_MOVE){ func_8033568C(this->unk148, &sp5C, &sp58); if(sp5C < 0.6 && 0.6 <= sp58){ - func_8030E878(SFX_6C_LOCKUP_CLOSING, randf2(-0.05f, 0.05f) + local->unk0->unk14, 0x4e20, &this->position, 500.0f, 1000.0f); + func_8030E878(SFX_6C_LOCKUP_CLOSING, randf2(-0.05f, 0.05f) + local->unk0->unk14, 20000, this->position, 500.0f, 1000.0f); }//L8038DC04 if(sp5C < 0.1 && 0.1 <= sp58){ func_8038C39C(this); @@ -584,7 +584,7 @@ void func_8038D8BC(Actor *this){ func_8033568C(this->unk148, &sp54, &sp50); if(0.1 <= sp50 && sp50 <= 0.6){ sp4C = (sp50 - 0.1)/0.5; - func_80255FE4(&this->position, &local->unk8, &local->unk14, sp4C); + func_80255FE4(this->position, local->unk8, local->unk14, sp4C); this->yaw = local->unk24 + sp4C*(local->unk28 - local->unk24); } @@ -602,7 +602,7 @@ void func_8038D8BC(Actor *this){ tmp_f2 = tmp_f2/0.3; else tmp_f2 = 1.0f; - func_80255FE4(&this->position, &local->unk8, &local->unk14, tmp_f2); + func_80255FE4(this->position, local->unk8, local->unk14, tmp_f2); } }//L8038DE10 diff --git a/src/RBB/code_8520.c b/src/RBB/code_8520.c index 3c990a7c..6e6d8872 100644 --- a/src/RBB/code_8520.c +++ b/src/RBB/code_8520.c @@ -305,7 +305,7 @@ Actor * func_8038F4B0(ActorMarker *marker, Gfx **gdl, Mtx **mptr, s32 arg3){ D_803912A0[0] = actor->pitch; D_803912A0[1] = actor->yaw; D_803912A0[2] = actor->roll; - func_8033A334(sp28, &D_80390DDC); + modelRender_setPrimAndEnvColors(sp28, &D_80390DDC); }//L8038F5F8 return func_80325888(marker, gdl, mptr, arg3); } diff --git a/src/TTC/code_35D0.c b/src/TTC/code_35D0.c index e6972a23..cb16f42d 100644 --- a/src/TTC/code_35D0.c +++ b/src/TTC/code_35D0.c @@ -239,7 +239,7 @@ Actor *func_8038A0D0(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ sp40[2] = actor->position[2]; func_8032AA58(actor, sp3C); - func_8033A2D4(func_803253A0, actor); + modelRender_preDraw(func_803253A0, actor); modelRender_draw(gfx, mtx, sp40, sp4C, sp3C, NULL, func_80330B1C(marker)); return actor; } diff --git a/src/core2/ch/badShad.c b/src/core2/ch/badShad.c index e1dfd8d0..b2cf6dc4 100644 --- a/src/core2/ch/badShad.c +++ b/src/core2/ch/badShad.c @@ -48,7 +48,7 @@ Actor *func_802D6F48(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ } if(other) - func_8033A410(other->alpha_124_19); + modelRender_setAlpha(other->alpha_124_19); sp40 = ml_map_f(this->unk28, 0.0f , 800.0f, 0.53f, 0.18f)*this->unk1C[1]; modelRender_setDepthMode(MODEL_RENDER_DEPTH_COMPARE); modelRender_draw(gfx, mtx, this->position, sp44, sp40, NULL, func_80330B1C(marker)); diff --git a/src/core2/ch/gameSelect.c b/src/core2/ch/gameSelect.c index 117c114e..ce7c2b48 100644 --- a/src/core2/ch/gameSelect.c +++ b/src/core2/ch/gameSelect.c @@ -109,10 +109,10 @@ Actor *func_802C4360(ActorMarker *marker, Gfx **arg1, Mtx **arg2, Vtx **arg3){ func_8033A45C(0xC, 1); func_8033A45C(0xF, 1); if(sp1C == D_80365E00){ - func_8033A388(0xFF, 0xFF, 0xFF, 0xFF); + modelRender_setEnvColor(0xFF, 0xFF, 0xFF, 0xFF); } else{ - func_8033A388(0x64, 0x64, 0x64, 0xFF); + modelRender_setEnvColor(0x64, 0x64, 0x64, 0xFF); } return func_80325888(marker, arg1, arg2, arg3); } diff --git a/src/core2/code_43800.c b/src/core2/code_43800.c index d34fda66..5ea8325a 100644 --- a/src/core2/code_43800.c +++ b/src/core2/code_43800.c @@ -17,7 +17,7 @@ ActorInfo D_80366EF0 = { /* .code */ void func_802CA790(Actor *this){ - func_8033A410(0xff); + modelRender_setAlpha(0xff); modelRender_setDepthMode(MODEL_RENDER_DEPTH_COMPARE); } @@ -52,7 +52,7 @@ Actor *func_802CA7BC(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ sp48[1] = this->yaw; sp48[2] = this->roll; sp44 = ml_map_f(sp54[1] - sp40, 0.0f, 300.0f, 0.43f, 0.28f); - func_8033A2D4(func_802CA790, this); + modelRender_preDraw(func_802CA790, this); modelRender_draw(gfx, mtx, this->position, sp48, sp44, NULL, func_80330B1C(marker)); return this; } diff --git a/src/core2/code_47BD0.c b/src/core2/code_47BD0.c index b607b329..3a39bf0c 100644 --- a/src/core2/code_47BD0.c +++ b/src/core2/code_47BD0.c @@ -98,12 +98,12 @@ Actor *chBeeSwarm_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ sp8C[2] = this->position[2] + phi_s0->unk0[2]; modelRender_setDepthMode(MODEL_RENDER_DEPTH_COMPARE); - func_8033A410(0xFF); + modelRender_setAlpha(0xFF); modelRender_draw(gfx, mtx, sp8C, sp80, 0.25f, NULL, phi_fp); local->unk5 |= func_8033A170(); if(phi_s2 < 10){ sp8C[1] = local->unk18 + 6.0f; - func_8033A410(0xC0); + modelRender_setAlpha(0xC0); modelRender_setDepthMode(MODEL_RENDER_DEPTH_COMPARE); modelRender_draw(gfx, mtx, sp8C, sp80, 0.1f, NULL, local->unk20); local->unk5 |= func_8033A170(); diff --git a/src/core2/code_55390.c b/src/core2/code_55390.c index b70b7824..da3aa5ed 100644 --- a/src/core2/code_55390.c +++ b/src/core2/code_55390.c @@ -29,8 +29,8 @@ Actor *func_802DC320(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ f32 sp34[3]; this = marker_getActor(marker); - func_8033A2D4(func_803253A0, this); - func_8033A2E8(func_80325794, marker); + modelRender_preDraw( (GenMethod_1)func_803253A0, (s32)this); + modelRender_postDraw((GenMethod_1)func_80325794, (s32)marker); func_8024E258(); sp58[0] = 0.0f; sp58[1] = 0.0f; diff --git a/src/core2/code_55850.c b/src/core2/code_55850.c index 29cf87f0..74ed8b03 100644 --- a/src/core2/code_55850.c +++ b/src/core2/code_55850.c @@ -28,8 +28,8 @@ Actor *func_802DC7E0(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ f32 sp34[3]; this = marker_getActor(marker); - func_8033A2D4(func_803253A0, this); - func_8033A2E8(func_80325794, marker); + modelRender_preDraw( (GenMethod_1)func_803253A0, (s32)this); + modelRender_postDraw((GenMethod_1)func_80325794, (s32)marker); func_8024E258(); sp58[0] = 0.0f; sp58[1] = 0.0f; diff --git a/src/core2/code_55BC0.c b/src/core2/code_55BC0.c index 7fe82771..a1b48672 100644 --- a/src/core2/code_55BC0.c +++ b/src/core2/code_55BC0.c @@ -45,8 +45,8 @@ Actor *func_802DCB50(ActorMarker *marker, Gfx **gdl, Mtx **mptr, Vtx **vptr){ if(D_8037DE84) return actor; - func_8033A2D4(func_803253A0, actor); - func_8033A2E8(func_80325794, marker); + modelRender_preDraw((GenMethod_1)func_803253A0, (s32)actor); + modelRender_postDraw((GenMethod_1)func_80325794, (s32)marker); func_8024E258(); {sp58[0] = 0.0f; sp58[1] = 0.0f; sp58[2] = 1312.5f;}; {sp4C[0] = 0.0f; sp4C[1] = 0.0f; sp4C[2] = 0.0f;}; diff --git a/src/core2/code_55E70.c b/src/core2/code_55E70.c index c421f515..6e160296 100644 --- a/src/core2/code_55E70.c +++ b/src/core2/code_55E70.c @@ -35,8 +35,8 @@ Actor *func_802DCE00(ActorMarker *marker, Gfx **gdl, Mtx **mptr, Vtx **vptr){ actor = marker_getActor(marker); - func_8033A2D4(func_803253A0, actor); - func_8033A2E8(func_80325794, marker); + modelRender_preDraw((GenMethod_1)func_803253A0, (s32)actor); + modelRender_postDraw((GenMethod_1)func_80325794, (s32)marker); func_8024E258(); {sp58[0] = 0.0f; sp58[1] = 0.0f; sp58[2] = 1312.5f;}; {sp4C[0] = 0.0f; sp4C[1] = 0.0f; sp4C[2] = 0.0f;}; diff --git a/src/core2/code_560F0.c b/src/core2/code_560F0.c index 8b96168e..43f09511 100644 --- a/src/core2/code_560F0.c +++ b/src/core2/code_560F0.c @@ -171,8 +171,8 @@ Actor *func_802DD188(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx) { gDPSetTextureFilter((*gfx)++, G_TF_POINT); gSPSegment((*gfx)++, 0x04, osVirtualToPhysical(sp50)); - func_8033A2D4(func_803253A0, sp6C); - func_8033A2E8(func_80325794, marker); + modelRender_preDraw((GenMethod_1)func_803253A0, (s32)sp6C); + modelRender_postDraw((GenMethod_1)func_80325794, (s32)marker); modelRender_draw(gfx, mtx, sp60, NULL, D_80368250, sp54, func_80330B1C(marker)); gDPSetTextureFilter((*gfx)++, G_TF_BILERP); diff --git a/src/core2/code_57C70.c b/src/core2/code_57C70.c index d40aae33..4e3d7fbf 100644 --- a/src/core2/code_57C70.c +++ b/src/core2/code_57C70.c @@ -65,9 +65,9 @@ Actor *func_802DEC00(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ gDPSetColorDither((*gfx)++, G_CD_DISABLE); func_80253190(gfx); gSPSegment((*gfx)++, 0x04, osVirtualToPhysical(sp48)); - func_8033A2D4(func_803253A0, this); - func_8033A2E8(func_80325794, marker); - modelRender_draw(gfx, mtx, this->position, NULL, 4.5f, &sp4C, func_80330B1C(marker)); + modelRender_preDraw((GenMethod_1)func_803253A0, (s32)this); + modelRender_postDraw((GenMethod_1)func_80325794, (s32)marker); + modelRender_draw(gfx, mtx, this->position, NULL, 4.5f, sp4C, func_80330B1C(marker)); gDPSetTextureFilter((*gfx)++, G_TF_BILERP); gDPSetColorDither((*gfx)++, G_CD_MAGICSQ); func_802DD158(gfx, mtx); diff --git a/src/core2/code_581D0.c b/src/core2/code_581D0.c index 06a99cf3..138cdede 100644 --- a/src/core2/code_581D0.c +++ b/src/core2/code_581D0.c @@ -31,8 +31,8 @@ Actor *func_802DF160(Gfx **gfx, Mtx **mtx, Vtx **vtx) { modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); gDPSetTextureFilter((*gfx)++, G_TF_POINT); gSPSegment((*gfx)++, 0x04, osVirtualToPhysical(sp38)); - func_8033A2D4(func_803253A0, this); - func_8033A2E8(func_80325794, D_8037E000); + modelRender_preDraw((GenMethod_1)func_803253A0, (s32)this); + modelRender_postDraw((GenMethod_1)func_80325794, (s32)D_8037E000); modelRender_draw(gfx, mtx, &D_80368360, NULL, 1.0f, NULL, func_80330B1C(D_8037E000)); gDPSetTextureFilter((*gfx)++, G_TF_BILERP); return this; diff --git a/src/core2/code_584D0.c b/src/core2/code_584D0.c index 78682516..eb53aeba 100644 --- a/src/core2/code_584D0.c +++ b/src/core2/code_584D0.c @@ -146,8 +146,8 @@ void func_802DF71C(Gfx **gfx, Mtx **mtx, Vtx **vtx) { f32 sp3C; this = func_80325300(D_8037E060, &sp44); - func_8033A2D4(func_803253A0, this); - func_8033A2E8(func_80325794, D_8037E060); + modelRender_preDraw((GenMethod_1)func_803253A0, (s32)this); + modelRender_postDraw((GenMethod_1)func_80325794, (s32)D_8037E060); modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); actor_setOpacity(this, 0xB9); func_8024E030(this->position, D_8037E5C0.unk18); diff --git a/src/core2/code_59780.c b/src/core2/code_59780.c index 6e5ef811..e6204e7d 100644 --- a/src/core2/code_59780.c +++ b/src/core2/code_59780.c @@ -89,9 +89,9 @@ Actor *func_802E0738(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ Actor *this; this = func_80325300(marker, &sp34); - func_8033A2D4(func_802E0710, this); - func_8033A2E8(func_80325794, marker); - modelRender_draw(gfx, mtx, this->position, &sp34, this->scale, NULL, func_80330B1C(marker)); + modelRender_preDraw( (GenMethod_1)func_802E0710, (s32)this); + modelRender_postDraw((GenMethod_1)func_80325794, (s32)marker); + modelRender_draw(gfx, mtx, this->position, sp34, this->scale, NULL, func_80330B1C(marker)); return this; } diff --git a/src/core2/code_5C870.c b/src/core2/code_5C870.c index 5420533d..8e1d6adc 100644 --- a/src/core2/code_5C870.c +++ b/src/core2/code_5C870.c @@ -78,7 +78,7 @@ void func_802E3854(void){ func_80254464(); for(i = 0; i < 0xF; i++){ func_802E6820(5); - func_8033A4D8(); + modelRender_defrag(); mapSavestate_defrag_all(); gctransition_8030B740(); func_802F542C(); @@ -589,7 +589,7 @@ s32 func_802E48D8(void){ func_80288470(); func_802F1320(); func_802BA128(); - func_8033A4D8(); + modelRender_defrag(); func_8028FB68(); func_802F0E58(); func_8030A298(); diff --git a/src/core2/code_679A0.c b/src/core2/code_679A0.c index a40b12a4..85413b7c 100644 --- a/src/core2/code_679A0.c +++ b/src/core2/code_679A0.c @@ -162,7 +162,7 @@ void func_802EEE3C(ParticleEmitter *this, Gfx **gfx, Mtx **mtx, Vtx **vtx, u32 a sp8C[1] = iPtr->position_18[1] + this->unk4[1]; sp8C[2] = iPtr->position_18[2] + this->unk4[2]; if( 0.0f != this->unk10 || 1.0 != this->unk14 || this->unk49 != 0xff ){ - func_8033A410((s32) (iPtr->unkC*this->unk49)); + modelRender_setAlpha((s32) (iPtr->unkC*this->unk49)); }//L802EEF5C // tmp_a3 = (this->unk18 & 0x10)?0:1; modelRender_setDepthMode((this->unk18 & 0x10)?0:1); diff --git a/src/core2/code_82000.c b/src/core2/code_82000.c index f9f9c031..137590bf 100644 --- a/src/core2/code_82000.c +++ b/src/core2/code_82000.c @@ -9,7 +9,7 @@ extern UNK_TYPE(s32) func_802E92AC(BKCollisionList *, BKVertexList *, f32[3], f3 extern UNK_TYPE(s32) func_802EC394(BKMeshList *, UNK_TYPE(s32), UNK_TYPE(s32), f32, UNK_TYPE(s32), UNK_TYPE(s32), UNK_TYPE(s32)); extern void func_802EC458(BKVertexList *, s32[3], s32[3]); extern void func_8033A494(s32); -extern void func_8033A388(s32, s32, s32, s32); +extern void modelRender_setEnvColor(s32, s32, s32, s32); extern void func_802F7BC0(Gfx **, Mtx **, Vtx **); extern void func_8033A450(s32); extern void func_8033A45C(s32, s32); @@ -164,20 +164,20 @@ Struct_core2_82000_0 D_8036ABE0[] = { struct { void *unk0; void *unk4; - BKCollisionList *unk8; - BKCollisionList *unkC; - BKModel *unk10; - BKModel *unk14; - BKModelBin *unk18; - BKModelBin *unk1C; + BKCollisionList *collision_opa; + BKCollisionList *collision_xlu; + BKModel *model_opa; + BKModel *model_xlu; + BKModelBin *model_bin_opa; + BKModelBin *model_bin_xlu; s32 unk20; struct5Bs *unk24; Struct_core2_82000_0 *unk28; - u8 unk2C; - u8 unk2D; - u8 unk2E; + u8 env_red; + u8 env_green; + u8 env_blue; f32 unk30; -}D_80382350; +}levelModel; enum asset_e func_8030A068(void); @@ -237,7 +237,7 @@ f32 func_80308FDC(f32 arg0[3], u32 arg1) { return 0.0f; } -void func_803091D4(Gfx **gfx, Mtx **mtx, Vtx **vtx) { +void levelModel_opa_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { s32 temp_a0; if (func_80320708() && levelSpecificFlags_validateCRC2() && func_80320248()) { @@ -339,44 +339,42 @@ void func_803091D4(Gfx **gfx, Mtx **mtx, Vtx **vtx) { func_8033A45C(6, (func_8038EAE0(0xA) || func_8031FF1C(0xE2) || func_803203FC(0xC1))); break; } - func_8033A450(D_80382350.unk24); + func_8033A450(levelModel.unk24); modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); - temp_a0 = D_80382350.unk0; + temp_a0 = levelModel.unk0; if (temp_a0 != 0) { func_8033A494(temp_a0); } - func_8033A388(D_80382350.unk2C, D_80382350.unk2D, D_80382350.unk2E, 0xFF); - modelRender_draw(gfx, mtx, NULL, NULL, D_80382350.unk28->unk14, NULL, D_80382350.unk18); + modelRender_setEnvColor(levelModel.env_red, levelModel.env_green, levelModel.env_blue, 0xFF); + modelRender_draw(gfx, mtx, NULL, NULL, levelModel.unk28->unk14, NULL, levelModel.model_bin_opa); if (!func_80309F78()) { func_802F7BC0(gfx, mtx, vtx); } } } -//levelRender_model2_draw -void func_80309628(Gfx **gfx, Mtx **mtx, Vtx **vtx) { +void levelModel_xlu_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { s32 temp_a0; - if (D_80382350.unk1C != NULL) { + if (levelModel.model_bin_xlu != NULL) { if (map_get() == MAP_1D_MMM_CELLAR) { func_8033A45C(1, (func_80326EEC(0x191) != NULL) ? 0 : 1); } modelRender_setDepthMode(MODEL_RENDER_DEPTH_COMPARE); - temp_a0 = D_80382350.unk4; + temp_a0 = levelModel.unk4; if (temp_a0 != 0) { func_8033A494(temp_a0); } - func_8033A388(D_80382350.unk2C, D_80382350.unk2D, D_80382350.unk2E, 0xFF); - modelRender_draw(gfx, mtx, NULL, NULL, D_80382350.unk28->unk14, NULL, D_80382350.unk1C); + modelRender_setEnvColor(levelModel.env_red, levelModel.env_green, levelModel.env_blue, 0xFF); + modelRender_draw(gfx, mtx, NULL, NULL, levelModel.unk28->unk14, NULL, levelModel.model_bin_xlu); func_802F7BC0(gfx, mtx, vtx); } } - void func_80309704(s32 arg0, s32 arg1, s32 arg2){} s32 func_80309714(void){ - return D_80382350.unk8->unk12; + return levelModel.collision_opa->unk12; } f32 func_80309724(f32 arg0[3]){ @@ -384,44 +382,44 @@ f32 func_80309724(f32 arg0[3]){ } BKModel *func_80309744(s32 arg0){ - return (arg0) ? D_80382350.unk14 : D_80382350.unk10; + return (arg0) ? levelModel.model_xlu : levelModel.model_opa; } -s32 func_80309764(s32 arg0){ +BKModelBin *func_80309764(s32 arg0){ if(arg0 == 0) - return D_80382350.unk18; + return levelModel.model_bin_opa; if(arg0 == 1) - return D_80382350.unk1C; + return levelModel.model_bin_xlu; return 0; } s32 func_80309794(void){ - return D_80382350.unk20; + return levelModel.unk20; } struct5Bs *func_803097A0(void){ - return D_80382350.unk24; + return levelModel.unk24; } void func_803097AC(s32 arg0[3], s32 arg1[3]) { - func_802EC458(func_8033A148(D_80382350.unk18), arg0, arg1); + func_802EC458(func_8033A148(levelModel.model_bin_opa), arg0, arg1); func_8033ECD8(arg0, arg1, 0x3E8); - arg0[0] = arg0[0] + D_80382350.unk28->unk6[0]; - arg0[1] = arg0[1] + D_80382350.unk28->unk6[1]; - arg0[2] = arg0[2] + D_80382350.unk28->unk6[2]; - arg1[0] = arg1[0] + D_80382350.unk28->unkC[0]; - arg1[1] = arg1[1] + D_80382350.unk28->unkC[1]; - arg1[2] = arg1[2] + D_80382350.unk28->unkC[2]; + arg0[0] = arg0[0] + levelModel.unk28->unk6[0]; + arg0[1] = arg0[1] + levelModel.unk28->unk6[1]; + arg0[2] = arg0[2] + levelModel.unk28->unk6[2]; + arg1[0] = arg1[0] + levelModel.unk28->unkC[0]; + arg1[1] = arg1[1] + levelModel.unk28->unkC[1]; + arg1[2] = arg1[2] + levelModel.unk28->unkC[2]; } void func_80309888(s32 arg0[3], s32 arg1[3]) { s32 i; - func_802EC458(func_8033A148(D_80382350.unk18), arg0, arg1); + func_802EC458(func_8033A148(levelModel.model_bin_opa), arg0, arg1); for(i = 0; i < 3; i++){ - arg0[i] *= D_80382350.unk30; - arg1[i] *= D_80382350.unk30; + arg0[i] *= levelModel.unk30; + arg1[i] *= levelModel.unk30; } } @@ -430,14 +428,14 @@ void func_80309998(s32 arg0[3], s32 arg1[3]) { s32 sp3C[3]; s32 sp30[3]; - func_802EC458(func_8033A148(D_80382350.unk18), arg0, arg1); + func_802EC458(func_8033A148(levelModel.model_bin_opa), arg0, arg1); for(i = 0; i < 3; i++){ - arg0[i] *= D_80382350.unk30; - arg1[i] *= D_80382350.unk30; + arg0[i] *= levelModel.unk30; + arg1[i] *= levelModel.unk30; } - if (D_80382350.unk1C != NULL) { - func_802EC458(func_8033A148(D_80382350.unk1C), sp3C, sp30); + if (levelModel.model_bin_xlu != NULL) { + func_802EC458(func_8033A148(levelModel.model_bin_xlu), sp3C, sp30); for(j = 0; j < 3; j++){ if(sp3C[j] < arg0[j]){ arg0[j] = sp3C[j]; @@ -458,27 +456,27 @@ BKCollisionTri *func_80309B48(f32 arg0[3], f32 arg1[3], f32 arg2[3], s32 arg3) { BKCollisionTri *sp2C; BKCollisionTri *temp_v0; - D_80382350.unk20 = 0; - if (D_80382350.unkC != NULL) { + levelModel.unk20 = 0; + if (levelModel.collision_xlu != NULL) { if ((arg3 & 0x80001F00) == 0x80001F00) { sp2C = NULL; } else { - sp2C = func_802E76B0(D_80382350.unk8, func_8033A148(D_80382350.unk18), arg0, arg1, arg2, arg3); + sp2C = func_802E76B0(levelModel.collision_opa, func_8033A148(levelModel.model_bin_opa), arg0, arg1, arg2, arg3); } - temp_v0 = func_802E76B0(D_80382350.unkC, func_8033A148(D_80382350.unk1C), arg0, arg1, arg2, arg3); + temp_v0 = func_802E76B0(levelModel.collision_xlu, func_8033A148(levelModel.model_bin_xlu), arg0, arg1, arg2, arg3); if (temp_v0 != NULL) { - D_80382350.unk20 = (s32) D_80382350.unk1C; + levelModel.unk20 = (s32) levelModel.model_bin_xlu; return temp_v0; } if (sp2C != NULL) { - D_80382350.unk20 = (s32) D_80382350.unk18; + levelModel.unk20 = (s32) levelModel.model_bin_opa; } return sp2C; } else{ - sp2C = func_802E76B0(D_80382350.unk8, func_8033A148(D_80382350.unk18), arg0, arg1, arg2, arg3); + sp2C = func_802E76B0(levelModel.collision_opa, func_8033A148(levelModel.model_bin_opa), arg0, arg1, arg2, arg3); if (sp2C != NULL) { - D_80382350.unk20 = (s32) D_80382350.unk18; + levelModel.unk20 = (s32) levelModel.model_bin_opa; } } return sp2C; @@ -488,17 +486,17 @@ BKCollisionTri *func_80309C74(f32 arg0[3], f32 arg1[3], f32 arg2[3], s32 arg3, B BKCollisionTri *sp2C; BKCollisionTri *phi_v0; - sp2C = func_802E76B0(D_80382350.unk8, func_8033A148(D_80382350.unk18), arg0, arg1, arg2, arg3); + sp2C = func_802E76B0(levelModel.collision_opa, func_8033A148(levelModel.model_bin_opa), arg0, arg1, arg2, arg3); if (sp2C != NULL) { - *arg4 = D_80382350.unk18; + *arg4 = levelModel.model_bin_opa; } - if (D_80382350.unkC == NULL) { + if (levelModel.collision_xlu == NULL) { return sp2C; } - phi_v0 = func_802E76B0(D_80382350.unkC, func_8033A148(D_80382350.unk1C), arg0, arg1, arg2, arg3); + phi_v0 = func_802E76B0(levelModel.collision_xlu, func_8033A148(levelModel.model_bin_xlu), arg0, arg1, arg2, arg3); if (phi_v0 != 0) { - *arg4 = D_80382350.unk1C; + *arg4 = levelModel.model_bin_xlu; } return (phi_v0 != NULL) ? phi_v0 : sp2C; } @@ -506,7 +504,7 @@ BKCollisionTri *func_80309C74(f32 arg0[3], f32 arg1[3], f32 arg2[3], s32 arg3, B UNK_TYPE(s32) func_80309D58(UNK_TYPE(s32) arg0, UNK_TYPE(s32) arg1) { BKMeshList *temp_v0; - temp_v0 = func_8033A12C(D_80382350.unk18); + temp_v0 = func_8033A12C(levelModel.model_bin_opa); if (temp_v0 != NULL) { return func_802EC394(temp_v0, 0, 0, 1.0f, 0, arg0, arg1); } @@ -517,17 +515,17 @@ UNK_TYPE(s32) func_80309DBC(f32 arg0[3], f32 arg1[3], f32 arg2, f32 arg3[3], s32 s32 sp34; s32 temp_v0_2; - D_80382350.unk20 = 0; - sp34 = func_802E8E88(D_80382350.unk8, func_8033A148(D_80382350.unk18), arg0, arg1, arg2, arg3, arg4, arg5); + levelModel.unk20 = 0; + sp34 = func_802E8E88(levelModel.collision_opa, func_8033A148(levelModel.model_bin_opa), arg0, arg1, arg2, arg3, arg4, arg5); if (sp34 != 0) { - D_80382350.unk20 = (s32) D_80382350.unk18; + levelModel.unk20 = (s32) levelModel.model_bin_opa; } - if (D_80382350.unkC == 0) { + if (levelModel.collision_xlu == 0) { return sp34; } - temp_v0_2 = func_802E8E88(D_80382350.unkC, func_8033A148(D_80382350.unk1C), arg0, arg1, arg2, arg3, arg4, arg5); + temp_v0_2 = func_802E8E88(levelModel.collision_xlu, func_8033A148(levelModel.model_bin_xlu), arg0, arg1, arg2, arg3, arg4, arg5); if (temp_v0_2 != 0) { - D_80382350.unk20 = (s32) D_80382350.unk1C; + levelModel.unk20 = (s32) levelModel.model_bin_xlu; return temp_v0_2; } return sp34; @@ -537,16 +535,16 @@ UNK_TYPE(s32) func_80309EB0(f32 arg0[3], f32 arg1, f32 arg2[3], s32 arg3) { s32 sp24; s32 temp_v0_2; - sp24 = func_802E92AC(D_80382350.unk8, func_8033A148(D_80382350.unk18), arg0, arg1, arg2, arg3); - if (D_80382350.unkC == 0) { + sp24 = func_802E92AC(levelModel.collision_opa, func_8033A148(levelModel.model_bin_opa), arg0, arg1, arg2, arg3); + if (levelModel.collision_xlu == 0) { return sp24; } - temp_v0_2 = func_802E92AC(D_80382350.unkC, func_8033A148(D_80382350.unk1C), arg0, arg1, arg2, arg3); + temp_v0_2 = func_802E92AC(levelModel.collision_xlu, func_8033A148(levelModel.model_bin_xlu), arg0, arg1, arg2, arg3); return (temp_v0_2 != 0) ? temp_v0_2 : sp24; } bool func_80309F78(void) { - return (D_80382350.unk18 != NULL) && (D_80382350.unk1C != NULL); + return (levelModel.model_bin_opa != NULL) && (levelModel.model_bin_xlu != NULL); } bool func_80309FA4(enum map_e map_id){ @@ -560,97 +558,97 @@ bool func_80309FA4(enum map_e map_id){ return FALSE; } -void func_80309FF0(void){ - assetcache_release(D_80382350.unk18); +void levelModel_free(void){ + assetcache_release(levelModel.model_bin_opa); - if(D_80382350.unk1C) - assetcache_release(D_80382350.unk1C); + if(levelModel.model_bin_xlu) + assetcache_release(levelModel.model_bin_xlu); - if(D_80382350.unk10) - model_free(D_80382350.unk10); + if(levelModel.model_opa) + model_free(levelModel.model_opa); - if(D_80382350.unk14) - model_free(D_80382350.unk14); + if(levelModel.model_xlu) + model_free(levelModel.model_xlu); - func_8034A2A8(D_80382350.unk24); + func_8034A2A8(levelModel.unk24); } enum asset_e func_8030A068(void){ - return D_80382350.unk28->model1_id; + return levelModel.unk28->model1_id; } void func_8030A078(void) { BKMeshList *sp24; Struct_core2_82000_0 *temp_v0; - D_80382350.unk2E = 0xFF; - D_80382350.unk2D = 0xFF; - D_80382350.unk2C = 0xFF; + levelModel.env_blue = 0xFF; + levelModel.env_green = 0xFF; + levelModel.env_red = 0xFF; temp_v0 = func_80308F90(map_get());; - D_80382350.unk28 = temp_v0; - D_80382350.unk30 = (f32) temp_v0->unk14; - D_80382350.unk18 = (BKModelBin *)assetcache_get(D_80382350.unk28->model1_id); - D_80382350.unk8 = func_8033A084(D_80382350.unk18); - D_80382350.unk20 = 0; - if (D_80382350.unk28->model2_id != 0) { - D_80382350.unk1C = (BKModelBin *)assetcache_get(D_80382350.unk28->model2_id); - D_80382350.unkC = func_8033A084(D_80382350.unk1C); + levelModel.unk28 = temp_v0; + levelModel.unk30 = (f32) temp_v0->unk14; + levelModel.model_bin_opa = (BKModelBin *)assetcache_get(levelModel.unk28->model1_id); + levelModel.collision_opa = func_8033A084(levelModel.model_bin_opa); + levelModel.unk20 = 0; + if (levelModel.unk28->model2_id != 0) { + levelModel.model_bin_xlu = (BKModelBin *)assetcache_get(levelModel.unk28->model2_id); + levelModel.collision_xlu = func_8033A084(levelModel.model_bin_xlu); } else { - D_80382350.unk1C = NULL; - D_80382350.unkC = NULL; + levelModel.model_bin_xlu = NULL; + levelModel.collision_xlu = NULL; } - sp24 = func_8033A0B0(D_80382350.unk18); + sp24 = func_8033A0B0(levelModel.model_bin_opa); if (sp24 != NULL) { - D_80382350.unk10 = func_8033F5F8(sp24, func_8033A148(D_80382350.unk18)); + levelModel.model_opa = func_8033F5F8(sp24, func_8033A148(levelModel.model_bin_opa)); } else { - D_80382350.unk10 = NULL; + levelModel.model_opa = NULL; } - if (D_80382350.unk10 != NULL) { - func_8034C6DC(D_80382350.unk10); + if (levelModel.model_opa != NULL) { + func_8034C6DC(levelModel.model_opa); } - if (D_80382350.unk1C != NULL) { - sp24 = func_8033A0B0(D_80382350.unk1C); + if (levelModel.model_bin_xlu != NULL) { + sp24 = func_8033A0B0(levelModel.model_bin_xlu); } else{ sp24 = NULL; } if (sp24 != NULL) { - D_80382350.unk14 = func_8033F5F8(sp24, func_8033A148(D_80382350.unk1C)); + levelModel.model_xlu = func_8033F5F8(sp24, func_8033A148(levelModel.model_bin_xlu)); } else { - D_80382350.unk14 = 0; + levelModel.model_xlu = 0; } - if (D_80382350.unk14 != NULL) { - func_8034C6DC(D_80382350.unk14); + if (levelModel.model_xlu != NULL) { + func_8034C6DC(levelModel.model_xlu); } - D_80382350.unk24 = func_8034A2C8(); + levelModel.unk24 = func_8034A2C8(); func_80320B44(func_80309B48, func_80309DBC, func_80309EB0, func_80309794); - if (( D_80382350.unk18 != NULL) && (func_8033A110( D_80382350.unk18) != NULL)) { - D_80382350.unk0 = func_80349C3C(); - func_80349D00(D_80382350.unk0, func_8033A110(D_80382350.unk18)); + if (( levelModel.model_bin_opa != NULL) && (func_8033A110( levelModel.model_bin_opa) != NULL)) { + levelModel.unk0 = func_80349C3C(); + func_80349D00(levelModel.unk0, func_8033A110(levelModel.model_bin_opa)); } else { - D_80382350.unk0 = NULL; + levelModel.unk0 = NULL; } - if ((D_80382350.unk1C != NULL) && (func_8033A110(D_80382350.unk1C) != 0)) { - D_80382350.unk4 = func_80349C3C(); - func_80349D00(D_80382350.unk4, func_8033A110(D_80382350.unk1C)); + if ((levelModel.model_bin_xlu != NULL) && (func_8033A110(levelModel.model_bin_xlu) != 0)) { + levelModel.unk4 = func_80349C3C(); + func_80349D00(levelModel.unk4, func_8033A110(levelModel.model_bin_xlu)); } else{ - D_80382350.unk4 = NULL; + levelModel.unk4 = NULL; } } -void func_8030A280(s32 r, s32 g, s32 b){ - D_80382350.unk2C = r; - D_80382350.unk2D = g; - D_80382350.unk2E = b; +void levelModel_setEnvColor(s32 r, s32 g, s32 b){ + levelModel.env_red = r; + levelModel.env_green = g; + levelModel.env_blue = b; } void func_8030A298(void){ - if(D_80382350.unk24 != NULL){ - D_80382350.unk24 = func_8034A348(D_80382350.unk24); + if(levelModel.unk24 != NULL){ + levelModel.unk24 = func_8034A348(levelModel.unk24); } } diff --git a/src/core2/code_94780.c b/src/core2/code_94780.c index fc219345..cc59180a 100644 --- a/src/core2/code_94780.c +++ b/src/core2/code_94780.c @@ -24,7 +24,7 @@ void func_8031B718(void){ } void func_8031B760(void){ - func_8030A280(D_80383170.rgb[0], D_80383170.rgb[1], D_80383170.rgb[2]); + levelModel_setEnvColor(D_80383170.rgb[0], D_80383170.rgb[1], D_80383170.rgb[2]); } void func_8031B790(void) { diff --git a/src/core2/code_9E370.c b/src/core2/code_9E370.c index ffc7f7fe..4f76b151 100644 --- a/src/core2/code_9E370.c +++ b/src/core2/code_9E370.c @@ -13,10 +13,9 @@ extern void func_802EE6CC(f32[3], s32[4], s32[4], s32, f32, f32, s32, s32, s32); extern void func_8033A244(f32); -extern void func_8033A410(s32); f32 func_80257204(f32, f32, f32, f32); -extern Actor *func_802C4260(enum actor_id, s32 x, s32 y, s32 z, s32 yaw); +extern Actor *func_802C4260(enum actor_e actor_id, s32 x, s32 y, s32 z, s32 yaw); f32 func_8033229C(ActorMarker *); f32 func_8028EBA4(void); extern void func_8032FFF4(ActorMarker *, ActorMarker *, s32); @@ -87,7 +86,7 @@ Actor *func_80325340(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ } void func_803253A0(Actor *this){ - s32 pad; + s32 pad4C; BKModelBin *sp48; bool sp44; BKVertexList *sp40; @@ -116,11 +115,11 @@ void func_803253A0(Actor *this){ }//L8032548C if(this->alpha_124_19 < 0xFF){ - func_8033A410(this->alpha_124_19); + modelRender_setAlpha(this->alpha_124_19); } modelRender_setDepthMode(this->depth_mode); - if(this->marker->unk44 != 0){ + if((s32)this->marker->unk44 != 0){ if((s32)this->marker->unk44 == 1){ func_8033A450(D_8036E568); } @@ -219,8 +218,8 @@ Actor *func_80325888(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx) { Actor *this; this = func_80325300(marker, sp3C); - func_8033A2D4(func_803253A0, this); - func_8033A2E8(func_80325794, marker); + modelRender_preDraw((GenMethod_1)func_803253A0, (s32)this); + modelRender_postDraw((GenMethod_1)func_80325794, (s32)marker); modelRender_draw(gfx, mtx, this->position, sp3C, this->scale, (this->unk104 != NULL) ? D_8036E580 : NULL, func_803257B4(marker)); return this; } @@ -341,8 +340,8 @@ Actor *func_80325E78(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx) { this = func_80325300(marker, rotation); modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); - func_8033A2D4(func_803253A0, this); - func_8033A2E8(func_80325794, marker); + modelRender_preDraw((GenMethod_1)func_803253A0, (s32)this); + modelRender_postDraw((GenMethod_1)func_80325794, (s32)marker); modelRender_draw(gfx, mtx, this->position, rotation, this->scale, (this->unk104 != NULL) ? D_8036E580 : NULL, func_803257B4(marker)); return this; } diff --git a/src/core2/code_AA60.c b/src/core2/code_AA60.c index 9eae2972..7cf5aa30 100644 --- a/src/core2/code_AA60.c +++ b/src/core2/code_AA60.c @@ -102,9 +102,9 @@ void func_80291AF0(Gfx **gfx, Mtx **mtx, Vtx **vtx){ if(D_8037C0E0){ func_80289F30(); func_8029DD6C(); - func_8033A388(sp50[0], sp50[1], sp50[2], D_8037C0E6); + modelRender_setEnvColor(sp50[0], sp50[1], sp50[2], D_8037C0E6); func_8033A280(2.0f); - func_8033A2D4(func_80291AC4, 0); + modelRender_preDraw(func_80291AC4, 0); func_8033A450(D_80363780); modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); if(D_8037C150.unk0){ diff --git a/src/core2/code_AD5B0.c b/src/core2/code_AD5B0.c index d065b6ef..35448214 100644 --- a/src/core2/code_AD5B0.c +++ b/src/core2/code_AD5B0.c @@ -42,7 +42,7 @@ void func_80334540(Gfx** gdl, Mtx **mptr, Vtx **vptr) { func_8024CE60(sp44, sp40); func_8024C904(gdl, mptr); if (func_80309F78() != 0) { - func_803091D4(gdl, mptr, vptr); + levelModel_opa_draw(gdl, mptr, vptr); if (func_802E49F0() == 0) { func_80322E64(gdl, mptr, vptr); } @@ -65,7 +65,7 @@ void func_80334540(Gfx** gdl, Mtx **mptr, Vtx **vptr) { func_802F0A34(gdl, mptr, vptr); } if (func_802E49F0() == 0) { - func_80309628(gdl, mptr, vptr); + levelModel_xlu_draw(gdl, mptr, vptr); } if (func_802E49F0() == 0) { func_8032D3D8(gdl, mptr, vptr); @@ -78,7 +78,7 @@ void func_80334540(Gfx** gdl, Mtx **mptr, Vtx **vptr) { } func_802D520C(gdl, mptr, vptr); } else { - func_803091D4(gdl, mptr, vptr); + levelModel_opa_draw(gdl, mptr, vptr); func_80322E64(gdl, mptr, vptr); func_8034F6F0(gdl, mptr, vptr); func_8028E6A4(gdl, mptr, vptr); @@ -154,7 +154,7 @@ void func_80334910(void) { func_80323100(); cubeList_free(); func_8031B710(); - func_80309FF0(); + levelModel_free(); func_8030A6B0(); func_80333918(); sky_free(); diff --git a/src/core2/code_C97F0.c b/src/core2/code_C97F0.c index 8f77b675..ebf483fe 100644 --- a/src/core2/code_C97F0.c +++ b/src/core2/code_C97F0.c @@ -162,7 +162,7 @@ void func_80350818(Gfx **gfx, Mtx **mtx, Vtx **vtx) { sp80[2] = temp_s2->unk4[i].unk4[2]; sp80[3] = temp_s2->unk4[i].unk4[3]; sp80[3] *= var_f22; - func_8033A334(sp80, D_803725A8); + modelRender_setPrimAndEnvColors(sp80, D_803725A8); modelRender_draw(gfx, mtx, spB8, spD0, temp_s2->unk4[i].unk14*0.25, NULL, D_80386170.unk8); } } diff --git a/src/core2/code_D7D10.c b/src/core2/code_D7D10.c index cd59a568..c2fdf0e6 100644 --- a/src/core2/code_D7D10.c +++ b/src/core2/code_D7D10.c @@ -48,8 +48,8 @@ Actor *func_8035ECA0(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx) { local = (ActorLocal_core2_D7D10 *)&this->local; func_8033A45C(3, (s32) this->velocity[1]); func_8033A45C(4, local->unk0); - func_8033A2D4(func_803253A0, this); - func_8033A2E8(func_80325794, marker); + modelRender_preDraw( (GenMethod_1)func_803253A0, (s32)this); + modelRender_postDraw((GenMethod_1)func_80325794, (s32)marker); modelRender_draw(gfx, mtx, this->position, rotation, this->scale, D_80373008, func_803257B4(marker)); return this; } diff --git a/src/core2/gc/pauseMenu.c b/src/core2/gc/pauseMenu.c index 436c5ba1..8350d5ff 100644 --- a/src/core2/gc/pauseMenu.c +++ b/src/core2/gc/pauseMenu.c @@ -1358,7 +1358,7 @@ void gcpausemenu_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { } func_8033A45C(i, 1); modelRender_setDepthMode(MODEL_RENDER_DEPTH_NONE); - func_8033A410(D_80383010.sns_alpha); + modelRender_setAlpha(D_80383010.sns_alpha); modelRender_draw(gfx, mtx, &sp98, &sp8C, 0.8f, &sp80, D_80383010.sns_egg_model); func_8024E2FC(); func_8024C904(gfx, mtx); @@ -1399,7 +1399,7 @@ void gcpausemenu_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { sp80[1] = 120.0f; sp80[2] = 0.0f; modelRender_setDepthMode(MODEL_RENDER_DEPTH_NONE); - func_8033A410(D_80383010.sns_alpha); + modelRender_setAlpha(D_80383010.sns_alpha); modelRender_draw(gfx, mtx, sp98, sp8C, 0.8f, sp80, D_80383010.ice_key_model); func_8024E2FC(); func_8024C904(gfx, mtx); diff --git a/src/core2/gc/zoombox.c b/src/core2/gc/zoombox.c index 47bed1b8..c3e40eff 100644 --- a/src/core2/gc/zoombox.c +++ b/src/core2/gc/zoombox.c @@ -467,9 +467,9 @@ void func_803152C4(gczoombox_t *this){ } void func_80315300(gczoombox_t *this){ - if(this->unkF0 != NULL){ - func_8033BD20(&this->unkF0); - this->unkF0 = NULL; + if(this->model != NULL){ + func_8033BD20(&this->model); + this->model = NULL; } if(this->anim_ctrl != NULL){ animctrl_free(this->anim_ctrl); @@ -845,7 +845,7 @@ void func_803163A8(gczoombox_t *this, Gfx **gfx, Mtx **mtx) { if (this->anim_ctrl != NULL) { func_8028781C(this->anim_ctrl, sp50, 1); } - modelRender_draw(gfx, mtx, sp50, sp5C, this->unk198 * sp34, &sp38, this->unkF0); + modelRender_draw(gfx, mtx, sp50, sp5C, this->unk198 * sp34, &sp38, this->model); } void func_803164B0(gczoombox_t *this, Gfx **gfx, Mtx **mtx, s32 arg3, s32 arg4, s32 arg5, f32 arg6) { @@ -993,7 +993,7 @@ void gczoombox_draw(gczoombox_t *this, Gfx **gdl, Mtx ** mptr, void *vptr){ if(getGameMode() == GAME_MODE_9_BANJO_AND_KAZOOIE) func_8034A900(); //L80316BCC - if(this->unk1A4_28 && this->state && this->unkF0){ + if(this->unk1A4_28 && this->state && this->model){ func_803162B4(this); func_803163A8(this, gdl, mptr); if( this->unk139 == 2 @@ -1453,7 +1453,7 @@ gczoombox_t *gczoombox_new(s32 arg0, enum talk_pic_e portrait_id, s32 arg2, s32 this->unk1A4_11 = this->unk1A4_18 = 1; - this->unkF0 = assetcache_get(0x89d); + this->model = assetcache_get(0x89d); func_80317C90(this, portrait_id); this->anim_ctrl = animctrl_new(0); animctrl_reset(this->anim_ctrl); diff --git a/src/core2/modelRender.c b/src/core2/modelRender.c index 358ce439..881c4c3c 100644 --- a/src/core2/modelRender.c +++ b/src/core2/modelRender.c @@ -22,25 +22,12 @@ extern void mlMtxApply(Mtx* mtx); extern struct58s *func_802EA154(); extern struct58s *func_802EA374(struct58s *); -typedef struct{ - s32 env[4]; - s32 prim[4]; -} Struct_Core2_B1400_0; typedef struct{ void (* unk0)(Actor *); Actor *unk4; } Struct_Core2_B1400_1; - -typedef struct{ - f32 unk0[3]; - f32 unkC[3]; - s32 unk18; - f32 unk1C[3]; - f32 unk28[3]; -} Struct_Core2_B1400_2; - typedef void (*GeoListFunc)(Gfx **, Mtx **, void *); typedef struct { @@ -150,7 +137,8 @@ typedef struct { s32 unk8; }GeoCmd10; -void modelRender_reset(void); + + void func_803384A8(Gfx **, Mtx **, void *); void func_803385BC(Gfx **, Mtx **, void *); void func_803387F8(Gfx **, Mtx **, void *); @@ -168,7 +156,6 @@ void func_80338DCC(Gfx **, Mtx **, void *); void func_80338EB8(Gfx **, Mtx **, void *); void func_8033909C(Gfx **, Mtx **, void *); void func_80339124(Gfx **, Mtx **, BKGeoList *); -void func_8033A410(s32 a); void func_8033A45C(s32 arg0, s32 arg1); // Sets up 2 cycle mode @@ -605,44 +592,69 @@ GeoListFunc D_80370994[] = { func_8033878C }; +enum model_render_color_mode_e{ + COLOR_MODE_DYNAMIC_PRIM_AND_ENV, + COLOR_MODE_DYNAMIC_ENV, + COLOR_MODE_STATIC_OPAQUE, + COLOR_MODE_STATIC_TRANSPARENT +}; + /* .bss */ -s32 D_80383650; -s32 D_80383658[0x2A]; -s32 D_80383700; +s32 D_80383650; +s32 D_80383658[0x2A]; +s32 D_80383700; bool D_80383704; -f32 D_80383708; -f32 D_8038370C; -s32 D_80383710; -s32 D_80383714; -BKGfxList *modelRenderDisplayList; -struct58s *D_8038371C; -static BKTextureList *modelRenderTextureList; -s32 D_80383724; -static BKVertexList *modelRenderVextureList; -BKModelUnk20List *D_8038372C; -struct58s *D_80383730; -f32 D_80383734; -Struct_Core2_B1400_0 D_80383738; -Struct_Core2_B1400_2 D_80383758; +f32 D_80383708; +f32 D_8038370C; +s32 D_80383710; +enum model_render_color_mode_e modelRenderColorMode; +BKGfxList * modelRenderDisplayList; +struct58s * D_8038371C; +static BKTextureList * modelRenderTextureList; +s32 D_80383724; +static BKVertexList * modelRenderVextureList; +BKModelUnk20List * D_8038372C; +struct58s * D_80383730; +f32 D_80383734; + struct{ - void (* unk0)(Actor *); - Actor *unk4; - void (* unk8)(ActorMarker *); - ActorMarker *unkC; -} D_80383790; -s32 D_803837A0[4]; + s32 env[4]; + s32 prim[4]; +} modelRenderDynColors; + +struct{ + f32 unk0[3]; + f32 unkC[3]; + s32 unk18; + f32 unk1C[3]; + f32 unk28[3]; +} D_80383758; + +struct{ + GenMethod_1 pre_method; + s32 pre_arg; + GenMethod_1 post_method; + s32 post_arg; +} modelRenderCallback; + +s32 modelRenderDynEnvColor[4]; + struct { s32 unk0; f32 unk4[3]; }D_803837B0; -u8 D_803837C0; + +u8 modelRenderDynAlpha; + struct { s32 model_id; //model_asset_index f32 unk4; f32 unk8; u8 padC[0x4]; } D_803837C8; -static s32 modelRenderDepthMode; + +static enum model_render_depth_mode_e modelRenderDepthMode; + struct { LookAt lookat_buffer[32]; LookAt *cur_lookat; @@ -650,8 +662,8 @@ struct { f32 eye_pos[3]; } D_803837E0; Mtx D_80383BF8; -f32 D_80383C38[3]; -f32 D_80383C48[3]; +f32 modelRenderCameraPosition[3]; +f32 modelRenderCameraRotation[3]; BKModelBin *modelRenderModelBin; f32 D_80383C58[3]; f32 D_80383C64; @@ -667,7 +679,7 @@ void modelRender_reset(void){ D_80383704 = TRUE; D_8038370C = 1.0f; D_80383710 = FALSE; - D_80383714 = 2; + modelRenderColorMode = COLOR_MODE_STATIC_OPAQUE; D_80383650 = 0; modelRenderDisplayList = NULL; D_8038371C = NULL; @@ -675,11 +687,11 @@ void modelRender_reset(void){ D_80383724 = 0; modelRenderVextureList = NULL; D_8038372C = 0; - D_80383790.unk0 = NULL; - D_80383790.unk8 = NULL; + modelRenderCallback.pre_method = NULL; + modelRenderCallback.post_method = NULL; D_803837B0.unk0 = 0; D_803837C8.model_id = 0; - modelRenderDepthMode = 0; + modelRenderDepthMode = MODEL_RENDER_DEPTH_NONE; func_8033A45C(1,1); func_8033A45C(2,0); if(D_80383758.unk18){ @@ -702,9 +714,9 @@ void func_803384A8(Gfx **gfx, Mtx **mtx, void *arg2){ if(cmd->unk8){ func_8025235C(sp30, cmd->unkC); func_80251788(sp30[0], sp30[1], sp30[2]); - mlMtxRotYaw(D_80383C48[1]); + mlMtxRotYaw(modelRenderCameraRotation[1]); if(!cmd->unkA){ - mlMtxRotPitch(D_80383C48[0]); + mlMtxRotPitch(modelRenderCameraRotation[0]); } mlMtxScale(D_80383734); mlMtxTranslate(-cmd->unkC[0], -cmd->unkC[1], -cmd->unkC[2]); @@ -869,9 +881,9 @@ void func_80338BFC(Gfx **gfx, Mtx **mtx, void *arg2){ else{ func_8025235C(sp20, cmd->unkC); } - sp20[0] += D_80383C38[0]; - sp20[1] += D_80383C38[1]; - sp20[2] += D_80383C38[2]; + sp20[0] += modelRenderCameraPosition[0]; + sp20[1] += modelRenderCameraPosition[1]; + sp20[2] += modelRenderCameraPosition[2]; func_8034A308(D_80383650, cmd->unk8, sp20); } } @@ -963,9 +975,9 @@ void func_80338EB8(Gfx ** gfx, Mtx ** mtx, void *arg2){ func_8025235C(sp34, sp34); } - sp34[0] += D_80383C38[0]; - sp34[1] += D_80383C38[1]; - sp34[2] += D_80383C38[2]; + sp34[0] += modelRenderCameraPosition[0]; + sp34[1] += modelRenderCameraPosition[1]; + sp34[2] += modelRenderCameraPosition[2]; if(func_8024DB50(sp34, sp30) && cmd->unk10){ func_80339124(gfx, mtx, (BKGeoList*)((s32)cmd + cmd->unk10)); } @@ -999,9 +1011,9 @@ void func_80339124(Gfx ** gfx, Mtx ** mtx, BKGeoList *geo_list){ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 arg3[3], f32 scale, f32*arg5, BKModelBin* model_bin){ f32 camera_focus[3]; - f32 spF0; + f32 camera_focus_distance; f32 padEC; - f32 camera_position[3]; + f32 object_position[3]; void *rendermode_table_opa; // Table of render modes to use for opaque rendering void *rendermode_table_xlu; // Table of render modes to use for translucent rendering f32 spD4; @@ -1019,30 +1031,30 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 arg3[3], } D_80370990 = 0; - func_8024C5CC(D_80383C38); - func_8024C764(D_80383C48); + func_8024C5CC(modelRenderCameraPosition); + func_8024C764(modelRenderCameraRotation); if(D_80383758.unk18){ - D_80383758.unk1C[0] = D_80383C38[0]; - D_80383758.unk1C[1] = D_80383C38[1]; - D_80383758.unk1C[2] = D_80383C38[2]; + D_80383758.unk1C[0] = modelRenderCameraPosition[0]; + D_80383758.unk1C[1] = modelRenderCameraPosition[1]; + D_80383758.unk1C[2] = modelRenderCameraPosition[2]; - D_80383758.unk28[0] = D_80383C48[0];\ - D_80383758.unk28[1] = D_80383C48[1];\ - D_80383758.unk28[2] = D_80383C48[2]; + D_80383758.unk28[0] = modelRenderCameraRotation[0];\ + D_80383758.unk28[1] = modelRenderCameraRotation[1];\ + D_80383758.unk28[2] = modelRenderCameraRotation[2]; } if(position){ - camera_position[0] = position[0]; - camera_position[1] = position[1]; - camera_position[2] = position[2]; + object_position[0] = position[0]; + object_position[1] = position[1]; + object_position[2] = position[2]; } else{ - camera_position[0] = camera_position[1] = camera_position[2] = 0.0f; + object_position[0] = object_position[1] = object_position[2] = 0.0f; } - camera_focus[0] = camera_position[0] - D_80383C38[0]; - camera_focus[1] = camera_position[1] - D_80383C38[1]; - camera_focus[2] = camera_position[2] - D_80383C38[2]; + camera_focus[0] = object_position[0] - modelRenderCameraPosition[0]; + camera_focus[1] = object_position[1] - modelRenderCameraPosition[1]; + camera_focus[2] = object_position[2] - modelRenderCameraPosition[2]; if( ((camera_focus[0] < -17000.0f) || (17000.0f < camera_focus[0])) || ((camera_focus[1] < -17000.0f) || (17000.0f < camera_focus[1])) @@ -1053,19 +1065,19 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 arg3[3], } if(D_80383758.unk18){ - D_80383C38[0] = D_80383758.unk0[0]; - D_80383C38[1] = D_80383758.unk0[1]; - D_80383C38[2] = D_80383758.unk0[2]; + modelRenderCameraPosition[0] = D_80383758.unk0[0]; + modelRenderCameraPosition[1] = D_80383758.unk0[1]; + modelRenderCameraPosition[2] = D_80383758.unk0[2]; - D_80383C48[0] = D_80383758.unkC[0], - D_80383C48[1] = D_80383758.unkC[1], - D_80383C48[2] = D_80383758.unkC[2]; - func_8024CD88(D_80383C38); - func_8024CE18(D_80383C48); + modelRenderCameraRotation[0] = D_80383758.unkC[0], + modelRenderCameraRotation[1] = D_80383758.unkC[1], + modelRenderCameraRotation[2] = D_80383758.unkC[2]; + func_8024CD88(modelRenderCameraPosition); + func_8024CE18(modelRenderCameraRotation); func_8024CFD4(); - camera_focus[0] = camera_position[0] - D_80383C38[0]; - camera_focus[1] = camera_position[1] - D_80383C38[1]; - camera_focus[2] = camera_position[2] - D_80383C38[2]; + camera_focus[0] = object_position[0] - modelRenderCameraPosition[0]; + camera_focus[1] = object_position[1] - modelRenderCameraPosition[1]; + camera_focus[2] = object_position[2] - modelRenderCameraPosition[2]; } if(model_bin){ @@ -1077,24 +1089,24 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 arg3[3], spD0 = D_803837C8.unk8; spD4 = D_803837C8.unk4; } - spF0 = gu_sqrtf(camera_focus[0]*camera_focus[0] + camera_focus[1]*camera_focus[1] + camera_focus[2]*camera_focus[2]); - if( 4000.0f <= spF0 && spD4*scale*D_8038370C*50.0f < D_80383708){ + camera_focus_distance = gu_sqrtf(camera_focus[0]*camera_focus[0] + camera_focus[1]*camera_focus[1] + camera_focus[2]*camera_focus[2]); + if( 4000.0f <= camera_focus_distance && spD4*scale*D_8038370C*50.0f < D_80383708){ D_80383708 = spD4*scale*D_8038370C*50.0f; } - if(D_80383708 <= spF0){ + if(D_80383708 <= camera_focus_distance){ modelRender_reset(); return 0; } - D_80370990 = (D_80383704) ? func_8024DB50(camera_position, spD0*scale) : 1; + D_80370990 = (D_80383704) ? func_8024DB50(object_position, spD0*scale) : 1; if(D_80370990 == 0){ modelRender_reset(); return 0; } - if(D_80383790.unk0){ - D_80383790.unk0(D_80383790.unk4); + if(modelRenderCallback.pre_method != NULL){ + modelRenderCallback.pre_method(modelRenderCallback.pre_arg); } func_80349AD0(); if(model_bin == NULL){ @@ -1108,19 +1120,19 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 arg3[3], if(D_80383710){ tmp_f0 = D_80383708 - 500.0f; - if(tmp_f0 < spF0){ - alpha = (s32)((1.0f - (spF0 - tmp_f0)/500.0f)*255.0f); - if(D_80383714 == 0){ - D_80383738.prim[3] = (D_80383738.prim[3] * alpha) / 0xff; + if(tmp_f0 < camera_focus_distance){ + alpha = (s32)((1.0f - (camera_focus_distance - tmp_f0)/500.0f)*255.0f); + if(modelRenderColorMode == COLOR_MODE_DYNAMIC_PRIM_AND_ENV){ + modelRenderDynColors.prim[3] = (modelRenderDynColors.prim[3] * alpha) / 0xff; } - else if(D_80383714 == 1){ - D_803837A0[3] = (D_803837A0[3] * alpha)/0xff; + else if(modelRenderColorMode == COLOR_MODE_DYNAMIC_ENV){ + modelRenderDynEnvColor[3] = (modelRenderDynEnvColor[3] * alpha)/0xff; } - else if(D_80383714 == 2){ - func_8033A410(alpha); + else if(modelRenderColorMode == COLOR_MODE_STATIC_OPAQUE){ + modelRender_setAlpha(alpha); } - else if(D_80383714 == 3){ - D_803837C0 = (D_803837C0 *alpha)/0xff; + else if(modelRenderColorMode == COLOR_MODE_STATIC_TRANSPARENT){ + modelRenderDynAlpha = (modelRenderDynAlpha *alpha)/0xff; } } } @@ -1160,13 +1172,13 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 arg3[3], rendermode_table_xlu = renderModesDepthCompareXlu; } - if(D_80383714 == 0){ + if(modelRenderColorMode == COLOR_MODE_DYNAMIC_PRIM_AND_ENV){ s32 alpha; - alpha = D_80383738.prim[3] + (D_80383738.env[3]*(0xFF - D_80383738.prim[3]))/0xff; + alpha = modelRenderDynColors.prim[3] + (modelRenderDynColors.env[3]*(0xFF - modelRenderDynColors.prim[3]))/0xff; gSPDisplayList((*gfx)++, setup2CycleDL); - gDPSetEnvColor((*gfx)++, D_80383738.env[0], D_80383738.env[1], D_80383738.env[2], alpha); - gDPSetPrimColor((*gfx)++, 0, 0, D_80383738.prim[0], D_80383738.prim[1], D_80383738.prim[2], 0); + gDPSetEnvColor((*gfx)++, modelRenderDynColors.env[0], modelRenderDynColors.env[1], modelRenderDynColors.env[2], alpha); + gDPSetPrimColor((*gfx)++, 0, 0, modelRenderDynColors.prim[0], modelRenderDynColors.prim[1], modelRenderDynColors.prim[2], 0); // Set up segment 3 to point to the right render mode table based on the alpha value if(alpha == 0xFF){ @@ -1177,25 +1189,25 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 arg3[3], } //TODO } - else if(D_80383714 == 1){ + else if(modelRenderColorMode == COLOR_MODE_DYNAMIC_ENV){ gSPDisplayList((*gfx)++, setup2CycleBlackPrimDL); - gDPSetEnvColor((*gfx)++, D_803837A0[0], D_803837A0[1], D_803837A0[2], D_803837A0[3]); + gDPSetEnvColor((*gfx)++, modelRenderDynEnvColor[0], modelRenderDynEnvColor[1], modelRenderDynEnvColor[2], modelRenderDynEnvColor[3]); // Set up segment 3 to point to the right render mode table based on the alpha value - if(D_803837A0[3] == 0xFF){ + if(modelRenderDynEnvColor[3] == 0xFF){ gSPSegment((*gfx)++, 0x03, osVirtualToPhysical(rendermode_table_opa)); } else{ gSPSegment((*gfx)++, 0x03, osVirtualToPhysical(rendermode_table_xlu)); } } - else if(D_80383714 == 2){ + else if(modelRenderColorMode == COLOR_MODE_STATIC_OPAQUE){ gSPDisplayList((*gfx)++, setup2CycleWhiteEnvDL); gSPSegment((*gfx)++, 0x03, osVirtualToPhysical(rendermode_table_opa)); } - else if(D_80383714 == 3){ + else if(modelRenderColorMode == COLOR_MODE_STATIC_TRANSPARENT){ gSPDisplayList((*gfx)++, setup2CycleDL_copy); - gDPSetEnvColor((*gfx)++, 0xFF, 0xFF, 0xFF, D_803837C0); + gDPSetEnvColor((*gfx)++, 0xFF, 0xFF, 0xFF, modelRenderDynAlpha); gSPSegment((*gfx)++, 0x03, osVirtualToPhysical(rendermode_table_xlu)); } @@ -1232,7 +1244,7 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 arg3[3], } if(D_8038372C){ - func_802ED52C(D_8038372C, D_80383C38, scale); + func_802ED52C(D_8038372C, modelRenderCameraPosition, scale); } if(model_bin->unk28 != NULL && D_8038371C != NULL){ @@ -1241,10 +1253,10 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 arg3[3], mlMtxIdent(); if(D_80383758.unk18){ - func_80252AF0(D_80383758.unk1C, camera_position, arg3, scale, arg5); + func_80252AF0(D_80383758.unk1C, object_position, arg3, scale, arg5); } else{ - func_80252AF0(D_80383C38, camera_position, arg3, scale, arg5); + func_80252AF0(modelRenderCameraPosition, object_position, arg3, scale, arg5); } if(D_803837B0.unk0){ @@ -1268,8 +1280,8 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 arg3[3], func_80339124(gfx, mtx, (BKGeoList *)((u8 *)model_bin + model_bin->geo_list_offset_4)); gSPPopMatrix((*gfx)++, G_MTX_MODELVIEW); - if(D_80383790.unk8){ - D_80383790.unk8(D_80383790.unkC); + if(modelRenderCallback.post_method != NULL){ + modelRenderCallback.post_method(modelRenderCallback.post_arg); } if(D_803837C8.model_id){ @@ -1409,14 +1421,14 @@ void func_8033A298(bool arg0){ } } -void func_8033A2D4(void(*func)(Actor *), Actor* actor){ - D_80383790.unk0 = func; - D_80383790.unk4 = actor; +void modelRender_preDraw(GenMethod_1 func, s32 arg){ + modelRenderCallback.pre_method = func; + modelRenderCallback.pre_arg = arg; } -void func_8033A2E8(void(*func)(ActorMarker *), ActorMarker* marker){ - D_80383790.unk8 = func; - D_80383790.unkC = marker; +void modelRender_postDraw(GenMethod_1 func, s32 arg){ + modelRenderCallback.post_method = func; + modelRenderCallback.post_arg = arg; } void modelRender_setDisplayList(BKGfxList *gfx_list){ @@ -1430,36 +1442,36 @@ void func_8033A308(f32 arg0[3]){ D_803837B0.unk4[2] = arg0[2]; } -void func_8033A334(s32 env[4], s32 prim[4]){ - D_80383714 = 0; +void modelRender_setPrimAndEnvColors(s32 env[4], s32 prim[4]){ + modelRenderColorMode = COLOR_MODE_DYNAMIC_PRIM_AND_ENV; - D_80383738.env[0] = env[0]; - D_80383738.env[1] = env[1]; - D_80383738.env[2] = env[2]; - D_80383738.env[3] = env[3]; + modelRenderDynColors.env[0] = env[0]; + modelRenderDynColors.env[1] = env[1]; + modelRenderDynColors.env[2] = env[2]; + modelRenderDynColors.env[3] = env[3]; - D_80383738.prim[0] = prim[0]; - D_80383738.prim[1] = prim[1]; - D_80383738.prim[2] = prim[2]; - D_80383738.prim[3] = prim[3]; + modelRenderDynColors.prim[0] = prim[0]; + modelRenderDynColors.prim[1] = prim[1]; + modelRenderDynColors.prim[2] = prim[2]; + modelRenderDynColors.prim[3] = prim[3]; } -void func_8033A388(s32 r, s32 g, s32 b, s32 a){ - D_80383714 = 1; +void modelRender_setEnvColor(s32 r, s32 g, s32 b, s32 a){ + modelRenderColorMode = COLOR_MODE_DYNAMIC_ENV; - D_803837A0[0] = MIN(0xFF, r); - D_803837A0[1] = MIN(0xFF, g); - D_803837A0[2] = MIN(0xFF, b); - D_803837A0[3] = MIN(0xFF, a); + modelRenderDynEnvColor[0] = MIN(0xFF, r); + modelRenderDynEnvColor[1] = MIN(0xFF, g); + modelRenderDynEnvColor[2] = MIN(0xFF, b); + modelRenderDynEnvColor[3] = MIN(0xFF, a); } -void func_8033A410(s32 a){ +void modelRender_setAlpha(s32 a){ if(a == 0xff){ - D_80383714 = 2; + modelRenderColorMode = COLOR_MODE_STATIC_OPAQUE; } else{ - D_80383714 = 3; - D_803837C0 = a; + modelRenderColorMode = COLOR_MODE_STATIC_TRANSPARENT; + modelRenderDynAlpha = a; } } @@ -1501,7 +1513,7 @@ void modelRender_setDepthMode(enum model_render_depth_mode_e renderMode){ modelRenderDepthMode = renderMode; } -void func_8033A4D8(void){ +void modelRender_defrag(void){ if(D_80383730 != NULL){ D_80383730 = func_802EA374(D_80383730); }