AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Movement Namespace Reference

Classes

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

Typedefs

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

Enumerations

enum  MonsterMoveType {
  MonsterMoveNormal = 0 ,
  MonsterMoveStop = 1 ,
  MonsterMoveFacingSpot = 2 ,
  MonsterMoveFacingTarget = 3 ,
  MonsterMoveFacingAngle = 4
}
 
enum  { minimal_duration = 1 }
 
enum  AnimType {
  ToGround = 0 ,
  FlyToFly = 1 ,
  ToFly = 2 ,
  FlyToGround = 3
}
 

Functions

void operator<< (ByteBuffer &b, const Vector3 &v)
 
void operator>> (ByteBuffer &b, Vector3 &v)
 
void WriteLinearPath (const Spline< int32 > &spline, ByteBuffer &data)
 
void WriteCatmullRomPath (const Spline< int32 > &spline, ByteBuffer &data)
 
void WriteCatmullRomCyclicPath (const Spline< int32 > &spline, ByteBuffer &data, bool flying)
 
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)
 
template<class Flags , int N>
void print_flags (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 (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

double gravity = 19.29110527038574
 
UInt32Counter splineIdGen
 
float terminalVelocity = 60.148003f
 Velocity bounds that makes fall speed limited.
 
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 const * g_MovementFlag_names []
 
char const * g_SplineFlag_names [32]
 

Typedef Documentation

◆ PointsArray

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

◆ UInt32Counter

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

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
minimal_duration 
104 {
106 };
@ minimal_duration
Definition MoveSpline.cpp:105

◆ AnimType

Enumerator
ToGround 
FlyToFly 
ToFly 
FlyToGround 
33 {
34 ToGround = 0, // 460 = ToGround, index of AnimationData.dbc
35 FlyToFly = 1, // 461 = FlyToFly?
36 ToFly = 2, // 458 = ToFly
37 FlyToGround = 3 // 463 = FlyToGround
38 };
@ ToFly
Definition MoveSplineInit.h:36
@ ToGround
Definition MoveSplineInit.h:34
@ FlyToFly
Definition MoveSplineInit.h:35
@ FlyToGround
Definition MoveSplineInit.h:37

◆ MonsterMoveType

Enumerator
MonsterMoveNormal 
MonsterMoveStop 
MonsterMoveFacingSpot 
MonsterMoveFacingTarget 
MonsterMoveFacingAngle 
35 {
41 };
@ MonsterMoveFacingSpot
Definition MovementPacketBuilder.cpp:38
@ MonsterMoveFacingTarget
Definition MovementPacketBuilder.cpp:39
@ MonsterMoveStop
Definition MovementPacketBuilder.cpp:37
@ MonsterMoveNormal
Definition MovementPacketBuilder.cpp:36
@ MonsterMoveFacingAngle
Definition MovementPacketBuilder.cpp:40

Function Documentation

◆ C_Evaluate()

void Movement::C_Evaluate ( const Vector3 *  vertice,
float  t,
const Matrix4 &  matr,
Vector3 &  result 
)
inline
98 {
99 Vector4 tvec(t * t * t, t * t, t, 1.f);
100 Vector4 weights(tvec * matr);
101
102 result = vertice[0] * weights[0] + vertice[1] * weights[1]
103 + vertice[2] * weights[2] + vertice[3] * weights[3];
104 }

Referenced by Movement::SplineBase::EvaluateBezier3(), Movement::SplineBase::EvaluateCatmullRom(), Movement::SplineBase::SegLengthBezier3(), and Movement::SplineBase::SegLengthCatmullRom().

◆ C_Evaluate_Derivative()

void Movement::C_Evaluate_Derivative ( const Vector3 *  vertice,
float  t,
const Matrix4 &  matr,
Vector3 &  result 
)
inline
107 {
108 Vector4 tvec(3.f * t * t, 2.f * t, 1.f, 0.f);
109 Vector4 weights(tvec * matr);
110
111 result = vertice[0] * weights[0] + vertice[1] * weights[1]
112 + vertice[2] * weights[2] + vertice[3] * weights[3];
113 }

Referenced by Movement::SplineBase::EvaluateDerivativeBezier3(), and Movement::SplineBase::EvaluateDerivativeCatmullRom().

◆ computeDuration()

uint32 Movement::computeDuration ( float  length,
float  velocity 
)
inline
89 {
90 return SecToMS(length / velocity);
91 }
uint32 SecToMS(float sec)
Definition MovementTypedefs.h:36

References SecToMS().

◆ computeFallElevation()

float Movement::computeFallElevation ( float  t_passed,
bool  isSafeFall,
float  start_velocity = 0.0f 
)
61 {
62 float termVel;
63 float result;
64
65 if (isSafeFall)
67 else
68 termVel = terminalVelocity;
69
70 if (start_velocity > termVel)
71 start_velocity = termVel;
72
73 float terminal_time = (isSafeFall ? terminal_safeFall_fallTime : terminal_fallTime) - start_velocity / gravity; // the time that needed to reach terminalVelocity
74
75 if (t_passed > terminal_time)
76 {
77 result = termVel * (t_passed - terminal_time) +
78 start_velocity * terminal_time +
79 gravity * terminal_time * terminal_time * 0.5f;
80 }
81 else
82 result = t_passed * (start_velocity + t_passed * gravity * 0.5f);
83
84 return result;
85 }
const float terminal_safeFall_fallTime
Definition MovementUtil.cpp:34
float terminalSafefallVelocity
Definition MovementUtil.cpp:29
float terminalVelocity
Velocity bounds that makes fall speed limited.
Definition MovementUtil.cpp:28
const float terminal_fallTime
Definition MovementUtil.cpp:33

References gravity, terminal_fallTime, terminal_safeFall_fallTime, terminalSafefallVelocity, and terminalVelocity.

Referenced by Movement::MoveSpline::computeFallElevation(), MotionMaster::MoveJump(), and MotionMaster::MoveKnockbackFrom().

◆ computeFallTime()

float Movement::computeFallTime ( float  path_length,
bool  isSafeFall 
)
37 {
38 if (path_length < 0.0f)
39 return 0.0f;
40
41 float time;
42 if (isSafeFall)
43 {
44 if (path_length >= terminal_safeFall_length)
45 time = (path_length - terminal_safeFall_length) / terminalSafefallVelocity + terminal_safeFall_fallTime;
46 else
47 time = sqrtf(2.0f * path_length / gravity);
48 }
49 else
50 {
51 if (path_length >= terminal_length)
52 time = (path_length - terminal_length) / terminalVelocity + terminal_fallTime;
53 else
54 time = sqrtf(2.0f * path_length / gravity);
55 }
56
57 return time;
58 }
const float terminal_safeFall_length
Definition MovementUtil.cpp:32

References gravity, terminal_fallTime, terminal_length, terminal_safeFall_fallTime, terminal_safeFall_length, terminalSafefallVelocity, and terminalVelocity.

Referenced by Movement::FallInitializer::operator()().

◆ MSToSec()

float Movement::MSToSec ( uint32  ms)
inline

◆ operator<<()

void Movement::operator<< ( ByteBuffer b,
const Vector3 &  v 
)
inline
25 {
26 b << v.x << v.y << v.z;
27 }

◆ operator>>()

void Movement::operator>> ( ByteBuffer b,
Vector3 &  v 
)
inline
30 {
31 b >> v.x >> v.y >> v.z;
32 }

◆ print_flags()

template<class Flags , int N>
void Movement::print_flags ( 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] != nullptr)
184 str.append(" ").append(names[i]);
185 }
186 }

