diff options
author | David Fioramonti | 2017-08-15 04:48:10 -0700 |
---|---|---|
committer | David Fioramonti | 2017-08-15 15:02:02 -0700 |
commit | 781c679c7f8e761e35c3d72ac27e16350c55964a (patch) | |
tree | 77950201eb109ff140d38372c13dacad2594fd64 /engines/titanic | |
parent | 8eb7bf3807198f2ff200550050e32fe852d6054e (diff) | |
download | scummvm-rg350-781c679c7f8e761e35c3d72ac27e16350c55964a.tar.gz scummvm-rg350-781c679c7f8e761e35c3d72ac27e16350c55964a.tar.bz2 scummvm-rg350-781c679c7f8e761e35c3d72ac27e16350c55964a.zip |
TITANIC: daffine refactor, changed Yaxis rotation convention
The X and Z rotation already follow the convention given in wikipedia,
but the Y axis rotation doesn't (its the negative angle) so I switched
that and updated where that was used.
This allowed stray negatives for angle calls to this function (for Y
rotations) to be removed from other parts of the code (dvector).
In theory this was a non-functional change. In dvector the code was taking
the negative of the angle so it was essentially doing the negative of the
negative, but when it was used once in star_camera it was not
(when it should of been). So That was changed. That part of the code
was used for locking onto the third star after the 2nd was already locked.
I can't tell if the star control puzzle has improved after this change.
It can still have issues locking onto the 2nd star and also not.
Also added lots of todos for things to check.
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/star_control/daffine.cpp | 7 | ||||
-rw-r--r-- | engines/titanic/star_control/daffine.h | 21 | ||||
-rw-r--r-- | engines/titanic/star_control/dvector.cpp | 6 |
3 files changed, 18 insertions, 16 deletions
diff --git a/engines/titanic/star_control/daffine.cpp b/engines/titanic/star_control/daffine.cpp index 8c956da9dd..6dfee29b32 100644 --- a/engines/titanic/star_control/daffine.cpp +++ b/engines/titanic/star_control/daffine.cpp @@ -65,7 +65,7 @@ DAffine::DAffine(const FMatrix &src) { _col3 = src._row3; } -//TODO: What is _static_ for? +//TODO: What is _static for? void DAffine::init() { _static = nullptr; } @@ -90,6 +90,7 @@ void DAffine::clear() { _col4._z = 0.0; } +// Source: https://en.wikipedia.org/wiki/Rotation_matrix void DAffine::setRotationMatrix(Axis axis, double angleDeg) { clear(); @@ -107,9 +108,9 @@ void DAffine::setRotationMatrix(Axis axis, double angleDeg) { case Y_AXIS: _col1._x = cosVal; - _col1._z = sinVal; + _col1._z = -sinVal; _col2._y = 1.0; - _col3._x = -sinVal; + _col3._x = sinVal; _col3._z = cosVal; break; diff --git a/engines/titanic/star_control/daffine.h b/engines/titanic/star_control/daffine.h index dda87323c6..631b6003f0 100644 --- a/engines/titanic/star_control/daffine.h +++ b/engines/titanic/star_control/daffine.h @@ -50,6 +50,7 @@ public: static void deinit(); public: DAffine(); + //TODO: consider making mode an enum since that is more helpful when it is used in code DAffine(int mode, const DVector &src); DAffine(Axis axis, double angleDeg); DAffine(const FMatrix &src); @@ -69,18 +70,18 @@ public: */ DAffine inverseTransform() const; - /** - * Change this Daffine to have its first three columns be some mapping from src matrix - * and the 4rth column to be (three) zeros. The mapping is not as simple as replacing - * matching row/colmn indices - */ + /** + * Change this Daffine to have its first three columns be some mapping from src matrix + * and the 4rth column to be (three) zeros. The mapping is not as simple as replacing + * matching row/colmn indices + */ void loadTransform(const CMatrixTransform &src); - /** - * Do the affine product between this Daffine on the left - * and the m Daffine matrix on the right. This is product is NOT the same - * as multiplying two matrices of dimensions 4x4. - */ + /** + * Do the affine product between this Daffine on the right + * and the m Daffine matrix on the left. This product is NOT the same + * as multiplying two matrices of dimensions 3x4. + */ DAffine compose(const DAffine &m); }; diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp index 9f35ff6b67..c7481a2b49 100644 --- a/engines/titanic/star_control/dvector.cpp +++ b/engines/titanic/star_control/dvector.cpp @@ -86,13 +86,13 @@ DAffine DVector::getFrameTransform(const DVector &v) { DVector vector1 = getAnglesAsVect(); matrix1.setRotationMatrix(X_AXIS, vector1._y * Rad2Deg); - matrix2.setRotationMatrix(Y_AXIS, -(vector1._z * Rad2Deg)); + matrix2.setRotationMatrix(Y_AXIS, vector1._z * Rad2Deg); matrix3 = matrix1.compose(matrix2); matrix4 = matrix3.inverseTransform(); vector1 = v.getAnglesAsVect(); matrix1.setRotationMatrix(X_AXIS, vector1._y * Rad2Deg); - matrix2.setRotationMatrix(Y_AXIS, -(vector1._z * Rad2Deg)); + matrix2.setRotationMatrix(Y_AXIS, vector1._z * Rad2Deg); matrix3 = matrix1.compose(matrix2); return matrix4.compose(matrix3); @@ -102,7 +102,7 @@ DAffine DVector::rotXY() const { DVector v1 = getAnglesAsVect(); DAffine m1, m2; m1.setRotationMatrix(X_AXIS, v1._y * Rad2Deg); - m2.setRotationMatrix(Y_AXIS, -(v1._z * Rad2Deg)); + m2.setRotationMatrix(Y_AXIS, v1._z * Rad2Deg); return m1.compose(m2); } |