aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/star_control/fpose.cpp81
-rw-r--r--engines/titanic/star_control/fpose.h6
-rw-r--r--engines/titanic/star_control/viewport.cpp2
3 files changed, 24 insertions, 65 deletions
diff --git a/engines/titanic/star_control/fpose.cpp b/engines/titanic/star_control/fpose.cpp
index 98de447e85..a3697ae6d5 100644
--- a/engines/titanic/star_control/fpose.cpp
+++ b/engines/titanic/star_control/fpose.cpp
@@ -146,69 +146,28 @@ void FPose::copyFrom(const FMatrix &src) {
_row3 = src._row3;
}
-// This looks like DAffine DAffine::inverseTransform()
-FPose FPose::fn4() const {
- float v2, v3, v6, v7, v8, v9, v10, v11;
- float v12, v13, v14, v15, v16, v17, v18;
+FPose FPose::inverseTransform() const {
FPose result;
- v16 = _row3._z * _row2._y;
- v2 = _row1._x * v16;
- v3 = 0.0;
- v18 = v2;
- if (v2 < 0.0) {
- v3 = v18;
- v2 = 0.0;
- }
- v6 = _row3._x * _row1._y * _row2._z;
- if (v6 < 0.0)
- v3 = v3 + v6;
- else
- v2 = v2 + v6;
- v7 = _row3._y * _row1._z * _row2._x;
- if (v7 < 0.0)
- v3 = v3 + v7;
- else
- v2 = v2 + v7;
- if (-(_row3._x * _row1._z * _row2._y) < 0.0)
- v3 = v3 - _row3._x * _row1._z * _row2._y;
- else
- v2 = v2 - _row3._x * _row1._z * _row2._y;
- if (-(_row1._y * _row2._x * _row3._z) < 0.0)
- v3 = v3 - _row1._y * _row2._x * _row3._z;
- else
- v2 = v2 - _row1._y * _row2._x * _row3._z;
- v17 = _row2._z * _row3._y;
- if (-(_row1._x * v17) < 0.0)
- v3 = v3 - _row1._x * v17;
- else
- v2 = v2 - _row1._x * v17;
- v18 = v3 + v2;
- assert(!(v18 == 0.0 || fabs(v18 / (v2 - v3)) < 1.0e-10));
-
- v8 = 1.0 / v18;
- v18 = v8;
- result._row1._x = (v16 - v17) * v8;
- result._row2._x = -(_row2._x * _row3._z - _row3._x * _row2._z) * v8;
- result._row3._x = (_row3._y * _row2._x - _row3._x * _row2._y) * v8;
- result._row1._y = -(_row1._y * _row3._z - _row3._y * _row1._z) * v8;
- result._row2._y = (_row1._x * _row3._z - _row3._x * _row1._z) * v8;
- result._row3._y = -(_row1._x * _row3._y - _row3._x * _row1._y) * v8;
- result._row1._z = (_row1._y * _row2._z - _row1._z * _row2._y) * v8;
- result._row2._z = -(_row1._x * _row2._z - _row1._z * _row2._x) * v8;
- v9 = result._row1._x;
- v10 = result._row2._y;
- v11 = result._row3._y;
- v12 = result._row1._z;
- v13 = result._row2._z;
- result._row3._z = (_row1._x * _row2._y - _row1._y * _row2._x) * v18;
- v14 = v9;
- v15 = result._row3._z;
- result._vector._x = -(v14 * _vector._x
- + _vector._y * result._row2._x
- + _vector._z * result._row3._x);
- result._vector._y = -(_vector._x * result._row1._y + v10 * _vector._y + v11 * _vector._z);
- result._vector._z = -(v12 * _vector._x + v13 * _vector._y + v15 * _vector._z);
+ 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;
}
diff --git a/engines/titanic/star_control/fpose.h b/engines/titanic/star_control/fpose.h
index 02e00c914d..f1f00ea7a7 100644
--- a/engines/titanic/star_control/fpose.h
+++ b/engines/titanic/star_control/fpose.h
@@ -29,7 +29,7 @@ namespace Titanic {
/*
* This class combines a position and orientation in 3D space
- * TODO: consider merging with DAffine
+ * TODO: Merge with DAffine
*/
class FPose : public FMatrix {
public:
@@ -61,9 +61,9 @@ public:
void copyFrom(const FMatrix &src);
/**
- * Probably the inverse of the this 3x4
+ * The inverse of rotation and the position vector
*/
- FPose fn4() const;
+ FPose inverseTransform() const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/viewport.cpp b/engines/titanic/star_control/viewport.cpp
index 39d2c5f201..130d59d8d6 100644
--- a/engines/titanic/star_control/viewport.cpp
+++ b/engines/titanic/star_control/viewport.cpp
@@ -248,7 +248,7 @@ void CViewport::reset() {
_rawPose.copyFrom(_orientation);
_rawPose._vector = _position;
- _currentPose = _rawPose.fn4();
+ _currentPose = _rawPose.inverseTransform();
_center = FPoint((double)_width * 0.5, (double)_height * 0.5);
_centerVector._x = MIN(_center._x, _center._y);