TrinityCore
Movement Namespace Reference

Classes

struct  AnimTierTransition
 
struct  CommonInitializer
 
class  counter
 
struct  FacingInfo
 
struct  FallInitializer
 
struct  Location
 
class  MoveSpline
 
class  MoveSplineFlag
 
class  MoveSplineInit
 
struct  MoveSplineInitArgs
 
struct  SpellEffectExtraData
 
class  Spline
 
class  SplineBase
 
class  TransportPathTransform
 

Typedefs

typedef counter< uint32, 0xFFFFFFFF > UInt32Counter
 
typedef std::vector< Vector3 > PointsArray
 

Enumerations

enum  MonsterMoveType { MONSTER_MOVE_NORMAL = 0 , MONSTER_MOVE_FACING_SPOT = 1 , MONSTER_MOVE_FACING_TARGET = 2 , MONSTER_MOVE_FACING_ANGLE = 3 }
 
enum  { minimal_duration = 1 }
 

Functions

uint32 SecToMS (float sec)
 
float MSToSec (uint32 ms)
 
float computeFallTime (float path_length, bool isSafeFall)
 
float computeFallElevation (float t_passed, bool isSafeFall, float start_velocity=0.0f)
 
TC_GAME_API std::string MovementFlags_ToString (uint32 flags)
 
TC_GAME_API std::string MovementFlagsExtra_ToString (uint32 flags)
 
template<class Flags , int N>
void PrintFlags (Flags t, char const *(&names)[N], std::string &str)
 
uint32 computeDuration (float length, float velocity)
 
UnitMoveType SelectSpeedType (uint32 moveFlags)
 
static const Matrix4 s_catmullRomCoeffs (-0.5f, 1.5f, -1.5f, 0.5f, 1.f, -2.5f, 2.f, -0.5f, -0.5f, 0.f, 0.5f, 0.f, 0.f, 1.f, 0.f, 0.f)
 
static const Matrix4 s_Bezier3Coeffs (-1.f, 3.f, -3.f, 1.f, 3.f, -6.f, 3.f, 0.f, -3.f, 3.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f)
 
void C_Evaluate (Vector3 const *vertice, float t, Matrix4 const &matr, Vector3 &result)
 
void C_Evaluate_Derivative (Vector3 const *vertice, float t, Matrix4 const &matr, Vector3 &result)
 

Variables

float constexpr gravity = static_cast<float>(19.29110527038574)
 
TC_GAME_API UInt32Counter splineIdGen
 
float constexpr terminalVelocity = 60.148003f
 Velocity bounds that makes fall speed limited. More...
 
float constexpr terminalSafefallVelocity = 7.0f
 
float constexpr terminal_length = float(terminalVelocity * terminalVelocity) / (2.0f * gravity)
 
float constexpr terminal_safeFall_length = (terminalSafefallVelocity * terminalSafefallVelocity) / (2.0f * gravity)
 
float constexpr terminal_fallTime = float(terminalVelocity / gravity)
 
float constexpr terminal_safeFall_fallTime = float(terminalSafefallVelocity / gravity)
 
char const * MovementFlagNames []
 
char const * MovementFlagExtraNames []
 
char const * SplineFlagNames [32]
 

Typedef Documentation

◆ PointsArray

typedef std::vector<Vector3> Movement::PointsArray

Definition at line 33 of file MoveSplineInitArgs.h.

◆ UInt32Counter

typedef counter<uint32, 0xFFFFFFFF> Movement::UInt32Counter

Definition at line 77 of file MovementTypedefs.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
minimal_duration 

Definition at line 132 of file MoveSpline.cpp.

132 {
134};
@ minimal_duration
Definition: MoveSpline.cpp:133

◆ MonsterMoveType

Enumerator
MONSTER_MOVE_NORMAL 
MONSTER_MOVE_FACING_SPOT 
MONSTER_MOVE_FACING_TARGET 
MONSTER_MOVE_FACING_ANGLE 

Definition at line 34 of file MovementTypedefs.h.

Function Documentation

◆ C_Evaluate()

void Movement::C_Evaluate ( Vector3 const *  vertice,
float  t,
Matrix4 const &  matr,
Vector3 &  result 
)
inline

Definition at line 96 of file Spline.cpp.

97{
98 Vector4 tvec(t*t*t, t*t, t, 1.f);
99 Vector4 weights(tvec * matr);
100
101 result = vertice[0] * weights[0] + vertice[1] * weights[1]
102 + vertice[2] * weights[2] + vertice[3] * weights[3];
103}
+ Here is the caller graph for this function:

◆ C_Evaluate_Derivative()

void Movement::C_Evaluate_Derivative ( Vector3 const *  vertice,
float  t,
Matrix4 const &  matr,
Vector3 &  result 
)
inline

Definition at line 105 of file Spline.cpp.

106{
107 Vector4 tvec(3.f*t*t, 2.f*t, 1.f, 0.f);
108 Vector4 weights(tvec * matr);
109
110 result = vertice[0] * weights[0] + vertice[1] * weights[1]
111 + vertice[2] * weights[2] + vertice[3] * weights[3];
112}
+ Here is the caller graph for this function:

