diff options
author | Paul Gilbert | 2017-03-25 18:28:48 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-03-25 18:28:48 -0400 |
commit | 87d894f6f2fb0a230d51669531c2ac69bce6958f (patch) | |
tree | 10f01bab9b39057186a9bdd3048d97fe750ac903 /engines/titanic/star_control | |
parent | c4ea4c362d054fea3aa399ade16aadd4a1807cb2 (diff) | |
download | scummvm-rg350-87d894f6f2fb0a230d51669531c2ac69bce6958f.tar.gz scummvm-rg350-87d894f6f2fb0a230d51669531c2ac69bce6958f.tar.bz2 scummvm-rg350-87d894f6f2fb0a230d51669531c2ac69bce6958f.zip |
TITANIC: Added CBaseStarRef process method
Diffstat (limited to 'engines/titanic/star_control')
-rw-r--r-- | engines/titanic/star_control/base_star.h | 3 | ||||
-rw-r--r-- | engines/titanic/star_control/star_ref.cpp | 53 |
2 files changed, 54 insertions, 2 deletions
diff --git a/engines/titanic/star_control/base_star.h b/engines/titanic/star_control/base_star.h index ff096520e5..1b94b19d21 100644 --- a/engines/titanic/star_control/base_star.h +++ b/engines/titanic/star_control/base_star.h @@ -70,7 +70,6 @@ private: void draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5); void draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5); protected: - Common::Array<CBaseStarEntry> _data; FRange _minMax; double _minVal; double _maxVal; @@ -93,6 +92,8 @@ protected: */ void resetEntry(CBaseStarEntry &entry); public: + Common::Array<CBaseStarEntry> _data; +public: CBaseStar(); virtual ~CBaseStar() {} diff --git a/engines/titanic/star_control/star_ref.cpp b/engines/titanic/star_control/star_ref.cpp index 7f36ae7473..6bb5dbe5df 100644 --- a/engines/titanic/star_control/star_ref.cpp +++ b/engines/titanic/star_control/star_ref.cpp @@ -25,7 +25,58 @@ namespace Titanic { void CBaseStarRef::process(CSurfaceArea *surface, CStarControlSub12 *sub12) { - // TODO + if (_star->_data.empty()) + return; + + const double MAX_VAL = 1.0e9 * 1.0e9; + CStarControlSub6 sub6 = sub12->proc23(); + double threshold = sub12->proc25(); + double vWidth2 = (double)surface->_width * 0.5; + double vHeight2 = (double)surface->_height * 0.5; + FVector vTemp, vector1, vector2; + double val1, val2, val3, val4; + + for (int idx = 0; idx < _star->size(); ++idx) { + const CBaseStarEntry &se = _star->_data[idx]; + vTemp = se._position; + vector1._x = vTemp._x * sub6._row1._x + vTemp._y * sub6._row2._x + vTemp._z * sub6._row3._x + sub6._vector._x; + vector1._y = vTemp._x * sub6._row1._y + vTemp._y * sub6._row2._y + vTemp._z * sub6._row3._y + sub6._vector._y; + vector1._z = vTemp._x * sub6._row1._z + vTemp._y * sub6._row2._z + vTemp._z * sub6._row3._z + sub6._vector._z; + double hyp = vector1._x * vector1._x + vector1._y * vector1._y + vector1._z * vector1._z; + + if (vector1._z > threshold && hyp >= 1.0e12 && hyp < MAX_VAL) { + vector2.clear(); + sub12->proc28(2, vector1, vector2); + + const Common::Point pt((int)(vector2._x + vWidth2 - -0.5), + (int)(vector2._y + vHeight2 - -0.5)); + if (pt.y >= 0 && pt.y < (surface->_height - 1) && + pt.x >= 0 && pt.x < (surface->_width - 1)) { + val1 = sqrt(hyp); + if (val1 >= 100000.0) + val1 = 1.0 - (val1 - 100000.0) / 1000000000.0; + else + val1 = 1.0; + + val2 = val1 * (double)se._field1; + val3 = val1 * (double)se._field2; + val4 = val1 * (double)se._field0; + + int count = 0; + if (val4 < 0.0) + ++count; + if (val2 < 0.0) + ++count; + if (val3 < 0.0) + ++count; + + if (count < 3) { + if (!check(pt, idx)) + break; + } + } + } + } } /*------------------------------------------------------------------------*/ |