diff options
author | David Fioramonti | 2017-08-16 19:44:11 -0700 |
---|---|---|
committer | David Fioramonti | 2017-08-16 20:42:09 -0700 |
commit | 24354ac6a8425133e3b39caa1e55b4b63dc41665 (patch) | |
tree | 8328298bbf765f536db82b406bb3e660cb5ca00d /engines/titanic/star_control/fpose.cpp | |
parent | 09eb399c07714ed084a4cbf69b2938c36434e548 (diff) | |
download | scummvm-rg350-24354ac6a8425133e3b39caa1e55b4b63dc41665.tar.gz scummvm-rg350-24354ac6a8425133e3b39caa1e55b4b63dc41665.tar.bz2 scummvm-rg350-24354ac6a8425133e3b39caa1e55b4b63dc41665.zip |
TITANIC: fpose, simplify inverse
Was doing 3x3 inverse now it is doing a transpose.
Also named the function.
Diffstat (limited to 'engines/titanic/star_control/fpose.cpp')
-rw-r--r-- | engines/titanic/star_control/fpose.cpp | 81 |
1 files changed, 20 insertions, 61 deletions
diff --git a/engines/titanic/star_control/fpose.cpp b/engines/titanic/star_control/fpose.cpp index 98de447e85..a3697ae6d5 100644 --- a/engines/titanic/star_control/fpose.cpp +++ b/engines/titanic/star_control/fpose.cpp @@ -146,69 +146,28 @@ void FPose::copyFrom(const FMatrix &src) { _row3 = src._row3; } -// This looks like DAffine DAffine::inverseTransform() -FPose FPose::fn4() const { - float v2, v3, v6, v7, v8, v9, v10, v11; - float v12, v13, v14, v15, v16, v17, v18; +FPose FPose::inverseTransform() const { FPose result; - v16 = _row3._z * _row2._y; - v2 = _row1._x * v16; - v3 = 0.0; - v18 = v2; - if (v2 < 0.0) { - v3 = v18; - v2 = 0.0; - } - v6 = _row3._x * _row1._y * _row2._z; - if (v6 < 0.0) - v3 = v3 + v6; - else - v2 = v2 + v6; - v7 = _row3._y * _row1._z * _row2._x; - if (v7 < 0.0) - v3 = v3 + v7; - else - v2 = v2 + v7; - if (-(_row3._x * _row1._z * _row2._y) < 0.0) - v3 = v3 - _row3._x * _row1._z * _row2._y; - else - v2 = v2 - _row3._x * _row1._z * _row2._y; - if (-(_row1._y * _row2._x * _row3._z) < 0.0) - v3 = v3 - _row1._y * _row2._x * _row3._z; - else - v2 = v2 - _row1._y * _row2._x * _row3._z; - v17 = _row2._z * _row3._y; - if (-(_row1._x * v17) < 0.0) - v3 = v3 - _row1._x * v17; - else - v2 = v2 - _row1._x * v17; - v18 = v3 + v2; - assert(!(v18 == 0.0 || fabs(v18 / (v2 - v3)) < 1.0e-10)); - - v8 = 1.0 / v18; - v18 = v8; - result._row1._x = (v16 - v17) * v8; - result._row2._x = -(_row2._x * _row3._z - _row3._x * _row2._z) * v8; - result._row3._x = (_row3._y * _row2._x - _row3._x * _row2._y) * v8; - result._row1._y = -(_row1._y * _row3._z - _row3._y * _row1._z) * v8; - result._row2._y = (_row1._x * _row3._z - _row3._x * _row1._z) * v8; - result._row3._y = -(_row1._x * _row3._y - _row3._x * _row1._y) * v8; - result._row1._z = (_row1._y * _row2._z - _row1._z * _row2._y) * v8; - result._row2._z = -(_row1._x * _row2._z - _row1._z * _row2._x) * v8; - v9 = result._row1._x; - v10 = result._row2._y; - v11 = result._row3._y; - v12 = result._row1._z; - v13 = result._row2._z; - result._row3._z = (_row1._x * _row2._y - _row1._y * _row2._x) * v18; - v14 = v9; - v15 = result._row3._z; - result._vector._x = -(v14 * _vector._x - + _vector._y * result._row2._x - + _vector._z * result._row3._x); - result._vector._y = -(_vector._x * result._row1._y + v10 * _vector._y + v11 * _vector._z); - result._vector._z = -(v12 * _vector._x + v13 * _vector._y + v15 * _vector._z); + result._row1._x = _row1._x; + result._row2._x = _row1._y; + result._row3._x = _row1._z; + result._row1._y = _row2._x; + result._row2._y = _row2._y; + result._row3._y = _row2._z; + result._row1._z = _row3._x; + result._row2._z = _row3._y; + result._row3._z = _row3._z; + + result._vector._x = -(_vector._x * result._row1._x + + _vector._y * result._row2._x + + _vector._z * result._row3._x); + result._vector._y = -(_vector._x * result._row1._y + + _vector._y * result._row2._y + + _vector._z * result._row3._y); + result._vector._z = -(_vector._x * result._row1._z + + _vector._y * result._row2._z + + _vector._z * result._row3._z); return result; } |