aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorteravus2013-01-30 07:34:48 -0500
committerMelanie2013-01-31 20:38:14 +0000
commitbfe0f5d0819577c854a9f814620635dc0e7db1b2 (patch)
treec3beecdb2ec23337b717a539179d3b5f0862733a /OpenSim/Region/Framework
parent* Adds a satisfying angular roll when an avatar is flying and turning. (Gene... (diff)
downloadopensim-SC_OLD-bfe0f5d0819577c854a9f814620635dc0e7db1b2.zip
opensim-SC_OLD-bfe0f5d0819577c854a9f814620635dc0e7db1b2.tar.gz
opensim-SC_OLD-bfe0f5d0819577c854a9f814620635dc0e7db1b2.tar.bz2
opensim-SC_OLD-bfe0f5d0819577c854a9f814620635dc0e7db1b2.tar.xz
* This adds a bit more to the previous flying roll effect by adding additional roll when pressing page down, and reducing your roll when pressing page up to make it feel more responsive and give the user more visual feedback.
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs60
1 files changed, 50 insertions, 10 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 3e5f947..471caa2 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -206,8 +206,8 @@ namespace OpenSim.Region.Framework.Scenes
206 206
207 private const float FLY_ROLL_MAX_RADIANS = 1.1f; 207 private const float FLY_ROLL_MAX_RADIANS = 1.1f;
208 208
209 private const float FLY_ROLL_RADIANS_PER_SECOND = 0.06f; 209 private const float FLY_ROLL_RADIANS_PER_UPDATE = 0.06f;
210 private const float FLY_ROLL_RESET_RADIANS_PER_SECOND = 0.02f; 210 private const float FLY_ROLL_RESET_RADIANS_PER_UPDATE = 0.02f;
211 211
212 private float m_health = 100f; 212 private float m_health = 100f;
213 213
@@ -1244,11 +1244,47 @@ namespace OpenSim.Region.Framework.Scenes
1244 /// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect. 1244 /// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect.
1245 /// </summary> 1245 /// </summary>
1246 /// <param name="amount">Postive or negative roll amount in radians</param> 1246 /// <param name="amount">Postive or negative roll amount in radians</param>
1247 private void ApplyFlyingRoll(float amount) 1247 private void ApplyFlyingRoll(float amount, bool PressingUp, bool PressingDown)
1248 { 1248 {
1249 float noise = ((float)(Util.RandomClass.NextDouble()*0.2f)-0.1f); 1249
1250 float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS) + noise; 1250 float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS);
1251 m_AngularVelocity.Z = rollAmount; 1251 m_AngularVelocity.Z = rollAmount;
1252
1253 // APPLY EXTRA consideration for flying up and flying down during this time.
1254 // if we're turning left
1255 if (amount > 0)
1256 {
1257
1258 // If we're at the max roll and pressing up, we want to swing BACK a bit
1259 // Automatically adds noise
1260 if (PressingUp)
1261 {
1262 if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS - 0.04f)
1263 m_AngularVelocity.Z -= 0.9f;
1264 }
1265 // If we're at the max roll and pressing down, we want to swing MORE a bit
1266 if (PressingDown)
1267 {
1268 if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS && m_AngularVelocity.Z < FLY_ROLL_MAX_RADIANS + 0.6f)
1269 m_AngularVelocity.Z += 0.6f;
1270 }
1271 }
1272 else // we're turning right.
1273 {
1274 // If we're at the max roll and pressing up, we want to swing BACK a bit
1275 // Automatically adds noise
1276 if (PressingUp)
1277 {
1278 if (m_AngularVelocity.Z <= (-FLY_ROLL_MAX_RADIANS))
1279 m_AngularVelocity.Z += 0.6f;
1280 }
1281 // If we're at the max roll and pressing down, we want to swing MORE a bit
1282 if (PressingDown)
1283 {
1284 if (m_AngularVelocity.Z >= -FLY_ROLL_MAX_RADIANS - 0.6f)
1285 m_AngularVelocity.Z -= 0.6f;
1286 }
1287 }
1252 } 1288 }
1253 1289
1254 /// <summary> 1290 /// <summary>
@@ -1800,26 +1836,30 @@ namespace OpenSim.Region.Framework.Scenes
1800 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 1836 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
1801 1837
1802 1838
1803 1839 //m_log.Debug("[CONTROL]: " +flags);
1804 // Applies a satisfying roll effect to the avatar when flying. 1840 // 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)) 1841 if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0))
1806 { 1842 {
1807 ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_SECOND); 1843
1844 ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0));
1845
1808 1846
1809 } 1847 }
1810 else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) && 1848 else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) &&
1811 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)) 1849 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0))
1812 { 1850 {
1813 ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_SECOND); 1851 ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0));
1852
1814 1853
1815 } 1854 }
1816 else 1855 else
1817 { 1856 {
1818 if (m_AngularVelocity.Z != 0) 1857 if (m_AngularVelocity.Z != 0)
1819 m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_SECOND); 1858 m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE);
1820 1859
1821 } 1860 }
1822 1861
1862
1823 1863
1824 1864
1825 if (Flying && IsColliding && controlland) 1865 if (Flying && IsColliding && controlland)