mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
Core/Maps: Implemented PolygonBoundary
(cherry picked from commit aed08b8a82)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user