diff options
author | David Fioramonti | 2017-08-12 18:13:25 -0700 |
---|---|---|
committer | David Fioramonti | 2017-08-12 18:32:52 -0700 |
commit | a3199414369bcdf51f6425b83d00263999285404 (patch) | |
tree | 8021e1ff9d81e77f212bf21d49f5702cb7338de3 /engines | |
parent | a03183760a428144987832956355054736173878 (diff) | |
download | scummvm-rg350-a3199414369bcdf51f6425b83d00263999285404.tar.gz scummvm-rg350-a3199414369bcdf51f6425b83d00263999285404.tar.bz2 scummvm-rg350-a3199414369bcdf51f6425b83d00263999285404.zip |
TITANIC: Star control dvector work, renamed fn1 to DAffMatrixProdVec
It does a matrix product with a vector and a z translation
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/star_control/dvector.cpp | 20 | ||||
-rw-r--r-- | engines/titanic/star_control/dvector.h | 8 | ||||
-rw-r--r-- | engines/titanic/star_control/star_camera.cpp | 34 |
3 files changed, 40 insertions, 22 deletions
diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp index 0a6fa97d16..1408740f15 100644 --- a/engines/titanic/star_control/dvector.cpp +++ b/engines/titanic/star_control/dvector.cpp @@ -40,11 +40,23 @@ double DVector::getDistance(const DVector &src) { return sqrt((src._x - _x) * (src._x - _x) + (src._y - _y) * (src._y - _y) + (src._z - _z) * (src._z - _z)); } -DVector DVector::fn1(const DAffine &m) { +DVector DVector::DAffMatrixProdVec(const DAffine &m) { DVector dest; - dest._x = m._col3._x * _z + m._col2._x * _y + m._col1._x * _x + m._col4._x; - dest._y = m._col2._y * _y + m._col3._y * _z + m._col1._y * _x + m._col4._y; - dest._z = m._col3._z * _z + m._col2._z * _y + m._col1._z * _x + m._col4._z; + dest._x = m._col1._x * _x + + m._col2._x * _y + + m._col3._x * _z + + m._col4._x; + + dest._y = m._col1._y * _x + + m._col2._y * _y + + m._col3._y * _z + + m._col4._y; + + dest._z = m._col1._z * _x + + m._col2._z * _y + + m._col3._z * _z + + m._col4._z; + return dest; } diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h index 94df30ebbd..cd57cbc82e 100644 --- a/engines/titanic/star_control/dvector.h +++ b/engines/titanic/star_control/dvector.h @@ -48,7 +48,13 @@ public: */ double getDistance(const DVector &src); - DVector fn1(const DAffine &m); + /** + * Returns the matrix product with this vector and + * also does a z translations + * Doesn't change this vector + */ + DVector DAffMatrixProdVec(const DAffine &m); + void fn2(double angle); DVector fn3() const; DAffine fn4(const DVector &v); diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp index 6829194904..dcc295ad07 100644 --- a/engines/titanic/star_control/star_camera.cpp +++ b/engines/titanic/star_control/star_camera.cpp @@ -321,15 +321,15 @@ void CStarCamera::setViewportAngle(const FPoint &angles) { tempV7._x = m3._row3._x * 1000000.0 + tempV3._x; mrow3 = tempV8 = tempV7; - tempV3 = tempV3.fn1(subX); - mrow1 = mrow1.fn1(subX); - mrow2 = mrow2.fn1(subX); - mrow3 = mrow3.fn1(subX); + tempV3 = tempV3.DAffMatrixProdVec(subX); + mrow1 = mrow1.DAffMatrixProdVec(subX); + mrow2 = mrow2.DAffMatrixProdVec(subX); + mrow3 = mrow3.DAffMatrixProdVec(subX); - tempV3 = tempV3.fn1(m1); - mrow1 = mrow1.fn1(m1); - mrow2 = mrow2.fn1(m1); - mrow3 = mrow3.fn1(m1); + tempV3 = tempV3.DAffMatrixProdVec(m1); + mrow1 = mrow1.DAffMatrixProdVec(m1); + mrow2 = mrow2.DAffMatrixProdVec(m1); + mrow3 = mrow3.DAffMatrixProdVec(m1); mrow1 -= tempV3; mrow2 -= tempV3; @@ -497,11 +497,11 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) { tempV3._z = m5._row3._z * 1000000.0 + m4._col1._z; m4._col4 = tempV3; - tempV2 = tempV2.fn1(m2); - m4._col1 = m4._col1.fn1(m2); - m4._col3 = m4._col3.fn1(m2); - m4._col2 = m4._col2.fn1(m2); - m4._col4 = m4._col4.fn1(m2); + tempV2 = tempV2.DAffMatrixProdVec(m2); + m4._col1 = m4._col1.DAffMatrixProdVec(m2); + m4._col3 = m4._col3.DAffMatrixProdVec(m2); + m4._col2 = m4._col2.DAffMatrixProdVec(m2); + m4._col4 = m4._col4.DAffMatrixProdVec(m2); // Find the angle that gives the minimum distance DVector tempPos; @@ -522,10 +522,10 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) { m4._col2.fn2((double)minDegree); m4._col3.fn2((double)minDegree); m4._col4.fn2((double)minDegree); - m4._col1 = m4._col1.fn1(m1); - m4._col2 = m4._col2.fn1(m1); - m4._col3 = m4._col3.fn1(m1); - m4._col4 = m4._col4.fn1(m1); + m4._col1 = m4._col1.DAffMatrixProdVec(m1); + m4._col2 = m4._col2.DAffMatrixProdVec(m1); + m4._col3 = m4._col3.DAffMatrixProdVec(m1); + m4._col4 = m4._col4.DAffMatrixProdVec(m1); m4._col3 -= m4._col1; m4._col2 -= m4._col1; |