aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorMelanie2013-01-31 20:37:58 +0000
committerMelanie2013-01-31 20:37:58 +0000
commitcc1781926b4c49c72977d4ddb16cc583a9ffeb80 (patch)
tree68dc63b18069129fdc1696473a13decc19ca0768 /OpenSim/Region/Framework
parentChange keyframe motion to use a single timer for all objects. This is required (diff)
downloadopensim-SC_OLD-cc1781926b4c49c72977d4ddb16cc583a9ffeb80.zip
opensim-SC_OLD-cc1781926b4c49c72977d4ddb16cc583a9ffeb80.tar.gz
opensim-SC_OLD-cc1781926b4c49c72977d4ddb16cc583a9ffeb80.tar.bz2
opensim-SC_OLD-cc1781926b4c49c72977d4ddb16cc583a9ffeb80.tar.xz
* 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
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs81
1 files changed, 81 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index a9195f7..3e5f947 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -204,6 +204,11 @@ namespace OpenSim.Region.Framework.Scenes
204 204
205 private const int LAND_VELOCITYMAG_MAX = 12; 205 private const int LAND_VELOCITYMAG_MAX = 12;
206 206
207 private const float FLY_ROLL_MAX_RADIANS = 1.1f;
208
209 private const float FLY_ROLL_RADIANS_PER_SECOND = 0.06f;
210 private const float FLY_ROLL_RESET_RADIANS_PER_SECOND = 0.02f;
211
207 private float m_health = 100f; 212 private float m_health = 100f;
208 213
209 protected ulong crossingFromRegion; 214 protected ulong crossingFromRegion;
@@ -606,6 +611,14 @@ namespace OpenSim.Region.Framework.Scenes
606 } 611 }
607 } 612 }
608 613
614 // Used for limited viewer 'fake' user rotations.
615 private Vector3 m_AngularVelocity = Vector3.Zero;
616
617 public Vector3 AngularVelocity
618 {
619 get { return m_AngularVelocity; }
620 }
621
609 public bool IsChildAgent { get; set; } 622 public bool IsChildAgent { get; set; }
610 public bool IsLoggingIn { get; set; } 623 public bool IsLoggingIn { get; set; }
611 624
@@ -736,6 +749,8 @@ namespace OpenSim.Region.Framework.Scenes
736 749
737 #endregion 750 #endregion
738 751
752
753
739 #region Constructor(s) 754 #region Constructor(s)
740 755
741 public ScenePresence( 756 public ScenePresence(
@@ -1225,6 +1240,49 @@ namespace OpenSim.Region.Framework.Scenes
1225 ControllingClient.StopFlying(this); 1240 ControllingClient.StopFlying(this);
1226 } 1241 }
1227 1242
1243 /// <summary>
1244 /// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect.
1245 /// </summary>
1246 /// <param name="amount">Postive or negative roll amount in radians</param>
1247 private void ApplyFlyingRoll(float amount)
1248 {
1249 float noise = ((float)(Util.RandomClass.NextDouble()*0.2f)-0.1f);
1250 float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS) + noise;
1251 m_AngularVelocity.Z = rollAmount;
1252 }
1253
1254 /// <summary>
1255 /// incrementally sets roll amount to zero
1256 /// </summary>
1257 /// <param name="amount">Positive roll amount in radians</param>
1258 /// <returns></returns>
1259 private float CalculateFlyingRollResetToZero(float amount)
1260 {
1261 const float rollMinRadians = 0f;
1262
1263 if (m_AngularVelocity.Z > 0)
1264 {
1265
1266 float leftOverToMin = m_AngularVelocity.Z - rollMinRadians;
1267 if (amount > leftOverToMin)
1268 return -leftOverToMin;
1269 else
1270 return -amount;
1271
1272 }
1273 else
1274 {
1275
1276 float leftOverToMin = -m_AngularVelocity.Z - rollMinRadians;
1277 if (amount > leftOverToMin)
1278 return leftOverToMin;
1279 else
1280 return amount;
1281 }
1282 }
1283
1284
1285
1228 // neighbouring regions we have enabled a child agent in 1286 // neighbouring regions we have enabled a child agent in
1229 // holds the seed cap for the child agent in that region 1287 // holds the seed cap for the child agent in that region
1230 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); 1288 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>();
@@ -1741,6 +1799,29 @@ namespace OpenSim.Region.Framework.Scenes
1741 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || 1799 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
1742 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 1800 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
1743 1801
1802
1803
1804 // Applies a satisfying roll effect to the avatar when flying.
1805 if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0))
1806 {
1807 ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_SECOND);
1808
1809 }
1810 else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) &&
1811 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0))
1812 {
1813 ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_SECOND);
1814
1815 }
1816 else
1817 {
1818 if (m_AngularVelocity.Z != 0)
1819 m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_SECOND);
1820
1821 }
1822
1823
1824
1744 if (Flying && IsColliding && controlland) 1825 if (Flying && IsColliding && controlland)
1745 { 1826 {
1746 // nesting this check because LengthSquared() is expensive and we don't 1827 // nesting this check because LengthSquared() is expensive and we don't