Merge branch 'mr-origin-69'

This commit is contained in:
Banjo Kazooie
2024-09-13 20:26:40 -05:00
80 changed files with 806 additions and 660 deletions

View File

@@ -2,95 +2,80 @@
#include "functions.h"
#include "variables.h"
#include "ml/mtx.h"
#include "core1/viewport.h"
extern void guPerspective(Mtx *, u16*, f32, f32, f32, f32, f32);
extern f32 ml_dotProduct_vec3f(f32[3], f32[3]);
#define VIEWPORT_FOVY_DEFAULT (40.0f)
#define VIEWPORT_STACK_SIZE (8)
/* .data */
f32 s_viewport_fovy = VIEWPORT_FOVY_DEFAULT; //fovy
f32 s_viewport_aspect = 1.35185182f; //aspect
f32 s_viewport_near = 30.0f; //near
f32 s_viewport_far = 4000.0f; //far
f32 sViewportFOVy = VIEWPORT_FOVY_DEFAULT;
f32 sViewportAspect = 1.35185182f;
f32 sViewportNear = 30.0f;
f32 sViewportFar = 4000.0f;
f32 sViewportLookVector[3];
f32 sViewportPosition[3];
f32 sViewportRotation[3];
f32 sViewportUnused1; // debug?
f32 sViewportFrustumPlanes[4][4];
Vp sViewportStack[VIEWPORT_STACK_SIZE];
int sViewportUnused2; // debug?
MtxF sViewportMatrix;
MtxF sViewportDefaultMatrix;
s32 sViewportStackIndex;
/* .data */
f32 D_80280EA0[3];
f32 viewportPosition[3];
f32 viewportRotation[3];
f32 D_80280ECC;
f32 D_80280ED0[4][4];
Vp s_viewport_stack[8];
int D_80280F90;
MtxF D_80280F98;
MtxF D_80280FD8;
s32 s_viewport_stack_index; //viewport indx
void viewport_moveAlongZAxis(f32 offset) {
f32 delta_position[3];
func_80256E24(delta_position, sViewportRotation[0], sViewportRotation[1], 0.0f, 0.0f, offset);
void func_8024F450(void);
void func_8024F4AC(void);
void func_8024C964(Gfx **, Mtx **, f32, f32);
void func_8024CD7C(int);
void viewport_set_position_f3(f32, f32, f32);
void viewport_set_rotation_f3(f32, f32, f32);
void viewport_set_near_far(f32, f32);
void func_8024CE74(s32 arg0, s32 arg1, s32 arg2, s32 arg3);
void viewport_set_field_of_view(f32);
void func_80256E24(f32 [3], f32, f32, f32, f32, f32);
/* .code */
void func_8024C510(f32 arg0){
f32 sp24[3];
func_80256E24(sp24, viewportRotation[0], viewportRotation[1], 0.0f, 0.0f, arg0);
viewportPosition[0] += sp24[0];
viewportPosition[1] += sp24[1];
viewportPosition[2] += sp24[2];
sViewportPosition[0] += delta_position[0];
sViewportPosition[1] += delta_position[1];
sViewportPosition[2] += delta_position[2];
}
f32 viewport_getDistance(f32 arg0[3]){
ml_distance_vec3f(arg0, viewportPosition);
f32 viewport_getDistance(f32 arg0[3]) {
ml_distance_vec3f(arg0, sViewportPosition);
}
void func_8024C5A8(f32 arg0[3]){
ml_vec3f_copy(arg0, D_80280EA0);
void viewport_getLookVector(f32 arg0[3]) {
ml_vec3f_copy(arg0, sViewportLookVector);
}
void viewport_get_position_vec3f(f32 arg0[3]){
ml_vec3f_copy(arg0, viewportPosition);
void viewport_getPosition_vec3f(f32 arg0[3]) {
ml_vec3f_copy(arg0, sViewportPosition);
}
void veiwport_get_position_vec3w(s32 dst[3]){
dst[0] = ((f32)(s32)(viewportPosition[0]*500.0))/500.0;
dst[1] = ((f32)(s32)(viewportPosition[1]*500.0))/500.0;
dst[2] = ((f32)(s32)(viewportPosition[2]*500.0))/500.0;
void viewport_getPosition_vec3w(s32 dst[3]) {
dst[0] = ((f32)(s32)(sViewportPosition[0] * 500.0)) / 500.0;
dst[1] = ((f32)(s32)(sViewportPosition[1] * 500.0)) / 500.0;
dst[2] = ((f32)(s32)(sViewportPosition[2] * 500.0)) / 500.0;
}
void veiwport_get_position_vec3s(s16 dst[3]){
dst[0] = ((f32)(s32)(viewportPosition[0]*500.0))/500.0;
dst[1] = ((f32)(s32)(viewportPosition[1]*500.0))/500.0;
dst[2] = ((f32)(s32)(viewportPosition[2]*500.0))/500.0;
void viewport_getPosition_vec3s(s16 dst[3]) {
dst[0] = ((f32)(s32)(sViewportPosition[0] * 500.0)) / 500.0;
dst[1] = ((f32)(s32)(sViewportPosition[1] * 500.0)) / 500.0;
dst[2] = ((f32)(s32)(sViewportPosition[2] * 500.0)) / 500.0;
}
void viewport_get_rotation_vec3f(f32 arg0[3]){
ml_vec3f_copy(arg0, viewportRotation);
void viewport_getRotation_vec3f(f32 arg0[3]) {
ml_vec3f_copy(arg0, sViewportRotation);
}
f32 viewport_get_yaw(void){
return viewportRotation[1];
f32 viewport_getYaw(void) {
return sViewportRotation[1];
}
void viewport_get_rotation_f3(f32 *pitch, f32 *yaw, f32 *roll){
*pitch = viewportRotation[0];
*yaw = viewportRotation[1];
*roll = viewportRotation[2];
void viewport_getRotation_f3(f32 *pitch, f32 *yaw, f32 *roll) {
*pitch = sViewportRotation[0];
*yaw = sViewportRotation[1];
*roll = sViewportRotation[2];
}
void func_8024C7B8(Gfx **gfx, Mtx **mtx){
gSPViewport((*gfx)++, &s_viewport_stack[s_viewport_stack_index]);
void viewport_setRenderViewportAndOrthoMatrix(Gfx **gfx, Mtx **mtx) {
gSPViewport((*gfx)++, &sViewportStack[sViewportStackIndex]);
guOrtho(*mtx, -(2*(f32)framebuffer_width), (2*(f32)framebuffer_width), -(2*(f32)framebuffer_height), (2*(f32)framebuffer_height), 1.0f, 20.0f, 1.0f);
gSPMatrix((*gfx)++, OS_K0_TO_PHYSICAL((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
@@ -99,421 +84,457 @@ void func_8024C7B8(Gfx **gfx, Mtx **mtx){
gSPMatrix((*gfx)++, OS_K0_TO_PHYSICAL((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
}
void func_8024C904(Gfx **gfx, Mtx **mtx){
gSPViewport((*gfx)++, &s_viewport_stack[s_viewport_stack_index]);
func_8024C964(gfx, mtx, s_viewport_near, s_viewport_far);
void viewport_setRenderViewportAndPerspectiveMatrix(Gfx **gfx, Mtx **mtx) {
gSPViewport((*gfx)++, &sViewportStack[sViewportStackIndex]);
viewport_setRenderPerspectiveMatrix(gfx, mtx, sViewportNear, sViewportFar);
}
void func_8024C964(Gfx **gfx, Mtx **mtx, f32 near, f32 far){
u16 sp5e;
void viewport_setRenderPerspectiveMatrix(Gfx **gfx, Mtx **mtx, f32 near, f32 far) {
u16 perspNorm;
near = MAX(s_viewport_near, near);
far = MIN(s_viewport_far, far);
near = MAX(sViewportNear, near);
far = MIN(sViewportFar, far);
if(*(u32*)OS_PHYSICAL_TO_K1(0x1D8) + 0x53D4FFF0){
near = 750.0f;
if(*(u32*)OS_PHYSICAL_TO_K1(0x1D8) + 0x53D4FFF0) { // what's this?
near = 750.0f;
far = 1250.0f;
}
guPerspective(*mtx, &sp5e, s_viewport_fovy, s_viewport_aspect, near, far, 0.5f);
gSPPerspNormalize((*gfx)++, sp5e);
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, -viewportRotation[2], 0.0f, 0.0f, -1.0f);
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, -viewportRotation[0], 1.0f, 0.0f, 0.0f);
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, -viewportRotation[1], 0.0f, 1.0f, 0.0f);
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);
}
void func_8024CBD4(Gfx **gfx, Mtx **mtx){
func_8024C964(gfx, mtx, s_viewport_near, s_viewport_far);
void viewport_setRenderPerspectiveMatrixDefaultNearAndFar(Gfx **gfx, Mtx **mtx) {
viewport_setRenderPerspectiveMatrix(gfx, mtx, sViewportNear, sViewportFar);
}
void viewport_debug(void){}
void viewport_debug(void) {}
void func_8024CC08(f32 arg0){
if(90.0f < arg0) arg0 = 90.0f;
if(arg0 < 5.0f) arg0 = 10.0f;
D_80280ECC = arg0;
void viewport_debug2(f32 arg0) {
if (90.0f < arg0) arg0 = 90.0f;
if (arg0 < 5.0f) arg0 = 10.0f;
sViewportUnused1 = arg0;
}
f32 func_8024CC50(void){
return D_80280ECC;
f32 viewport_debug3(void) {
return sViewportUnused1;
}
void func_8024CC5C(void){
func_8024CE74((s32) ((f32)framebuffer_width/2), (s32) ((f32)framebuffer_height/2), (s32) ((f32)framebuffer_width/2), (s32) ((f32)framebuffer_height/2));
void viewport_pushFramebufferExtendsToVpStack(void) {
viewport_pushVpScaleAndTranslation((s32) ((f32)framebuffer_width/2), (s32) ((f32)framebuffer_height/2), (s32) ((f32)framebuffer_width/2), (s32) ((f32)framebuffer_height/2));
}
void viewport_reset(void){
func_8024CD7C(1);
viewport_set_position_f3(0.0f, 0.0f, 0.0f);
viewport_set_rotation_f3(0.0f, 0.0f, 0.0f);
func_8024CC08(40.0f);
viewport_set_near_far(1.0f, 10000.0f);
func_8024CC5C();
viewport_set_field_of_view(VIEWPORT_FOVY_DEFAULT);
void viewport_reset(void) {
viewport_debug4(1);
viewport_setPosition_f3(0.0f, 0.0f, 0.0f);
viewport_setRotation_f3(0.0f, 0.0f, 0.0f);
viewport_debug2(40.0f);
viewport_setNearAndFar(1.0f, 10000.0f);
viewport_pushFramebufferExtendsToVpStack();
viewport_setFOVy(VIEWPORT_FOVY_DEFAULT);
mlMtxIdent();
mlMtxRotYaw(-60.0f);
mlMtxRotPitch(-90.0f);
mlMtxGet(&D_80280FD8);
mlMtxGet(&sViewportDefaultMatrix);
}
void func_8024CD7C(int arg0){
D_80280F90 = arg0;
void viewport_debug4(int arg0) {
sViewportUnused2 = arg0;
}
void viewport_set_position_vec3f(f32 src[3]){
ml_vec3f_copy(viewportPosition, src);
void viewport_setPosition_vec3f(f32 src[3]) {
ml_vec3f_copy(sViewportPosition, src);
}
void viewport_set_position_vec3w(s32 src[3]){
viewportPosition[0] = (f32)src[0];
viewportPosition[1] = (f32)src[1];
viewportPosition[2] = (f32)src[2];
void viewport_setPosition_vec3w(s32 src[3]) {
sViewportPosition[0] = (f32)src[0];
sViewportPosition[1] = (f32)src[1];
sViewportPosition[2] = (f32)src[2];
}
void viewport_set_position_f3(f32 x, f32 y, f32 z){
viewportPosition[0] = x;
viewportPosition[1] = y;
viewportPosition[2] = z;
void viewport_setPosition_f3(f32 x, f32 y, f32 z) {
sViewportPosition[0] = x;
sViewportPosition[1] = y;
sViewportPosition[2] = z;
}
void viewport_set_rotation_vec3f(f32 src[3]){
ml_vec3f_copy(viewportRotation, src);
void viewport_setRotation_vec3f(f32 src[3]) {
ml_vec3f_copy(sViewportRotation, src);
}
void viewport_set_rotation_f3(f32 pitch, f32 yaw, f32 roll){
viewportRotation[0] = pitch;
viewportRotation[1] = yaw;
viewportRotation[2] = roll;
void viewport_setRotation_f3(f32 pitch, f32 yaw, f32 roll) {
sViewportRotation[0] = pitch;
sViewportRotation[1] = yaw;
sViewportRotation[2] = roll;
}
void viewport_set_near_far(f32 near, f32 far){
s_viewport_near = near;
s_viewport_far = far;
void viewport_setNearAndFar(f32 near, f32 far) {
sViewportNear = near;
sViewportFar = far;
}
void func_8024CE74(s32 arg0, s32 arg1, s32 arg2, s32 arg3){
s_viewport_stack_index = (s_viewport_stack_index + 1) % 8;
s_viewport_stack[s_viewport_stack_index].vp.vscale[0] = arg0 << 2;
s_viewport_stack[s_viewport_stack_index].vp.vscale[1] = arg1 << 2;
s_viewport_stack[s_viewport_stack_index].vp.vscale[2] = 0x1ff;
s_viewport_stack[s_viewport_stack_index].vp.vscale[3] = 0;
s_viewport_stack[s_viewport_stack_index].vp.vtrans[0] = arg2 << 2;
s_viewport_stack[s_viewport_stack_index].vp.vtrans[1] = arg3 << 2;
s_viewport_stack[s_viewport_stack_index].vp.vtrans[2] = 0x1ff;
s_viewport_stack[s_viewport_stack_index].vp.vtrans[3] = 0;
osWritebackDCache(&s_viewport_stack[s_viewport_stack_index], sizeof(Vp)*8);
void viewport_pushVpScaleAndTranslation(s32 scale_x, s32 scale_y, s32 translation_x, s32 translation_y) {
sViewportStackIndex = (sViewportStackIndex + 1) % 8;
sViewportStack[sViewportStackIndex].vp.vscale[0] = scale_x << 2;
sViewportStack[sViewportStackIndex].vp.vscale[1] = scale_y << 2;
sViewportStack[sViewportStackIndex].vp.vscale[2] = 0x1ff;
sViewportStack[sViewportStackIndex].vp.vscale[3] = 0;
sViewportStack[sViewportStackIndex].vp.vtrans[0] = translation_x << 2;
sViewportStack[sViewportStackIndex].vp.vtrans[1] = translation_y << 2;
sViewportStack[sViewportStackIndex].vp.vtrans[2] = 0x1ff;
sViewportStack[sViewportStackIndex].vp.vtrans[3] = 0;
osWritebackDCache(&sViewportStack[sViewportStackIndex], VIEWPORT_STACK_SIZE * sizeof(Vp));
}
void func_8024CF10(f32 arg0, f32 arg1, f32 arg2, f32 arg3){
s_viewport_stack_index = (s_viewport_stack_index + 1) % 8;
s_viewport_stack[s_viewport_stack_index].vp.vscale[0] = arg0*4;
s_viewport_stack[s_viewport_stack_index].vp.vscale[1] = arg1*4;
s_viewport_stack[s_viewport_stack_index].vp.vscale[2] = 0x1ff;
s_viewport_stack[s_viewport_stack_index].vp.vscale[3] = 0;
s_viewport_stack[s_viewport_stack_index].vp.vtrans[0] = arg2*4;
s_viewport_stack[s_viewport_stack_index].vp.vtrans[1] = arg3*4;
s_viewport_stack[s_viewport_stack_index].vp.vtrans[2] = 0x1ff;
s_viewport_stack[s_viewport_stack_index].vp.vtrans[3] = 0;
osWritebackDCache(&s_viewport_stack[s_viewport_stack_index], sizeof(Vp)*8);
void viewport_unused_pushVpScaleAndTranslation(f32 scale_x, f32 scale_y, f32 translation_x, f32 translation_y) {
sViewportStackIndex = (sViewportStackIndex + 1) % 8;
sViewportStack[sViewportStackIndex].vp.vscale[0] = scale_x * 4;
sViewportStack[sViewportStackIndex].vp.vscale[1] = scale_y * 4;
sViewportStack[sViewportStackIndex].vp.vscale[2] = 0x1ff;
sViewportStack[sViewportStackIndex].vp.vscale[3] = 0;
sViewportStack[sViewportStackIndex].vp.vtrans[0] = translation_x * 4;
sViewportStack[sViewportStackIndex].vp.vtrans[1] = translation_y * 4;
sViewportStack[sViewportStackIndex].vp.vtrans[2] = 0x1ff;
sViewportStack[sViewportStackIndex].vp.vtrans[3] = 0;
osWritebackDCache(&sViewportStack[sViewportStackIndex], VIEWPORT_STACK_SIZE * sizeof(Vp));
}
void viewport_update(void){
func_80256E24(D_80280ED0[0], viewportRotation[0], viewportRotation[1], -89.21774f, 0.0f, 45.168514251708984f);
func_80256E24(D_80280ED0[1], viewportRotation[0], viewportRotation[1], 89.21774f, 0.0f, 45.168514251708984f);
func_80256E24(D_80280ED0[2], viewportRotation[0], viewportRotation[1], 0.0f, 93.9692611694336f, 34.20201110839844f);
func_80256E24(D_80280ED0[3], viewportRotation[0], viewportRotation[1], 0.0f, -93.9692611694336f, 34.20201110839844f);
ml_vec3f_normalize(D_80280ED0[0]);
ml_vec3f_normalize(D_80280ED0[1]);
ml_vec3f_normalize(D_80280ED0[2]);
ml_vec3f_normalize(D_80280ED0[3]);
D_80280ED0[0][3] = -(viewportPosition[0]*D_80280ED0[0][0] + viewportPosition[1]*D_80280ED0[0][1] + viewportPosition[2]*D_80280ED0[0][2]);
D_80280ED0[1][3] = -(viewportPosition[0]*D_80280ED0[1][0] + viewportPosition[1]*D_80280ED0[1][1] + viewportPosition[2]*D_80280ED0[1][2]);
D_80280ED0[2][3] = -(viewportPosition[0]*D_80280ED0[2][0] + viewportPosition[1]*D_80280ED0[2][1] + viewportPosition[2]*D_80280ED0[2][2]);
D_80280ED0[3][3] = -(viewportPosition[0]*D_80280ED0[3][0] + viewportPosition[1]*D_80280ED0[3][1] + viewportPosition[2]*D_80280ED0[3][2]);
void viewport_update(void) {
func_80256E24(sViewportFrustumPlanes[0], sViewportRotation[0], sViewportRotation[1], -89.21774f, 0.0f, 45.168514251708984f);
func_80256E24(sViewportFrustumPlanes[1], sViewportRotation[0], sViewportRotation[1], 89.21774f, 0.0f, 45.168514251708984f);
func_80256E24(sViewportFrustumPlanes[2], sViewportRotation[0], sViewportRotation[1], 0.0f, 93.9692611694336f, 34.20201110839844f);
func_80256E24(sViewportFrustumPlanes[3], sViewportRotation[0], sViewportRotation[1], 0.0f, -93.9692611694336f, 34.20201110839844f);
ml_vec3f_normalize(sViewportFrustumPlanes[0]);
ml_vec3f_normalize(sViewportFrustumPlanes[1]);
ml_vec3f_normalize(sViewportFrustumPlanes[2]);
ml_vec3f_normalize(sViewportFrustumPlanes[3]);
sViewportFrustumPlanes[0][3] = -(sViewportPosition[0]*sViewportFrustumPlanes[0][0] + sViewportPosition[1]*sViewportFrustumPlanes[0][1] + sViewportPosition[2]*sViewportFrustumPlanes[0][2]);
sViewportFrustumPlanes[1][3] = -(sViewportPosition[0]*sViewportFrustumPlanes[1][0] + sViewportPosition[1]*sViewportFrustumPlanes[1][1] + sViewportPosition[2]*sViewportFrustumPlanes[1][2]);
sViewportFrustumPlanes[2][3] = -(sViewportPosition[0]*sViewportFrustumPlanes[2][0] + sViewportPosition[1]*sViewportFrustumPlanes[2][1] + sViewportPosition[2]*sViewportFrustumPlanes[2][2]);
sViewportFrustumPlanes[3][3] = -(sViewportPosition[0]*sViewportFrustumPlanes[3][0] + sViewportPosition[1]*sViewportFrustumPlanes[3][1] + sViewportPosition[2]*sViewportFrustumPlanes[3][2]);
mlMtxIdent();
mlMtxRotYaw(viewportRotation[1]);
mlMtxRotPitch(viewportRotation[0]);
mlMtxGet(&D_80280F98);
D_80280EA0[0] = 0.0f;
D_80280EA0[1] = 0.0f;
D_80280EA0[2] = -1.0f;
func_8025235C(D_80280EA0, D_80280EA0);
mlMtxRotYaw(sViewportRotation[1]);
mlMtxRotPitch(sViewportRotation[0]);
mlMtxGet(&sViewportMatrix);
sViewportLookVector[0] = 0.0f;
sViewportLookVector[1] = 0.0f;
sViewportLookVector[2] = -1.0f;
func_8025235C(sViewportLookVector, sViewportLookVector);
}
void func_8024D1EC(f32 arg0[4], f32 arg1[4], f32 arg2[4], f32 arg3[4]){
void viewport_getFrustumPlanes(f32 arg0[4], f32 arg1[4], f32 arg2[4], f32 arg3[4]) {
s32 i;
for(i = 0; i < 4; i++){
arg0[i] = D_80280ED0[0][i];
arg1[i] = D_80280ED0[1][i];
arg2[i] = D_80280ED0[2][i];
arg3[i] = D_80280ED0[3][i];
arg0[i] = sViewportFrustumPlanes[0][i];
arg1[i] = sViewportFrustumPlanes[1][i];
arg2[i] = sViewportFrustumPlanes[2][i];
arg3[i] = sViewportFrustumPlanes[3][i];
}
}
void func_8024D2B0(f32 arg0[4], f32 arg1[4], f32 arg2[4], f32 arg3[4]){
void viewport_setFrustumPlanes(f32 arg0[4], f32 arg1[4], f32 arg2[4], f32 arg3[4]) {
s32 i;
for(i = 0; i < 4; i++){
D_80280ED0[0][i] = arg0[i];
D_80280ED0[1][i] = arg1[i];
D_80280ED0[2][i] = arg2[i];
D_80280ED0[3][i] = arg3[i];
for(i = 0; i < 4; i++) {
sViewportFrustumPlanes[0][i] = arg0[i];
sViewportFrustumPlanes[1][i] = arg1[i];
sViewportFrustumPlanes[2][i] = arg2[i];
sViewportFrustumPlanes[3][i] = arg3[i];
}
}
bool func_8024D374(f32 arg0[3], f32 arg1[3]) {
bool viewport_isBoundingBoxInFrustum(f32 min[3], f32 max[3]) {
if ((D_80280ED0[0][0] * arg0[0] + D_80280ED0[0][1] * arg0[1] + D_80280ED0[0][2] * arg0[2] + D_80280ED0[0][3]) >= 0.0f)
if ((D_80280ED0[0][0] * arg0[0] + D_80280ED0[0][1] * arg0[1] + D_80280ED0[0][2] * arg1[2] + D_80280ED0[0][3]) >= 0.0f)
if ((D_80280ED0[0][0] * arg0[0] + D_80280ED0[0][1] * arg1[1] + D_80280ED0[0][2] * arg0[2] + D_80280ED0[0][3]) >= 0.0f)
if ((D_80280ED0[0][0] * arg0[0] + D_80280ED0[0][1] * arg1[1] + D_80280ED0[0][2] * arg1[2] + D_80280ED0[0][3]) >= 0.0f)
if ((D_80280ED0[0][0] * arg1[0] + D_80280ED0[0][1] * arg0[1] + D_80280ED0[0][2] * arg0[2] + D_80280ED0[0][3]) >= 0.0f)
if ((D_80280ED0[0][0] * arg1[0] + D_80280ED0[0][1] * arg0[1] + D_80280ED0[0][2] * arg1[2] + D_80280ED0[0][3]) >= 0.0f)
if ((D_80280ED0[0][0] * arg1[0] + D_80280ED0[0][1] * arg1[1] + D_80280ED0[0][2] * arg0[2] + D_80280ED0[0][3]) >= 0.0f)
if ((D_80280ED0[0][0] * arg1[0] + D_80280ED0[0][1] * arg1[1] + D_80280ED0[0][2] * arg1[2] + D_80280ED0[0][3]) >= 0.0f)
return 0;
if ((D_80280ED0[1][0] * arg0[0] + D_80280ED0[1][1] * arg0[1] + D_80280ED0[1][2] * arg0[2] + D_80280ED0[1][3]) >= 0.0f)
if ((D_80280ED0[1][0] * arg0[0] + D_80280ED0[1][1] * arg0[1] + D_80280ED0[1][2] * arg1[2] + D_80280ED0[1][3]) >= 0.0f)
if ((D_80280ED0[1][0] * arg0[0] + D_80280ED0[1][1] * arg1[1] + D_80280ED0[1][2] * arg0[2] + D_80280ED0[1][3]) >= 0.0f)
if ((D_80280ED0[1][0] * arg0[0] + D_80280ED0[1][1] * arg1[1] + D_80280ED0[1][2] * arg1[2] + D_80280ED0[1][3]) >= 0.0f)
if ((D_80280ED0[1][0] * arg1[0] + D_80280ED0[1][1] * arg0[1] + D_80280ED0[1][2] * arg0[2] + D_80280ED0[1][3]) >= 0.0f)
if ((D_80280ED0[1][0] * arg1[0] + D_80280ED0[1][1] * arg0[1] + D_80280ED0[1][2] * arg1[2] + D_80280ED0[1][3]) >= 0.0f)
if ((D_80280ED0[1][0] * arg1[0] + D_80280ED0[1][1] * arg1[1] + D_80280ED0[1][2] * arg0[2] + D_80280ED0[1][3]) >= 0.0f)
if ((D_80280ED0[1][0] * arg1[0] + D_80280ED0[1][1] * arg1[1] + D_80280ED0[1][2] * arg1[2] + D_80280ED0[1][3]) >= 0.0f)
return 0;
if ((D_80280ED0[2][0] * arg0[0] + D_80280ED0[2][1] * arg0[1] + D_80280ED0[2][2] * arg0[2] + D_80280ED0[2][3]) >= 0.0f)
if ((D_80280ED0[2][0] * arg0[0] + D_80280ED0[2][1] * arg0[1] + D_80280ED0[2][2] * arg1[2] + D_80280ED0[2][3]) >= 0.0f)
if ((D_80280ED0[2][0] * arg0[0] + D_80280ED0[2][1] * arg1[1] + D_80280ED0[2][2] * arg0[2] + D_80280ED0[2][3]) >= 0.0f)
if ((D_80280ED0[2][0] * arg0[0] + D_80280ED0[2][1] * arg1[1] + D_80280ED0[2][2] * arg1[2] + D_80280ED0[2][3]) >= 0.0f)
if ((D_80280ED0[2][0] * arg1[0] + D_80280ED0[2][1] * arg0[1] + D_80280ED0[2][2] * arg0[2] + D_80280ED0[2][3]) >= 0.0f)
if ((D_80280ED0[2][0] * arg1[0] + D_80280ED0[2][1] * arg0[1] + D_80280ED0[2][2] * arg1[2] + D_80280ED0[2][3]) >= 0.0f)
if ((D_80280ED0[2][0] * arg1[0] + D_80280ED0[2][1] * arg1[1] + D_80280ED0[2][2] * arg0[2] + D_80280ED0[2][3]) >= 0.0f)
if ((D_80280ED0[2][0] * arg1[0] + D_80280ED0[2][1] * arg1[1] + D_80280ED0[2][2] * arg1[2] + D_80280ED0[2][3]) >= 0.0f)
return 0;
if ((D_80280ED0[3][0] * arg0[0] + D_80280ED0[3][1] * arg0[1] + D_80280ED0[3][2] * arg0[2] + D_80280ED0[3][3]) >= 0.0f)
if ((D_80280ED0[3][0] * arg0[0] + D_80280ED0[3][1] * arg0[1] + D_80280ED0[3][2] * arg1[2] + D_80280ED0[3][3]) >= 0.0f)
if ((D_80280ED0[3][0] * arg0[0] + D_80280ED0[3][1] * arg1[1] + D_80280ED0[3][2] * arg0[2] + D_80280ED0[3][3]) >= 0.0f)
if ((D_80280ED0[3][0] * arg0[0] + D_80280ED0[3][1] * arg1[1] + D_80280ED0[3][2] * arg1[2] + D_80280ED0[3][3]) >= 0.0f)
if ((D_80280ED0[3][0] * arg1[0] + D_80280ED0[3][1] * arg0[1] + D_80280ED0[3][2] * arg0[2] + D_80280ED0[3][3]) >= 0.0f)
if ((D_80280ED0[3][0] * arg1[0] + D_80280ED0[3][1] * arg0[1] + D_80280ED0[3][2] * arg1[2] + D_80280ED0[3][3]) >= 0.0f)
if ((D_80280ED0[3][0] * arg1[0] + D_80280ED0[3][1] * arg1[1] + D_80280ED0[3][2] * arg0[2] + D_80280ED0[3][3]) >= 0.0f)
if ((D_80280ED0[3][0] * arg1[0] + D_80280ED0[3][1] * arg1[1] + D_80280ED0[3][2] * arg1[2] + D_80280ED0[3][3]) >= 0.0f)
return 0;
return 1;
}
bool func_8024D8F4(Cube *cube) {
f32 sp24[3];
f32 sp18[3];
sp24[0] = (f32) ((cube->x * 1000) - 150);
sp24[1] = (f32) ((cube->y * 1000) - 150);
sp24[2] = (f32) ((cube->z * 1000) - 150);
sp18[0] = sp24[0] + 1300.0f;
sp18[1] = sp24[1] + 1300.0f;
sp18[2] = sp24[2] + 1300.0f;
return func_8024D374(sp24, sp18);
}
bool func_8024D9B0(Cube *cube) {
f32 sp34[3];
f32 sp28[3];
f32 sp1C[3];
if (cube->x == -0x10) {
return TRUE;
}
sp1C[0] = (f32) ((cube->x * 1000) + 500) - viewportPosition[0];
sp1C[1] = (f32) ((cube->y * 1000) + 500) - viewportPosition[1];
sp1C[2] = (f32) ((cube->z * 1000) + 500) - viewportPosition[2];
if (LENGTH_SQ_VEC3F(sp1C) > 1.6e7f) {
if (((sViewportFrustumPlanes[0][0] * min[0] + sViewportFrustumPlanes[0][1] * min[1] + sViewportFrustumPlanes[0][2] * min[2] + sViewportFrustumPlanes[0][3]) >= 0.0f) &&
((sViewportFrustumPlanes[0][0] * min[0] + sViewportFrustumPlanes[0][1] * min[1] + sViewportFrustumPlanes[0][2] * max[2] + sViewportFrustumPlanes[0][3]) >= 0.0f) &&
((sViewportFrustumPlanes[0][0] * min[0] + sViewportFrustumPlanes[0][1] * max[1] + sViewportFrustumPlanes[0][2] * min[2] + sViewportFrustumPlanes[0][3]) >= 0.0f) &&
((sViewportFrustumPlanes[0][0] * min[0] + sViewportFrustumPlanes[0][1] * max[1] + sViewportFrustumPlanes[0][2] * max[2] + sViewportFrustumPlanes[0][3]) >= 0.0f) &&
((sViewportFrustumPlanes[0][0] * max[0] + sViewportFrustumPlanes[0][1] * min[1] + sViewportFrustumPlanes[0][2] * min[2] + sViewportFrustumPlanes[0][3]) >= 0.0f) &&
((sViewportFrustumPlanes[0][0] * max[0] + sViewportFrustumPlanes[0][1] * min[1] + sViewportFrustumPlanes[0][2] * max[2] + sViewportFrustumPlanes[0][3]) >= 0.0f) &&
((sViewportFrustumPlanes[0][0] * max[0] + sViewportFrustumPlanes[0][1] * max[1] + sViewportFrustumPlanes[0][2] * min[2] + sViewportFrustumPlanes[0][3]) >= 0.0f) &&
((sViewportFrustumPlanes[0][0] * max[0] + sViewportFrustumPlanes[0][1] * max[1] + sViewportFrustumPlanes[0][2] * max[2] + sViewportFrustumPlanes[0][3]) >= 0.0f))
return FALSE;
}
sp34[0] = (f32) ((cube->x * 1000) - 150);
sp34[1] = (f32) ((cube->y * 1000) - 150);
sp34[2] = (f32) ((cube->z * 1000) - 150);
sp28[0] = sp34[0] + 1300.0f;
sp28[1] = sp34[1] + 1300.0f;
sp28[2] = sp34[2] + 1300.0f;
return func_8024D374(sp34, sp28);
}
bool func_8024DB50(f32 arg0[3], f32 arg1) {
f32 delta[3];
s32 i;
if (((sViewportFrustumPlanes[1][0] * min[0] + sViewportFrustumPlanes[1][1] * min[1] + sViewportFrustumPlanes[1][2] * min[2] + sViewportFrustumPlanes[1][3]) >= 0.0f) &&
((sViewportFrustumPlanes[1][0] * min[0] + sViewportFrustumPlanes[1][1] * min[1] + sViewportFrustumPlanes[1][2] * max[2] + sViewportFrustumPlanes[1][3]) >= 0.0f) &&
((sViewportFrustumPlanes[1][0] * min[0] + sViewportFrustumPlanes[1][1] * max[1] + sViewportFrustumPlanes[1][2] * min[2] + sViewportFrustumPlanes[1][3]) >= 0.0f) &&
((sViewportFrustumPlanes[1][0] * min[0] + sViewportFrustumPlanes[1][1] * max[1] + sViewportFrustumPlanes[1][2] * max[2] + sViewportFrustumPlanes[1][3]) >= 0.0f) &&
((sViewportFrustumPlanes[1][0] * max[0] + sViewportFrustumPlanes[1][1] * min[1] + sViewportFrustumPlanes[1][2] * min[2] + sViewportFrustumPlanes[1][3]) >= 0.0f) &&
((sViewportFrustumPlanes[1][0] * max[0] + sViewportFrustumPlanes[1][1] * min[1] + sViewportFrustumPlanes[1][2] * max[2] + sViewportFrustumPlanes[1][3]) >= 0.0f) &&
((sViewportFrustumPlanes[1][0] * max[0] + sViewportFrustumPlanes[1][1] * max[1] + sViewportFrustumPlanes[1][2] * min[2] + sViewportFrustumPlanes[1][3]) >= 0.0f) &&
((sViewportFrustumPlanes[1][0] * max[0] + sViewportFrustumPlanes[1][1] * max[1] + sViewportFrustumPlanes[1][2] * max[2] + sViewportFrustumPlanes[1][3]) >= 0.0f))
return FALSE;
if (((sViewportFrustumPlanes[2][0] * min[0] + sViewportFrustumPlanes[2][1] * min[1] + sViewportFrustumPlanes[2][2] * min[2] + sViewportFrustumPlanes[2][3]) >= 0.0f) &&
((sViewportFrustumPlanes[2][0] * min[0] + sViewportFrustumPlanes[2][1] * min[1] + sViewportFrustumPlanes[2][2] * max[2] + sViewportFrustumPlanes[2][3]) >= 0.0f) &&
((sViewportFrustumPlanes[2][0] * min[0] + sViewportFrustumPlanes[2][1] * max[1] + sViewportFrustumPlanes[2][2] * min[2] + sViewportFrustumPlanes[2][3]) >= 0.0f) &&
((sViewportFrustumPlanes[2][0] * min[0] + sViewportFrustumPlanes[2][1] * max[1] + sViewportFrustumPlanes[2][2] * max[2] + sViewportFrustumPlanes[2][3]) >= 0.0f) &&
((sViewportFrustumPlanes[2][0] * max[0] + sViewportFrustumPlanes[2][1] * min[1] + sViewportFrustumPlanes[2][2] * min[2] + sViewportFrustumPlanes[2][3]) >= 0.0f) &&
((sViewportFrustumPlanes[2][0] * max[0] + sViewportFrustumPlanes[2][1] * min[1] + sViewportFrustumPlanes[2][2] * max[2] + sViewportFrustumPlanes[2][3]) >= 0.0f) &&
((sViewportFrustumPlanes[2][0] * max[0] + sViewportFrustumPlanes[2][1] * max[1] + sViewportFrustumPlanes[2][2] * min[2] + sViewportFrustumPlanes[2][3]) >= 0.0f) &&
((sViewportFrustumPlanes[2][0] * max[0] + sViewportFrustumPlanes[2][1] * max[1] + sViewportFrustumPlanes[2][2] * max[2] + sViewportFrustumPlanes[2][3]) >= 0.0f))
return FALSE;
if (((sViewportFrustumPlanes[3][0] * min[0] + sViewportFrustumPlanes[3][1] * min[1] + sViewportFrustumPlanes[3][2] * min[2] + sViewportFrustumPlanes[3][3]) >= 0.0f) &&
((sViewportFrustumPlanes[3][0] * min[0] + sViewportFrustumPlanes[3][1] * min[1] + sViewportFrustumPlanes[3][2] * max[2] + sViewportFrustumPlanes[3][3]) >= 0.0f) &&
((sViewportFrustumPlanes[3][0] * min[0] + sViewportFrustumPlanes[3][1] * max[1] + sViewportFrustumPlanes[3][2] * min[2] + sViewportFrustumPlanes[3][3]) >= 0.0f) &&
((sViewportFrustumPlanes[3][0] * min[0] + sViewportFrustumPlanes[3][1] * max[1] + sViewportFrustumPlanes[3][2] * max[2] + sViewportFrustumPlanes[3][3]) >= 0.0f) &&
((sViewportFrustumPlanes[3][0] * max[0] + sViewportFrustumPlanes[3][1] * min[1] + sViewportFrustumPlanes[3][2] * min[2] + sViewportFrustumPlanes[3][3]) >= 0.0f) &&
((sViewportFrustumPlanes[3][0] * max[0] + sViewportFrustumPlanes[3][1] * min[1] + sViewportFrustumPlanes[3][2] * max[2] + sViewportFrustumPlanes[3][3]) >= 0.0f) &&
((sViewportFrustumPlanes[3][0] * max[0] + sViewportFrustumPlanes[3][1] * max[1] + sViewportFrustumPlanes[3][2] * min[2] + sViewportFrustumPlanes[3][3]) >= 0.0f) &&
((sViewportFrustumPlanes[3][0] * max[0] + sViewportFrustumPlanes[3][1] * max[1] + sViewportFrustumPlanes[3][2] * max[2] + sViewportFrustumPlanes[3][3]) >= 0.0f))
return FALSE;
delta[0] = arg0[0] - viewportPosition[0];
delta[1] = arg0[1] - viewportPosition[1];
delta[2] = arg0[2] - viewportPosition[2];
for(i = 0; i < 4; i++){
if(arg1 <= ml_dotProduct_vec3f(delta, D_80280ED0[i])){
return FALSE;
}
}
return TRUE;
}
bool viewport_cube_isInFrustum(Cube *cube) {
f32 min[3];
f32 max[3];
bool func_8024DC04(f32 arg0, f32 arg1, f32 arg2) {
if (
(((D_80280ED0[0][0] * arg0) + (D_80280ED0[0][1] * arg1) + (D_80280ED0[0][2] * arg2) + D_80280ED0[0][3]) <= 0.0f)
&& (((D_80280ED0[1][0] * arg0) + (D_80280ED0[1][1] * arg1) + (D_80280ED0[1][2] * arg2) + D_80280ED0[1][3]) <= 0.0f)
&& (((D_80280ED0[2][0] * arg0) + (D_80280ED0[2][1] * arg1) + (D_80280ED0[2][2] * arg2) + D_80280ED0[2][3]) <= 0.0f)
&& (((D_80280ED0[3][0] * arg0) + (D_80280ED0[3][1] * arg1) + (D_80280ED0[3][2] * arg2) + D_80280ED0[3][3]) <= 0.0f)
) {
min[0] = (f32) ((cube->x * 1000) - 150);
min[1] = (f32) ((cube->y * 1000) - 150);
min[2] = (f32) ((cube->z * 1000) - 150);
max[0] = min[0] + 1300.0f;
max[1] = min[1] + 1300.0f;
max[2] = min[2] + 1300.0f;
return viewport_isBoundingBoxInFrustum(min, max);
}
bool viewport_cube_isInFrustum2(Cube *cube) {
f32 min[3];
f32 max[3];
f32 rel_pos[3];
if (cube->x == -16) {
return TRUE;
}
rel_pos[0] = (f32) ((cube->x * 1000) + 500) - sViewportPosition[0];
rel_pos[1] = (f32) ((cube->y * 1000) + 500) - sViewportPosition[1];
rel_pos[2] = (f32) ((cube->z * 1000) + 500) - sViewportPosition[2];
if (LENGTH_SQ_VEC3F(rel_pos) > 1.6e7f) {
return FALSE;
}
min[0] = (f32) ((cube->x * 1000) - 150);
min[1] = (f32) ((cube->y * 1000) - 150);
min[2] = (f32) ((cube->z * 1000) - 150);
max[0] = min[0] + 1300.0f;
max[1] = min[1] + 1300.0f;
max[2] = min[2] + 1300.0f;
return viewport_isBoundingBoxInFrustum(min, max);
}
// viewport_distanceFromPlane ?
bool viewport_func_8024DB50(f32 pos[3], f32 distance) {
f32 delta[3];
s32 i;
delta[0] = pos[0] - sViewportPosition[0];
delta[1] = pos[1] - sViewportPosition[1];
delta[2] = pos[2] - sViewportPosition[2];
for(i = 0; i < 4; i++) {
if(distance <= ml_dotProduct_vec3f(delta, sViewportFrustumPlanes[i])) {
return FALSE;
}
}
return TRUE;
}
bool viewport_isPointOutsideFrustum_3f(f32 x, f32 y, f32 z) {
if ((sViewportFrustumPlanes[0][0] * x + sViewportFrustumPlanes[0][1] * y + sViewportFrustumPlanes[0][2] * z + sViewportFrustumPlanes[0][3] <= 0.0f) &&
(sViewportFrustumPlanes[1][0] * x + sViewportFrustumPlanes[1][1] * y + sViewportFrustumPlanes[1][2] * z + sViewportFrustumPlanes[1][3] <= 0.0f) &&
(sViewportFrustumPlanes[2][0] * x + sViewportFrustumPlanes[2][1] * y + sViewportFrustumPlanes[2][2] * z + sViewportFrustumPlanes[2][3] <= 0.0f) &&
(sViewportFrustumPlanes[3][0] * x + sViewportFrustumPlanes[3][1] * y + sViewportFrustumPlanes[3][2] * z + sViewportFrustumPlanes[3][3] <= 0.0f))
return TRUE;
return FALSE;
}
bool func_8024DD0C(f32 arg0[3]){
return func_8024DC04(arg0[0], arg0[1], arg0[2]);
bool viewport_isPointOutsideFrustum_vec3f(f32 arg0[3]) {
return viewport_isPointOutsideFrustum_3f(arg0[0], arg0[1], arg0[2]);
}
bool func_8024DD34(f32 arg0, f32 arg1, f32 arg2) {
return ((D_80280ED0[2][0]*arg0 + D_80280ED0[2][1]*arg1 + D_80280ED0[2][2]*arg2 + D_80280ED0[2][3]) <= 0.0f);
// need to figure out, what plane 2 is (neg/pos x/y ?)
bool viewport_isPointPlane_3f(f32 arg0, f32 arg1, f32 arg2) {
return ((sViewportFrustumPlanes[2][0]*arg0 + sViewportFrustumPlanes[2][1]*arg1 + sViewportFrustumPlanes[2][2]*arg2 + sViewportFrustumPlanes[2][3]) <= 0.0f);
}
MtxF *func_8024DD90(void){
return &D_80280F98;
MtxF *viewport_getMatrix(void) {
return &sViewportMatrix;
}
MtxF *func_8024DD9C(void){
return &D_80280FD8;
MtxF *viewport_getDefaultMatrix(void) {
return &sViewportDefaultMatrix;
}
f32 viewport_get_field_of_view(void){
return s_viewport_fovy;
f32 viewport_getFOVy(void) {
return sViewportFOVy;
}
void viewport_set_field_of_view(f32 fovy){
s_viewport_fovy = fovy;
void viewport_setFOVy(f32 fovy) {
sViewportFOVy = fovy;
}
f32 viewport_get_aspect_ratio(void){
return s_viewport_aspect;
f32 viewport_getAspectRatio(void) {
return sViewportAspect;
}
f32 viewport_get_near(void){
return s_viewport_near;
f32 viewport_getNear(void) {
return sViewportNear;
}
f32 func_8024DDD8(s32 arg0, f32 arg1){
return mlNormalizeAngle((viewportRotation[1] + arg1) + 90.0);
f32 viewport_adjustAngleToRight(f32 pos[3], f32 angle) {
return mlNormalizeAngle((sViewportRotation[1] + angle) + 90.0);
}
f32 func_8024DE1C(f32 arg0, f32 arg1, f32 arg2[3], f32 arg3[3]) {
f32 viewport_transformCoordinate(f32 x, f32 y, f32 viewport_translation[3], f32 viewport_rotation[3]) {
f32 fovy_rad;
static f32 D_8028101C;
static f32 D_80281020;
static f32 D_80281024;
static f32 fovy;
static f32 near;
static f32 scale;
if ((s_viewport_fovy != D_8028101C) || (s_viewport_near != D_80281020)) {
fovy_rad = (s_viewport_fovy * M_PI) / 360.0;
D_80281024 = (500.0 + s_viewport_near) / (((framebuffer_height / (f32)2) / sinf(fovy_rad)) * cosf(fovy_rad));
D_8028101C = s_viewport_fovy;
D_80281020 = s_viewport_near;
if ((sViewportFOVy != fovy) || (sViewportNear != near)) {
fovy_rad = (sViewportFOVy * M_PI) / 360.0;
scale = (500.0 + sViewportNear) / (((framebuffer_height / (f32)2) / sinf(fovy_rad)) * cosf(fovy_rad));
fovy = sViewportFOVy;
near = sViewportNear;
}
arg0 = arg0 - (framebuffer_width / (f32)2);
arg1 = (framebuffer_height / (f32)2) - arg1;
arg3[0] = viewportRotation[0];
arg3[1] = viewportRotation[1];
arg3[2] = viewportRotation[2];
arg2[0] = arg0 * D_80281024;
arg2[1] = arg1 * D_80281024;
arg2[2] = (-500.0 - s_viewport_near);
ml_vec3f_pitch_rotate_copy(arg2, arg2, arg3[0]);
ml_vec3f_yaw_rotate_copy(arg2, arg2, arg3[1]);
x = x - (framebuffer_width / (f32)2);
y = (framebuffer_height / (f32)2) - y;
viewport_rotation[0] = sViewportRotation[0];
viewport_rotation[1] = sViewportRotation[1];
viewport_rotation[2] = sViewportRotation[2];
viewport_translation[0] = x * scale;
viewport_translation[1] = y * scale;
viewport_translation[2] = (-500.0 - sViewportNear);
ml_vec3f_pitch_rotate_copy(viewport_translation, viewport_translation, viewport_rotation[0]);
ml_vec3f_yaw_rotate_copy(viewport_translation, viewport_translation, viewport_rotation[1]);
arg2[0] += viewportPosition[0];
arg2[1] += viewportPosition[1];
arg2[2] += viewportPosition[2];
return D_80281024;
viewport_translation[0] += sViewportPosition[0];
viewport_translation[1] += sViewportPosition[1];
viewport_translation[2] += sViewportPosition[2];
return scale;
}
f32 D_80281028[3];
f32 D_80281038[3];
f32 D_80281048[3];
f32 D_80281058[3];
f32 D_80281068[3];
f32 D_80281078[3];
f32 D_80281088[3];
MtxF D_80281098;
f32 sViewportBackupPosition[3];
f32 sViewportBackupRotation[3];
f32 sViewportBackupFrustumPlanes[4][4];
f32 sViewportBackupLookVector[3];
MtxF sViewportBackupMatrix;
bool func_8024E030(f32 arg0[3], f32 *arg1)
// ??
bool viewport_func_8024E030(f32 pos[3], f32 *arg1)
{
f32 sp34[3];
f32 delta[3];
f32 temp_f2_2;
f32 temp_f2;
f32 sp28;
sp28 = (s_viewport_fovy * M_PI) / 360.0;
sp34[0] = arg0[0] - viewportPosition[0];
sp34[1] = arg0[1] - viewportPosition[1];
sp34[2] = arg0[2] - viewportPosition[2];
ml_vec3f_yaw_rotate_copy(sp34, sp34, -viewportRotation[1]);
ml_vec3f_pitch_rotate_copy(sp34, sp34, -viewportRotation[0]);
if ((-s_viewport_near) <= sp34[2]) {
return 0;
f32 fovy_radians;
fovy_radians = (sViewportFOVy * M_PI) / 360.0;
delta[0] = pos[0] - sViewportPosition[0];
delta[1] = pos[1] - sViewportPosition[1];
delta[2] = pos[2] - sViewportPosition[2];
ml_vec3f_yaw_rotate_copy(delta, delta, -sViewportRotation[1]);
ml_vec3f_pitch_rotate_copy(delta, delta, -sViewportRotation[0]);
if ((-sViewportNear) <= delta[2]) {
return FALSE;
}
temp_f2 = gu_sqrtf((sp34[1] * sp34[1]) + (sp34[2] * sp34[2])) * sinf(sp28);
temp_f2 = gu_sqrtf((delta[1] * delta[1]) + (delta[2] * delta[2])) * sinf(fovy_radians);
temp_f2_2 = (((f32) framebuffer_width) / ((f32) framebuffer_height)) * temp_f2;
arg1[0] = (f32) (((sp34[0] / temp_f2_2) + 1) * (((f32) framebuffer_width) / 2));
arg1[1] = (f32) ((1 - (sp34[1] / temp_f2)) * (((f32) framebuffer_height) / 2));
arg1[0] = (f32) (((delta[0] / temp_f2_2) + 1) * (((f32) framebuffer_width) / 2));
arg1[1] = (f32) ((1 - (delta[1] / temp_f2)) * (((f32) framebuffer_height) / 2));
if ((arg1[0] < (-((f32) framebuffer_width))) || ((((f32) framebuffer_width) * 2) < arg1[0])) {
return 0;
return FALSE;
}
if ((arg1[1] < (-((f32) framebuffer_height))) || ((((f32) framebuffer_height) * 2) < arg1[1])) {
return 0;
return FALSE;
}
return 1;
return TRUE;
}
void func_8024E258(void){
void viewport_backupState(void) {
s32 i, j;
viewport_get_position_vec3f(D_80281028);
viewport_get_rotation_vec3f(D_80281038);
func_8024D1EC(D_80281048, D_80281058, D_80281068, D_80281078);
func_8024C5A8(D_80281088);
viewport_getPosition_vec3f(sViewportBackupPosition);
viewport_getRotation_vec3f(sViewportBackupRotation);
viewport_getFrustumPlanes(sViewportBackupFrustumPlanes[0], sViewportBackupFrustumPlanes[1], sViewportBackupFrustumPlanes[2], sViewportBackupFrustumPlanes[3]);
viewport_getLookVector(sViewportBackupLookVector);
for(i = 0; i < 4; i++){
for(j = 0; j < 4; j++){
D_80281098.m[i][j] = D_80280F98.m[i][j];
sViewportBackupMatrix.m[i][j] = sViewportMatrix.m[i][j];
}
}
}
void func_8024E2FC(void){
void viewport_restoreState(void) {
s32 i, j;
viewport_set_position_vec3f(D_80281028);
viewport_set_rotation_vec3f(D_80281038);
func_8024D2B0(D_80281048, D_80281058, D_80281068, D_80281078);
ml_vec3f_copy(D_80280EA0, D_80281088);
viewport_setPosition_vec3f(sViewportBackupPosition);
viewport_setRotation_vec3f(sViewportBackupRotation);
viewport_setFrustumPlanes(sViewportBackupFrustumPlanes[0], sViewportBackupFrustumPlanes[1], sViewportBackupFrustumPlanes[2], sViewportBackupFrustumPlanes[3]);
ml_vec3f_copy(sViewportLookVector, sViewportBackupLookVector);
for(i = 0; i < 4; i++){
for(j = 0; j < 4; j++){
D_80280F98.m[i][j] = D_80281098.m[i][j];
sViewportMatrix.m[i][j] = sViewportBackupMatrix.m[i][j];
}
}
}
//moves the point(arg0) some distance (arg1) further away from the camera
void func_8024E3A8(f32 arg0[3], f32 distance){
f32 sp1C[3];
ml_vec3f_diff_copy(sp1C, viewportPosition, arg0);
ml_vec3f_set_length_copy(sp1C, sp1C, distance);
arg0[0] += sp1C[0];
arg0[1] += sp1C[1];
arg0[2] += sp1C[2];
void viewport_adjustPointDistance(f32 pos[3], f32 distance) {
f32 out[3];
ml_vec3f_diff_copy(out, sViewportPosition, pos);
ml_vec3f_set_length_copy(out, out, distance);
pos[0] += out[0];
pos[1] += out[1];
pos[2] += out[2];
}