ScummVM API documentation
walkregion.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/*
23 * This code is based on Broken Sword 2.5 engine
24 *
25 * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
26 *
27 * Licensed under GNU GPL v2
28 *
29 */
30
31#ifndef SWORD25_WALKREGION_H
32#define SWORD25_WALKREGION_H
33
34#include "common/array.h"
35#include "sword25/kernel/common.h"
36#include "sword25/math/region.h"
37
38namespace Sword25 {
39
40typedef Common::Array<Vertex> BS_Path;
41
45class WalkRegion : public Region {
46 friend class Region;
47
48protected:
49 WalkRegion();
50 WalkRegion(InputPersistenceBlock &Reader, uint handle);
51
52public:
53 ~WalkRegion() override;
54
55 bool init(const Polygon &contour, const Common::Array<Polygon> *pHoles = 0) override;
56
71 bool queryPath(int x1, int y1, int x2, int y2, BS_Path &path) {
72 return queryPath(Vertex(x1, y1), Vertex(x2, y2), path);
73 }
74
83 bool queryPath(Vertex startPoint, Vertex endPoint, BS_Path &path);
84
85 void setPos(int x, int y) override;
86
87 const Common::Array<Vertex> &getNodes() const {
88 return _nodes;
89 }
90 const Common::Array< Common::Array<int> > &getVisibilityMatrix() const {
91 return _visibilityMatrix;
92 }
93
94 bool persist(OutputPersistenceBlock &writer) override;
95 bool unpersist(InputPersistenceBlock &reader) override;
96
97private:
99 Common::Array< Common::Array<int> > _visibilityMatrix;
100
101 void initNodeVector();
102 void computeVisibilityMatrix();
103 bool checkAndPrepareStartAndEnd(Vertex &start, Vertex &end) const;
104 bool findPath(const Vertex &start, const Vertex &end, BS_Path &path) const;
105};
106
107} // End of namespace Sword25
108
109#endif
Definition: array.h:52
Definition: inputpersistenceblock.h:40
Eine Polygonklasse.
Definition: polygon.h:46
Definition: region.h:51
Definition: vertex.h:52
Definition: walkregion.h:45
bool queryPath(int x1, int y1, int x2, int y2, BS_Path &path)
Definition: walkregion.h:71
void setPos(int x, int y) override
bool queryPath(Vertex startPoint, Vertex endPoint, BS_Path &path)
bool init(const Polygon &contour, const Common::Array< Polygon > *pHoles=0) override
Definition: console.h:27
Definition: display_client.h:53