From 1f660de7e53eb3675bc258dc57dfff99d779fc55 Mon Sep 17 00:00:00 2001 From: donkopunchstania Date: Wed, 1 Dec 2010 04:26:21 +0000 Subject: Avoid repeatedly asserting in SWG plugin when matrix indices don't match. Small change to the transform unit to avoid some unnecessary work. Check if Q is zero before dividing UV coordinates by it. Fixes issue 3454. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6504 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_VideoSoftware/Src/TransformUnit.cpp | 32 ++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'Source/Plugins/Plugin_VideoSoftware/Src/TransformUnit.cpp') diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/TransformUnit.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/TransformUnit.cpp index dcdf0daa1f..f17074d1c9 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/TransformUnit.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/TransformUnit.cpp @@ -35,6 +35,7 @@ void MultiplyVec2Mat24(const Vec3 &vec, const float *mat, Vec3 &result) { result.x = mat[0] * vec.x + mat[1] * vec.y + mat[2] + mat[3]; result.y = mat[4] * vec.x + mat[5] * vec.y + mat[6] + mat[7]; + result.z = 1.0f; } void MultiplyVec2Mat34(const Vec3 &vec, const float *mat, Vec3 &result) @@ -51,6 +52,13 @@ void MultiplyVec3Mat33(const Vec3 &vec, const float *mat, Vec3 &result) result.z = mat[6] * vec.x + mat[7] * vec.y + mat[8] * vec.z; } +void MultiplyVec3Mat24(const Vec3 &vec, const float *mat, Vec3 &result) +{ + result.x = mat[0] * vec.x + mat[1] * vec.y + mat[2] * vec.z + mat[3]; + result.y = mat[4] * vec.x + mat[5] * vec.y + mat[6] * vec.z + mat[7]; + result.z = 1.0f; +} + void MultiplyVec3Mat34(const Vec3 &vec, const float *mat, Vec3 &result) { result.x = mat[0] * vec.x + mat[1] * vec.y + mat[2] * vec.z + mat[3]; @@ -134,14 +142,22 @@ inline void TransformTexCoordRegular(const TexMtxInfo &texinfo, int coordNum, bo const float *mat = (const float*)&xfregs.posMatrices[srcVertex->texMtx[coordNum] * 4]; Vec3 *dst = &dstVertex->texCoords[coordNum]; - if (texinfo.inputform == XF_TEXINPUT_AB11) - { - MultiplyVec2Mat34(*src, mat, *dst); - } - else - { - MultiplyVec3Mat34(*src, mat, *dst); - } + if (texinfo.projection == XF_TEXPROJ_ST) + { + if (texinfo.inputform == XF_TEXINPUT_AB11 || specialCase) + MultiplyVec2Mat24(*src, mat, *dst); + else + MultiplyVec3Mat24(*src, mat, *dst); + } + else // texinfo.projection == XF_TEXPROJ_STQ + { + _assert_(!specialCase); + + if (texinfo.inputform == XF_TEXINPUT_AB11) + MultiplyVec2Mat34(*src, mat, *dst); + else + MultiplyVec3Mat34(*src, mat, *dst); + } if (xfregs.dualTexTrans) { -- cgit v1.2.3