diff --git a/asm/math.s b/asm/math.s index 7ffd9751d..fca208c37 100644 --- a/asm/math.s +++ b/asm/math.s @@ -8,7 +8,7 @@ .balign 32 glabel mtxf_to_mtx_asm - lwc1 $f6, gWorldScale + li.s $f6, 4.0 li.s $f8, 1.0 li $v0, 1 li.s $f4, 65536.0 diff --git a/src/engine/math_util.c b/src/engine/math_util.c index c2669b275..be4018ddb 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -581,50 +581,6 @@ void mtxf_mul_vec3s(Mat4 mtx, Vec3s b) { } } -/** - * Convert float matrix 'src' to fixed point matrix 'dest'. - * The float matrix may not contain entries larger than 65536 or the console - * crashes. The fixed point matrix has entries with a 16-bit integer part, so - * the floating point numbers are multiplied by 2^16 before being cast to a s32 - * integer. If this doesn't fit, the N64 and iQue consoles will throw an - * exception. On Wii and Wii U Virtual Console the value will simply be clamped - * and no crashes occur. - - * Modified into a hybrid of the original function and the worldscale altered function. - * Will check if the worldscale is below what's considered safe in vanilla bounds and - * just run the faster vanilla function, otherwise it'll run the slower, but safer scale - * function, for extended boundaries. - */ -void mtxf_to_mtx_scale(Mtx *dest, Mat4 src) { - Mat4 temp; - register s32 i, j; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - temp[i][j] = (src[i][j] / gWorldScale); - } - temp[i][3] = src[i][3]; - } - guMtxF2L(temp, dest); -} - -void mtxf_to_mtx_constant(register s16 *dest, register f32 *src) { //! TODO: asm - s32 asFixedPoint; - s32 i; - for (i = 0; i < 16; i++) { - asFixedPoint = (src[i] * (1 << 16)); - dest[i ] = (asFixedPoint >> 16); - dest[i + 16] = (asFixedPoint & 0xFFFF); - } -} - -void mtxf_to_mtx(void *dest, void *src) { - if (gWorldScale > 2.0f) { - mtxf_to_mtx_scale(dest, src); - } else { - mtxf_to_mtx_constant(dest, src); - } -} - /** * Set 'mtx' to a transformation matrix that rotates around the z axis. */ diff --git a/src/engine/math_util.h b/src/engine/math_util.h index 38778ba78..d1808ce54 100644 --- a/src/engine/math_util.h +++ b/src/engine/math_util.h @@ -482,9 +482,10 @@ void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s32 yaw, f32 radius); void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b); void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s); void mtxf_mul_vec3s(Mat4 mtx, Vec3s b); -void mtxf_to_mtx(void *dest, void *src); -void mtxf_to_mtx_constant(register s16 *dest, register f32 *src); -void mtxf_to_mtx_scale(Mtx *dest, Mat4 src); +extern void mtxf_to_mtx_asm(register s16 *dest, register f32 *src); +inline void mtxf_to_mtx(register s16 *dest, register f32 *src) { + mtxf_to_mtx_asm(dest, src); +} void mtxf_rotate_xy(Mtx *mtx, s32 angle); void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx); diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index 556fcb2db..7188c1423 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -49,7 +49,6 @@ s16 gMatStackIndex; Mat4 gMatStack[32]; Mtx *gMatStackFixed[32]; f32 sAspectRatio; -f32 gWorldScale = 1.0f; /** * Animation nodes have state in global variables, so this struct captures @@ -432,20 +431,7 @@ void geo_process_perspective(struct GraphNodePerspective *node) { #else sAspectRatio = (4.0f / 3.0f); // 1.33333f #endif - if (gCamera) { - // gWorldScale = ((sqr(gCamera->pos[0]) + sqr(gCamera->pos[1]) + sqr(gCamera->pos[2])) / sqr(0x2000)); - gWorldScale = (max_3f(ABS(gCamera->pos[0]), ABS(gCamera->pos[1]), ABS(gCamera->pos[2])) / (f32)0x2000); - } else { - gWorldScale = 1.0f; - } - farClip = CLAMP(farClip / gWorldScale, 4096, 61440); - if (farClip / farClipDelta != 1) { - farClipDelta /= farClip; - gWorldScale *= farClipDelta; - } - gWorldScale = MAX(gWorldScale, 1.0f); - - guPerspective(mtx, &perspNorm, node->fov, sAspectRatio, ((farClip / 300) / gWorldScale), (farClip / gWorldScale), 1.0f); + guPerspective(mtx, &perspNorm, node->fov, sAspectRatio, ((farClip / 300) / 4), (farClip / 4), 1.0f); gSPPerspNormalize(gDisplayListHead++, perspNorm); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(mtx), (G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH)); gCurGraphNodeCamFrustum = node;