diff options
author | Melanie | 2013-01-31 02:53:11 +0000 |
---|---|---|
committer | Melanie | 2013-01-31 02:53:11 +0000 |
commit | 9a4de546fe92105c570d6861377ec47d32b4186e (patch) | |
tree | edfb86074fc7c78126203a2c05a38e260c0d4076 /OpenSim/Region/Framework/Scenes/ScenePresence.cs | |
parent | Merge branch 'avination' into careminster (diff) | |
parent | Add JsonTestStore to determine if a JsonStore is associated with (diff) | |
download | opensim-SC-9a4de546fe92105c570d6861377ec47d32b4186e.zip opensim-SC-9a4de546fe92105c570d6861377ec47d32b4186e.tar.gz opensim-SC-9a4de546fe92105c570d6861377ec47d32b4186e.tar.bz2 opensim-SC-9a4de546fe92105c570d6861377ec47d32b4186e.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f024f52..6005f07 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_UPDATE = 0.06f; | ||
210 | private const float FLY_ROLL_RESET_RADIANS_PER_UPDATE = 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; |
@@ -604,6 +609,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
604 | } | 609 | } |
605 | } | 610 | } |
606 | 611 | ||
612 | // Used for limited viewer 'fake' user rotations. | ||
613 | private Vector3 m_AngularVelocity = Vector3.Zero; | ||
614 | |||
615 | public Vector3 AngularVelocity | ||
616 | { | ||
617 | get { return m_AngularVelocity; } | ||
618 | } | ||
619 | |||
607 | public bool IsChildAgent { get; set; } | 620 | public bool IsChildAgent { get; set; } |
608 | public bool IsLoggingIn { get; set; } | 621 | public bool IsLoggingIn { get; set; } |
609 | 622 | ||
@@ -734,6 +747,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
734 | 747 | ||
735 | #endregion | 748 | #endregion |
736 | 749 | ||
750 | |||
751 | |||
737 | #region Constructor(s) | 752 | #region Constructor(s) |
738 | 753 | ||
739 | public ScenePresence( | 754 | public ScenePresence( |
@@ -1223,6 +1238,85 @@ namespace OpenSim.Region.Framework.Scenes | |||
1223 | ControllingClient.StopFlying(this); | 1238 | ControllingClient.StopFlying(this); |
1224 | } | 1239 | } |
1225 | 1240 | ||
1241 | /// <summary> | ||
1242 | /// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect. | ||
1243 | /// </summary> | ||
1244 | /// <param name="amount">Postive or negative roll amount in radians</param> | ||
1245 | private void ApplyFlyingRoll(float amount, bool PressingUp, bool PressingDown) | ||
1246 | { | ||
1247 | |||
1248 | float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS); | ||
1249 | m_AngularVelocity.Z = rollAmount; | ||
1250 | |||
1251 | // APPLY EXTRA consideration for flying up and flying down during this time. | ||
1252 | // if we're turning left | ||
1253 | if (amount > 0) | ||
1254 | { | ||
1255 | |||
1256 | // If we're at the max roll and pressing up, we want to swing BACK a bit | ||
1257 | // Automatically adds noise | ||
1258 | if (PressingUp) | ||
1259 | { | ||
1260 | if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS - 0.04f) | ||
1261 | m_AngularVelocity.Z -= 0.9f; | ||
1262 | } | ||
1263 | // If we're at the max roll and pressing down, we want to swing MORE a bit | ||
1264 | if (PressingDown) | ||
1265 | { | ||
1266 | if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS && m_AngularVelocity.Z < FLY_ROLL_MAX_RADIANS + 0.6f) | ||
1267 | m_AngularVelocity.Z += 0.6f; | ||
1268 | } | ||
1269 | } | ||
1270 | else // we're turning right. | ||
1271 | { | ||
1272 | // If we're at the max roll and pressing up, we want to swing BACK a bit | ||
1273 | // Automatically adds noise | ||
1274 | if (PressingUp) | ||
1275 | { | ||
1276 | if (m_AngularVelocity.Z <= (-FLY_ROLL_MAX_RADIANS)) | ||
1277 | m_AngularVelocity.Z += 0.6f; | ||
1278 | } | ||
1279 | // If we're at the max roll and pressing down, we want to swing MORE a bit | ||
1280 | if (PressingDown) | ||
1281 | { | ||
1282 | if (m_AngularVelocity.Z >= -FLY_ROLL_MAX_RADIANS - 0.6f) | ||
1283 | m_AngularVelocity.Z -= 0.6f; | ||
1284 | } | ||
1285 | } | ||
1286 | } | ||
1287 | |||
1288 | /// <summary> | ||
1289 | /// incrementally sets roll amount to zero | ||
1290 | /// </summary> | ||
1291 | /// <param name="amount">Positive roll amount in radians</param> | ||
1292 | /// <returns></returns> | ||
1293 | private float CalculateFlyingRollResetToZero(float amount) | ||
1294 | { | ||
1295 | const float rollMinRadians = 0f; | ||
1296 | |||
1297 | if (m_AngularVelocity.Z > 0) | ||
1298 | { | ||
1299 | |||
1300 | float leftOverToMin = m_AngularVelocity.Z - rollMinRadians; | ||
1301 | if (amount > leftOverToMin) | ||
1302 | return -leftOverToMin; | ||
1303 | else | ||
1304 | return -amount; | ||
1305 | |||
1306 | } | ||
1307 | else | ||
1308 | { | ||
1309 | |||
1310 | float leftOverToMin = -m_AngularVelocity.Z - rollMinRadians; | ||
1311 | if (amount > leftOverToMin) | ||
1312 | return leftOverToMin; | ||
1313 | else | ||
1314 | return amount; | ||
1315 | } | ||
1316 | } | ||
1317 | |||
1318 | |||
1319 | |||
1226 | // neighbouring regions we have enabled a child agent in | 1320 | // neighbouring regions we have enabled a child agent in |
1227 | // holds the seed cap for the child agent in that region | 1321 | // holds the seed cap for the child agent in that region |
1228 | private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); | 1322 | private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); |
@@ -1739,6 +1833,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
1739 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || | 1833 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || |
1740 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 1834 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
1741 | 1835 | ||
1836 | |||
1837 | //m_log.Debug("[CONTROL]: " +flags); | ||
1838 | // Applies a satisfying roll effect to the avatar when flying. | ||
1839 | if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)) | ||
1840 | { | ||
1841 | |||
1842 | ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)); | ||
1843 | |||
1844 | |||
1845 | } | ||
1846 | else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) && | ||
1847 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)) | ||
1848 | { | ||
1849 | ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)); | ||
1850 | |||
1851 | |||
1852 | } | ||
1853 | else | ||
1854 | { | ||
1855 | if (m_AngularVelocity.Z != 0) | ||
1856 | m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); | ||
1857 | |||
1858 | } | ||
1859 | |||
1860 | |||
1861 | |||
1862 | |||
1742 | if (Flying && IsColliding && controlland) | 1863 | if (Flying && IsColliding && controlland) |
1743 | { | 1864 | { |
1744 | // nesting this check because LengthSquared() is expensive and we don't | 1865 | // nesting this check because LengthSquared() is expensive and we don't |