aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorDavid Fioramonti2017-08-15 04:29:38 -0700
committerDavid Fioramonti2017-08-15 04:46:43 -0700
commit8eb7bf3807198f2ff200550050e32fe852d6054e (patch)
treeeb8f467c0ab5d3c539bc14eee424f3f8a996f116 /engines/titanic
parent0f600dc21ac0469f581856c34876a63794023b06 (diff)
downloadscummvm-rg350-8eb7bf3807198f2ff200550050e32fe852d6054e.tar.gz
scummvm-rg350-8eb7bf3807198f2ff200550050e32fe852d6054e.tar.bz2
scummvm-rg350-8eb7bf3807198f2ff200550050e32fe852d6054e.zip
TITANIC: daffine refactor, call clear before setting rot matrix
The previous code wasn't reseting all the other elements to zero when setting up a rotation matrix. This would of left other values in the not set elements leading to a matrix not quite what the caller wanted. This should lead to the function getFrameTransform returning a different Daffine matrix. Also added lots of todos
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/star_control/daffine.cpp21
-rw-r--r--engines/titanic/star_control/daffine.h10
2 files changed, 29 insertions, 2 deletions
diff --git a/engines/titanic/star_control/daffine.cpp b/engines/titanic/star_control/daffine.cpp
index 56c705b6a5..8c956da9dd 100644
--- a/engines/titanic/star_control/daffine.cpp
+++ b/engines/titanic/star_control/daffine.cpp
@@ -65,6 +65,7 @@ DAffine::DAffine(const FMatrix &src) {
_col3 = src._row3;
}
+//TODO: What is _static_ for?
void DAffine::init() {
_static = nullptr;
}
@@ -74,7 +75,24 @@ void DAffine::deinit() {
_static = nullptr;
}
+void DAffine::clear() {
+ _col1._x = 0.0;
+ _col1._y = 0.0;
+ _col1._z = 0.0;
+ _col2._x = 0.0;
+ _col2._y = 0.0;
+ _col2._z = 0.0;
+ _col3._x = 0.0;
+ _col3._y = 0.0;
+ _col3._z = 0.0;
+ _col4._x = 0.0;
+ _col4._y = 0.0;
+ _col4._z = 0.0;
+}
+
void DAffine::setRotationMatrix(Axis axis, double angleDeg) {
+ clear();
+
double sinVal = sin(angleDeg * Deg2Rad);
double cosVal = cos(angleDeg * Deg2Rad);
@@ -108,6 +126,7 @@ void DAffine::setRotationMatrix(Axis axis, double angleDeg) {
}
}
+//TODO: Check math and provide source
DAffine DAffine::inverseTransform() const {
double val1 = _col1._x * _col3._z * _col2._y;
double val2 = 0.0;
@@ -173,6 +192,7 @@ DAffine DAffine::inverseTransform() const {
return m;
}
+//TODO: Check math and provide source
void DAffine::loadTransform(const CMatrixTransform &src) {
double total = src.fn1();
double factor = (total <= 0.0) ? 0.0 : 2.0 / total;
@@ -200,6 +220,7 @@ void DAffine::loadTransform(const CMatrixTransform &src) {
_col4._z = 0;
}
+//TODO: Check math and provide source
DAffine DAffine::compose(const DAffine &m) {
DAffine dm;
dm._col1._x = m._col3._x * _col1._z + m._col2._x * _col1._y
diff --git a/engines/titanic/star_control/daffine.h b/engines/titanic/star_control/daffine.h
index 50450b9427..dda87323c6 100644
--- a/engines/titanic/star_control/daffine.h
+++ b/engines/titanic/star_control/daffine.h
@@ -55,6 +55,11 @@ public:
DAffine(const FMatrix &src);
/**
+ * Sets all elements to zero
+ */
+ void clear();
+
+ /**
* Sets up an affine matrix for rotating on a given axis by an amount in degrees
*/
void setRotationMatrix(Axis axis, double angleDeg);
@@ -65,8 +70,9 @@ public:
DAffine inverseTransform() const;
/**
- * Change this Daffine to have its first three columns be the src matrix
- * and the 4rth column to be (three) zeros
+ * 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);