TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Movement Namespace Reference

Classes

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

Typedefs

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

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 }
 
enum  AnimType { ToGround = 0, FlyToFly = 1, ToFly = 2, FlyToGround = 3 }
 

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_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 (const Vector3 *vertice, float t, const Matrix4 &matr, Vector3 &result)
 
void C_Evaluate_Derivative (const Vector3 *vertice, float t, const Matrix4 &matr, Vector3 &result)
 

Variables

TC_GAME_API float gravity = static_cast<float>(19.29110527038574)
 
TC_GAME_API UInt32Counter splineIdGen
 
float terminalVelocity = 60.148003f
 Velocity bounds that makes fall speed limited. More...
 
float terminalSafefallVelocity = 7.0f
 
const float terminal_length = float(terminalVelocity * terminalVelocity) / (2.0f * gravity)
 
const float terminal_safeFall_length = (terminalSafefallVelocity * terminalSafefallVelocity) / (2.0f * gravity)
 
const float terminal_fallTime = float(terminalVelocity / gravity)
 
const float terminal_safeFall_fallTime = float(terminalSafefallVelocity / gravity)
 
char constMovementFlagNames []
 
char constMovementFlagExtraNames []
 
char constSplineFlagNames [32]
 
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)
 

Typedef Documentation

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

Enumeration Type Documentation

anonymous enum
Enumerator
minimal_duration 
104  {
105  minimal_duration = 1
106 };
Definition: MoveSpline.cpp:105
Enumerator
ToGround 
FlyToFly 
ToFly 
FlyToGround 
30  {
31  ToGround = 0, // 460 = ToGround, index of AnimationData.dbc
32  FlyToFly = 1, // 461 = FlyToFly?
33  ToFly = 2, // 458 = ToFly
34  FlyToGround = 3 // 463 = FlyToGround
35  };
Definition: MoveSplineInit.h:34
Definition: MoveSplineInit.h:33
Definition: MoveSplineInit.h:31
Definition: MoveSplineInit.h:32
Enumerator
MONSTER_MOVE_NORMAL 
MONSTER_MOVE_FACING_SPOT 
MONSTER_MOVE_FACING_TARGET 
MONSTER_MOVE_FACING_ANGLE 
36  {
41  };
Definition: MovementTypedefs.h:39
Definition: MovementTypedefs.h:37
Definition: MovementTypedefs.h:38
Definition: MovementTypedefs.h:40

Function Documentation

void Movement::C_Evaluate ( const Vector3 *  vertice,
float  t,
const Matrix4 &  matr,
Vector3 &  result 
)
inline
99 {
100  Vector4 tvec(t*t*t, t*t, t, 1.f);
101  Vector4 weights(tvec * matr);
102 
103  result = vertice[0] * weights[0] + vertice[1] * weights[1]
104  + vertice[2] * weights[2] + vertice[3] * weights[3];
105 }
void Movement::C_Evaluate_Derivative ( const Vector3 *  vertice,
float  t,
const Matrix4 &  matr,
Vector3 &  result 
)
inline
108 {
109  Vector4 tvec(3.f*t*t, 2.f*t, 1.f, 0.f);
110  Vector4 weights(tvec * matr);
111 
112  result = vertice[0] * weights[0] + vertice[1] * weights[1]
113  + vertice[2] * weights[2] + vertice[3] * weights[3];
114 }
uint32 Movement::computeDuration ( float  length,
float  velocity 
)
inline
90 {
91  return SecToMS(length / velocity);
92 }
uint32 SecToMS(float sec)
Definition: MovementTypedefs.h:43
float length(float v)
Definition: vectorMath.h:208

+ Here is the call graph for this function:

float Movement::computeFallElevation ( float  t_passed,
bool  isSafeFall,
float  start_velocity = 0.0f 
)
60  {
61  float termVel;
62  float result;
63 
64  if (isSafeFall)
65  termVel = terminalSafefallVelocity;
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  }
TC_GAME_API float gravity
Definition: MovementUtil.cpp:23
const float terminal_fallTime
Definition: MovementUtil.cpp:32
float terminalSafefallVelocity
Definition: MovementUtil.cpp:28
float terminalVelocity
Velocity bounds that makes fall speed limited.
Definition: MovementUtil.cpp:27
const float terminal_safeFall_fallTime
Definition: MovementUtil.cpp:33

+ Here is the caller graph for this function:

float Movement::computeFallTime ( float  path_length,
bool  isSafeFall 
)
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  }
TC_GAME_API float gravity
Definition: MovementUtil.cpp:23
const float terminal_safeFall_length
Definition: MovementUtil.cpp:31
const float terminal_fallTime
Definition: MovementUtil.cpp:32
float terminalSafefallVelocity
Definition: MovementUtil.cpp:28
const float terminal_length
Definition: MovementUtil.cpp:30
float terminalVelocity
Velocity bounds that makes fall speed limited.
Definition: MovementUtil.cpp:27
const float terminal_safeFall_fallTime
Definition: MovementUtil.cpp:33

