diff options
author | David Fioramonti | 2017-09-02 05:38:50 -0700 |
---|---|---|
committer | David Fioramonti | 2017-09-02 06:41:07 -0700 |
commit | d6ca9eda93fd6b1808e24fb647f0cc0f3d50f2e5 (patch) | |
tree | 0144952890081a08a13b1eb10e0fc96a0d5e516c /engines/titanic/star_control | |
parent | d55406b6426d82c49afb00973f8b7da377bb0849 (diff) | |
download | scummvm-rg350-d6ca9eda93fd6b1808e24fb647f0cc0f3d50f2e5.tar.gz scummvm-rg350-d6ca9eda93fd6b1808e24fb647f0cc0f3d50f2e5.tar.bz2 scummvm-rg350-d6ca9eda93fd6b1808e24fb647f0cc0f3d50f2e5.zip |
TITANIC: Move Matrix4Inv out of starcamera and into FPose function
Diffstat (limited to 'engines/titanic/star_control')
-rw-r--r-- | engines/titanic/star_control/fpose.cpp | 50 | ||||
-rw-r--r-- | engines/titanic/star_control/star_camera.cpp | 18 |
2 files changed, 30 insertions, 38 deletions
diff --git a/engines/titanic/star_control/fpose.cpp b/engines/titanic/star_control/fpose.cpp index 2bcb6c36f5..34a7a40d29 100644 --- a/engines/titanic/star_control/fpose.cpp +++ b/engines/titanic/star_control/fpose.cpp @@ -22,6 +22,7 @@ #include "titanic/star_control/fpose.h" #include "titanic/star_control/matrix_transform.h" +#include "titanic/star_control/matrix_inv.h" namespace Titanic { @@ -159,29 +160,32 @@ void FPose::copyFrom(const FMatrix &src) { } FPose FPose::inverseTransform() const { - FPose result; - - 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; + FPose matrix_inv; + + matrix_inv._row1._x = _row1._x; + matrix_inv._row2._x = _row1._y; + matrix_inv._row3._x = _row1._z; + matrix_inv._row1._y = _row2._x; + matrix_inv._row2._y = _row2._y; + matrix_inv._row3._y = _row2._z; + matrix_inv._row1._z = _row3._x; + matrix_inv._row2._z = _row3._y; + matrix_inv._row3._z = _row3._z; + + float A[16]={_row1._x,_row1._y,_row1._z, 0.0, + _row2._x,_row2._y,_row2._z, 0.0, + _row3._x,_row3._y,_row3._z, 0.0, + _vector._x,_vector._y,_vector._z, 1.0}; + // Inverse matrix + float B[16]={}; + + // B contains inverse of A + matrix4Inverse<float>(A,B); + matrix_inv._vector._x=B[12]; + matrix_inv._vector._y=B[13]; + matrix_inv._vector._z=B[14]; + + return matrix_inv; } //TODO: Check math and provide source diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp index 9885f0ba04..a99d70276f 100644 --- a/engines/titanic/star_control/star_camera.cpp +++ b/engines/titanic/star_control/star_camera.cpp @@ -26,7 +26,7 @@ #include "titanic/star_control/fmatrix.h" #include "titanic/star_control/fpoint.h" #include "titanic/star_control/marked_camera_mover.h" -#include "titanic/star_control/matrix_inv.h" +//#include "titanic/star_control/matrix_inv.h" #include "titanic/star_control/unmarked_camera_mover.h" #include "titanic/star_control/error_code.h" #include "titanic/support/simple_file.h" @@ -525,20 +525,8 @@ bool CStarCamera::lockMarker2(CViewport *viewport, const FVector &secondStarPosi FPose m10 = starDelta.formRotXY(); FPose m11; fposeProd(m10,m3,m11); - - float A[16]={m11._row1._x,m11._row1._y,m11._row1._z, 0.0, - m11._row2._x,m11._row2._y,m11._row2._z, 0.0, - m11._row3._x,m11._row3._y,m11._row3._z, 0.0, - m11._vector._x,m11._vector._y,m11._vector._z, 1.0}; - // Inverse matrix - float B[16]={}; - - // B contains inverse of A - matrix4Inverse<float>(A,B); - m10=m11.inverseTransform(); - m10._vector._x=B[12]; - m10._vector._y=B[13]; - m10._vector._z=B[14]; + + m10 = m11.inverseTransform(); FVector oldPos = _viewport._position; |