Skip to content
Permalink
Browse files

TITANIC: Added CBaseStarRef process method

  • Loading branch information
dreammaster committed Mar 25, 2017
1 parent c4ea4c3 commit 87d894f6f2fb0a230d51669531c2ac69bce6958f
Showing with 54 additions and 2 deletions.
  1. +2 −1 engines/titanic/star_control/base_star.h
  2. +52 −1 engines/titanic/star_control/star_ref.cpp
@@ -70,7 +70,6 @@ class CBaseStar {
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;
@@ -92,6 +91,8 @@ class CBaseStar {
* Reset the data for an entry
*/
void resetEntry(CBaseStarEntry &entry);
public:
Common::Array<CBaseStarEntry> _data;
public:
CBaseStar();
virtual ~CBaseStar() {}
@@ -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;
}
}
}
}
}

/*------------------------------------------------------------------------*/

0 comments on commit 87d894f

Please sign in to comment.
You can’t perform that action at this time.