diff options
author | Filippos Karapetis | 2019-12-27 01:33:02 +0200 |
---|---|---|
committer | Filippos Karapetis | 2019-12-27 01:33:28 +0200 |
commit | f7a5c21d4de443f861544db17b18c958cea2811f (patch) | |
tree | fab74f9d0e1008b626f466d5b17c1fbf9fc32b32 /engines/startrek/awaymission.cpp | |
parent | 26fcce1e4174d528829d42196a27667c0996108d (diff) | |
download | scummvm-rg350-f7a5c21d4de443f861544db17b18c958cea2811f.tar.gz scummvm-rg350-f7a5c21d4de443f861544db17b18c958cea2811f.tar.bz2 scummvm-rg350-f7a5c21d4de443f861544db17b18c958cea2811f.zip |
STARTREK: Move isPointInPolygon() inside the Room class
This accesses the room data, so it's better to move it inside the Room
class, to reduce direct visibility of the room vertex data
Diffstat (limited to 'engines/startrek/awaymission.cpp')
-rw-r--r-- | engines/startrek/awaymission.cpp | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/engines/startrek/awaymission.cpp b/engines/startrek/awaymission.cpp index 08016c158b..5db4f42248 100644 --- a/engines/startrek/awaymission.cpp +++ b/engines/startrek/awaymission.cpp @@ -679,32 +679,11 @@ void StarTrekEngine::handleAwayMissionAction() { } } -bool StarTrekEngine::isPointInPolygon(int16 *data, int16 x, int16 y) { - int16 numVertices = data[1]; - int16 *vertData = &data[2]; - - for (int i = 0; i < numVertices; i++) { - Common::Point p1(vertData[0], vertData[1]); - Common::Point p2; - if (i == numVertices - 1) // Loop to 1st vertex - p2 = Common::Point(data[2], data[3]); - else - p2 = Common::Point(vertData[2], vertData[3]); - - if ((p2.x - p1.x) * (y - p1.y) - (p2.y - p1.y) * (x - p1.x) < 0) - return false; - - vertData += 2; - } - - return true; -} - void StarTrekEngine::checkTouchedLoadingZone(int16 x, int16 y) { int16 offset = _room->getFirstDoorPolygonOffset(); while (offset != _room->getDoorPolygonEndOffset()) { - if (isPointInPolygon((int16 *)(_room->_rdfData + offset), x, y)) { + if (_room->isPointInPolygon(offset, x, y)) { uint16 var = _room->readRdfWord(offset); if (_activeDoorWarpHotspot != var) { _activeDoorWarpHotspot = var; @@ -722,7 +701,7 @@ void StarTrekEngine::checkTouchedLoadingZone(int16 x, int16 y) { offset = _room->getFirstWarpPolygonOffset(); while (offset != _room->getWarpPolygonEndOffset()) { - if (isPointInPolygon((int16 *)(_room->_rdfData + offset), x, y)) { + if (_room->isPointInPolygon(offset, x, y)) { uint16 var = _room->readRdfWord(offset); if (_activeWarpHotspot != var) { _activeWarpHotspot = var; |