diff options
author | Paul Gilbert | 2017-06-04 20:17:11 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-06-04 20:17:11 -0400 |
commit | 032cd3f4eb84fb63d47e72c66812fdf6decf1026 (patch) | |
tree | c329c7983656ff0a9f7bb2d860a42460decfa4c3 /engines/titanic/star_control | |
parent | a8e03289dfa0faabd5e1dde388d0f09b3e600dea (diff) | |
download | scummvm-rg350-032cd3f4eb84fb63d47e72c66812fdf6decf1026.tar.gz scummvm-rg350-032cd3f4eb84fb63d47e72c66812fdf6decf1026.tar.bz2 scummvm-rg350-032cd3f4eb84fb63d47e72c66812fdf6decf1026.zip |
TITANIC: Simplify DVector fn1
Diffstat (limited to 'engines/titanic/star_control')
-rw-r--r-- | engines/titanic/star_control/dvector.cpp | 5 | ||||
-rw-r--r-- | engines/titanic/star_control/dvector.h | 2 | ||||
-rw-r--r-- | engines/titanic/star_control/star_camera.cpp | 64 |
3 files changed, 25 insertions, 46 deletions
diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp index b4a9ede3b2..6e962fe876 100644 --- a/engines/titanic/star_control/dvector.cpp +++ b/engines/titanic/star_control/dvector.cpp @@ -40,11 +40,12 @@ 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(DVector &dest, const DMatrix &m) { +DVector DVector::fn1(const DMatrix &m) { + DVector dest; dest._x = m._row3._x * _z + m._row2._x * _y + _x * m._row1._x + m._row4._x; dest._y = m._row2._y * _y + m._row3._y * _z + m._row1._y * _x + m._row4._y; dest._z = m._row3._z * _z + m._row2._z * _y + m._row1._z * _x + m._row4._z; - return &dest; + return dest; } void DVector::fn2(double val) { diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h index cb0d8fb4ee..b4fb21b5be 100644 --- a/engines/titanic/star_control/dvector.h +++ b/engines/titanic/star_control/dvector.h @@ -48,7 +48,7 @@ public: */ double getDistance(const DVector &src); - DVector *fn1(DVector &dest, const DMatrix &m); + DVector fn1(const DMatrix &m); void fn2(double val); DVector fn3() const; DMatrix fn4(const DVector &v); diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp index 9b11043fa0..c12d794f8d 100644 --- a/engines/titanic/star_control/star_camera.cpp +++ b/engines/titanic/star_control/star_camera.cpp @@ -321,23 +321,15 @@ void CStarCamera::setViewportAngle(const FPoint &angles) { tempV7._x = m3._row3._x * 1000000.0 + tempV3._x; mrow3 = tempV8; - DVector *v = tempV3.fn1(tempV9, subX); - tempV3 = *v; - v = mrow1.fn1(tempV10, subX); - mrow1 = *v; - v = mrow2.fn1(tempV11, subX); - mrow2 = *v; - v = mrow3.fn1(tempV12, subX); - mrow3 = *v; - - v = tempV3.fn1(tempV13, m1); - tempV3 = *v; - v = mrow1.fn1(tempV14, m1); - mrow1 = *v; - v = mrow2.fn1(tempV15, m1); - mrow2 = *v; - v = mrow3.fn1(tempV16, m1); - mrow3 = *v; + tempV3 = tempV3.fn1(subX); + mrow1 = mrow1.fn1(subX); + mrow2 = mrow2.fn1(subX); + mrow3 = mrow3.fn1(subX); + + tempV3 = tempV3.fn1(m1); + mrow1 = mrow1.fn1(m1); + mrow2 = mrow2.fn1(m1); + mrow3 = mrow3.fn1(m1); mrow1 -= tempV3; mrow2 -= tempV3; @@ -500,16 +492,11 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) { tempV3._z = m5._row3._z * 1000000.0 + m4._row1._z; m4._row4 = tempV3; - DVector *dv = tempV2.fn1(tempV3, m2); - tempV3 = *dv; - dv = m4._row1.fn1(tempV3, m2); - m4._row1 = *dv; - dv = m4._row3.fn1(tempV3, m2); - m4._row3 = *dv; - dv = m4._row2.fn1(tempV3, m2); - m4._row2 = *dv; - dv = m4._row4.fn1(tempV3, m2); - m4._row4 = *dv; + tempV3 = tempV2.fn1(m2); + m4._row1 = m4._row1.fn1(m2); + m4._row2 = m4._row2.fn1(m2); + m4._row3 = m4._row3.fn1(m2); + m4._row4 = m4._row4.fn1(m2); // Find the angle that gives the minimum distance DVector tempV5; @@ -530,25 +517,16 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) { m4._row2.fn2((double)minDegree); m4._row3.fn2((double)minDegree); m4._row4.fn2((double)minDegree); - dv = m4._row1.fn1(tempV3, m1); - m4._row1 = *dv; - dv = m4._row3.fn1(tempV3, m1); - m4._row3 = *dv; - dv = m4._row2.fn1(tempV3, m1); - m4._row2 = *dv; - dv = m4._row4.fn1(tempV3, m1); - m4._row4 = *dv; - - m4._row3._x -= m4._row1._x; - m4._row3._y -= m4._row1._y; - m4._row3._z -= m4._row1._z; + m4._row1 = m4._row1.fn1(m1); + m4._row2 = m4._row2.fn1(m1); + m4._row3 = m4._row3.fn1(m1); + m4._row4 = m4._row4.fn1(m1); + + m4._row3 -= m4._row1; m4._row2._x -= m4._row1._x; m4._row2._y -= m4._row1._y; m4._row2._z = m4._row2._z - m4._row1._z; - - m4._row4._x = m4._row4._x - m4._row1._x; - m4._row4._y = m4._row4._y - m4._row1._y; - m4._row4._z = m4._row4._z - m4._row1._z; + m4._row4 -= m4._row1; m4._row3.normalize(); m4._row2.normalize(); |