* Implemented Walk Vs Run in ODE. Also helps make the walk look smoother.

* All thanks to unimplemented packet listing :D
afrisby
Teravus Ovares 2007-11-12 23:46:26 +00:00
parent 5952441fcc
commit d9d35f9fd7
11 changed files with 81 additions and 6 deletions

View File

@ -184,6 +184,7 @@ namespace OpenSim.Framework
public delegate void DisconnectUser(); public delegate void DisconnectUser();
public delegate void RequestAvatarProperties(IClientAPI remoteClient, LLUUID avatarID); public delegate void RequestAvatarProperties(IClientAPI remoteClient, LLUUID avatarID);
public delegate void SetAlwaysRun (IClientAPI remoteClient, bool SetAlwaysRun);
public delegate void GenericCall2(); public delegate void GenericCall2();
@ -293,7 +294,7 @@ namespace OpenSim.Framework
event TeleportLocationRequest OnTeleportLocationRequest; event TeleportLocationRequest OnTeleportLocationRequest;
event DisconnectUser OnDisconnectUser; event DisconnectUser OnDisconnectUser;
event RequestAvatarProperties OnRequestAvatarProperties; event RequestAvatarProperties OnRequestAvatarProperties;
event SetAlwaysRun OnSetAlwaysRun;
event GenericCall4 OnDeRezObject; event GenericCall4 OnDeRezObject;
event Action<IClientAPI> OnRegionHandShakeReply; event Action<IClientAPI> OnRegionHandShakeReply;
event GenericCall2 OnRequestWearables; event GenericCall2 OnRequestWearables;

View File

@ -84,6 +84,7 @@ namespace OpenSim.Region.ClientStack
public event TeleportLocationRequest OnTeleportLocationRequest; public event TeleportLocationRequest OnTeleportLocationRequest;
public event DisconnectUser OnDisconnectUser; public event DisconnectUser OnDisconnectUser;
public event RequestAvatarProperties OnRequestAvatarProperties; public event RequestAvatarProperties OnRequestAvatarProperties;
public event SetAlwaysRun OnSetAlwaysRun;
public event CreateNewInventoryItem OnCreateNewInventoryItem; public event CreateNewInventoryItem OnCreateNewInventoryItem;
public event CreateInventoryFolder OnCreateNewInventoryFolder; public event CreateInventoryFolder OnCreateNewInventoryFolder;

View File

@ -168,6 +168,13 @@ namespace OpenSim.Region.ClientStack
{ {
OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam); OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam);
} }
break;
case PacketType.SetAlwaysRun:
SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
if (OnSetAlwaysRun != null)
OnSetAlwaysRun(this,run.AgentData.AlwaysRun);
break; break;
case PacketType.CompleteAgentMovement: case PacketType.CompleteAgentMovement:
if (OnCompleteMovementToRegion != null) if (OnCompleteMovementToRegion != null)

View File

@ -55,6 +55,7 @@ namespace OpenSim.Region.Environment.Scenes
private bool m_oldColliding = true; private bool m_oldColliding = true;
private bool m_isTyping = false; private bool m_isTyping = false;
private bool m_setAlwaysRun = false;
private Quaternion m_bodyRot; private Quaternion m_bodyRot;
private byte[] m_visualParams; private byte[] m_visualParams;
@ -271,6 +272,7 @@ namespace OpenSim.Region.Environment.Scenes
m_controllingClient.OnAgentUpdate += HandleAgentUpdate; m_controllingClient.OnAgentUpdate += HandleAgentUpdate;
m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit;
m_controllingClient.OnAgentSit += HandleAgentSit; m_controllingClient.OnAgentSit += HandleAgentSit;
m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun;
// ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
// ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
//ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
@ -637,7 +639,15 @@ namespace OpenSim.Region.Environment.Scenes
SendAnimPack(Animations.AnimsLLUUID["SIT"], 1); SendAnimPack(Animations.AnimsLLUUID["SIT"], 1);
SendFullUpdateToAllClients(); SendFullUpdateToAllClients();
} }
public void HandleSetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun)
{
m_setAlwaysRun = SetAlwaysRun;
if (PhysicsActor != null)
{
PhysicsActor.SetAlwaysRun = SetAlwaysRun;
}
}
protected void UpdateMovementAnimations(bool update_movementflag) protected void UpdateMovementAnimations(bool update_movementflag)
{ {
if (update_movementflag) if (update_movementflag)
@ -666,9 +676,16 @@ namespace OpenSim.Region.Environment.Scenes
SendAnimPack(Animations.AnimsLLUUID["JUMP"], 1); SendAnimPack(Animations.AnimsLLUUID["JUMP"], 1);
} }
else else
{
if (!m_setAlwaysRun)
{ {
SendAnimPack(Animations.AnimsLLUUID["WALK"], 1); SendAnimPack(Animations.AnimsLLUUID["WALK"], 1);
} }
else
{
SendAnimPack(Animations.AnimsLLUUID["RUN"], 1);
}
}
} }
} }
} }

View File

@ -61,6 +61,7 @@ namespace SimpleApp
public event TeleportLocationRequest OnTeleportLocationRequest; public event TeleportLocationRequest OnTeleportLocationRequest;
public event DisconnectUser OnDisconnectUser; public event DisconnectUser OnDisconnectUser;
public event RequestAvatarProperties OnRequestAvatarProperties; public event RequestAvatarProperties OnRequestAvatarProperties;
public event SetAlwaysRun OnSetAlwaysRun;
public event GenericCall4 OnDeRezObject; public event GenericCall4 OnDeRezObject;
public event Action<IClientAPI> OnRegionHandShakeReply; public event Action<IClientAPI> OnRegionHandShakeReply;

View File

