TrinityCore
Loading...
Searching...
No Matches
AreaBoundary.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITY_AREA_BOUNDARY_H
19#define TRINITY_AREA_BOUNDARY_H
20
21#include "Position.h"
22#include <vector>
23
25{
26public:
27 bool IsWithinBoundary(Position const* pos) const { return pos && (IsWithinBoundaryArea(pos) != _isInvertedBoundary); }
28 bool IsWithinBoundary(Position const& pos) const { return IsWithinBoundary(&pos); }
29
30 AreaBoundary(AreaBoundary const&) = delete;
34
35 virtual ~AreaBoundary() = default;
36
37protected:
38 explicit AreaBoundary(bool isInverted) : _isInvertedBoundary(isInverted) { }
39
40 virtual bool IsWithinBoundaryArea(Position const* pos) const = 0;
41
42private:
44};
45
47{
48public:
49 // X axis is north/south, Y axis is east/west, larger values are northwest
50 RectangleBoundary(float southX, float northX, float eastY, float westY, bool isInverted = false);
51
52protected:
53 bool IsWithinBoundaryArea(Position const* pos) const override;
54
55private:
56 float const _minX, _maxX, _minY, _maxY;
57};
58
60{
61public:
62 CircleBoundary(Position const& center, float radius, bool isInverted = false);
63 CircleBoundary(Position const& center, Position const& pointOnCircle, bool isInverted = false);
64
65protected:
66 bool IsWithinBoundaryArea(Position const* pos) const override;
67
68private:
70 float const _radiusSq;
71};
72
74{
75public:
76 EllipseBoundary(Position const& center, float radiusX, float radiusY, bool isInverted = false);
77
78protected:
79 bool IsWithinBoundaryArea(Position const* pos) const override;
80
81private:
83 float const _radiusYSq, _scaleXSq;
84};
85
87{
88public:
89 TriangleBoundary(Position const& pointA, Position const& pointB, Position const& pointC, bool isInverted = false);
90
91protected:
92 bool IsWithinBoundaryArea(Position const* pos) const override;
93
94private:
95 Position const _a, _b, _c;
96 float const _abx, _bcx, _cax, _aby, _bcy, _cay;
97};
98
100{
101public:
102 // Note: AB must be orthogonal to AD
103 ParallelogramBoundary(Position const& cornerA, Position const& cornerB, Position const& cornerD, bool isInverted = false);
104
105protected:
106 bool IsWithinBoundaryArea(Position const* pos) const override;
107
108private:
109 Position const _a, _b, _d, _c;
110 float const _abx, _dax, _aby, _day;
111};
112
114{
115public:
116 ZRangeBoundary(float minZ, float maxZ, bool isInverted = false);
117
118protected:
119 bool IsWithinBoundaryArea(Position const* pos) const override;
120
121private:
122 float const _minZ, _maxZ;
123};
124
126{
127public:
128 PolygonBoundary(Position const& origin, std::vector<Position>&& vertices, bool isInverted = false);
129
130protected:
131 bool IsWithinBoundaryArea(Position const* pos) const override;
132
133private:
135 std::vector<Position> _vertices;
136};
137
139{
140public:
141 BoundaryUnionBoundary(AreaBoundary const* b1, AreaBoundary const* b2, bool isInverted = false);
146
147protected:
148 virtual ~BoundaryUnionBoundary();
149 bool IsWithinBoundaryArea(Position const* pos) const override;
150
151private:
152 AreaBoundary const* const _b1;
153 AreaBoundary const* const _b2;
154};
155
157{
158public:
159 BoundaryIntersectionBoundary(AreaBoundary const* b1, AreaBoundary const* b2, bool isInverted = false);
164
165protected:
167 bool IsWithinBoundaryArea(Position const* pos) const override;
168
169private:
170 AreaBoundary const* const _b1;
171 AreaBoundary const* const _b2;
172};
173
174#endif //TRINITY_AREA_BOUNDARY_H
#define TC_GAME_API
Definition Define.h:129
AreaBoundary(AreaBoundary &&)=delete
bool IsWithinBoundary(Position const *pos) const
AreaBoundary & operator=(AreaBoundary &&)=delete
bool const _isInvertedBoundary
AreaBoundary & operator=(AreaBoundary const &)=delete
AreaBoundary(AreaBoundary const &)=delete
bool IsWithinBoundary(Position const &pos) const
virtual ~AreaBoundary()=default
AreaBoundary(bool isInverted)
virtual bool IsWithinBoundaryArea(Position const *pos) const =0
BoundaryIntersectionBoundary & operator=(BoundaryIntersectionBoundary const &)=delete
AreaBoundary const *const _b1
BoundaryIntersectionBoundary(BoundaryIntersectionBoundary const &)=delete
AreaBoundary const *const _b2
BoundaryIntersectionBoundary(BoundaryIntersectionBoundary &&)=delete
BoundaryIntersectionBoundary & operator=(BoundaryIntersectionBoundary &&)=delete
BoundaryUnionBoundary & operator=(BoundaryUnionBoundary const &)=delete
AreaBoundary const *const _b1
BoundaryUnionBoundary & operator=(BoundaryUnionBoundary &&)=delete
BoundaryUnionBoundary(BoundaryUnionBoundary const &)=delete
AreaBoundary const *const _b2
BoundaryUnionBoundary(BoundaryUnionBoundary &&)=delete
float const _radiusSq
Position const _center
float const _radiusYSq
Position const _center
std::vector< Position > _vertices
float const _maxX
Position const _a
float const _abx
float const _maxZ