◆ computeDuration()

uint32 Movement::computeDuration ( float  length,
float  velocity 
)
inline

Definition at line 117 of file MoveSpline.cpp.

118{
119 return SecToMS(length / velocity);
120}
uint32 SecToMS(float sec)
+ Here is the call graph for this function:

◆ computeFallElevation()

float Movement::computeFallElevation ( float  t_passed,
bool  isSafeFall,
float  start_velocity = 0.0f 
)

Definition at line 59 of file MovementUtil.cpp.

60 {
61 float termVel;
62 float result;
63
64 if (isSafeFall)
66 else
67 termVel = terminalVelocity;
68
69 if (start_velocity > termVel)
70 start_velocity = termVel;
71
72 float terminal_time = (isSafeFall ? terminal_safeFall_fallTime : terminal_fallTime) - start_velocity / gravity; // the time that needed to reach terminalVelocity
73
74 if (t_passed > terminal_time)
75 {
76 result = termVel * (t_passed - terminal_time) +
77 start_velocity * terminal_time +
78 gravity * terminal_time * terminal_time * 0.5f;
79 }
80 else
81 result = t_passed * (start_velocity + t_passed * gravity * 0.5f);
82
83 return result;
84 }
float constexpr terminalVelocity
Velocity bounds that makes fall speed limited.
float constexpr gravity
float constexpr terminalSafefallVelocity
float constexpr terminal_fallTime
float constexpr terminal_safeFall_fallTime
+ Here is the caller graph for this function:

◆ computeFallTime()

float Movement::computeFallTime ( float  path_length,
bool  isSafeFall 
)

Definition at line 35 of file MovementUtil.cpp.

36 {
37 if (path_length < 0.0f)
38 return 0.0f;
39
40 float time;
41 if (isSafeFall)
42 {
43 if (path_length >= terminal_safeFall_length)
45 else
46 time = std::sqrt(2.0f * path_length / gravity);
47 }
48 else
49 {
50 if (path_length >= terminal_length)
51 time = (path_length - terminal_length) / terminalVelocity + terminal_fallTime;
52 else
53 time = std::sqrt(2.0f * path_length / gravity);
54 }
55
56 return time;
57 }
float constexpr terminal_safeFall_length
float constexpr terminal_length
+ Here is the caller graph for this function:

◆ MovementFlags_ToString()

std::string Movement::MovementFlags_ToString ( uint32  flags)

Definition at line 199 of file MovementUtil.cpp.

200 {
201 std::string str;
203 return str;
204 }
uint16 flags
Definition: DisableMgr.cpp:49
char const * MovementFlagNames[]
void PrintFlags(Flags t, char const *(&names)[N], std::string &str)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MovementFlagsExtra_ToString()

std::string Movement::MovementFlagsExtra_ToString ( uint32  flags)

Definition at line 206 of file MovementUtil.cpp.

207 {
208 std::string str;
210 return str;
211 }
char const * MovementFlagExtraNames[]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MSToSec()

float Movement::MSToSec ( uint32  ms)
inline

Definition at line 47 of file MovementTypedefs.h.

48 {
49 return ms / 1000.f;
50 }
+ Here is the caller graph for this function:

◆ PrintFlags()

template<class Flags , int N>
void Movement::PrintFlags ( Flags  t,
char const *(&)  names[N],
std::string &  str 
)

Definition at line 183 of file MovementUtil.cpp.

184 {
185 for (int i = 0; i < N; ++i)
186 {
187 if ((t & Flags(1 << i)) && names[i] != nullptr)
188 str.append(" ").append(names[i]);
189 }
190 }
+ Here is the caller graph for this function:

◆ s_Bezier3Coeffs()

static const Matrix4 Movement::s_Bezier3Coeffs ( -1.  f,
3.  f,
-3.  f,
1.  f,
3.  f,
-6.  f,
3.  f,
0.  f,
-3.  f,
3.  f,
0.  f,
0.  f,
1.  f,
0.  f,
0.  f,
0.  f 
)
static
+ Here is the caller graph for this function:

◆ s_catmullRomCoeffs()

static const Matrix4 Movement::s_catmullRomCoeffs ( -0.  5f,
1.  5f,
-1.  5f,
0.  5f,
1.  f,
-2.  5f,
2.  f,
-0.  5f,
-0.  5f,
0.  f,
0.  5f,
0.  f,
0.  f,
1.  f,
0.  f,
0.  f 
)
static
+ Here is the caller graph for this function:

◆ SecToMS()

uint32 Movement::SecToMS ( float  sec)
inline

Definition at line 42 of file MovementTypedefs.h.

43 {
44 return static_cast<uint32>(sec * 1000.f);
45 }
uint32_t uint32
Definition: Define.h:143
+ Here is the caller graph for this function:

◆ SelectSpeedType()

UnitMoveType Movement::SelectSpeedType ( uint32  moveFlags)

