applied falcobuster's long render distance fix

This commit is contained in:
Reonu
2021-04-27 11:54:51 +01:00
parent 960f695115
commit cbcba7b6f9
4 changed files with 151 additions and 29 deletions

View File

@@ -249,7 +249,7 @@ static void geo_process_perspective(struct GraphNodePerspective *node) {
f32 aspect = (f32) gCurGraphNodeRoot->width / (f32) gCurGraphNodeRoot->height;
#endif
guPerspective(mtx, &perspNorm, node->fov, aspect, node->near, node->far, 1.0f);
guPerspective(mtx, &perspNorm, node->fov, aspect, node->near / WORLD_SCALE, node->far / WORLD_SCALE, 1.0f);
gSPPerspNormalize(gDisplayListHead++, perspNorm);
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(mtx), G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH);
@@ -267,17 +267,8 @@ static void geo_process_perspective(struct GraphNodePerspective *node) {
* range of this node.
*/
static void geo_process_level_of_detail(struct GraphNodeLevelOfDetail *node) {
#ifdef GBI_FLOATS
Mtx *mtx = gMatStackFixed[gMatStackIndex];
s16 distanceFromCam = (s32) -mtx->m[3][2]; // z-component of the translation column
#else
// The fixed point Mtx type is defined as 16 longs, but it's actually 16
// shorts for the integer parts followed by 16 shorts for the fraction parts
Mtx *mtx = gMatStackFixed[gMatStackIndex];
s16 distanceFromCam = -GET_HIGH_S16_OF_32(mtx->m[1][3]); // z-component of the translation column
#endif
if (node->minDistance <= distanceFromCam && distanceFromCam < node->maxDistance) {
f32 distanceFromCam = -gMatStack[gMatStackIndex][3][2];
if ((f32)node->minDistance <= distanceFromCam && distanceFromCam < (f32)node->maxDistance) {
if (node->node.children != 0) {
geo_process_node_and_siblings(node->node.children);
}
@@ -304,6 +295,17 @@ static void geo_process_switch(struct GraphNodeSwitchCase *node) {
}
}
static void make_roll_matrix(Mtx *mtx, s16 angle) {
Mat4 temp;
mtxf_identity(temp);
temp[0][0] = coss(angle);
temp[0][1] = sins(angle);
temp[1][0] = -temp[0][1];
temp[1][1] = temp[0][0];
guMtxF2L(temp, mtx);
}
/**
* Process a camera node.
*/
@@ -315,7 +317,7 @@ static void geo_process_camera(struct GraphNodeCamera *node) {
if (node->fnNode.func != NULL) {
node->fnNode.func(GEO_CONTEXT_RENDER, &node->fnNode.node, gMatStack[gMatStackIndex]);
}
mtxf_rotate_xy(rollMtx, node->rollScreen);
make_roll_matrix(rollMtx, node->rollScreen);
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(rollMtx), G_MTX_PROJECTION | G_MTX_MUL | G_MTX_NOPUSH);