diff options
author | Paul Gilbert | 2017-04-18 22:34:29 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-04-18 22:34:29 -0400 |
commit | c2e9fee93264468d89de66eccdc0cc712cdb76fe (patch) | |
tree | 58758a8b97bfe37e72a511185ce28212345d5806 /engines/titanic | |
parent | fdf2a70f447502f6785affad35061e0870bfa970 (diff) | |
download | scummvm-rg350-c2e9fee93264468d89de66eccdc0cc712cdb76fe.tar.gz scummvm-rg350-c2e9fee93264468d89de66eccdc0cc712cdb76fe.tar.bz2 scummvm-rg350-c2e9fee93264468d89de66eccdc0cc712cdb76fe.zip |
TITANIC: Cleanup of CStarControlSub26 fn5
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/star_control/star_control_sub25.cpp | 3 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub26.cpp | 47 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub26.h | 2 |
3 files changed, 22 insertions, 30 deletions
diff --git a/engines/titanic/star_control/star_control_sub25.cpp b/engines/titanic/star_control/star_control_sub25.cpp index 1cec704300..3fccbd3591 100644 --- a/engines/titanic/star_control/star_control_sub25.cpp +++ b/engines/titanic/star_control/star_control_sub25.cpp @@ -41,8 +41,7 @@ void CStarControlSub25::fn2(double val, FMatrix &m) { } else if (val > 1.0) { m = _matrix2; } else { - CStarControlSub26 sub26; - _sub1.fn5(val, &_sub2, &sub26); + CStarControlSub26 sub26 = _sub1.fn5(val, &_sub2); DMatrix m1; m1.fn3(&sub26); diff --git a/engines/titanic/star_control/star_control_sub26.cpp b/engines/titanic/star_control/star_control_sub26.cpp index 198e2f9074..ce23d51330 100644 --- a/engines/titanic/star_control/star_control_sub26.cpp +++ b/engines/titanic/star_control/star_control_sub26.cpp @@ -96,10 +96,11 @@ void CStarControlSub26::fn4(const DMatrix &m) { } } -void CStarControlSub26::fn5(double val, CStarControlSub26 *s1, CStarControlSub26 *s2) { +CStarControlSub26 CStarControlSub26::fn5(double val, CStarControlSub26 *src) { CStarControlSub26 sub1 = *this; CStarControlSub26 sub2, sub3, sub4; - double val1 = sub1.fn2(s1); + CStarControlSub26 dest; + double val1 = sub1.fn2(src); if (val1 < 0.0) { val1 = -val1; @@ -107,44 +108,36 @@ void CStarControlSub26::fn5(double val, CStarControlSub26 *s1, CStarControlSub26 sub1 = sub2; } - if (val1 - -1.0 <= 0.00001) { - double sval1 = sub1._sub._v1; - double sval3 = sub1._sub._v3; - double sval2 = -sub1._sub._v2; - double sval0 = -sub1._field0; - - sub2._sub._v1 = sval2; - sub2._sub._v2 = sval1; - sub2._sub._v3 = sval0; - sub2._field0 = sval3; - - double sinVal = sin(val * M_PI); - double val2 = sinVal * sval2; - double val3 = sin((0.5 - val) * M_PI); - double val4 = sinVal * sval0; - double val5 = sub1._sub._v3 * val3; - - sub2._sub._v1 = val2 + sub1._sub._v1 * val3; - sub2._sub._v2 = sub1._sub._v2 * val3 + sub1._sub._v1 * sinVal; - sub2._sub._v3 = val4 + val5; + if (val1 + 1.0 <= 0.00001) { + dest._sub._v1 = -sub1._sub._v2; + dest._sub._v2 = sub1._sub._v1; + dest._sub._v3 = -sub1._field0; + dest._field0 = sub1._sub._v3; + + double sin1 = sin(val * M_PI); + double sin2 = sin((0.5 - val) * 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; + return dest; } else { - double val2; const CStarControlSub26 *sp; + double val2; if (1.0 - val1 <= 0.00001) { val2 = 1.0 - val; - sp = s1->fn3(&sub3, val); + sp = src->fn3(&sub3, val); } else { double cosVal = acos(val1); double sinVal = sin(cosVal); val2 = sin((1.0 - val) * cosVal) / sinVal; - sp = s1->fn3(&sub3, sin(cosVal * val) / sinVal); + sp = src->fn3(&sub3, sin(cosVal * val) / sinVal); } const CStarControlSub26 *sp2 = sub1.fn3(&sub4, val2); - sub2.setup(sp2->_field0 + sp->_field0, sp->_sub._v1 + sp2->_sub._v1, + dest.setup(sp2->_field0 + sp->_field0, sp->_sub._v1 + sp2->_sub._v1, sp->_sub._v2 + sp2->_sub._v2, sp->_sub._v3 + sp2->_sub._v3); - *s2 = sub2; + return dest; } } diff --git a/engines/titanic/star_control/star_control_sub26.h b/engines/titanic/star_control/star_control_sub26.h index 081e5e42b1..577e769767 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); - void fn5(double val, CStarControlSub26 *s1, CStarControlSub26 *s2); + CStarControlSub26 fn5(double val, CStarControlSub26 *src); }; } // End of namespace Titanic |