From b90e8433da68ae76df9a110dffc14057d81e182c Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Tue, 31 Dec 2024 16:57:20 +0200 Subject: [PATCH 1/3] Revert buggy optimizations in CMatrix::Rotate*. Didn't investigate much, they aren't often called --- src/math/Matrix.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/math/Matrix.cpp b/src/math/Matrix.cpp index 88433b26..97484eb5 100644 --- a/src/math/Matrix.cpp +++ b/src/math/Matrix.cpp @@ -282,7 +282,7 @@ CMatrix::SetRotate(float xAngle, float yAngle, float zAngle) void CMatrix::RotateX(float x) { -#ifdef DC_SH4 +#if 0 && defined(DC_SH4) // this is bugged and does not yield correct results mat_load(reinterpret_cast(this)); mat_rotate_x(x); mat_store(reinterpret_cast(this)); @@ -312,7 +312,7 @@ CMatrix::RotateX(float x) void CMatrix::RotateY(float y) { -#ifdef DC_SH4 +#if 0 && defined(DC_SH4) // this is bugged and does not yield correct results mat_load(reinterpret_cast(this)); mat_rotate_y(y); mat_store(reinterpret_cast(this)); @@ -342,7 +342,7 @@ CMatrix::RotateY(float y) void CMatrix::RotateZ(float z) { -#ifdef DC_SH4 +#if 0 && defined(DC_SH4) // this is bugged and does not yield correct results mat_load(reinterpret_cast(this)); mat_rotate_z(z); mat_store(reinterpret_cast(this)); @@ -372,7 +372,7 @@ CMatrix::RotateZ(float z) void CMatrix::Rotate(float x, float y, float z) { -#ifdef DC_SH4 +#if 0 && defined(DC_SH4) // this is bugged and does not yield correct results mat_load(reinterpret_cast(this)); mat_rotate(x, y, z); mat_store(reinterpret_cast(this)); From bf0e36858e394ec7442c4f2bf85433be265cfb07 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Sun, 5 Jan 2025 09:19:02 +0200 Subject: [PATCH 2/3] Use fipr in CMatrix::Rotate, simplifies it so it doesn't ICE --- src/math/Matrix.cpp | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/math/Matrix.cpp b/src/math/Matrix.cpp index 97484eb5..e8688242 100644 --- a/src/math/Matrix.cpp +++ b/src/math/Matrix.cpp @@ -404,18 +404,31 @@ CMatrix::Rotate(float x, float y, float z) float z2 = sZ * sY - (cZ * sX) * cY; float z3 = cX * cY; - this->rx = x1 * rx + y1 * ry + z1 * rz; - this->ry = x2 * rx + y2 * ry + z2 * rz; - this->rz = x3 * rx + y3 * ry + z3 * rz; - this->fx = x1 * ux + y1 * uy + z1 * uz; - this->fy = x2 * ux + y2 * uy + z2 * uz; - this->fz = x3 * ux + y3 * uy + z3 * uz; - this->ux = x1 * ax + y1 * ay + z1 * az; - this->uy = x2 * ax + y2 * ay + z2 * az; - this->uz = x3 * ax + y3 * ay + z3 * az; - this->px = x1 * px + y1 * py + z1 * pz; - this->py = x2 * px + y2 * py + z2 * pz; - this->pz = x3 * px + y3 * py + z3 * pz; + this->rx = fipr(x1, y1, z1, 0, rx, ry, rz, 0); + this->ry = fipr(x2, y2, z2, 0, rx, ry, rz, 0); + this->rz = fipr(x3, y3, z3, 0, rx, ry, rz, 0); + this->fx = fipr(x1, y1, z1, 0, ux, uy, uz, 0); + this->fy = fipr(x2, y2, z2, 0, ux, uy, uz, 0); + this->fz = fipr(x3, y3, z3, 0, ux, uy, uz, 0); + this->ux = fipr(x1, y1, z1, 0, ax, ay, az, 0); + this->uy = fipr(x2, y2, z2, 0, ax, ay, az, 0); + this->uz = fipr(x3, y3, z3, 0, ax, ay, az, 0); + this->px = fipr(x1, y1, z1, 0, px, py, pz, 0); + this->py = fipr(x2, y2, z2, 0, px, py, pz, 0); + this->pz = fipr(x3, y3, z3, 0, px, py, pz, 0); + + // this->rx = x1 * rx + y1 * ry + z1 * rz; + // this->ry = x2 * rx + y2 * ry + z2 * rz; + // this->rz = x3 * rx + y3 * ry + z3 * rz; + // this->fx = x1 * ux + y1 * uy + z1 * uz; + // this->fy = x2 * ux + y2 * uy + z2 * uz; + // this->fz = x3 * ux + y3 * uy + z3 * uz; + // this->ux = x1 * ax + y1 * ay + z1 * az; + // this->uy = x2 * ax + y2 * ay + z2 * az; + // this->uz = x3 * ax + y3 * ay + z3 * az; + // this->px = x1 * px + y1 * py + z1 * pz; + // this->py = x2 * px + y2 * py + z2 * pz; + // this->pz = x3 * px + y3 * py + z3 * pz; #endif } From ca866bdb2ab3da2d6be716af43825a70b843df81 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Sun, 5 Jan 2025 10:15:30 +0200 Subject: [PATCH 3/3] Fix sim build --- src/math/Matrix.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/math/Matrix.cpp b/src/math/Matrix.cpp index e8688242..41265e87 100644 --- a/src/math/Matrix.cpp +++ b/src/math/Matrix.cpp @@ -404,6 +404,7 @@ CMatrix::Rotate(float x, float y, float z) float z2 = sZ * sY - (cZ * sX) * cY; float z3 = cX * cY; + #if !defined(DC_TEXCONV) && !defined(DC_SIM) this->rx = fipr(x1, y1, z1, 0, rx, ry, rz, 0); this->ry = fipr(x2, y2, z2, 0, rx, ry, rz, 0); this->rz = fipr(x3, y3, z3, 0, rx, ry, rz, 0); @@ -416,19 +417,20 @@ CMatrix::Rotate(float x, float y, float z) this->px = fipr(x1, y1, z1, 0, px, py, pz, 0); this->py = fipr(x2, y2, z2, 0, px, py, pz, 0); this->pz = fipr(x3, y3, z3, 0, px, py, pz, 0); - - // this->rx = x1 * rx + y1 * ry + z1 * rz; - // this->ry = x2 * rx + y2 * ry + z2 * rz; - // this->rz = x3 * rx + y3 * ry + z3 * rz; - // this->fx = x1 * ux + y1 * uy + z1 * uz; - // this->fy = x2 * ux + y2 * uy + z2 * uz; - // this->fz = x3 * ux + y3 * uy + z3 * uz; - // this->ux = x1 * ax + y1 * ay + z1 * az; - // this->uy = x2 * ax + y2 * ay + z2 * az; - // this->uz = x3 * ax + y3 * ay + z3 * az; - // this->px = x1 * px + y1 * py + z1 * pz; - // this->py = x2 * px + y2 * py + z2 * pz; - // this->pz = x3 * px + y3 * py + z3 * pz; + #else + this->rx = x1 * rx + y1 * ry + z1 * rz; + this->ry = x2 * rx + y2 * ry + z2 * rz; + this->rz = x3 * rx + y3 * ry + z3 * rz; + this->fx = x1 * ux + y1 * uy + z1 * uz; + this->fy = x2 * ux + y2 * uy + z2 * uz; + this->fz = x3 * ux + y3 * uy + z3 * uz; + this->ux = x1 * ax + y1 * ay + z1 * az; + this->uy = x2 * ax + y2 * ay + z2 * az; + this->uz = x3 * ax + y3 * ay + z3 * az; + this->px = x1 * px + y1 * py + z1 * pz; + this->py = x2 * px + y2 * py + z2 * pz; + this->pz = x3 * px + y3 * py + z3 * pz; + #endif #endif }