Core/Movement: Use MonsterMoveStop spline type to stop movement instead of sending movement to current position

This commit is contained in:
Shauren committed 2012-08-11 20:18:00 +02:00
1 parent c3e1443a13
commit e7590abce7
11 files changed
+141 -92

No files matched your search

@@ -27,31 +27,31 @@ namespace Movement
/// Velocity bounds that makes fall speed limited
float terminalVelocity = 60.148003f;
float terminalSavefallVelocity = 7.f;
float terminalSafefallVelocity = 7.f;
const float terminal_length = float(terminalVelocity * terminalVelocity) / (2.f * gravity);
const float terminal_savefall_length = (terminalSavefallVelocity * terminalSavefallVelocity) / (2.f * gravity);
const float terminalFallTime = float(terminalVelocity/gravity); // the time that needed to reach terminalVelocity
const float terminal_length = float(terminalVelocity * terminalVelocity) / (2.0f * gravity);
const float terminal_safefall_length = (terminalSafefallVelocity * terminalSafefallVelocity) / (2.0f * gravity);
const float terminalFallTime = float(terminalVelocity / gravity); // the time that needed to reach terminalVelocity
float computeFallTime(float path_length, bool isSafeFall)
{
if (path_length < 0.f)
return 0.f;
if (path_length < 0.0f)
return 0.0f;
float time;
if ( isSafeFall )
if (isSafeFall)
{
if (path_length >= terminal_savefall_length)
time = (path_length - terminal_savefall_length)/terminalSavefallVelocity + terminalSavefallVelocity/gravity;
if (path_length >= terminal_safefall_length)
time = (path_length - terminal_safefall_length) / terminalSafefallVelocity + terminalSafefallVelocity / gravity;
else
time = sqrtf(2.f * path_length/gravity);
time = sqrtf(2.0f * path_length / gravity);
}
else
{
if (path_length >= terminal_length)
time = (path_length - terminal_length)/terminalVelocity + terminalFallTime;
time = (path_length - terminal_length) / terminalVelocity + terminalFallTime;
else
time = sqrtf(2.f * path_length/gravity);
time = sqrtf(2.0f * path_length / gravity);
}
return time;
@@ -62,20 +62,21 @@ namespace Movement
float termVel;
float result;
if ( isSafeFall )
termVel = terminalSavefallVelocity;
if (isSafeFall)
termVel = terminalSafefallVelocity;
else
termVel = terminalVelocity;
if ( start_velocity > termVel )
if (start_velocity > termVel)
start_velocity = termVel;
float terminal_time = terminalFallTime - start_velocity / gravity; // the time that needed to reach terminalVelocity
if ( t_passed > terminal_time )
if (t_passed > terminal_time)
{
result = terminalVelocity*(t_passed - terminal_time) +
start_velocity*terminal_time + gravity*terminal_time*terminal_time*0.5f;
result = terminalVelocity * (t_passed - terminal_time) +
start_velocity * terminal_time +
gravity * terminal_time * terminal_time*0.5f;
}
else
result = t_passed * (start_velocity + t_passed * gravity * 0.5f);
@@ -101,7 +102,7 @@ namespace Movement
#define STR(x) #x
const char* g_MovementFlag_names[]=
char const* g_MovementFlag_names[] =
{
STR(Forward ),// 0x00000001,
STR(Backward ),// 0x00000002,
@@ -136,25 +137,25 @@ namespace Movement
STR(Local_Dirty ),// 0x20000000
STR(None31 ),// 0x40000000
STR(None32 ),// 0x80000000
STR(Unk1 ),
STR(Unk2 ),
STR(Unk3 ),
STR(Fullspeedturning ),
STR(Fullspeedpitching ),
STR(Allow_Pitching ),
STR(Unk4 ),
STR(Unk5 ),
STR(Unk6 ),
STR(Unk7 ),
STR(Interp_Move ),
STR(Interp_Turning ),
STR(Interp_Pitching ),
STR(Unk8 ),
STR(Unk9 ),
STR(Unk10 ),
STR(Unk1 ),
STR(Unk2 ),
STR(Unk3 ),
STR(Fullspeedturning ),
STR(Fullspeedpitching ),
STR(Allow_Pitching ),
STR(Unk4 ),
STR(Unk5 ),
STR(Unk6 ),
STR(Unk7 ),
STR(Interp_Move ),
STR(Interp_Turning ),
STR(Interp_Pitching ),
STR(None8 ),
STR(None9 ),
STR(None10 ),
};
const char * g_SplineFlag_names[32]=
char const* g_SplineFlag_names[32] =
{
STR(AnimBit1 ),// 0x00000001,
STR(AnimBit2 ),// 0x00000002,
@@ -191,11 +192,11 @@ namespace Movement
};
template<class Flags, int N>
void print_flags(Flags t, const char* (&names)[N], std::string& str)
void print_flags(Flags t, char const* (&names)[N], std::string& str)
{
for (int i = 0; i < N; ++i)
{
if ((t & (Flags)(1 << i)) && names[i] != NULL)
if ((t & Flags(1 << i)) && names[i] != NULL)
str.append(" ").append(names[i]);
}
}