ScummVM API documentation
pathfinder.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ILLUSIONS_PATHFINDER_H
23 #define ILLUSIONS_PATHFINDER_H
24 
25 #include "illusions/graphics.h"
26 #include "common/array.h"
27 #include "common/list.h"
28 #include "common/rect.h"
29 
30 namespace Illusions {
31 
32 struct PathLine {
33  Common::Point p0, p1;
34 };
35 
38 
39 class PathFinder {
40 public:
41  PointArray *findPath(Camera *camera, Common::Point sourcePt, Common::Point destPt,
42  PointArray *walkPoints, PathLines *walkRects, WidthHeight bgDimensions);
43 protected:
44  PathLine _screenRect;
45  PointArray *_walkPoints;
46  PathLines *_walkRects;
47  WidthHeight _bgDimensions;
48  byte *_pathBytes;
49  PointArray *findPathInternal(Common::Point sourcePt, Common::Point destPt);
50  void postProcess(Common::Point sourcePt, PointArray *foundPath);
51  bool isLineBlocked(PathLine &line);
52  int calcLineDistance(PathLine &line);
53  bool findClosestPt(Common::Point &sourcePt, Common::Point &closestPt, Common::Point &destPt);
54  bool findValidDestLine(Common::Point &destPt);
55  void findValidDestPt(Common::Point &destPt);
56  WidthHeight calcRectDimensions(PathLine &rect);
57  void adjustRectDimensions(WidthHeight &dimensions);
58  void swapDimensions(WidthHeight &dimensions);
59  void clipLineToBg(Common::Point &destPt, WidthHeight &rectDimensions, PathLine &outDestLine);
60  void findDeltaPt(Common::Point pt, Common::Point &outDeltaPt);
61  bool isLineWithinRectangle(PathLine &line, PathLine &rect);
62  void swapLine(PathLine &line, PathLine &outLine);
63  int calcLineStatus(PathLine &sourceLine, PathLine &destRect, Common::Point *outPoint);
64 };
65 
66 } // End of namespace Illusions
67 
68 #endif // ILLUSIONS_PATHFINDER_H
Definition: pathfinder.h:32
Definition: array.h:52
Definition: actor.h:34
Definition: pathfinder.h:39
Definition: graphics.h:31
Definition: camera.h:65
Definition: rect.h:45