diff options
author | Paul Gilbert | 2017-05-21 22:58:31 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-05-21 22:58:31 -0400 |
commit | 1ed01c2f7f2b9691f913148565b4f9c14a5e0f32 (patch) | |
tree | d73089903f90f3658b3a894be3741a42b4146f8c | |
parent | 63a87ac1f7f890edfd3b2b183260b4859dabc6b2 (diff) | |
download | scummvm-rg350-1ed01c2f7f2b9691f913148565b4f9c14a5e0f32.tar.gz scummvm-rg350-1ed01c2f7f2b9691f913148565b4f9c14a5e0f32.tar.bz2 scummvm-rg350-1ed01c2f7f2b9691f913148565b4f9c14a5e0f32.zip |
TITANIC: Rename Sub25 class to COrientationChanger, fixes & cleanup
-rw-r--r-- | engines/titanic/module.mk | 2 | ||||
-rw-r--r-- | engines/titanic/star_control/orientation_changer.cpp (renamed from engines/titanic/star_control/star_control_sub25.cpp) | 28 | ||||
-rw-r--r-- | engines/titanic/star_control/orientation_changer.h (renamed from engines/titanic/star_control/star_control_sub25.h) | 26 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub23.h | 4 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub24.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub26.cpp | 14 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub26.h | 2 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub27.cpp | 4 |
8 files changed, 47 insertions, 39 deletions
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index 1228d73ae8..e003d48e24 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -441,6 +441,7 @@ MODULE_OBJS := \ star_control/frange.o \ star_control/frect.o \ star_control/fvector.o \ + star_control/orientation_changer.o \ star_control/star_camera.o \ star_control/star_closeup.o \ star_control/star_control_sub2.o \ @@ -450,7 +451,6 @@ MODULE_OBJS := \ star_control/star_control_sub22.o \ star_control/star_control_sub23.o \ star_control/star_control_sub24.o \ - star_control/star_control_sub25.o \ star_control/star_control_sub26.o \ star_control/star_control_sub27.o \ star_control/star_field.o \ diff --git a/engines/titanic/star_control/star_control_sub25.cpp b/engines/titanic/star_control/orientation_changer.cpp index 39588725fa..decbd6b74b 100644 --- a/engines/titanic/star_control/star_control_sub25.cpp +++ b/engines/titanic/star_control/orientation_changer.cpp @@ -20,32 +20,30 @@ * */ -#include "titanic/star_control/star_control_sub25.h" +#include "titanic/star_control/orientation_changer.h" #include "titanic/star_control/dmatrix.h" namespace Titanic { -void CStarControlSub25::fn1(const FMatrix &m1, const FMatrix &m2) { - _matrix1 = m1; - _matrix2 = m2; +void COrientationChanger::load(const FMatrix &minOrient, const FMatrix &maxOrient) { + _minOrient = minOrient; + _maxOrient = maxOrient; - DMatrix matrix = _matrix2; - _sub1.fn4(matrix); - matrix = _matrix2; - _sub2.fn4(matrix); + _sub1.fn4(_minOrient); + _sub2.fn4(_maxOrient); } -void CStarControlSub25::fn2(double val, FMatrix &orientation) { - if (val <= 0.0) { - orientation = _matrix1; - } else if (val > 1.0) { - orientation = _matrix2; +FMatrix COrientationChanger::getOrientation(double percent) { + if (percent <= 0.0) { + return _minOrient; + } else if (percent > 1.0) { + return _maxOrient; } else { - CStarControlSub26 sub26 = _sub1.fn5(val, &_sub2); + CStarControlSub26 sub26 = _sub1.fn5(percent, &_sub2); DMatrix m1; m1.fn3(&sub26); - orientation = m1; + return m1; } } diff --git a/engines/titanic/star_control/star_control_sub25.h b/engines/titanic/star_control/orientation_changer.h index e6a303439f..fc1a132e9a 100644 --- a/engines/titanic/star_control/star_control_sub25.h +++ b/engines/titanic/star_control/orientation_changer.h @@ -20,25 +20,35 @@ * */ -#ifndef TITANIC_STAR_CONTROL_SUB25_H -#define TITANIC_STAR_CONTROL_SUB25_H +#ifndef TITANIC_ORIENTATION_CHANGER_H +#define TITANIC_ORIENTATION_CHANGER_H #include "titanic/star_control/fmatrix.h" #include "titanic/star_control/star_control_sub26.h" namespace Titanic { -class CStarControlSub25 { +class COrientationChanger { public: - FMatrix _matrix1; - FMatrix _matrix2; + FMatrix _minOrient; + FMatrix _maxOrient; CStarControlSub26 _sub1; CStarControlSub26 _sub2; public: - void fn1(const FMatrix &m1, const FMatrix &m2); - void fn2(double val, FMatrix &orientation); + /** + * Loads the constraints for the minimum and maximum orientation + */ + void load(const FMatrix &minOrient, const FMatrix &maxOrient); + + /** + * Returns the orientation for a given percentage between the two + * extremes + * @param percent Percentage transition 0.0 to 1.0 + * @returns New orientation for the given percentage between the two + */ + FMatrix getOrientation(double percent); }; } // End of namespace Titanic -#endif /* TITANIC_STAR_CONTROL_SUB25_H */ +#endif /* TITANIC_ORIENTATION_CHANGER_H */ diff --git a/engines/titanic/star_control/star_control_sub23.h b/engines/titanic/star_control/star_control_sub23.h index e1e1ba08b5..d747f358bf 100644 --- a/engines/titanic/star_control/star_control_sub23.h +++ b/engines/titanic/star_control/star_control_sub23.h @@ -26,7 +26,7 @@ #include "titanic/star_control/error_code.h" #include "titanic/star_control/fmatrix.h" #include "titanic/star_control/fvector.h" -#include "titanic/star_control/star_control_sub25.h" +#include "titanic/star_control/orientation_changer.h" namespace Titanic { @@ -48,7 +48,7 @@ protected: int _field54; double _moveDelayCtr; double _moveDelayInc; - CStarControlSub25 _sub25; + COrientationChanger _sub25; public: CStarControlSub23(); virtual ~CStarControlSub23() {} diff --git a/engines/titanic/star_control/star_control_sub24.cpp b/engines/titanic/star_control/star_control_sub24.cpp index 48737535c5..b3f873fcd8 100644 --- a/engines/titanic/star_control/star_control_sub24.cpp +++ b/engines/titanic/star_control/star_control_sub24.cpp @@ -27,7 +27,7 @@ namespace Titanic { void CStarControlSub24::proc3(const FMatrix &m1, const FMatrix &m2) { CStarControlSub23::proc3(m1, m2); - _sub25.fn1(m1, m2); + _sub25.load(m1, m2); _moveDelayInc = 0.1; _moveDelayCtr = 0.0; _field40 = _field44 = _field48 = -1; @@ -71,7 +71,7 @@ void CStarControlSub24::setPath(const FVector &srcV, const FVector &destV, const FMatrix m1; m1.fn1(tempV1); - _sub25.fn1(orientation, m1); + _sub25.load(orientation, m1); _moveDelayCtr = 0.0; _moveDelayInc = 0.1; @@ -88,7 +88,7 @@ int CStarControlSub24::proc5(CErrorCode &errorCode, FVector &pos, FMatrix &orien if (_moveDelayCtr < 1.0) { _moveDelayCtr += _moveDelayInc; - _sub25.fn2(_moveDelayCtr, orientation); + orientation = _sub25.getOrientation(_moveDelayCtr); errorCode.set(); return 1; } diff --git a/engines/titanic/star_control/star_control_sub26.cpp b/engines/titanic/star_control/star_control_sub26.cpp index ce23d51330..5625457f2a 100644 --- a/engines/titanic/star_control/star_control_sub26.cpp +++ b/engines/titanic/star_control/star_control_sub26.cpp @@ -96,7 +96,7 @@ void CStarControlSub26::fn4(const DMatrix &m) { } } -CStarControlSub26 CStarControlSub26::fn5(double val, CStarControlSub26 *src) { +CStarControlSub26 CStarControlSub26::fn5(double percent, CStarControlSub26 *src) { CStarControlSub26 sub1 = *this; CStarControlSub26 sub2, sub3, sub4; CStarControlSub26 dest; @@ -114,8 +114,8 @@ CStarControlSub26 CStarControlSub26::fn5(double val, CStarControlSub26 *src) { dest._sub._v3 = -sub1._field0; dest._field0 = sub1._sub._v3; - double sin1 = sin(val * M_PI); - double sin2 = sin((0.5 - val) * M_PI); + double sin1 = sin(percent * M_PI); + double sin2 = sin((0.5 - percent) * M_PI); dest._sub._v1 = sin1 * dest._sub._v1 + sub1._sub._v1 * sin2; dest._sub._v2 = sub1._sub._v2 * sin2 + sub1._sub._v1 * sin1; dest._sub._v3 = sin1 * -sub1._field0 + sub1._sub._v3 * sin2; @@ -125,13 +125,13 @@ CStarControlSub26 CStarControlSub26::fn5(double val, CStarControlSub26 *src) { double val2; if (1.0 - val1 <= 0.00001) { - val2 = 1.0 - val; - sp = src->fn3(&sub3, val); + val2 = 1.0 - percent; + sp = src->fn3(&sub3, percent); } else { double cosVal = acos(val1); double sinVal = sin(cosVal); - val2 = sin((1.0 - val) * cosVal) / sinVal; - sp = src->fn3(&sub3, sin(cosVal * val) / sinVal); + val2 = sin((1.0 - percent) * cosVal) / sinVal; + sp = src->fn3(&sub3, sin(cosVal * percent) / sinVal); } const CStarControlSub26 *sp2 = sub1.fn3(&sub4, val2); diff --git a/engines/titanic/star_control/star_control_sub26.h b/engines/titanic/star_control/star_control_sub26.h index 577e769767..690a274583 100644 --- a/engines/titanic/star_control/star_control_sub26.h +++ b/engines/titanic/star_control/star_control_sub26.h @@ -56,7 +56,7 @@ public: double fn1() const; void fn4(const DMatrix &m); - CStarControlSub26 fn5(double val, CStarControlSub26 *src); + CStarControlSub26 fn5(double percent, CStarControlSub26 *src); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub27.cpp b/engines/titanic/star_control/star_control_sub27.cpp index 3c56b7d93e..01b8f2e442 100644 --- a/engines/titanic/star_control/star_control_sub27.cpp +++ b/engines/titanic/star_control/star_control_sub27.cpp @@ -37,7 +37,7 @@ void CStarControlSub27::proc2(FVector &oldPos, FVector &newPos, } if (newPos != oldPos) { - _sub25.fn1(oldOrientation, newOrientation); + _sub25.load(oldOrientation, newOrientation); _moveDelayCtr = 0.0; if (_field4C == 0) { @@ -55,7 +55,7 @@ int CStarControlSub27::proc5(CErrorCode &errorCode, FVector &pos, FMatrix &orien return 0; _moveDelayCtr += _moveDelayInc; - _sub25.fn2(_moveDelayCtr, orientation); + orientation = _sub25.getOrientation(_moveDelayCtr); errorCode.set(); if (_field40 >= 0) { |