mirror of
https://github.com/BanjoRecomp/BanjoRecomp
synced 2026-05-23 06:34:20 -04:00
Reorganize transform tagging and add tagging to level models
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
#include "patches.h"
|
||||
#include "core1/core1.h"
|
||||
|
||||
extern f32 sViewportFOVy;
|
||||
extern f32 sViewportAspect;
|
||||
extern f32 sViewportNear;
|
||||
extern f32 sViewportFar;
|
||||
extern f32 sViewportPosition[3];
|
||||
extern f32 sViewportRotation[3];
|
||||
extern Vp sViewportStack[];
|
||||
extern s32 sViewportStackIndex;
|
||||
|
||||
// @recomp Patched to specify the view matrix for better transform interpolation.
|
||||
RECOMP_PATCH void viewport_setRenderPerspectiveMatrix(Gfx **gfx, Mtx **mtx, f32 near, f32 far) {
|
||||
u16 perspNorm;
|
||||
|
||||
near = MAX(sViewportNear, near);
|
||||
far = MIN(sViewportFar, far);
|
||||
|
||||
if(*(u32*)OS_PHYSICAL_TO_K0(0x1D8) + 0x53D4FFF0) {
|
||||
near = 750.0f;
|
||||
far = 1250.0f;
|
||||
}
|
||||
|
||||
guPerspective(*mtx, &perspNorm, sViewportFOVy, sViewportAspect, near, far, 0.5f);
|
||||
gSPPerspNormalize((*gfx)++, perspNorm);
|
||||
gSPMatrix((*gfx)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
|
||||
|
||||
guRotate(*mtx, -sViewportRotation[2], 0.0f, 0.0f, -1.0f);
|
||||
gSPMatrix((*gfx)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
|
||||
|
||||
guRotate(*mtx, -sViewportRotation[0], 1.0f, 0.0f, 0.0f);
|
||||
gSPMatrix((*gfx)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
|
||||
|
||||
guRotate(*mtx, -sViewportRotation[1], 0.0f, 1.0f, 0.0f);
|
||||
gSPMatrix((*gfx)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
|
||||
|
||||
guTranslate(*mtx, 0.0f, 0.0f, 0.0f);
|
||||
gSPMatrix((*gfx)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
// @recomp Create an isolated view matrix for the viewport translation and provide it as the view matrix to counteract the camera translation.
|
||||
MtxF* view = (MtxF*)*mtx;
|
||||
(*mtx)++;
|
||||
guTranslateF(view->m, sViewportPosition[0], sViewportPosition[1], sViewportPosition[2]);
|
||||
gEXSetViewMatrixFloat((*gfx)++, view->m);
|
||||
}
|
||||
|
||||
float identity_matrix[4][4] = {
|
||||
{ 1.0f, 0.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 1.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 1.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f }
|
||||
};
|
||||
|
||||
// @recomp Patched to set up an identity view matrix to prevent bleeding the perspective projection's view matrix.
|
||||
RECOMP_PATCH void viewport_setRenderViewportAndOrthoMatrix(Gfx **gfx, Mtx **mtx) {
|
||||
gSPViewport((*gfx)++, &sViewportStack[sViewportStackIndex]);
|
||||
|
||||
guOrtho(*mtx, -(2*(f32)gFramebufferWidth), (2*(f32)gFramebufferWidth), -(2*(f32)gFramebufferHeight), (2*(f32)gFramebufferHeight), 1.0f, 20.0f, 1.0f);
|
||||
gSPMatrix((*gfx)++, OS_K0_TO_PHYSICAL((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
|
||||
|
||||
guTranslate(*mtx, 0.0f, 0.0f, 0.0f);
|
||||
gSPMatrix((*gfx)++, OS_K0_TO_PHYSICAL((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
// @recomp Set an identity view matrix.
|
||||
gEXSetViewMatrixFloat((*gfx)++, identity_matrix);
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
#include "patches.h"
|
||||
#include "transform_ids.h"
|
||||
#include "functions.h"
|
||||
#include "core2/anctrl.h"
|
||||
#include "core2/modelRender.h"
|
||||
|
||||
s32 func_80320708(void);
|
||||
s32 levelSpecificFlags_validateCRC2(void);
|
||||
s32 dummy_func_80320248(void);
|
||||
enum asset_e mapModel_getOpaModelId(void);
|
||||
enum map_e map_get(void);
|
||||
s32 mapSpecificFlags_get(s32 i);
|
||||
s32 levelSpecificFlags_get(s32 i);
|
||||
u32 jiggyscore_isCollected(enum jiggy_e);
|
||||
enum bsgroup_e player_movementGroup(void);
|
||||
bool jigsawPicture_isJigsawPictureComplete(s32 world);
|
||||
bool fileProgressFlag_get(enum file_progress_e index);
|
||||
void modelRender_setAnimatedTexturesCacheId(s32 arg0);
|
||||
bool mapModel_has_xlu_bin(void);
|
||||
void func_802F7BC0(Gfx **, Mtx **, Vtx **);
|
||||
|
||||
typedef struct {
|
||||
s16 map_id; //enum map_e
|
||||
s16 opa_model_id; //enum asset_e level_model_id
|
||||
s16 xlu_model_id; //enum asset_e level2_model_id
|
||||
s16 unk6[3]; // min bounds (for cubes?)
|
||||
s16 unkC[3]; // max bounds (for cubes?)
|
||||
// u8 pad12[0x2];
|
||||
f32 scale;
|
||||
}MapModelDescription;
|
||||
|
||||
extern struct {
|
||||
s32 unk0; // Changed from void* in the decomp
|
||||
s32 unk4; // Changed from void* in the decomp
|
||||
BKCollisionList *collision_opa;
|
||||
BKCollisionList *collision_xlu;
|
||||
BKModel *model_opa;
|
||||
BKModel *model_xlu;
|
||||
BKModelBin *model_bin_opa;
|
||||
BKModelBin *model_bin_xlu;
|
||||
s32 unk20;
|
||||
struct5Bs *unk24;
|
||||
MapModelDescription *description;
|
||||
u8 env_red;
|
||||
u8 env_green;
|
||||
u8 env_blue;
|
||||
f32 scale;
|
||||
}mapModel;
|
||||
|
||||
// @recomp Patched to set the transform ID when drawing the map's opaque model.
|
||||
RECOMP_PATCH void mapModel_opa_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) {
|
||||
s32 temp_a0;
|
||||
|
||||
if (func_80320708() && levelSpecificFlags_validateCRC2() && dummy_func_80320248()) {
|
||||
if (mapModel_getOpaModelId() == ASSET_14CF_MODEL_SM_SPIRAL_MOUNTAIN_OPA) {
|
||||
func_8033A45C(1, 0);
|
||||
func_8033A45C(2, 1);
|
||||
}
|
||||
switch (map_get()) { /* irregular */
|
||||
case MAP_88_CS_SPIRAL_MOUNTAIN_6:
|
||||
if (mapSpecificFlags_get(0) != 0) {
|
||||
func_8033A45C(1, 1);
|
||||
func_8033A45C(2, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case MAP_12_GV_GOBIS_VALLEY:
|
||||
func_8033A45C(1, levelSpecificFlags_get(LEVEL_FLAG_6_GV_UNKNOWN) ? 1 : 0);
|
||||
func_8033A45C(2, jiggyscore_isCollected(JIGGY_42_GV_WATER_PYRAMID) ? 0 : 1);
|
||||
func_8033A45C(5, jiggyscore_isCollected(JIGGY_42_GV_WATER_PYRAMID) ? 1 : 0);
|
||||
break;
|
||||
|
||||
case MAP_14_GV_SANDYBUTTS_MAZE:
|
||||
func_8033A45C(5, (player_movementGroup() == BSGROUP_4_LOOK) ? 1 : 0);
|
||||
break;
|
||||
|
||||
case MAP_E_MM_MUMBOS_SKULL:
|
||||
func_8033A45C(1, 1);
|
||||
func_8033A45C(5, 1);
|
||||
break;
|
||||
|
||||
case MAP_47_BGS_MUMBOS_SKULL:
|
||||
func_8033A45C(1, 2);
|
||||
func_8033A45C(5, 2);
|
||||
break;
|
||||
|
||||
case MAP_48_FP_MUMBOS_SKULL:
|
||||
func_8033A45C(1, 3);
|
||||
func_8033A45C(5, 3);
|
||||
break;
|
||||
|
||||
case MAP_30_MMM_MUMBOS_SKULL:
|
||||
func_8033A45C(1, 4);
|
||||
func_8033A45C(5, 4);
|
||||
break;
|
||||
|
||||
case MAP_4A_CCW_SPRING_MUMBOS_SKULL:
|
||||
func_8033A45C(1, 5);
|
||||
func_8033A45C(5, 5);
|
||||
break;
|
||||
case MAP_4B_CCW_SUMMER_MUMBOS_SKULL:
|
||||
func_8033A45C(1, 6);
|
||||
func_8033A45C(5, 6);
|
||||
break;
|
||||
case MAP_4C_CCW_AUTUMN_MUMBOS_SKULL:
|
||||
func_8033A45C(1, 7);
|
||||
func_8033A45C(5, 7);
|
||||
break;
|
||||
case MAP_4D_CCW_WINTER_MUMBOS_SKULL:
|
||||
func_8033A45C(1, 8);
|
||||
func_8033A45C(5, 8);
|
||||
break;
|
||||
case MAP_5E_CCW_SPRING_NABNUTS_HOUSE:
|
||||
case MAP_5F_CCW_SUMMER_NABNUTS_HOUSE:
|
||||
case MAP_60_CCW_AUTUMN_NABNUTS_HOUSE:
|
||||
func_8033A45C(1, 1);
|
||||
func_8033A45C(2, 0);
|
||||
break;
|
||||
case MAP_61_CCW_WINTER_NABNUTS_HOUSE:
|
||||
func_8033A45C(1, 0);
|
||||
func_8033A45C(2, 1);
|
||||
break;
|
||||
case MAP_1D_MMM_CELLAR:
|
||||
func_8033A45C(1, actorArray_findActorFromActorId(0x191) ? 0 : 1);
|
||||
break;
|
||||
case MAP_7C_CS_INTRO_BANJOS_HOUSE_1:
|
||||
case MAP_89_CS_INTRO_BANJOS_HOUSE_2:
|
||||
case MAP_8A_CS_INTRO_BANJOS_HOUSE_3:
|
||||
case MAP_8C_SM_BANJOS_HOUSE:
|
||||
case MAP_91_FILE_SELECT:
|
||||
func_8033A45C(5, 1);
|
||||
break;
|
||||
case MAP_7B_CS_INTRO_GL_DINGPOT_1:
|
||||
case MAP_81_CS_INTRO_GL_DINGPOT_2:
|
||||
func_8033A45C(4, 0);
|
||||
func_8033A45C(5, 0);
|
||||
func_8033A45C(6, 0);
|
||||
break;
|
||||
case MAP_82_CS_ENTERING_GL_MACHINE_ROOM:
|
||||
case MAP_83_CS_GAME_OVER_MACHINE_ROOM:
|
||||
case MAP_84_CS_UNUSED_MACHINE_ROOM:
|
||||
func_8033A45C(4, 1);
|
||||
func_8033A45C(5, 1);
|
||||
func_8033A45C(6, 1);
|
||||
break;
|
||||
case MAP_93_GL_DINGPOT:
|
||||
func_8033A45C(4, 1);
|
||||
func_8033A45C(5, 1);
|
||||
func_8033A45C(6, (jigsawPicture_isJigsawPictureComplete(0xA) || fileProgressFlag_get(FILEPROG_E2_DOOR_OF_GRUNTY_OPEN) || volatileFlag_get(VOLATILE_FLAG_C1_IN_FINAL_CHARACTER_PARADE)));
|
||||
break;
|
||||
}
|
||||
func_8033A450(mapModel.unk24);
|
||||
modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL);
|
||||
temp_a0 = mapModel.unk0;
|
||||
if (temp_a0 != 0) {
|
||||
modelRender_setAnimatedTexturesCacheId(temp_a0);
|
||||
}
|
||||
modelRender_setEnvColor(mapModel.env_red, mapModel.env_green, mapModel.env_blue, 0xFF);
|
||||
|
||||
// @recomp Set the map opaque model transform id.
|
||||
cur_drawn_model_transform_id = MAP_MODEL_OPA_TRANSFORM_ID_START;
|
||||
|
||||
modelRender_draw(gfx, mtx, NULL, NULL, mapModel.description->scale, NULL, mapModel.model_bin_opa);
|
||||
|
||||
// @recomp Clear the current model transform id after drawing.
|
||||
cur_drawn_model_transform_id = 0;
|
||||
|
||||
if (!mapModel_has_xlu_bin()) {
|
||||
func_802F7BC0(gfx, mtx, vtx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @recomp Patched to set the transform ID when drawing the map's translucent model.
|
||||
RECOMP_PATCH void mapModel_xlu_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) {
|
||||
s32 temp_a0;
|
||||
|
||||
if (mapModel.model_bin_xlu != NULL) {
|
||||
if (map_get() == MAP_1D_MMM_CELLAR) {
|
||||
func_8033A45C(1, (actorArray_findActorFromActorId(0x191) != NULL) ? 0 : 1);
|
||||
}
|
||||
modelRender_setDepthMode(MODEL_RENDER_DEPTH_COMPARE);
|
||||
temp_a0 = mapModel.unk4;
|
||||
if (temp_a0 != 0) {
|
||||
modelRender_setAnimatedTexturesCacheId(temp_a0);
|
||||
}
|
||||
modelRender_setEnvColor(mapModel.env_red, mapModel.env_green, mapModel.env_blue, 0xFF);
|
||||
|
||||
// @recomp Set the map opaque model transform id.
|
||||
cur_drawn_model_transform_id = MAP_MODEL_XLU_TRANSFORM_ID_START;
|
||||
|
||||
modelRender_draw(gfx, mtx, NULL, NULL, mapModel.description->scale, NULL, mapModel.model_bin_xlu);
|
||||
|
||||
// @recomp Clear the current model transform id after drawing.
|
||||
cur_drawn_model_transform_id = 0;
|
||||
|
||||
func_802F7BC0(gfx, mtx, vtx);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
#include "patches.h"
|
||||
#include "bk_api.h"
|
||||
#include "transform_ids.h"
|
||||
#include "functions.h"
|
||||
|
||||
extern u8 D_8037BFB8;
|
||||
extern s32 D_8036E7B0;
|
||||
|
||||
void eggShatter_draw(Gfx **gPtr, Mtx **mPtr, Vtx **vPtr);
|
||||
void baModel_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx);
|
||||
void func_8033A28C(bool arg0);
|
||||
void func_8033A244(f32);
|
||||
void func_8033A280(f32);
|
||||
|
||||
// @recomp Patched to set the current transform ID to banjo's when drawing the player.
|
||||
RECOMP_PATCH void player_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) {
|
||||
if (D_8037BFB8) {
|
||||
eggShatter_draw(gfx, mtx, vtx);
|
||||
|
||||
// @recomp Set the current transform ID to banjo's.
|
||||
cur_drawn_model_transform_id = BANJO_TRANSFORM_ID_START;
|
||||
|
||||
baModel_draw(gfx, mtx, vtx);
|
||||
|
||||
// @recomp Clear the current transform ID.
|
||||
cur_drawn_model_transform_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// @recomp Patched to set the actor being drawn before the actor's draw func is called.
|
||||
RECOMP_PATCH void __marker_draw(ActorMarker *this, Gfx **gfx, Mtx **mtx, Vtx **vtx){
|
||||
Actor *actor;
|
||||
u32 draw_dist;
|
||||
f32 draw_dist_f;
|
||||
f32 percentage;
|
||||
|
||||
// @recomp Set the current drawn marker's transform ID.
|
||||
s32 cur_drawn_marker_spawn_index = bkrecomp_get_marker_spawn_index(this);
|
||||
cur_drawn_model_transform_id = MARKER_TRANSFORM_ID_START + cur_drawn_marker_spawn_index * MARKER_TRANSFORM_ID_COUNT;
|
||||
if(!this->unk3E_0){
|
||||
this->drawFunc(this, gfx, mtx, vtx);
|
||||
// @recomp Clear the current transform ID after drawing.
|
||||
cur_drawn_model_transform_id = 0;
|
||||
return;
|
||||
}
|
||||
actor = marker_getActor(this);
|
||||
func_8033A28C(actor->unk58_2);
|
||||
if( actor->unk58_2 && !this->unk40_23 && !this->unk40_21 && !D_8036E7B0){
|
||||
func_8033A244(3700.0f);
|
||||
}
|
||||
|
||||
if(actor->unk124_7 && !actor->despawn_flag && actor->unk58_0){
|
||||
draw_dist = actor->actor_info->draw_distance;
|
||||
if(draw_dist != 0){
|
||||
percentage = (f32)draw_dist*(1/(f64)0x400);
|
||||
}
|
||||
else if(this->unk40_21){
|
||||
percentage = 2.0f;
|
||||
}
|
||||
else{
|
||||
percentage = 1.0f;
|
||||
}
|
||||
func_8033A280(percentage);
|
||||
this->drawFunc(this, gfx, mtx, vtx);
|
||||
// @recomp Set the current drawn marker to null after drawing.
|
||||
cur_drawn_model_transform_id = 0;
|
||||
}//L8032D300
|
||||
func_8033A244(30000.0f);
|
||||
func_8033A280(1.0f);
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
#ifndef __TRANSFORM_IDS_H__
|
||||
#define __TRANSFORM_IDS_H__
|
||||
|
||||
#include "PR/ultratypes.h"
|
||||
|
||||
#define MAP_MODEL_OPA_TRANSFORM_ID_START 0x1000
|
||||
#define MAP_MODEL_XLU_TRANSFORM_ID_START 0x2000
|
||||
|
||||
#define MARKER_TRANSFORM_ID_COUNT 256 // Number of transform IDs for each ActorMarker.
|
||||
#define BANJO_TRANSFORM_ID_START 0x01000000
|
||||
#define MARKER_TRANSFORM_ID_START (BANJO_TRANSFORM_ID_START + MARKER_TRANSFORM_ID_COUNT)
|
||||
|
||||
extern u32 cur_drawn_model_transform_id;
|
||||
|
||||
#endif
|
||||
|
||||
+7
-203
@@ -6,129 +6,7 @@
|
||||
#include "core1/mlmtx.h"
|
||||
#include "functions.h"
|
||||
|
||||
extern struct{
|
||||
s32 unk0;
|
||||
s32 game_mode; //game_mode
|
||||
f32 unk8;
|
||||
s32 unkC; //freeze_scene_flag (used for pause menu)
|
||||
f32 unk10;
|
||||
u8 transition;
|
||||
u8 map;
|
||||
u8 exit;
|
||||
u8 unk17; //reset_on_map_load
|
||||
u8 unk18;
|
||||
u8 unk19;
|
||||
u8 unk1A;
|
||||
u8 unk1B;
|
||||
u8 unk1C;
|
||||
} D_8037E8E0;
|
||||
|
||||
void func_802E39D0(Gfx **gdl, Mtx **mptr, Vtx **vptr, s32 framebuffer_idx, s32 arg4);
|
||||
|
||||
#define PRINT_FUNC() \
|
||||
recomp_printf("%s\n", __func__)
|
||||
|
||||
#define PRINT_FUNC_INDENT() \
|
||||
recomp_printf(" %s\n", __func__)
|
||||
|
||||
extern f32 sViewportFOVy;
|
||||
extern f32 sViewportAspect;
|
||||
extern f32 sViewportNear;
|
||||
extern f32 sViewportFar;
|
||||
extern f32 sViewportPosition[3];
|
||||
extern f32 sViewportRotation[3];
|
||||
|
||||
void func_80256E24(f32 dst[3], f32 theta, f32 phi, f32 x, f32 y, f32 z);
|
||||
void ml_vec3f_copy(f32 dst[3], f32 src[3]);
|
||||
|
||||
// RECOMP_PATCH void viewport_moveAlongZAxis(f32 offset) {
|
||||
// PRINT_FUNC_INDENT();
|
||||
// f32 delta_position[3];
|
||||
|
||||
// func_80256E24(delta_position, sViewportRotation[0], sViewportRotation[1], 0.0f, 0.0f, offset);
|
||||
|
||||
// sViewportPosition[0] += delta_position[0];
|
||||
// sViewportPosition[1] += delta_position[1];
|
||||
// sViewportPosition[2] += delta_position[2];
|
||||
// }
|
||||
|
||||
// RECOMP_PATCH void viewport_setPosition_vec3f(f32 src[3]) {
|
||||
// PRINT_FUNC_INDENT();
|
||||
// ml_vec3f_copy(sViewportPosition, src);
|
||||
// }
|
||||
|
||||
// RECOMP_PATCH void viewport_setPosition_vec3w(s32 src[3]) {
|
||||
// PRINT_FUNC_INDENT();
|
||||
// sViewportPosition[0] = (f32)src[0];
|
||||
// sViewportPosition[1] = (f32)src[1];
|
||||
// sViewportPosition[2] = (f32)src[2];
|
||||
// }
|
||||
|
||||
// RECOMP_PATCH void viewport_setPosition_f3(f32 x, f32 y, f32 z) {
|
||||
// PRINT_FUNC_INDENT();
|
||||
// sViewportPosition[0] = x;
|
||||
// sViewportPosition[1] = y;
|
||||
// sViewportPosition[2] = z;
|
||||
// }
|
||||
|
||||
extern Vp sViewportStack[];
|
||||
extern s32 sViewportStackIndex;
|
||||
|
||||
// @recomp Patched to specify the view matrix for better transform interpolation.
|
||||
RECOMP_PATCH void viewport_setRenderPerspectiveMatrix(Gfx **gfx, Mtx **mtx, f32 near, f32 far) {
|
||||
u16 perspNorm;
|
||||
|
||||
near = MAX(sViewportNear, near);
|
||||
far = MIN(sViewportFar, far);
|
||||
|
||||
if(*(u32*)OS_PHYSICAL_TO_K0(0x1D8) + 0x53D4FFF0) {
|
||||
near = 750.0f;
|
||||
far = 1250.0f;
|
||||
}
|
||||
|
||||
guPerspective(*mtx, &perspNorm, sViewportFOVy, sViewportAspect, near, far, 0.5f);
|
||||
gSPPerspNormalize((*gfx)++, perspNorm);
|
||||
gSPMatrix((*gfx)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
|
||||
|
||||
guRotate(*mtx, -sViewportRotation[2], 0.0f, 0.0f, -1.0f);
|
||||
gSPMatrix((*gfx)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
|
||||
|
||||
guRotate(*mtx, -sViewportRotation[0], 1.0f, 0.0f, 0.0f);
|
||||
gSPMatrix((*gfx)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
|
||||
|
||||
guRotate(*mtx, -sViewportRotation[1], 0.0f, 1.0f, 0.0f);
|
||||
gSPMatrix((*gfx)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
|
||||
|
||||
guTranslate(*mtx, 0.0f, 0.0f, 0.0f);
|
||||
gSPMatrix((*gfx)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
// @recomp Create an isolated view matrix for the viewport translation and provide it as the view matrix to counteract the camera translation.
|
||||
MtxF* view = (MtxF*)*mtx;
|
||||
(*mtx)++;
|
||||
guTranslateF(view->m, sViewportPosition[0], sViewportPosition[1], sViewportPosition[2]);
|
||||
gEXSetViewMatrixFloat((*gfx)++, view->m);
|
||||
}
|
||||
|
||||
float identity_matrix[4][4] = {
|
||||
{ 1.0f, 0.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 1.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 1.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f }
|
||||
};
|
||||
|
||||
// @recomp Patched to set up an identity view matrix to prevent bleeding the perspective projection's view matrix.
|
||||
RECOMP_PATCH void viewport_setRenderViewportAndOrthoMatrix(Gfx **gfx, Mtx **mtx) {
|
||||
gSPViewport((*gfx)++, &sViewportStack[sViewportStackIndex]);
|
||||
|
||||
guOrtho(*mtx, -(2*(f32)gFramebufferWidth), (2*(f32)gFramebufferWidth), -(2*(f32)gFramebufferHeight), (2*(f32)gFramebufferHeight), 1.0f, 20.0f, 1.0f);
|
||||
gSPMatrix((*gfx)++, OS_K0_TO_PHYSICAL((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
|
||||
|
||||
guTranslate(*mtx, 0.0f, 0.0f, 0.0f);
|
||||
gSPMatrix((*gfx)++, OS_K0_TO_PHYSICAL((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
// @recomp Set an identity view matrix.
|
||||
gEXSetViewMatrixFloat((*gfx)++, identity_matrix);
|
||||
}
|
||||
u32 cur_drawn_model_transform_id = 0;
|
||||
|
||||
typedef void (*GeoListFunc)(Gfx **, Mtx **, void *);
|
||||
|
||||
@@ -139,19 +17,11 @@ typedef struct {
|
||||
s8 unk9;
|
||||
}GeoCmd2;
|
||||
|
||||
extern u8 D_8037BFB8;
|
||||
extern s32 D_8036E7B0;
|
||||
extern AnimMtxList *D_8038371C;
|
||||
extern MtxF D_80383BF8;
|
||||
extern s32 D_80370990;
|
||||
extern GeoListFunc D_80370994[];
|
||||
|
||||
void eggShatter_draw(Gfx **gPtr, Mtx **mPtr, Vtx **vPtr);
|
||||
void baModel_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx);
|
||||
Actor *marker_getActor(ActorMarker *);
|
||||
void func_8033A28C(bool arg0);
|
||||
void func_8033A244(f32);
|
||||
void func_8033A280(f32);
|
||||
void func_80339124(Gfx **, Mtx **, BKGeoList *);
|
||||
MtxF *animMtxList_get(AnimMtxList *this, s32 arg1);
|
||||
bool AnimTextureListCache_tryGetTextureOffset(s32 list_index, s32 texture_index, s32 *current_frame);
|
||||
@@ -162,72 +32,6 @@ void func_802ED52C(BKModelUnk20List *arg0, f32 arg1[3], f32 arg2);
|
||||
void func_802E6BD0(BKModelUnk28List *arg0, BKVertexList *arg1, AnimMtxList *mtx_list);
|
||||
void assetCache_free(void *arg0);
|
||||
|
||||
ActorMarker* cur_drawn_marker = NULL;
|
||||
u32 cur_drawn_marker_spawn_index = 0;
|
||||
u32 cur_drawn_marker_transform_id = 0;
|
||||
|
||||
// @recomp Patched to set the current transform ID to banjo's when drawing the player.
|
||||
RECOMP_PATCH void player_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) {
|
||||
if (D_8037BFB8) {
|
||||
eggShatter_draw(gfx, mtx, vtx);
|
||||
|
||||
// @recomp Set the current transform ID to banjo's.
|
||||
cur_drawn_marker_transform_id = BANJO_TRANSFORM_ID_START;
|
||||
|
||||
baModel_draw(gfx, mtx, vtx);
|
||||
|
||||
// @recomp Clear the current transform ID.
|
||||
cur_drawn_marker_transform_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// @recomp Patched to set the actor being drawn before the actor's draw func is called.
|
||||
RECOMP_PATCH void __marker_draw(ActorMarker *this, Gfx **gfx, Mtx **mtx, Vtx **vtx){
|
||||
Actor *actor;
|
||||
u32 draw_dist;
|
||||
f32 draw_dist_f;
|
||||
f32 percentage;
|
||||
|
||||
// @recomp Set the current drawn marker.
|
||||
cur_drawn_marker = this;
|
||||
cur_drawn_marker_spawn_index = bkrecomp_get_marker_spawn_index(this);
|
||||
cur_drawn_marker_transform_id = MARKER_TRANSFORM_ID_START + cur_drawn_marker_spawn_index * MARKER_TRANSFORM_ID_COUNT;
|
||||
if(!this->unk3E_0){
|
||||
this->drawFunc(this, gfx, mtx, vtx);
|
||||
// @recomp Set the current drawn marker to null after drawing.
|
||||
cur_drawn_marker = NULL;
|
||||
cur_drawn_marker_spawn_index = 0;
|
||||
cur_drawn_marker_transform_id = 0;
|
||||
return;
|
||||
}
|
||||
actor = marker_getActor(this);
|
||||
func_8033A28C(actor->unk58_2);
|
||||
if( actor->unk58_2 && !this->unk40_23 && !this->unk40_21 && !D_8036E7B0){
|
||||
func_8033A244(3700.0f);
|
||||
}
|
||||
|
||||
if(actor->unk124_7 && !actor->despawn_flag && actor->unk58_0){
|
||||
draw_dist = actor->actor_info->draw_distance;
|
||||
if(draw_dist != 0){
|
||||
percentage = (f32)draw_dist*(1/(f64)0x400);
|
||||
}
|
||||
else if(this->unk40_21){
|
||||
percentage = 2.0f;
|
||||
}
|
||||
else{
|
||||
percentage = 1.0f;
|
||||
}
|
||||
func_8033A280(percentage);
|
||||
this->drawFunc(this, gfx, mtx, vtx);
|
||||
// @recomp Set the current drawn marker to null after drawing.
|
||||
cur_drawn_marker = NULL;
|
||||
cur_drawn_marker_spawn_index = 0;
|
||||
cur_drawn_marker_transform_id = 0;
|
||||
}//L8032D300
|
||||
func_8033A244(30000.0f);
|
||||
func_8033A280(1.0f);
|
||||
}
|
||||
|
||||
#define gEXMatrixGroupSimpleNormal(cmd, id, push, proj, edit) \
|
||||
gEXMatrixGroup(cmd, id, G_EX_INTERPOLATE_SIMPLE, push, proj, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_SKIP, G_EX_COMPONENT_INTERPOLATE, G_EX_ORDER_LINEAR, edit, G_EX_ASPECT_AUTO)
|
||||
|
||||
@@ -244,10 +48,10 @@ RECOMP_PATCH void func_803387F8(Gfx **gfx, Mtx **mtx, void *arg2){
|
||||
mlMtxApply(*mtx);
|
||||
gSPMatrix((*gfx)++, (*mtx)++, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
if (cur_drawn_marker_transform_id != 0) {
|
||||
if (cur_drawn_model_transform_id != 0) {
|
||||
// @recomp Tag the matrix.
|
||||
// gEXMatrixGroupSimpleNormal((*gfx)++, cur_drawn_actor_transform_id + cmd->unk9, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_ALLOW);
|
||||
gEXMatrixGroupSimpleVerts((*gfx)++, cur_drawn_marker_transform_id + cmd->unk9, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_ALLOW);
|
||||
gEXMatrixGroupSimpleVerts((*gfx)++, cur_drawn_model_transform_id + cmd->unk9, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_ALLOW);
|
||||
// gEXMatrixGroupDecomposedNormal((*gfx)++, cur_drawn_actor_transform_id + cmd->unk9 + 1, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_ALLOW);
|
||||
}
|
||||
}
|
||||
@@ -260,7 +64,7 @@ RECOMP_PATCH void func_803387F8(Gfx **gfx, Mtx **mtx, void *arg2){
|
||||
if(D_80370990){
|
||||
gSPPopMatrix((*gfx)++, G_MTX_MODELVIEW);
|
||||
|
||||
if (cur_drawn_marker_transform_id != 0) {
|
||||
if (cur_drawn_model_transform_id != 0) {
|
||||
// @recomp Pop the matrix group.
|
||||
gEXPopMatrixGroup((*gfx)++, G_MTX_MODELVIEW);
|
||||
}
|
||||
@@ -621,8 +425,8 @@ RECOMP_PATCH BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3],
|
||||
gSPMatrix((*gfx)++, (*mtx)++, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
// @recomp Create a matrix group if a transform id is set.
|
||||
if (cur_drawn_marker_transform_id != 0) {
|
||||
gEXMatrixGroupDecomposedVerts((*gfx)++, cur_drawn_marker_transform_id, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_ALLOW);
|
||||
if (cur_drawn_model_transform_id != 0) {
|
||||
gEXMatrixGroupDecomposedVerts((*gfx)++, cur_drawn_model_transform_id, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_ALLOW);
|
||||
}
|
||||
|
||||
modelRenderScale = scale;
|
||||
@@ -639,7 +443,7 @@ RECOMP_PATCH BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3],
|
||||
gSPPopMatrix((*gfx)++, G_MTX_MODELVIEW);
|
||||
|
||||
// @recomp Pop the matrix group if a transform id is set.
|
||||
if (cur_drawn_marker_transform_id != 0) {
|
||||
if (cur_drawn_model_transform_id != 0) {
|
||||
gEXPopMatrixGroup((*gfx)++, G_MTX_MODELVIEW);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user