diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 81 |
2 files changed, 82 insertions, 1 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 0ccd69a..88b64f5 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -4893,7 +4893,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4893 | // may improve movement smoothness. | 4893 | // may improve movement smoothness. |
4894 | // acceleration = new Vector3(1, 0, 0); | 4894 | // acceleration = new Vector3(1, 0, 0); |
4895 | 4895 | ||
4896 | angularVelocity = Vector3.Zero; | 4896 | angularVelocity = presence.AngularVelocity; |
4897 | rotation = presence.Rotation; | 4897 | rotation = presence.Rotation; |
4898 | 4898 | ||
4899 | if (sendTexture) | 4899 | if (sendTexture) |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a90872e..1d22560 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -200,6 +200,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
200 | 200 | ||
201 | private const int LAND_VELOCITYMAG_MAX = 12; | 201 | private const int LAND_VELOCITYMAG_MAX = 12; |
202 | 202 | ||
203 | private const float FLY_ROLL_MAX_RADIANS = 1.1f; | ||
204 | |||
205 | private const float FLY_ROLL_RADIANS_PER_SECOND = 0.06f; | ||
206 | private const float FLY_ROLL_RESET_RADIANS_PER_SECOND = 0.02f; | ||
207 | |||
203 | private float m_health = 100f; | 208 | private float m_health = 100f; |
204 | 209 | ||
205 | protected ulong crossingFromRegion; | 210 | protected ulong crossingFromRegion; |
@@ -568,6 +573,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
568 | } | 573 | } |
569 | } | 574 | } |
570 | 575 | ||
576 | // Used for limited viewer 'fake' user rotations. | ||
577 | private Vector3 m_AngularVelocity = Vector3.Zero; | ||
578 | |||
579 | public Vector3 AngularVelocity | ||
580 | { | ||
581 | get { return m_AngularVelocity; } | ||
582 | } | ||
583 | |||
571 | public bool IsChildAgent { get; set; } | 584 | public bool IsChildAgent { get; set; } |
572 | 585 | ||
573 | /// <summary> | 586 | /// <summary> |
@@ -690,6 +703,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
690 | 703 | ||
691 | #endregion | 704 | #endregion |
692 | 705 | ||
706 | |||
707 | |||
693 | #region Constructor(s) | 708 | #region Constructor(s) |
694 | 709 | ||
695 | public ScenePresence( | 710 | public ScenePresence( |
@@ -1033,6 +1048,49 @@ namespace OpenSim.Region.Framework.Scenes | |||
1033 | ControllingClient.StopFlying(this); | 1048 | ControllingClient.StopFlying(this); |
1034 | } | 1049 | } |
1035 | 1050 | ||
1051 | /// <summary> | ||
1052 | /// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect. | ||
1053 | /// </summary> | ||
1054 | /// <param name="amount">Postive or negative roll amount in radians</param> | ||
1055 | private void ApplyFlyingRoll(float amount) | ||
1056 | { | ||
1057 | float noise = ((float)(Util.RandomClass.NextDouble()*0.2f)-0.1f); | ||
1058 | float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS) + noise; | ||
1059 | m_AngularVelocity.Z = rollAmount; | ||
1060 | } | ||
1061 | |||
1062 | /// <summary> | ||
1063 | /// incrementally sets roll amount to zero | ||
1064 | /// </summary> | ||
1065 | /// <param name="amount">Positive roll amount in radians</param> | ||
1066 | /// <returns></returns> | ||
1067 | private float CalculateFlyingRollResetToZero(float amount) | ||
1068 | { | ||
1069 | const float rollMinRadians = 0f; | ||
1070 | |||
1071 | if (m_AngularVelocity.Z > 0) | ||
1072 | { | ||
1073 | |||
1074 | float leftOverToMin = m_AngularVelocity.Z - rollMinRadians; | ||
1075 | if (amount > leftOverToMin) | ||
1076 | return -leftOverToMin; | ||
1077 | else | ||
1078 | return -amount; | ||
1079 | |||
1080 | } | ||
1081 | else | ||
1082 | { | ||
1083 | |||
1084 | float leftOverToMin = -m_AngularVelocity.Z - rollMinRadians; | ||
1085 | if (amount > leftOverToMin) | ||
1086 | return leftOverToMin; | ||
1087 | else | ||
1088 | return amount; | ||
1089 | } | ||
1090 | } | ||
1091 | |||
1092 | |||
1093 | |||
1036 | // neighbouring regions we have enabled a child agent in | 1094 | // neighbouring regions we have enabled a child agent in |
1037 | // holds the seed cap for the child agent in that region | 1095 | // holds the seed cap for the child agent in that region |
1038 | private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); | 1096 | private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); |
@@ -1513,6 +1571,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1513 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || | 1571 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || |
1514 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 1572 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
1515 | 1573 | ||
1574 | |||
1575 | |||
1576 | // Applies a satisfying roll effect to the avatar when flying. | ||
1577 | if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)) | ||
1578 | { | ||
1579 | ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_SECOND); | ||
1580 | |||
1581 | } | ||
1582 | else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) && | ||
1583 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)) | ||
1584 | { | ||
1585 | ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_SECOND); | ||
1586 | |||
1587 | } | ||
1588 | else | ||
1589 | { | ||
1590 | if (m_AngularVelocity.Z != 0) | ||
1591 | m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_SECOND); | ||
1592 | |||
1593 | } | ||
1594 | |||
1595 | |||
1596 | |||
1516 | if (Flying && IsColliding && controlland) | 1597 | if (Flying && IsColliding && controlland) |
1517 | { | 1598 | { |
1518 | // nesting this check because LengthSquared() is expensive and we don't | 1599 | // nesting this check because LengthSquared() is expensive and we don't |