Widescreen support.

This commit is contained in:
Reonu
2021-05-09 22:34:22 +01:00
parent b7e7c82e93
commit 08223110ff
13 changed files with 3702 additions and 12 deletions

View File

@@ -10,6 +10,7 @@
#include "rendering_graph_node.h"
#include "shadow.h"
#include "sm64.h"
#define WIDESCREEN
/**
* This file contains the code that processes the scene graph for rendering.
@@ -39,6 +40,7 @@
s16 gMatStackIndex;
Mat4 gMatStack[32];
Mtx *gMatStackFixed[32];
f32 aspect;
/**
* Animation nodes have state in global variables, so this struct captures
@@ -235,6 +237,7 @@ static void geo_process_ortho_projection(struct GraphNodeOrthoProjection *node)
/**
* Process a perspective projection node.
*/
extern u8 widescreen;
static void geo_process_perspective(struct GraphNodePerspective *node) {
if (node->fnNode.func != NULL) {
node->fnNode.func(GEO_CONTEXT_RENDER, &node->fnNode.node, gMatStack[gMatStackIndex]);
@@ -246,7 +249,12 @@ static void geo_process_perspective(struct GraphNodePerspective *node) {
#ifdef VERSION_EU
f32 aspect = ((f32) gCurGraphNodeRoot->width / (f32) gCurGraphNodeRoot->height) * 1.1f;
#else
f32 aspect = (f32) gCurGraphNodeRoot->width / (f32) gCurGraphNodeRoot->height;
if (widescreen == 1){
aspect = 1.775f;
}
else{
aspect = 1.33333f;
}
#endif
guPerspective(mtx, &perspNorm, node->fov, aspect, node->near / WORLD_SCALE, node->far / WORLD_SCALE, 1.0f);
@@ -763,7 +771,7 @@ static s32 obj_is_in_view(struct GraphNodeObject *node, Mat4 matrix) {
// ! @bug The aspect ratio is not accounted for. When the fov value is 45,
// the horizontal effective fov is actually 60 degrees, so you can see objects
// visibly pop in or out at the edge of the screen.
halfFov = (gCurGraphNodeCamFrustum->fov / 2.0f + 1.0f) * 32768.0f / 180.0f + 0.5f;
halfFov = ((gCurGraphNodeCamFrustum->fov*aspect) / 2.0f + 1.0f) * 32768.0f / 180.0f + 0.5f;
hScreenEdge = -matrix[3][2] * sins(halfFov) / coss(halfFov);
// -matrix[3][2] is the depth, which gets multiplied by tan(halfFov) to get