* Adds a satisfying angular roll when an avatar is flying and turning. (General, not physics). Makes flying not feel as stiff.

Conflicts:

	OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
avinationmerge
Melanie 2013-01-31 20:37:58 +00:00
parent d1ebb0a8f9
commit cc1781926b
2 changed files with 84 additions and 2 deletions

View File

@ -4964,7 +4964,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// may improve movement smoothness. // may improve movement smoothness.
// acceleration = new Vector3(1, 0, 0); // acceleration = new Vector3(1, 0, 0);
angularVelocity = Vector3.Zero; angularVelocity = presence.AngularVelocity;
rotation = presence.Rotation;
if (sendTexture) if (sendTexture)
textureEntry = presence.Appearance.Texture.GetBytes(); textureEntry = presence.Appearance.Texture.GetBytes();

View File

@ -204,6 +204,11 @@ namespace OpenSim.Region.Framework.Scenes
private const int LAND_VELOCITYMAG_MAX = 12; private const int LAND_VELOCITYMAG_MAX = 12;
private const float FLY_ROLL_MAX_RADIANS = 1.1f;
private const float FLY_ROLL_RADIANS_PER_SECOND = 0.06f;
private const float FLY_ROLL_RESET_RADIANS_PER_SECOND = 0.02f;
private float m_health = 100f; private float m_health = 100f;
protected ulong crossingFromRegion; protected ulong crossingFromRegion;
@ -606,6 +611,14 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
// Used for limited viewer 'fake' user rotations.
private Vector3 m_AngularVelocity = Vector3.Zero;
public Vector3 AngularVelocity
{
get { return m_AngularVelocity; }
}
public bool IsChildAgent { get; set; } public bool IsChildAgent { get; set; }
public bool IsLoggingIn { get; set; } public bool IsLoggingIn { get; set; }
@ -736,6 +749,8 @@ namespace OpenSim.Region.Framework.Scenes
#endregion #endregion
#region Constructor(s) #region Constructor(s)
public ScenePresence( public ScenePresence(
@ -1225,6 +1240,49 @@ namespace OpenSim.Region.Framework.Scenes
ControllingClient.StopFlying(this); ControllingClient.StopFlying(this);
} }
/// <summary>
/// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect.
/// </summary>
/// <param name="amount">Postive or negative roll amount in radians</param>
private void ApplyFlyingRoll(float amount)
{
float noise = ((float)(Util.RandomClass.NextDouble()*0.2f)-0.1f);
float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS) + noise;
m_AngularVelocity.Z = rollAmount;
}
/// <summary>
/// incrementally sets roll amount to zero
/// </summary>
/// <param name="amount">Positive roll amount in radians</param>
/// <returns></returns>
private float CalculateFlyingRollResetToZero(float amount)
{
const float rollMinRadians = 0f;
if (m_AngularVelocity.Z > 0)
{
float leftOverToMin = m_AngularVelocity.Z - rollMinRadians;
if (amount > leftOverToMin)
return -leftOverToMin;
else
return -amount;
}
else
{
float leftOverToMin = -m_AngularVelocity.Z - rollMinRadians;
if (amount > leftOverToMin)
return leftOverToMin;
else
return amount;
}
}
// neighbouring regions we have enabled a child agent in // neighbouring regions we have enabled a child agent in
// holds the seed cap for the child agent in that region // holds the seed cap for the child agent in that region
private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>();
@ -1741,6 +1799,29 @@ namespace OpenSim.Region.Framework.Scenes
bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
// Applies a satisfying roll effect to the avatar when flying.
if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0))
{
ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_SECOND);
}
else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) &&
((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0))
{
ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_SECOND);
}
else
{
if (m_AngularVelocity.Z != 0)
m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_SECOND);
}
if (Flying && IsColliding && controlland) if (Flying && IsColliding && controlland)
{ {
// nesting this check because LengthSquared() is expensive and we don't // nesting this check because LengthSquared() is expensive and we don't