aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2013-10-05 11:52:50 +0300
committerEugene Sandulenko2013-10-05 11:53:08 +0300
commit5dabd4bf3767f209fcd25107a5d3a0f0aedadce4 (patch)
tree136b9d9890a00cdd7cf8009e44c89e2de06b0c10 /engines
parenta1998abed4fd8e1abfc7cc5cb97978999849a29e (diff)
downloadscummvm-rg350-5dabd4bf3767f209fcd25107a5d3a0f0aedadce4.tar.gz
scummvm-rg350-5dabd4bf3767f209fcd25107a5d3a0f0aedadce4.tar.bz2
scummvm-rg350-5dabd4bf3767f209fcd25107a5d3a0f0aedadce4.zip
FULLPIPE: Implement MovGraphReact::pointInRegion()
Diffstat (limited to 'engines')
-rw-r--r--engines/fullpipe/motion.cpp55
-rw-r--r--engines/fullpipe/motion.h14
2 files changed, 48 insertions, 21 deletions
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index 2ff2c002e0..c3c5656cc5 100644
--- a/engines/fullpipe/motion.cpp
+++ b/engines/fullpipe/motion.cpp
@@ -652,7 +652,6 @@ ReactParallel::ReactParallel() {
_x2 = 0;
_dy = 0;
_dx = 0;
- _points = 0;
_y1 = 0;
_y2 = 0;
}
@@ -688,12 +687,13 @@ void ReactParallel::createRegion() {
_points[1]->x = (int16)(_x2 - _dx * cs);
_points[1]->y = (int16)(_y2 - _dx * sn);
- _points[2]->x = (int16)(_x1 + _dy * cs);
+ _points[2]->x = (int16)(_x2 + _dy * cs);
_points[2]->y = (int16)(_y2 + _dy * sn);
_points[3]->x = (int16)(_x1 + _dy * cs);
_points[3]->y = (int16)(_y1 + _dy * sn);
+ _pointCount = 4;
// GdiObject::Attach(_rgn, CreatePolygonRgn(_points, 4, 2);
}
@@ -701,18 +701,8 @@ void ReactParallel::method14() {
warning("STUB: ReactParallel::method14()");
}
-bool ReactParallel::pointInRegion(int x, int y) {
- warning("STUB: ReactParallel::pointInRegion()");
-
- warning("%d %d, %d %d, %d %d, %d %d", _points[0]->x, _points[0]->y, _points[1]->x, _points[1]->y, _points[2]->x, _points[2]->y, _points[3]->x, _points[3]->y);
-
- return false;
-}
-
ReactPolygonal::ReactPolygonal() {
_field_C = 0;
- _points = 0;
- _pointCount = 0;
_field_10 = 0;
}
@@ -751,10 +741,45 @@ void ReactPolygonal::method14() {
warning("STUB: ReactPolygonal::method14()");
}
-bool ReactPolygonal::pointInRegion(int x, int y) {
- warning("STUB: ReactPolygonal::pointInRegion()");
+bool MovGraphReact::pointInRegion(int x, int y) {
+ if (_pointCount < 3) {
+ return false;
+ }
+
+ int counter = 0;
+ double xinters;
+ Common::Point p, p1, p2;
+
+ p.x = (double)x;
+ p.y = (double)y;
+
+ p1.x = (double)_points[0]->x;
+ p1.y = (double)_points[0]->y;
+
+ for (uint32 i = 1; i <= _pointCount; i++) {
+ p2.x = (double)_points[i % _pointCount]->x;
+ p2.y = (double)_points[i % _pointCount]->y;
+
+ if (p.y > MIN(p1.y, p2.y)) {
+ if (p.y <= MAX(p1.y, p2.y)) {
+ if (p.x <= MAX(p1.x, p2.x)) {
+ if (p1.y != p2.y) {
+ xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x;
+ if (p1.x == p2.x || p.x <= xinters) {
+ counter++;
+ }
+ }
+ }
+ }
+ }
+ p1 = p2;
+ }
- return false;
+ if (counter % 2 == 0) {
+ return false;
+ } else {
+ return true;
+ }
}
int startWalkTo(int objId, int objKey, int x, int y, int a5) {
diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h
index f94fbc0a26..750f1dcceb 100644
--- a/engines/fullpipe/motion.h
+++ b/engines/fullpipe/motion.h
@@ -63,9 +63,16 @@ public:
class MovGraphReact : public CObject {
public:
+ int _pointCount;
+ Common::Point **_points;
+
+public:
+ MovGraphReact() : _pointCount(0), _points(0) {}
+ ~MovGraphReact() { free(_points); }
+
virtual void method14() {}
virtual void createRegion() {}
- virtual bool pointInRegion(int x, int y) { return false; }
+ virtual bool pointInRegion(int x, int y);
};
class MctlCompoundArrayItem : public CObject {
@@ -160,7 +167,6 @@ class ReactParallel : public MovGraphReact {
int _y2;
int _dx;
int _dy;
- Common::Point **_points;
public:
ReactParallel();
@@ -168,15 +174,12 @@ class ReactParallel : public MovGraphReact {
virtual void method14();
virtual void createRegion();
- virtual bool pointInRegion(int x, int y);
};
class ReactPolygonal : public MovGraphReact {
//CRgn _rgn;
int _field_C;
int _field_10;
- int _pointCount;
- Common::Point **_points;
public:
ReactPolygonal();
@@ -184,7 +187,6 @@ class ReactPolygonal : public MovGraphReact {
virtual void method14();
virtual void createRegion();
- virtual bool pointInRegion(int x, int y);
};
class MovGraphLink : public CObject {