aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorDavid Fioramonti2017-08-15 03:46:49 -0700
committerDavid Fioramonti2017-08-15 04:11:59 -0700
commit0f600dc21ac0469f581856c34876a63794023b06 (patch)
treebb5969923e0d0d07513f8b380b5a001bdf438396 /engines/titanic
parent970e4b2e8a72d62d1e3499aca98b7386ebf7eca9 (diff)
downloadscummvm-rg350-0f600dc21ac0469f581856c34876a63794023b06.tar.gz
scummvm-rg350-0f600dc21ac0469f581856c34876a63794023b06.tar.bz2
scummvm-rg350-0f600dc21ac0469f581856c34876a63794023b06.zip
TITANIC: daffine refactoring, non-functional changes
Made default constructor col4 construction explicit. Change amount argument to be angle_deg. Added constant from dvector that does conversion from degrees to radians". Also moved conversion constants for angles in dvector to header file so daffine could use that.
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/star_control/daffine.cpp13
-rw-r--r--engines/titanic/star_control/daffine.h18
-rw-r--r--engines/titanic/star_control/dvector.cpp3
-rw-r--r--engines/titanic/star_control/dvector.h3
4 files changed, 24 insertions, 13 deletions
diff --git a/engines/titanic/star_control/daffine.cpp b/engines/titanic/star_control/daffine.cpp
index a7bed770c7..56c705b6a5 100644
--- a/engines/titanic/star_control/daffine.cpp
+++ b/engines/titanic/star_control/daffine.cpp
@@ -29,7 +29,7 @@ namespace Titanic {
DAffine *DAffine::_static;
DAffine::DAffine() :
- _col1(0.0, 0.0, 0.0), _col2(0.0, 0.0, 0.0), _col3(0.0, 0.0, 0.0) {
+ _col1(0.0, 0.0, 0.0), _col2(0.0, 0.0, 0.0), _col3(0.0, 0.0, 0.0), _col4(0.0, 0.0, 0.0) {
}
DAffine::DAffine(int mode, const DVector &src) {
@@ -55,8 +55,8 @@ DAffine::DAffine(int mode, const DVector &src) {
}
}
-DAffine::DAffine(Axis axis, double amount) {
- setRotationMatrix(axis, amount);
+DAffine::DAffine(Axis axis, double angleDeg) {
+ setRotationMatrix(axis, angleDeg);
}
DAffine::DAffine(const FMatrix &src) {
@@ -74,10 +74,9 @@ void DAffine::deinit() {
_static = nullptr;
}
-void DAffine::setRotationMatrix(Axis axis, double amount) {
- const double FACTOR = 0.0174532925199433;
- double sinVal = sin(amount * FACTOR);
- double cosVal = cos(amount * FACTOR);
+void DAffine::setRotationMatrix(Axis axis, double angleDeg) {
+ double sinVal = sin(angleDeg * Deg2Rad);
+ double cosVal = cos(angleDeg * Deg2Rad);
switch (axis) {
case X_AXIS:
diff --git a/engines/titanic/star_control/daffine.h b/engines/titanic/star_control/daffine.h
index 50f8b9580b..50450b9427 100644
--- a/engines/titanic/star_control/daffine.h
+++ b/engines/titanic/star_control/daffine.h
@@ -51,18 +51,30 @@ public:
public:
DAffine();
DAffine(int mode, const DVector &src);
- DAffine(Axis axis, double amount);
+ DAffine(Axis axis, double angleDeg);
DAffine(const FMatrix &src);
/**
- * Sets up a matrix for rotating on a given axis by a given amount
+ * Sets up an affine matrix for rotating on a given axis by an amount in degrees
*/
- void setRotationMatrix(Axis axis, double amount);
+ void setRotationMatrix(Axis axis, double angleDeg);
+ /**
+ * Return the Inverse of this Daffine
+ */
DAffine inverseTransform() const;
+ /**
+ * Change this Daffine to have its first three columns be the src matrix
+ * and the 4rth column to be (three) zeros
+ */
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.
+ */
DAffine compose(const DAffine &m);
};
diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp
index 1f873b5764..9f35ff6b67 100644
--- a/engines/titanic/star_control/dvector.cpp
+++ b/engines/titanic/star_control/dvector.cpp
@@ -26,9 +26,6 @@
namespace Titanic {
-const double Rad2Deg = 180.0 / M_PI;
-const double Deg2Rad = 1.0 / Rad2Deg;
-
double DVector::normalize() {
double hyp = sqrt(_x * _x + _y * _y + _z * _z);
assert(hyp);
diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h
index eda69f9b81..bff271dd6f 100644
--- a/engines/titanic/star_control/dvector.h
+++ b/engines/titanic/star_control/dvector.h
@@ -27,6 +27,9 @@
namespace Titanic {
+const double Rad2Deg = 180.0 / M_PI;
+const double Deg2Rad = 1.0 / Rad2Deg;
+
class DAffine;
/**