Referenced by Movement::MoveSplineFlag::ToString().

◆ 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

◆ 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

◆ SecToMS()

uint32 Movement::SecToMS ( float  sec)
inline
37 {
38 return static_cast<uint32>(sec * 1000.f);
39 }
std::uint32_t uint32
Definition Define.h:107

Referenced by computeDuration().

◆ SelectSpeedType()

UnitMoveType Movement::SelectSpeedType ( uint32  moveFlags)
30 {
31 if (moveFlags & MOVEMENTFLAG_FLYING)
32 {
33 if (moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.flight >= speed_obj.flight_back*/)
34 return MOVE_FLIGHT_BACK;
35 else
36 return MOVE_FLIGHT;
37 }
38 else if (moveFlags & MOVEMENTFLAG_SWIMMING)
39 {
40 if (moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.swim >= speed_obj.swim_back*/)
41 return MOVE_SWIM_BACK;
42 else
43 return MOVE_SWIM;
44 }
45 else if (moveFlags & MOVEMENTFLAG_WALKING)
46 {
47 //if (speed_obj.run > speed_obj.walk)
48 return MOVE_WALK;
49 }
50 else if (moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.run >= speed_obj.run_back*/)
51 return MOVE_RUN_BACK;
52
53 // Flying creatures use MOVEMENTFLAG_CAN_FLY or MOVEMENTFLAG_DISABLE_GRAVITY
54 // Run speed is their default flight speed.
55 return MOVE_RUN;
56 }
@ MOVEMENTFLAG_BACKWARD
Definition UnitDefines.h:366
@ MOVEMENTFLAG_FLYING
Definition UnitDefines.h:390
@ MOVEMENTFLAG_SWIMMING
Definition UnitDefines.h:386
@ MOVEMENTFLAG_WALKING
Definition UnitDefines.h:373
@ MOVE_FLIGHT
Definition UnitDefines.h:355
@ MOVE_SWIM
Definition UnitDefines.h:352
@ MOVE_FLIGHT_BACK
Definition UnitDefines.h:356
@ MOVE_SWIM_BACK
Definition UnitDefines.h:353
@ MOVE_RUN
Definition UnitDefines.h:350
@ MOVE_RUN_BACK
Definition UnitDefines.h:351
@ MOVE_WALK
Definition UnitDefines.h:349

