Fix Mouse+WASD makes Av rise; Fix PREJUMP.

avinationmerge
Kitto Flora 2010-05-07 14:12:07 -04:00
parent f3c21524be
commit add7abc1de
4 changed files with 40 additions and 28 deletions

View File

@ -56,7 +56,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
// protected string m_movementAnimation = "DEFAULT"; //KF: 'DEFAULT' does not exist!
protected string m_movementAnimation = "CROUCH"; //KF: CROUCH ensures reliable Av Anim. init.
private int m_animTickFall;
private int m_animTickJump;
// private int m_animTickJump;
public int m_animTickJump; // ScenePresence has to see this to control +Z force
/// <value>
/// The scene presence that this animator applies to
@ -123,22 +124,15 @@ namespace OpenSim.Region.Framework.Scenes.Animation
/// </summary>
public void TrySetMovementAnimation(string anim)
{
//Console.WriteLine("Updating movement animation to {0}", anim);
if (!m_scenePresence.IsChildAgent)
{
if (m_animations.TrySetDefaultAnimation(
anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID))
{
//Console.WriteLine("TSMA {0} success.", anim);
// 16384 is CHANGED_ANIMATION
m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { 16384 });
SendAnimPack();
}
else
{
//Console.WriteLine("TSMA {0} fail.", anim);
}
}
}
@ -267,7 +261,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
m_animTickJump = Environment.TickCount;
return "PREJUMP";
}
else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 1000.0f)
else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 800.0f)
{
// Start actual jump
if (m_animTickJump == -1)
@ -317,7 +311,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation
public void UpdateMovementAnimations()
{
m_movementAnimation = GetMovementAnimation();
//Console.WriteLine("UMA got {0}", m_movementAnimation);
if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump)
{
// This was the previous behavior before PREJUMP

View File

@ -613,7 +613,7 @@ namespace OpenSim.Region.Framework.Scenes
m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
// TODO: Change default to true once the feature is supported
m_usePreJump = startupConfig.GetBoolean("enableprejump", false);
m_usePreJump = true; // Above line fails!?
m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
if (RegionInfo.NonphysPrimMax > 0)
{

View File

@ -665,7 +665,7 @@ namespace OpenSim.Region.Framework.Scenes
CreateSceneViewer();
m_animator = new ScenePresenceAnimator(this);
}
private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this()
{
m_rootRegionHandle = reginfo.RegionHandle;
@ -1459,7 +1459,6 @@ namespace OpenSim.Region.Framework.Scenes
}
i++;
}
//Paupaw:Do Proper PID for Autopilot here
if (bResetMoveToPosition)
{
@ -2433,10 +2432,11 @@ namespace OpenSim.Region.Framework.Scenes
Rotation = rotation;
Vector3 direc = vec * rotation;
direc.Normalize();
PhysicsActor actor = m_physicsActor;
if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up.
direc *= 0.03f * 128f * m_speedModifier;
PhysicsActor actor = m_physicsActor;
if (actor != null)
{
if (actor.Flying)
@ -2458,11 +2458,18 @@ namespace OpenSim.Region.Framework.Scenes
{
if (direc.Z > 2.0f)
{
direc.Z *= 3.0f;
// TODO: PreJump and jump happen too quickly. Many times prejump gets ignored.
Animator.TrySetMovementAnimation("PREJUMP");
Animator.TrySetMovementAnimation("JUMP");
if(m_animator.m_animTickJump == -1)
{
direc.Z *= 3.0f; // jump
}
else
{
direc.Z *= 0.1f; // prejump
}
/* Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs
Animator.TrySetMovementAnimation("PREJUMP");
Animator.TrySetMovementAnimation("JUMP");
*/
}
}
}

View File

@ -142,7 +142,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// unique UUID of this character object
public UUID m_uuid;
public bool bad = false;
public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, CollisionLocker dode, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor)
{
m_uuid = UUID.Random();
@ -892,7 +892,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// If the PID Controller isn't active then we set our force
// calculating base velocity to the current position
if (Body == IntPtr.Zero)
return;
@ -972,8 +972,17 @@ namespace OpenSim.Region.Physics.OdePlugin
// Prim to avatar collisions
d.Vector3 pos = d.BodyGetPosition(Body);
vec.X = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2);
vec.Y = (_target_velocity.Y - vel.Y)*(PID_D) + (_zeroPosition.Y - pos.Y)* (PID_P * 2);
float errX = _zeroPosition.X - pos.X;
float errY = _zeroPosition.Y - pos.Y;
if( (Math.Abs(errX) > 0.1f) || (Math.Abs(errY) > 0.1f) )
{
vec.X = (_target_velocity.X - vel.X) * (PID_D) + (errX) * (PID_P * 2);
vec.Y = (_target_velocity.Y - vel.Y) * (PID_D) + (errY) * (PID_P * 2);
}
else
{ // close, jump to lateral destination
d.BodySetPosition(Body, _zeroPosition.X, _zeroPosition.Y, pos.Z);
}
if (flying)
{
vec.Z = (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
@ -1056,11 +1065,14 @@ namespace OpenSim.Region.Physics.OdePlugin
}
if (vec.IsFinite())
{
doForce(vec);
if (!_zeroFlag)
{
AlignAvatarTiltWithCurrentDirectionOfMovement(vec);
}
if (!vec.ApproxEquals(Vector3.Zero, 0.01f))
{
doForce(vec);
if (!_zeroFlag)
{
AlignAvatarTiltWithCurrentDirectionOfMovement(vec);
}
}
}
else
{