Definition at line 28 of file MoveSplineInit.cpp.

29 {
30 if (moveFlags & MOVEMENTFLAG_FLYING)
31 {
32 if (moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.flight >= speed_obj.flight_back*/)
33 return MOVE_FLIGHT_BACK;
34 else
35 return MOVE_FLIGHT;
36 }
37 else if (moveFlags & MOVEMENTFLAG_SWIMMING)
38 {
39 if (moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.swim >= speed_obj.swim_back*/)
40 return MOVE_SWIM_BACK;
41 else
42 return MOVE_SWIM;
43 }
44 else if (moveFlags & MOVEMENTFLAG_WALKING)
45 {
46 //if (speed_obj.run > speed_obj.walk)
47 return MOVE_WALK;
48 }
49 else if (moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.run >= speed_obj.run_back*/)
50 return MOVE_RUN_BACK;
51
52 // Flying creatures use MOVEMENTFLAG_CAN_FLY or MOVEMENTFLAG_DISABLE_GRAVITY
53 // Run speed is their default flight speed.
54 return MOVE_RUN;
55 }
@ MOVE_FLIGHT
Definition: UnitDefines.h:123
@ MOVE_SWIM
Definition: UnitDefines.h:120
@ MOVE_FLIGHT_BACK
Definition: UnitDefines.h:124
@ MOVE_SWIM_BACK
Definition: UnitDefines.h:121
@ MOVE_RUN
Definition: UnitDefines.h:118
@ MOVE_RUN_BACK
Definition: UnitDefines.h:119
@ MOVE_WALK
Definition: UnitDefines.h:117
@ MOVEMENTFLAG_BACKWARD
Definition: UnitDefines.h:359
@ MOVEMENTFLAG_FLYING
Definition: UnitDefines.h:382
@ MOVEMENTFLAG_SWIMMING
Definition: UnitDefines.h:378
@ MOVEMENTFLAG_WALKING
Definition: UnitDefines.h:366
+ Here is the caller graph for this function:

Variable Documentation

◆ gravity

float constexpr Movement::gravity = static_cast<float>(19.29110527038574)
constexpr

Definition at line 79 of file MovementTypedefs.h.

◆ MovementFlagExtraNames

char const* Movement::MovementFlagExtraNames[]
Initial value:
=
{
STRINGIZE(NoStrafe ),
STRINGIZE(NoJump ),
STRINGIZE(FullSpeedTurning ),
STRINGIZE(FullSpeedPitching ),
STRINGIZE(Allow_Pitching ),
STRINGIZE(VehicleExitVoluntary ),
STRINGIZE(WaterwalkingFullPitch ),
STRINGIZE(VehiclePassengerIsTransitionAllowed),
STRINGIZE(CanSwimToFlyTrans ),
STRINGIZE(Unk9 ),
STRINGIZE(CanTurnWhileFalling ),
STRINGIZE(IgnoreMovementForces ),
STRINGIZE(CanDoubleJump ),
STRINGIZE(DoubleJump ),
STRINGIZE(Unk14 ),
STRINGIZE(Unk15 ),
STRINGIZE(AwaitingLoad ),
STRINGIZE(InterpolatedMovement ),
STRINGIZE(InterpolatedTurning ),
STRINGIZE(InterpolatedPitching ),
}
#define STRINGIZE(a)
Definition: Common.h:25

Definition at line 122 of file MovementUtil.cpp.

◆ MovementFlagNames

char const* Movement::MovementFlagNames[]

Definition at line 86 of file MovementUtil.cpp.

◆ SplineFlagNames

char const* Movement::SplineFlagNames[32]

Definition at line 146 of file MovementUtil.cpp.

◆ splineIdGen

UInt32Counter Movement::splineIdGen

Definition at line 24 of file MovementUtil.cpp.

◆ terminal_fallTime

float constexpr Movement::terminal_fallTime = float(terminalVelocity / gravity)
constexpr

Definition at line 32 of file MovementUtil.cpp.

◆ terminal_length

float constexpr Movement::terminal_length = float(terminalVelocity * terminalVelocity) / (2.0f * gravity)
constexpr

Definition at line 30 of file MovementUtil.cpp.

◆ terminal_safeFall_fallTime

float constexpr Movement::terminal_safeFall_fallTime = float(terminalSafefallVelocity / gravity)
constexpr

Definition at line 33 of file MovementUtil.cpp.

◆ terminal_safeFall_length

float constexpr Movement::terminal_safeFall_length = (terminalSafefallVelocity * terminalSafefallVelocity) / (2.0f * gravity)
constexpr

Definition at line 31 of file MovementUtil.cpp.

◆ terminalSafefallVelocity

float constexpr Movement::terminalSafefallVelocity = 7.0f
constexpr

Definition at line 28 of file MovementUtil.cpp.

◆ terminalVelocity

float constexpr Movement::terminalVelocity = 60.148003f
constexpr

Velocity bounds that makes fall speed limited.

Definition at line 27 of file MovementUtil.cpp.