References MOVE_FLIGHT, MOVE_FLIGHT_BACK, MOVE_RUN, MOVE_RUN_BACK, MOVE_SWIM, MOVE_SWIM_BACK, MOVE_WALK, MOVEMENTFLAG_BACKWARD, MOVEMENTFLAG_FLYING, MOVEMENTFLAG_SWIMMING, and MOVEMENTFLAG_WALKING.

Referenced by GetVelocity(), Movement::MoveSplineInit::Launch(), CreatureGroup::LeaderMoveTo(), and PredictPosition().

◆ WriteCatmullRomCyclicPath()

void Movement::WriteCatmullRomCyclicPath ( const Spline< int32 > &  spline,
ByteBuffer data,
bool  flying 
)
127 {
128 uint32 count = spline.getPointCount() - 3;
129 data << uint32(count + 1);
130 if (flying)
131 {
132 data << spline.getPoint(1); // fake point, client will erase it from the spline after first cycle done
133 data.append<Vector3>(&spline.getPoint(2), count);
134 }
135 else
136 {
137 data.append<Vector3>(&spline.getPoint(2), count);
138 data << Vector3::zero(); //Xinef: fake point
139 }
140 }
void append(T value)
Definition ByteBuffer.h:129
const Vector3 & getPoint(index_type i) const
Definition Spline.h:116
index_type getPointCount() const
Definition Spline.h:115

References ByteBuffer::append(), Movement::SplineBase::getPoint(), and Movement::SplineBase::getPointCount().

Referenced by Movement::PacketBuilder::WriteMonsterMove().

◆ WriteCatmullRomPath()

void Movement::WriteCatmullRomPath ( const Spline< int32 > &  spline,
ByteBuffer data 
)
120 {
121 uint32 count = spline.getPointCount() - 3;
122 data << count;
123 data.append<Vector3>(&spline.getPoint(2), count);
124 }

References ByteBuffer::append(), Movement::SplineBase::getPoint(), and Movement::SplineBase::getPointCount().

Referenced by Movement::PacketBuilder::WriteMonsterMove().

◆ WriteLinearPath()

void Movement::WriteLinearPath ( const Spline< int32 > &  spline,
ByteBuffer data 
)
100 {
101 uint32 last_idx = spline.getPointCount() - 3;
102 const Vector3* real_path = &spline.getPoint(1);
103
104 data << last_idx;
105 data << real_path[last_idx]; // destination
106 if (last_idx > 1)
107 {
108 Vector3 middle = (real_path[0] + real_path[last_idx]) / 2.f;
109 Vector3 offset;
110 // first and last points already appended
111 for (uint32 i = 1; i < last_idx; ++i)
112 {
113 offset = middle - real_path[i];
114 data.appendPackXYZ(offset.x, offset.y, offset.z);
115 }
116 }
117 }
void appendPackXYZ(float x, float y, float z)
Definition ByteBuffer.h:494

References ByteBuffer::appendPackXYZ(), Movement::SplineBase::getPoint(), and Movement::SplineBase::getPointCount().

Referenced by Movement::PacketBuilder::WriteMonsterMove().

Variable Documentation

◆ g_MovementFlag_names

