mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 09:45:47 +08:00
Falling animation fix, comment out instrumentation.
This commit is contained in:
@@ -61,6 +61,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
public bool m_jumping = false; // Add for jumping
|
||||
public float m_jumpVelocity = 0f; // Add for jumping
|
||||
private int m_landing = 0; // Add for jumping
|
||||
public bool m_falling = false; // Add for falling
|
||||
private float m_fallHeight; // Add for falling
|
||||
|
||||
/// <value>
|
||||
/// The scene presence that this animator applies to
|
||||
@@ -118,7 +120,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
|
||||
public void ResetAnimations()
|
||||
{
|
||||
Console.WriteLine("ResetA.............");
|
||||
m_animations.Clear();
|
||||
TrySetMovementAnimation("STAND");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -145,7 +149,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
public string GetMovementAnimation()
|
||||
{
|
||||
//Console.WriteLine("GMA-------"); //##
|
||||
const float FALL_DELAY = 0.33f;
|
||||
//#@ const float FALL_DELAY = 0.33f;
|
||||
const float FALL_DELAY = 800f; //## mS
|
||||
//rm for jumping const float PREJUMP_DELAY = 0.25f;
|
||||
const float PREJUMP_DELAY = 200f; // mS add for jumping
|
||||
const float JUMP_PERIOD = 800f; // mS add for jumping
|
||||
@@ -191,9 +196,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
{
|
||||
m_animTickFall = 0;
|
||||
m_animTickJump = 0;
|
||||
m_jumping = false; //add for jumping flag
|
||||
m_jumpVelocity = 0f; //add for jumping flag
|
||||
m_jumping = false; //add for jumping
|
||||
m_falling = true; //add for falling
|
||||
m_jumpVelocity = 0f; //add for jumping
|
||||
actor.Selected = false; //add for jumping flag
|
||||
m_fallHeight = actor.Position.Z; // save latest flying height
|
||||
|
||||
if (move.X != 0f || move.Y != 0f)
|
||||
{
|
||||
@@ -205,8 +212,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
}
|
||||
else if (move.Z < 0f)
|
||||
{
|
||||
if (actor != null && actor.IsColliding)
|
||||
if (actor != null && actor.IsColliding)
|
||||
{ //##
|
||||
//Console.WriteLine("LAND FLYING"); // ##
|
||||
return "LAND";
|
||||
} //#
|
||||
else
|
||||
return "HOVER_DOWN";
|
||||
}
|
||||
@@ -223,19 +233,25 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
// rm for jumping if (actor == null || !actor.IsColliding)
|
||||
if ((actor == null || !actor.IsColliding) && !m_jumping) // add for jumping
|
||||
{
|
||||
//Console.WriteLine("FFL"); //##
|
||||
float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
|
||||
// rm float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
|
||||
float fallElapsed = (float)(Environment.TickCount - m_animTickFall); // add, in mS
|
||||
float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f;
|
||||
//Console.WriteLine("falling t={0} v={1}", fallElapsed, fallVelocity); //##
|
||||
|
||||
if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f))
|
||||
// rm for fall if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f))
|
||||
if (!m_jumping && (fallVelocity < -3.0f) ) m_falling = true; // add for falling and jumping
|
||||
|
||||
if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) // add for jumping
|
||||
// not falling yet or going up
|
||||
{
|
||||
// Just started falling
|
||||
// reset start of fall time
|
||||
m_animTickFall = Environment.TickCount;
|
||||
}
|
||||
// else if (!jumping && fallElapsed > FALL_DELAY)
|
||||
else if (!m_jumping && fallElapsed > FALL_DELAY) // add for jumping
|
||||
else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) ) // add for falling and jumping
|
||||
{
|
||||
// Falling long enough to trigger the animation
|
||||
//Console.WriteLine("FALLDOWN"); //##
|
||||
return "FALLDOWN";
|
||||
}
|
||||
|
||||
@@ -247,7 +263,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
|
||||
#region Jumping // section added for jumping...
|
||||
|
||||
Vector3 vj = Vector3.Zero;
|
||||
int jumptime;
|
||||
jumptime = Environment.TickCount - m_animTickJump;
|
||||
|
||||
@@ -258,12 +273,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
// Start jumping, prejump
|
||||
m_animTickFall = 0;
|
||||
m_jumping = true;
|
||||
m_falling = false;
|
||||
actor.Selected = true; // borrowed for jmping flag
|
||||
m_animTickJump = Environment.TickCount;
|
||||
vj.Z = 0.35f;
|
||||
m_jumpVelocity = 0.35f;
|
||||
vj += actor.Velocity;
|
||||
// #@ actor.Velocity = vj;
|
||||
m_jumpVelocity = 0.35f;
|
||||
return "PREJUMP";
|
||||
}
|
||||
|
||||
@@ -274,8 +287,9 @@ m_jumpVelocity = 0.35f;
|
||||
//Console.WriteLine("LA {0}", jumptime); //##
|
||||
// end jumping
|
||||
m_jumping = false;
|
||||
m_falling = false;
|
||||
actor.Selected = false; // borrowed for jumping flag
|
||||
m_jumpVelocity = 0f;
|
||||
m_jumpVelocity = 0f;
|
||||
m_animTickFall = Environment.TickCount;
|
||||
return "LAND";
|
||||
}
|
||||
@@ -283,10 +297,7 @@ m_jumpVelocity = 0f;
|
||||
{
|
||||
//Console.WriteLine("JD {0}", jumptime); //##
|
||||
// jump down
|
||||
vj = actor.Velocity;
|
||||
vj.Z = 0f;
|
||||
m_jumpVelocity = 0f;
|
||||
// #@ actor.Velocity = vj;
|
||||
m_jumpVelocity = 0f;
|
||||
return "JUMP";
|
||||
}
|
||||
else if (jumptime > PREJUMP_DELAY)
|
||||
@@ -294,11 +305,7 @@ m_jumpVelocity = 0f;
|
||||
//Console.WriteLine("JU {0}", jumptime); //##
|
||||
// jump up
|
||||
m_jumping = true;
|
||||
vj.Z = 10f;
|
||||
m_jumpVelocity = 10f;
|
||||
vj.X = actor.Velocity.X;
|
||||
vj.Y = actor.Velocity.Y;
|
||||
// #@ actor.Velocity = vj;
|
||||
m_jumpVelocity = 10f;
|
||||
return "JUMP";
|
||||
}
|
||||
}
|
||||
@@ -309,29 +316,37 @@ m_jumpVelocity = 10f;
|
||||
|
||||
if (m_movementAnimation == "FALLDOWN")
|
||||
{
|
||||
m_falling = false;
|
||||
m_animTickFall = Environment.TickCount;
|
||||
|
||||
// TODO: SOFT_LAND support
|
||||
return "LAND";
|
||||
float fallHeight = m_fallHeight - actor.Position.Z;
|
||||
//Console.WriteLine("Hit from {0}", fallHeight); //##
|
||||
if (fallHeight > 15.0f) // add for falling
|
||||
return "STANDUP";
|
||||
else if (fallHeight > 8.0f) // add for falling
|
||||
return "SOFT_LAND"; // add for falling
|
||||
else // add for falling
|
||||
return "LAND"; // add for falling
|
||||
}
|
||||
else if (m_movementAnimation == "LAND")
|
||||
{
|
||||
// rm jumping float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
|
||||
int landElapsed = Environment.TickCount - m_animTickFall; // add for jumping
|
||||
// rm jumping if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY))
|
||||
/* Try change ##
|
||||
if ((m_animTickFall != 0) && (landElapsed <= 500)) // add for jumping
|
||||
return "LAND";
|
||||
*/
|
||||
// NB if this is set too long a weird anim reset from some place prevents STAND from being sent to client
|
||||
if ((m_animTickFall != 0) && (landElapsed <= 300)) // add for jumping
|
||||
// rm for landing return "LAND";
|
||||
else if ((m_movementAnimation == "LAND") || (m_movementAnimation == "SOFT_LAND") || (m_movementAnimation == "STANDUP"))
|
||||
{
|
||||
int landElapsed = Environment.TickCount - m_animTickFall; // add for jumping
|
||||
int limit = 1000; // add for jumping
|
||||
if(m_movementAnimation == "LAND") limit = 350; // add for jumping
|
||||
// NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client
|
||||
|
||||
if ((m_animTickFall != 0) && (landElapsed <= limit)) // add for jumping
|
||||
{
|
||||
//Console.WriteLine("LAND"); //##
|
||||
return "LAND";
|
||||
//Console.WriteLine("Lelapse {0}", m_movementAnimation); //##
|
||||
return m_movementAnimation;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Console.WriteLine("STAND"); //##
|
||||
//Console.WriteLine("end/STAND"); //##
|
||||
m_fallHeight = actor.Position.Z; // save latest flying height
|
||||
return "STAND";
|
||||
}
|
||||
}
|
||||
@@ -369,6 +384,8 @@ m_jumpVelocity = 10f;
|
||||
// next section moved outside paren. and realigned for jumping
|
||||
if (move.X != 0f || move.Y != 0f)
|
||||
{
|
||||
m_fallHeight = actor.Position.Z; // save latest flying height
|
||||
m_falling = false; // Add for falling
|
||||
// Walking / crouchwalking / running
|
||||
if (move.Z < 0f)
|
||||
return "CROUCHWALK";
|
||||
@@ -380,6 +397,7 @@ m_jumpVelocity = 10f;
|
||||
// rm for jumping else
|
||||
else if (!m_jumping) // add for jumping
|
||||
{
|
||||
m_falling = false; // Add for falling
|
||||
// Not walking
|
||||
if (move.Z < 0f)
|
||||
return "CROUCH";
|
||||
@@ -389,6 +407,7 @@ m_jumpVelocity = 10f;
|
||||
// end section realign for jumping
|
||||
#endregion Ground Movement
|
||||
|
||||
m_falling = false; // Add for falling
|
||||
return m_movementAnimation;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user