TrinityCore
Loading...
Searching...
No Matches
AreaTriggerTemplate.cpp
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#include "AreaTriggerTemplate.h"
19#include <algorithm>
20#include <cmath>
21
23{
24 return std::max(Radius, RadiusTarget);
25}
26
28{
29 return Radius != RadiusTarget;
30}
31
33{
34 return std::sqrt(std::max(
35 Extents.Pos.GetPositionX() * Extents.Pos.GetPositionX() + Extents.Pos.GetPositionY() * Extents.Pos.GetPositionY(),
36 ExtentsTarget.Pos.GetPositionX() * ExtentsTarget.Pos.GetPositionX() + ExtentsTarget.Pos.GetPositionY() * ExtentsTarget.Pos.GetPositionY()));
37}
38
40{
41 return Extents != ExtentsTarget;
42}
43
45{
46 Position center(0.0f, 0.0f);
47 float maxSearchRadius = 0.0f;
48
49 for (TaggedPosition<Position::XY> const& vertex : PolygonVertices)
50 maxSearchRadius = std::max(maxSearchRadius, center.GetExactDist2d(vertex));
51
52 for (TaggedPosition<Position::XY> const& vertex : PolygonVerticesTarget)
53 maxSearchRadius = std::max(maxSearchRadius, center.GetExactDist2d(vertex));
54
55 return maxSearchRadius;
56}
57
59{
60 return Height != HeightTarget || PolygonVertices != PolygonVerticesTarget;
61}
62
64{
65 return std::max(Radius, RadiusTarget);
66}
67
69{
70 return Radius != RadiusTarget || Height != HeightTarget || LocationZOffset != LocationZOffsetTarget;
71}
72
74{
75 return std::max(OuterRadius, OuterRadiusTarget);
76}
77
79{
80 return InnerRadius != InnerRadiusTarget || OuterRadius != OuterRadiusTarget || Height != HeightTarget || LocationZOffset != LocationZOffsetTarget;
81}
82
84{
85 return std::sqrt(std::max(
86 ExtentsY * ExtentsY + ExtentsZ * ExtentsZ,
87 ExtentsTargetY * ExtentsTargetY + ExtentsTargetZ * ExtentsTargetZ));
88}
89
91{
92 return ExtentsY != ExtentsTargetY || ExtentsZ != ExtentsTargetZ;
93}
94
96{
97 return std::visit([&](auto const& data) { return data.GetMaxSearchRadius(); }, Data);
98}
99
101{
102 return std::visit([&](auto const& data) { return data.IsDynamic(); }, Data);
103}
104
107
std::variant< Sphere, Box, Polygon, Cylinder, Disk, BoundedPlane > Data
float GetExactDist2d(const float x, const float y) const
Definition Position.h:117