char const* Movement::g_MovementFlag_names[]
90 {
91 STR(Forward ), // 0x00000001,
92 STR(Backward ), // 0x00000002,
93 STR(Strafe_Left ), // 0x00000004,
94 STR(Strafe_Right ), // 0x00000008,
95 STR(Turn_Left ), // 0x00000010,
96 STR(Turn_Right ), // 0x00000020,
97 STR(Pitch_Up ), // 0x00000040,
98 STR(Pitch_Down ), // 0x00000080,
99
100 STR(Walk ), // 0x00000100, // Walking
101 STR(Ontransport ), // 0x00000200,
102 STR(Levitation ), // 0x00000400,
103 STR(Root ), // 0x00000800,
104 STR(Falling ), // 0x00001000,
105 STR(Fallingfar ), // 0x00002000,
106 STR(Pendingstop ), // 0x00004000,
107 STR(PendingSTRafestop ), // 0x00008000,
108 STR(Pendingforward ), // 0x00010000,
109 STR(Pendingbackward ), // 0x00020000,
110 STR(PendingSTRafeleft ), // 0x00040000,
111 STR(PendingSTRaferight ), // 0x00080000,
112 STR(Pendingroot ), // 0x00100000,
113 STR(Swimming ), // 0x00200000, // Appears With Fly Flag Also
114 STR(Ascending ), // 0x00400000, // Swim Up Also
115 STR(Descending ), // 0x00800000, // Swim Down Also
116 STR(Can_Fly ), // 0x01000000, // Can Fly In 3.3?
117 STR(Flying ), // 0x02000000, // Actual Flying Mode
118 STR(Spline_Elevation ), // 0x04000000, // Used For Flight Paths
119 STR(Spline_Enabled ), // 0x08000000, // Used For Flight Paths
120 STR(Waterwalking ), // 0x10000000, // Prevent Unit From Falling Through Water
121 STR(Safe_Fall ), // 0x20000000, // Active Rogue Safe Fall Spell (Passive)
122 STR(Hover ), // 0x40000000
123 STR(Unknown13 ), // 0x80000000
124 STR(Unk1 ),
125 STR(Unk2 ),
126 STR(Unk3 ),
127 STR(Fullspeedturning ),
128 STR(Fullspeedpitching ),
129 STR(Allow_Pitching ),
130 STR(Unk4 ),
131 STR(Unk5 ),
132 STR(Unk6 ),
133 STR(Unk7 ),
134 STR(Interp_Move ),
135 STR(Interp_Turning ),
136 STR(Interp_Pitching ),
137 STR(Unk8 ),
138 STR(Unk9 ),
139 STR(Unk10 ),
140 };
#define STR(x)
Definition MovementUtil.cpp:87

◆ g_SplineFlag_names

char const* Movement::g_SplineFlag_names[32]
143 {
144 STR(AnimBit1 ), // 0x00000001,
145 STR(AnimBit2 ), // 0x00000002,
146 STR(AnimBit3 ), // 0x00000004,
147 STR(AnimBit4 ), // 0x00000008,
148 STR(AnimBit5 ), // 0x00000010,
149 STR(AnimBit6 ), // 0x00000020,
150 STR(AnimBit7 ), // 0x00000040,
151 STR(AnimBit8 ), // 0x00000080,
152 STR(Done ), // 0x00000100,
153 STR(Falling ), // 0x00000200, // Not Compartible With Trajectory Movement
154 STR(No_Spline ), // 0x00000400,
155 STR(Trajectory ), // 0x00000800, // Not Compartible With Fall Movement
156 STR(Walkmode ), // 0x00001000,
157 STR(Flying ), // 0x00002000, // Smooth Movement(Catmullrom Interpolation Mode), Flying Animation
158 STR(Knockback ), // 0x00004000, // Model Orientation Fixed
159 STR(Final_Point ), // 0x00008000,
160 STR(Final_Target ), // 0x00010000,
161 STR(Final_Angle ), // 0x00020000,
162 STR(Catmullrom ), // 0x00040000, // Used Catmullrom Interpolation Mode
163 STR(Cyclic ), // 0x00080000, // Movement By Cycled Spline
164 STR(Enter_Cycle ), // 0x00100000, // Everytime Appears With Cyclic Flag In Monster Move Packet
165 STR(Animation ), // 0x00200000, // Animationid (0...3), Uint32 Time, Not Compartible With Trajectory And Fall Movement
166 STR(Unknown4 ), // 0x00400000, // Disables Movement By Path
167 STR(Unknown5 ), // 0x00800000,
168 STR(Unknown6 ), // 0x01000000,
169 STR(Unknown7 ), // 0x02000000,
170 STR(Unknown8 ), // 0x04000000,
171 STR(OrientationInversed ), // 0x08000000, // Appears With Runmode Flag, Nodes ), // 1, Handles Orientation
172 STR(Unknown10 ), // 0x10000000,
173 STR(Unknown11 ), // 0x20000000,
174 STR(Unknown12 ), // 0x40000000,
175 STR(Unknown13 ), // 0x80000000,
176 };

Referenced by Movement::MoveSplineFlag::ToString().

◆ gravity

◆ splineIdGen

UInt32Counter Movement::splineIdGen

◆ terminal_fallTime

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

◆ terminal_length

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

Referenced by computeFallTime().

◆ terminal_safeFall_fallTime

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

◆ terminal_safeFall_length

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

Referenced by computeFallTime().

◆ terminalSafefallVelocity

float Movement::terminalSafefallVelocity = 7.0f

◆ terminalVelocity

float Movement::terminalVelocity = 60.148003f

Velocity bounds that makes fall speed limited.

Referenced by computeFallElevation(), and computeFallTime().