@ -206,6 +206,11 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
get { return m_rotationalVelocity; } get { return m_rotationalVelocity; }
set { m_rotationalVelocity = value; } set { m_rotationalVelocity = value; }
} }
public override bool SetAlwaysRun
{
get { return false; }
set { return; }
}
public override bool IsPhysical public override bool IsPhysical
{ {
get { return false; } get { return false; }

View File

@ -764,7 +764,11 @@ namespace OpenSim.Region.Physics.BulletXPlugin
return; return;
} }
} }
public override bool SetAlwaysRun
{
get { return false; }
set { return; }
}
public override PhysicsVector Acceleration public override PhysicsVector Acceleration
{ {
get { return _acceleration; } get { return _acceleration; }

View File

@ -153,7 +153,7 @@ namespace OpenSim.Region.Physics.Manager
public abstract bool IsPhysical {get; set;} public abstract bool IsPhysical {get; set;}
public abstract bool Flying { get; set; } public abstract bool Flying { get; set; }
public abstract bool SetAlwaysRun { get; set; }
public abstract bool ThrottleUpdates { get; set; } public abstract bool ThrottleUpdates { get; set; }
public abstract bool IsColliding { get; set; } public abstract bool IsColliding { get; set; }
@ -176,6 +176,11 @@ namespace OpenSim.Region.Physics.Manager
get { return PhysicsVector.Zero; } get { return PhysicsVector.Zero; }
set { return; } set { return; }
} }
public override bool SetAlwaysRun
{
get { return false; }
set { return; }
}
public override bool CollidingGround public override bool CollidingGround
{ {
get {return false;} get {return false;}

View File

@ -660,6 +660,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool flying = false; private bool flying = false;
private bool m_iscolliding = false; private bool m_iscolliding = false;
private bool m_wascolliding = false; private bool m_wascolliding = false;
private bool m_alwaysRun = false;
private bool[] m_colliderarr = new bool[11]; private bool[] m_colliderarr = new bool[11];
@ -702,6 +703,11 @@ namespace OpenSim.Region.Physics.OdePlugin
get { return (int)ActorTypes.Agent; } get { return (int)ActorTypes.Agent; }
set { return; } set { return; }
} }
public override bool SetAlwaysRun
{
get { return m_alwaysRun; }
set { m_alwaysRun = value;}
}
public override bool IsPhysical public override bool IsPhysical
{ {
get { return false; } get { return false; }
@ -876,6 +882,17 @@ namespace OpenSim.Region.Physics.OdePlugin
// no lock; for now it's only called from within Simulate() // no lock; for now it's only called from within Simulate()
PhysicsVector vec = new PhysicsVector(); PhysicsVector vec = new PhysicsVector();
d.Vector3 vel = d.BodyGetLinearVel(Body); d.Vector3 vel = d.BodyGetLinearVel(Body);
float movementdivisor = 1f;
if (!m_alwaysRun)
{
movementdivisor = 10.5f;
}
else
{
movementdivisor = 0.2079f;
}
// if velocity is zero, use position control; otherwise, velocity control // if velocity is zero, use position control; otherwise, velocity control
if (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f && m_iscolliding) if (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f && m_iscolliding)
@ -900,8 +917,9 @@ namespace OpenSim.Region.Physics.OdePlugin
_zeroFlag = false; _zeroFlag = false;
if (m_iscolliding || flying) if (m_iscolliding || flying)
{ {
vec.X = (_target_velocity.X - vel.X) * PID_D;
vec.Y = (_target_velocity.Y - vel.Y) * PID_D; vec.X = ((_target_velocity.X - vel.X)/movementdivisor) * PID_D;
vec.Y = ((_target_velocity.Y - vel.Y)/movementdivisor) * PID_D;
} }
if (m_iscolliding && !flying && _target_velocity.Z > 0.0f) if (m_iscolliding && !flying && _target_velocity.Z > 0.0f)
{ {
@ -1077,6 +1095,11 @@ namespace OpenSim.Region.Physics.OdePlugin
get { return (int)ActorTypes.Prim; } get { return (int)ActorTypes.Prim; }
set { return; } set { return; }
} }
public override bool SetAlwaysRun
{
get { return false; }
set { return; }
}
public void enableBody() public void enableBody()
{ {
// Sets the geom to a body // Sets the geom to a body

View File

@ -209,6 +209,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin
get { return (int)ActorTypes.Agent; } get { return (int)ActorTypes.Agent; }
set { return; } set { return; }
} }
public override bool SetAlwaysRun
{
get { return false; }
set { return; }
}
public override bool IsPhysical public override bool IsPhysical
{ {
get { return false; } get { return false; }
@ -363,6 +368,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin
get { return false; } get { return false; }
set { return; } set { return; }
} }
public override bool SetAlwaysRun
{
get { return false; }
set { return; }
}
public override bool ThrottleUpdates public override bool ThrottleUpdates
{ {
get { return false; } get { return false; }

View File

@ -14,4 +14,5 @@
<animation name="TYPE">c541c47f-e0c0-058b-ad1a-d6ae3a4584d9</animation> <animation name="TYPE">c541c47f-e0c0-058b-ad1a-d6ae3a4584d9</animation>
<animation name="FALLDOWN">666307d9-a860-572d-6fd4-c3ab8865c094</animation> <animation name="FALLDOWN">666307d9-a860-572d-6fd4-c3ab8865c094</animation>
<animation name="JUMP">2305bd75-1ca9-b03b-1faa-b176b8a8c49e</animation> <animation name="JUMP">2305bd75-1ca9-b03b-1faa-b176b8a8c49e</animation>
<animation name="RUN">05ddbff8-aaa9-92a1-2b74-8fe77a29b445</animation>
</animations> </animations>