From 78f69e198c8198075ded9e557bf1e2807a1c49f0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 25 May 2017 22:27:19 -0400 Subject: TITANIC: Fix calculating orientation transition matrixes --- engines/titanic/star_control/dmatrix.cpp | 41 +++++++++++++++----------------- engines/titanic/star_control/dvector.h | 4 ++++ 2 files changed, 23 insertions(+), 22 deletions(-) (limited to 'engines/titanic') diff --git a/engines/titanic/star_control/dmatrix.cpp b/engines/titanic/star_control/dmatrix.cpp index 93268d1187..079ce2f975 100644 --- a/engines/titanic/star_control/dmatrix.cpp +++ b/engines/titanic/star_control/dmatrix.cpp @@ -177,28 +177,25 @@ DMatrix DMatrix::fn1() const { void DMatrix::loadTransform(const CMatrixTransform &src) { double total = src.fn1(); double factor = (total <= 0.0) ? 0.0 : 2.0 / total; - DVector tempV = src._vector * factor; - - double val1 = tempV._x * src._vector._x; - double val2 = tempV._y * src._vector._x; - double val3 = tempV._y * src._vector._y; - double val4 = tempV._x * src._field0; - double val5 = tempV._z + val3; - double val6 = tempV._z * src._vector._y; - double val7 = tempV._z * src._field0; - double val8 = val3 + val1; - double val9 = tempV._z * src._vector._x; - double val10 = tempV._y * src._field0; - - _row1._x = 1.0 - val5; - _row1._y = val2 + val7; - _row1._z = val9 - val10; - _row2._x = val2 - val7; - _row2._y = 1.0 - (tempV._z + val1); - _row2._z = val6 + val4; - _row3._x = val9 + val10; - _row3._y = val6 - val4; - _row3._z = 1.0 - val8; + DVector temp1V = src._vector * factor; + DVector temp2V = temp1V * src._vector; + + double val1 = temp1V._y * src._vector._x; + double val2 = temp1V._z * src._vector._x; + double val3 = temp1V._z * src._vector._y; + double val4 = temp1V._x * src._field0; + double val5 = temp1V._y * src._field0; + double val6 = temp1V._z * src._field0; + + _row1._x = 1.0 - (temp2V._z + temp2V._y); + _row1._y = val1 + val6; + _row1._z = val2 - val5; + _row2._x = val1 - val6; + _row2._y = 1.0 - (temp2V._z + temp2V._x); + _row2._z = val3 + val4; + _row3._x = val2 + val5; + _row3._y = val3 - val4; + _row3._z = 1.0 - (temp2V._y + temp2V._x); _row4._x = 0; _row4._y = 0; _row4._z = 0; diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h index e64933ad3b..d9672065bf 100644 --- a/engines/titanic/star_control/dvector.h +++ b/engines/titanic/star_control/dvector.h @@ -91,6 +91,10 @@ public: const DVector operator*(double right) const { return DVector(_x * right, _y * right, _z * right); } + + const DVector operator*(const DVector &right) const { + return DVector(_x * right._x, _y * right._y, _z * right._z); + } }; } // End of namespace Titanic -- cgit v1.2.3