Falling animation fix, comment out instrumentation.

avinationmerge
Kitto Flora 2010-09-06 21:45:07 +00:00
parent 24c73aa8b2
commit c719e016ed
4 changed files with 90 additions and 50 deletions

View File

@ -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)
{
@ -206,7 +213,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
else if (move.Z < 0f)
{
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;
return "PREJUMP";
}
@ -274,6 +287,7 @@ 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_animTickFall = Environment.TickCount;
@ -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;
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;
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"))
{
//Console.WriteLine("LAND"); //##
return "LAND";
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("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;
}

View File

@ -2568,9 +2568,11 @@ namespace OpenSim.Region.Framework.Scenes
if (actor != null)
{
if (actor.Flying)
// rm falling if (actor.Flying)
if ((actor.Flying) || Animator.m_falling) // add for falling lateral speed
{
direc *= 4.0f;
// rm speed mod direc *= 4.0f;
direc *= 5.2f; // for speed mod
//bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
//bool colliding = (m_physicsActor.IsColliding==true);
//if (controlland)

View File

@ -269,7 +269,10 @@ namespace OpenSim.Region.Physics.OdePlugin
/// </summary>
public override bool IsColliding
{
get { return m_iscolliding; }
//#@ get { return m_iscolliding; }
get { //##
//Console.WriteLine(">>>>>>>>>>>> IC get = {0}", m_iscolliding); //##
return m_iscolliding; } //##
set
{
int i;
@ -307,6 +310,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_iscolliding = true;
}
// ## Console.WriteLine("IC SET = {0} t{1} f{2} i {3}", value, truecount, falsecount, m_iscolliding);
if (m_wascolliding != m_iscolliding)
{
//base.SendCollisionUpdate(new CollisionEventUpdate());
@ -589,7 +593,7 @@ namespace OpenSim.Region.Physics.OdePlugin
Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
_parent_scene.geom_name_map[Shell] = m_name;
_parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
//Console.WriteLine("**** Create {2} Dicts: actor={0} name={1}", _parent_scene.actor_name_map.Count, _parent_scene.geom_name_map.Count, m_name);
Console.WriteLine("**** Create {2} Dicts: actor={0} name={1} height={3} rad={4}", _parent_scene.actor_name_map.Count, _parent_scene.geom_name_map.Count, m_name, CAPSULE_LENGTH, CAPSULE_RADIUS);
d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
@ -857,6 +861,8 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_pidControllerActive = false;
force *= 100f;
//Console.WriteLine("DF 1"); // ##
if (!force.ApproxEquals(Vector3.Zero, 0.01f))
doForce(force);
// If uncommented, things get pushed off world
//
@ -896,7 +902,8 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodyAddForce(Body, force.X, force.Y, force.Z);
//d.BodySetRotation(Body, ref m_StandUpRotation);
//standupStraight();
d.Vector3 vel = d.BodyGetLinearVel(Body); //##
//Console.WriteLine("AvVel <{0},{1},{2}>", vel.X, vel.Y, vel.Z); //##
}
}
@ -1103,12 +1110,14 @@ namespace OpenSim.Region.Physics.OdePlugin
}
if (vec.IsFinite())
{
if (!vec.ApproxEquals(Vector3.Zero, 0.01f))
if (!vec.ApproxEquals(Vector3.Zero, 0.02f)) // 0.01 allows 0.002 !!
{
//Console.WriteLine("DF 2"); // ##
doForce(vec);
if (!_zeroFlag)
{
AlignAvatarTiltWithCurrentDirectionOfMovement(vec);
// AlignAvatarTiltWithCurrentDirectionOfMovement(vec);
}
}
}

View File

@ -713,7 +713,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Test if we're colliding a geom with a space.
// If so we have to drill down into the space recursively
//Console.WriteLine("near -----------"); //##
if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2))
{
if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
@ -844,11 +844,21 @@ namespace OpenSim.Region.Physics.OdePlugin
// Testing if the collision is at the feet of the avatar
//m_log.DebugFormat("[PHYSICS]: {0} - {1} - {2} - {3}", curContact.pos.Z, p2.Position.Z, (p2.Position.Z - curContact.pos.Z), (p2.Size.Z * 0.6f));
if ((p2.Position.Z - curContact.pos.Z) > (p2.Size.Z * 0.6f))
p2.IsColliding = true;
//#@ if ((p2.Position.Z - curContact.pos.Z) > (p2.Size.Z * 0.6f))
//#@ p2.IsColliding = true;
if ((p2.Position.Z - curContact.pos.Z) > (p2.Size.Z * 0.6f)){ //##
//Console.WriteLine("AvColl 1 {0} - {1} - {2} - {3}", //##
// curContact.pos.Z, p2.Position.Z, (p2.Position.Z - curContact.pos.Z), (p2.Size.Z * 0.6f)); //##
p2.IsColliding = true; //##
}else{
//Console.WriteLine("AvColl 2 {0} - {1} - {2} - {3}", //##
// curContact.pos.Z, p2.Position.Z, (p2.Position.Z - curContact.pos.Z), (p2.Size.Z * 0.6f)); //##
} //##
}
else
{
//Console.WriteLine("AvColl 3 {0}", p2.PhysicsActorType); //##
p2.IsColliding = true;
}