+ Here is the caller graph for this function:

std::string Movement::MovementFlags_ToString ( uint32  flags)
196  {
197  std::string str;
199  return str;
200  }
void PrintFlags(Flags t, char const *(&names)[N], std::string &str)
Definition: MovementUtil.cpp:179
char const * MovementFlagNames[]
Definition: MovementUtil.cpp:86
uint8 flags
Definition: DisableMgr.cpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Movement::MovementFlagsExtra_ToString ( uint32  flags)
203  {
204  std::string str;
206  return str;
207  }
void PrintFlags(Flags t, char const *(&names)[N], std::string &str)
Definition: MovementUtil.cpp:179
char const * MovementFlagExtraNames[]
Definition: MovementUtil.cpp:122
uint8 flags
Definition: DisableMgr.cpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Movement::MSToSec ( uint32  ms)
inline
49  {
50  return ms / 1000.f;
51  }

+ Here is the caller graph for this function:

template<class Flags , int N>
void Movement::PrintFlags ( Flags  t,
char const *(&)  names[N],
std::string &  str 
)
180  {
181  for (int i = 0; i < N; ++i)
182  {
183  if ((t & Flags(1 << i)) && names[i] != NULL)
184  str.append(" ").append(names[i]);
185  }
186  }
arena_t NULL
Definition: jemalloc_internal.h:624

+ Here is the caller graph for this function:

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
uint32 Movement::SecToMS ( float  sec)
inline
44  {
45  return static_cast<uint32>(sec * 1000.f);
46  }
uint32_t uint32
Definition: Define.h:150

+ Here is the caller graph for this function:

UnitMoveType Movement::SelectSpeedType ( uint32  moveFlags)
28  {
29  if (moveFlags & MOVEMENTFLAG_FLYING)
30  {
31  if (moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.flight >= speed_obj.flight_back*/)
32  return MOVE_FLIGHT_BACK;
33  else
34  return MOVE_FLIGHT;
35  }
36  else if (moveFlags & MOVEMENTFLAG_SWIMMING)
37  {
38  if (moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.swim >= speed_obj.swim_back*/)
39  return MOVE_SWIM_BACK;
40  else
41  return MOVE_SWIM;
42  }
43  else if (moveFlags & MOVEMENTFLAG_WALKING)
44  {
45  //if (speed_obj.run > speed_obj.walk)
46  return MOVE_WALK;
47  }
48  else if (moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.run >= speed_obj.run_back*/)
49  return MOVE_RUN_BACK;
50 
51  // Flying creatures use MOVEMENTFLAG_CAN_FLY or MOVEMENTFLAG_DISABLE_GRAVITY
52  // Run speed is their default flight speed.
53  return MOVE_RUN;
54  }
Definition: Unit.h:784
Definition: Unit.h:605
Definition: Unit.h:800
Definition: Unit.h:599
Definition: Unit.h:601
Definition: Unit.h:602
Definition: Unit.h:796
Definition: Unit.h:600
Definition: Unit.h:606
Definition: Unit.h:603
Definition: Unit.h:777

+ Here is the caller graph for this function:

Variable Documentation

float Movement::gravity = static_cast<float>(19.29110527038574)
char const* Movement::MovementFlagExtraNames[]
Initial value:
=
{
STRINGIZE(NoStrafe ),
STRINGIZE(NoJump ),
STRINGIZE(FullSpeedTurning ),
STRINGIZE(FullSpeedPitching ),
STRINGIZE(Allow_Pitching ),
STRINGIZE(Unk6 ),
STRINGIZE(Unk7 ),
STRINGIZE(Unk8 ),
STRINGIZE(Unk9 ),
STRINGIZE(Unk10 ),
STRINGIZE(Unk11 ),
STRINGIZE(Unk12 ),
STRINGIZE(Unk13 ),
STRINGIZE(Interpolated_Movement),
STRINGIZE(Interpolated_Turning ),
STRINGIZE(Interpolated_Pitching),
}
#define STRINGIZE(a)
Definition: Common.h:93
char const* Movement::MovementFlagNames[]
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
char const* Movement::SplineFlagNames[32]
UInt32Counter Movement::splineIdGen
const float Movement::terminal_fallTime = float(terminalVelocity / gravity)
const float Movement::terminal_length = float(terminalVelocity * terminalVelocity) / (2.0f * gravity)
const float Movement::terminal_safeFall_fallTime = float(terminalSafefallVelocity / gravity)
const float Movement::terminal_safeFall_length = (terminalSafefallVelocity * terminalSafefallVelocity) / (2.0f * gravity)
float Movement::terminalSafefallVelocity = 7.0f
float Movement::terminalVelocity = 60.148003f

Velocity bounds that makes fall speed limited.