TrinityCore
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 <cstring>
21#include <cmath>
22
24{
25}
26
28{
29}
30
32{
34 memset(DefaultDatas.Data, 0, sizeof(DefaultDatas.Data));
35}
36
38{
39 switch (Type)
40 {
42 return std::max(SphereDatas.Radius, SphereDatas.RadiusTarget);
44 return std::sqrt(std::max(
45 BoxDatas.Extents[0] * BoxDatas.Extents[0] + BoxDatas.Extents[1] * BoxDatas.Extents[1],
46 BoxDatas.ExtentsTarget[0] * BoxDatas.ExtentsTarget[0] + BoxDatas.ExtentsTarget[1] * BoxDatas.ExtentsTarget[1]));
48 {
49 Position center(0.0f, 0.0f);
50 float maxSearchRadius = 0.0f;
51
53 maxSearchRadius = std::max(maxSearchRadius, center.GetExactDist2d(vertex));
54
56 maxSearchRadius = std::max(maxSearchRadius, center.GetExactDist2d(vertex));
57
58 return maxSearchRadius;
59 }
61 return std::max(CylinderDatas.Radius, CylinderDatas.RadiusTarget);
63 return std::max(DiskDatas.OuterRadius, DiskDatas.OuterRadiusTarget);
65 return std::sqrt(std::max(
66 BoundedPlaneDatas.Extents[0] * BoundedPlaneDatas.Extents[0] / 4 + BoundedPlaneDatas.Extents[1] * BoundedPlaneDatas.Extents[1] / 4,
67 BoundedPlaneDatas.ExtentsTarget[0] * BoundedPlaneDatas.ExtentsTarget[0] / 4 + BoundedPlaneDatas.ExtentsTarget[1] * BoundedPlaneDatas.ExtentsTarget[1] / 4));
68 default:
69 break;
70 }
71
72 return 0.0f;
73}
74
77
80
82{
83 return SplinePoints.size() >= 2;
84}
CurveInterpolationMode
Definition: DBCEnums.h:907
std::vector< Position > SplinePoints
struct AreaTriggerShapeInfo::@189::@193 BoxDatas
struct AreaTriggerShapeInfo::@189::@196 DiskDatas
float GetMaxSearchRadius() const
std::vector< TaggedPosition< Position::XY > > PolygonVertices
struct AreaTriggerShapeInfo::@189::@197 BoundedPlaneDatas
AreaTriggerShapeType Type
std::vector< TaggedPosition< Position::XY > > PolygonVerticesTarget
struct AreaTriggerShapeInfo::@189::@192 SphereDatas
struct AreaTriggerShapeInfo::@189::@191 DefaultDatas
struct AreaTriggerShapeInfo::@189::@195 CylinderDatas
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:116