diff options
author | ModoX <moardox@gmail.com> | 2025-02-06 21:07:40 +0100 |
---|---|---|
committer | ModoX <moardox@gmail.com> | 2025-02-06 21:07:50 +0100 |
commit | aed08b8a82cd4c14a6831ace7e9c4065ce29c5a4 (patch) | |
tree | e00bd942c9af7e879ee29a5d333a0e10d43c7669 /src | |
parent | 320c44e8e74dbd6657cba227d4b16fed1e8aba7d (diff) |
Core/Maps: Implemented PolygonBoundary
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Maps/AreaBoundary.cpp | 9 | ||||
-rw-r--r-- | src/server/game/Maps/AreaBoundary.h | 13 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/server/game/Maps/AreaBoundary.cpp b/src/server/game/Maps/AreaBoundary.cpp index 179070fcaed..989c9957546 100644 --- a/src/server/game/Maps/AreaBoundary.cpp +++ b/src/server/game/Maps/AreaBoundary.cpp @@ -90,6 +90,15 @@ bool ZRangeBoundary::IsWithinBoundaryArea(Position const* pos) const return (_minZ <= pos->GetPositionZ() && pos->GetPositionZ() <= _maxZ); } +// ---== POLYGON ==--- +PolygonBoundary::PolygonBoundary(Position origin, std::vector<Position>&& vertices, bool isInverted /* = false*/) : + AreaBoundary(isInverted), _origin(origin), _vertices(std::move(vertices)) { } + +bool PolygonBoundary::IsWithinBoundaryArea(Position const* pos) const +{ + return pos->IsInPolygon2D(_origin, _vertices); +} + // ---== UNION OF 2 BOUNDARIES ==--- BoundaryUnionBoundary::BoundaryUnionBoundary(AreaBoundary const* b1, AreaBoundary const* b2, bool isInverted) : AreaBoundary(isInverted), _b1(b1), _b2(b2) diff --git a/src/server/game/Maps/AreaBoundary.h b/src/server/game/Maps/AreaBoundary.h index b08c13018d6..e650cb8b12a 100644 --- a/src/server/game/Maps/AreaBoundary.h +++ b/src/server/game/Maps/AreaBoundary.h @@ -150,6 +150,19 @@ class TC_GAME_API ZRangeBoundary : public AreaBoundary float const _minZ, _maxZ; }; +class TC_GAME_API PolygonBoundary : public AreaBoundary +{ +public: + PolygonBoundary(Position origin, std::vector<Position>&& vertices, bool isInverted = false); + +protected: + bool IsWithinBoundaryArea(Position const* pos) const override; + +private: + Position _origin; + std::vector<Position> _vertices; +}; + class TC_GAME_API BoundaryUnionBoundary : public AreaBoundary { public: |