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 std::sqrt(std::max(
30 Extents.Pos.GetPositionX() * Extents.Pos.GetPositionX() + Extents.Pos.GetPositionY() * Extents.Pos.GetPositionY(),
31 ExtentsTarget.Pos.GetPositionX() * ExtentsTarget.Pos.GetPositionX() + ExtentsTarget.Pos.GetPositionY() * ExtentsTarget.Pos.GetPositionY()));
32}
33
35{
36 Position center(0.0f, 0.0f);
37 float maxSearchRadius = 0.0f;
38
39 for (TaggedPosition<Position::XY> const& vertex : PolygonVertices)
40 maxSearchRadius = std::max(maxSearchRadius, center.GetExactDist2d(vertex));
41
42 for (TaggedPosition<Position::XY> const& vertex : PolygonVerticesTarget)
43 maxSearchRadius = std::max(maxSearchRadius, center.GetExactDist2d(vertex));
44
45 return maxSearchRadius;
46}
47
49{
50 return std::max(Radius, RadiusTarget);
51}
52
54{
55 return std::max(OuterRadius, OuterRadiusTarget);
56}
57
59{
60 return std::sqrt(std::max(
61 Extents.Pos.GetPositionX() * Extents.Pos.GetPositionX() / 4 + Extents.Pos.GetPositionY() * Extents.Pos.GetPositionY() / 4,
62 ExtentsTarget.Pos.GetPositionX() * ExtentsTarget.Pos.GetPositionX() / 4 + ExtentsTarget.Pos.GetPositionY() * ExtentsTarget.Pos.GetPositionY() / 4));
63}
64
66{
67 return std::visit([&](auto const& data) { return data.GetMaxSearchRadius(); }, Data);
68}
69
72
std::variant< Sphere, Box, Polygon, Cylinder, Disk, BoundedPlane > Data
float GetExactDist2d(const float x, const float y) const
Definition Position.h:117