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:108

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: Unit.h:553
@ MOVEMENTFLAG_FLYING
Definition: Unit.h:577
@ MOVEMENTFLAG_SWIMMING
Definition: Unit.h:573
@ MOVEMENTFLAG_WALKING
Definition: Unit.h:560
@ MOVE_FLIGHT
Definition: Unit.h:384
@ MOVE_SWIM
Definition: Unit.h:381
@ MOVE_FLIGHT_BACK
Definition: Unit.h:385
@ MOVE_SWIM_BACK
Definition: Unit.h:382
@ MOVE_RUN
Definition: Unit.h:379
@ MOVE_RUN_BACK
Definition: Unit.h:380
@ MOVE_WALK
Definition: Unit.h:378

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 }
const Vector3 & getPoint(index_type i) const
Definition: Spline.h:116
index_type getPointCount() const
Definition: Spline.h:115
void append(T value)
Definition: ByteBuffer.h:129

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[]

◆ g_SplineFlag_names

char const* Movement::g_SplineFlag_names[32]

◆ 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().