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 <G3D/Vector3.h>
20#include <algorithm>
21#include <cstring>
22#include <cmath>
23
25{
26}
27
29{
30}
31
33{
35 memset(DefaultDatas.Data, 0, sizeof(DefaultDatas.Data));
36}
37
39{
40 switch (Type)
41 {
43 return std::max(SphereDatas.Radius, SphereDatas.RadiusTarget);
45 return std::sqrt(std::max(
46 BoxDatas.Extents[0] * BoxDatas.Extents[0] + BoxDatas.Extents[1] * BoxDatas.Extents[1],
47 BoxDatas.ExtentsTarget[0] * BoxDatas.ExtentsTarget[0] + BoxDatas.ExtentsTarget[1] * BoxDatas.ExtentsTarget[1]));
49 {
50 Position center(0.0f, 0.0f);
51 float maxSearchRadius = 0.0f;
52
54 maxSearchRadius = std::max(maxSearchRadius, center.GetExactDist2d(vertex));
55
57 maxSearchRadius = std::max(maxSearchRadius, center.GetExactDist2d(vertex));
58
59 return maxSearchRadius;
60 }
62 return std::max(CylinderDatas.Radius, CylinderDatas.RadiusTarget);
64 return std::max(DiskDatas.OuterRadius, DiskDatas.OuterRadiusTarget);
66 return std::sqrt(std::max(
67 BoundedPlaneDatas.Extents[0] * BoundedPlaneDatas.Extents[0] / 4 + BoundedPlaneDatas.Extents[1] * BoundedPlaneDatas.Extents[1] / 4,
68 BoundedPlaneDatas.ExtentsTarget[0] * BoundedPlaneDatas.ExtentsTarget[0] / 4 + BoundedPlaneDatas.ExtentsTarget[1] * BoundedPlaneDatas.ExtentsTarget[1] / 4));
69 default:
70 break;
71 }
72
73 return 0.0f;
74}
75
77{
78 Id = { 0, false };
79}
80
82
84{
85 Id = { 0, false };
86 Template = nullptr;
87
88 MoveCurveId = 0;
89 ScaleCurveId = 0;
90 MorphCurveId = 0;
91 FacingCurveId = 0;
92
93 AnimId = 0;
94 AnimKitId = 0;
95
97
98 TimeToTarget = 0;
100
101 ExtraScale.emplace();
102
103 ScriptId = 0;
104}
105
107
109{
110 return SplinePoints.size() >= 2;
111}
AreaTriggerCreatePropertiesFlag
AreaTriggerFlag
CurveInterpolationMode
Definition: DBCEnums.h:862
AreaTriggerCreatePropertiesId Id
AreaTriggerTemplate const * Template
std::vector< Position > SplinePoints
Optional< AreaTriggerScaleCurveTemplate > ExtraScale
float GetMaxSearchRadius() const
struct AreaTriggerShapeInfo::@199::@203 BoxDatas
struct AreaTriggerShapeInfo::@199::@207 BoundedPlaneDatas
std::vector< TaggedPosition< Position::XY > > PolygonVertices
AreaTriggerShapeType Type
struct AreaTriggerShapeInfo::@199::@202 SphereDatas
std::vector< TaggedPosition< Position::XY > > PolygonVerticesTarget
struct AreaTriggerShapeInfo::@199::@205 CylinderDatas
struct AreaTriggerShapeInfo::@199::@201 DefaultDatas
struct AreaTriggerShapeInfo::@199::@206 DiskDatas
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:106