diff options
author | teravus | 2013-01-30 07:34:48 -0500 |
---|---|---|
committer | teravus | 2013-01-30 07:34:48 -0500 |
commit | 52ea6eadaed5e5d2d43807999e6bb805c60056fd (patch) | |
tree | b3e13945ce4ed1e94421c1a609ba013c117dd654 /OpenSim/Region | |
parent | * Adds a satisfying angular roll when an avatar is flying and turning. (Gene... (diff) | |
download | opensim-SC-52ea6eadaed5e5d2d43807999e6bb805c60056fd.zip opensim-SC-52ea6eadaed5e5d2d43807999e6bb805c60056fd.tar.gz opensim-SC-52ea6eadaed5e5d2d43807999e6bb805c60056fd.tar.bz2 opensim-SC-52ea6eadaed5e5d2d43807999e6bb805c60056fd.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 '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 60 |
1 files changed, 50 insertions, 10 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1d22560..e0dfb34 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -202,8 +202,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
202 | 202 | ||
203 | private const float FLY_ROLL_MAX_RADIANS = 1.1f; | 203 | private const float FLY_ROLL_MAX_RADIANS = 1.1f; |
204 | 204 | ||
205 | private const float FLY_ROLL_RADIANS_PER_SECOND = 0.06f; | 205 | private const float FLY_ROLL_RADIANS_PER_UPDATE = 0.06f; |
206 | private const float FLY_ROLL_RESET_RADIANS_PER_SECOND = 0.02f; | 206 | private const float FLY_ROLL_RESET_RADIANS_PER_UPDATE = 0.02f; |
207 | 207 | ||
208 | private float m_health = 100f; | 208 | private float m_health = 100f; |
209 | 209 | ||
@@ -1052,11 +1052,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
1052 | /// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect. | 1052 | /// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect. |
1053 | /// </summary> | 1053 | /// </summary> |
1054 | /// <param name="amount">Postive or negative roll amount in radians</param> | 1054 | /// <param name="amount">Postive or negative roll amount in radians</param> |
1055 | private void ApplyFlyingRoll(float amount) | 1055 | private void ApplyFlyingRoll(float amount, bool PressingUp, bool PressingDown) |
1056 | { | 1056 | { |
1057 | float noise = ((float)(Util.RandomClass.NextDouble()*0.2f)-0.1f); | 1057 | |
1058 | float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS) + noise; | 1058 | float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS); |
1059 | m_AngularVelocity.Z = rollAmount; | 1059 | m_AngularVelocity.Z = rollAmount; |
1060 | |||
1061 | // APPLY EXTRA consideration for flying up and flying down during this time. | ||
1062 | // if we're turning left | ||
1063 | if (amount > 0) | ||
1064 | { | ||
1065 | |||
1066 | // If we're at the max roll and pressing up, we want to swing BACK a bit | ||
1067 | // Automatically adds noise | ||
1068 | if (PressingUp) | ||
1069 | { | ||
1070 | if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS - 0.04f) | ||
1071 | m_AngularVelocity.Z -= 0.9f; | ||
1072 | } | ||
1073 | // If we're at the max roll and pressing down, we want to swing MORE a bit | ||
1074 | if (PressingDown) | ||
1075 | { | ||
1076 | if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS && m_AngularVelocity.Z < FLY_ROLL_MAX_RADIANS + 0.6f) | ||
1077 | m_AngularVelocity.Z += 0.6f; | ||
1078 | } | ||
1079 | } | ||
1080 | else // we're turning right. | ||
1081 | { | ||
1082 | // If we're at the max roll and pressing up, we want to swing BACK a bit | ||
1083 | // Automatically adds noise | ||
1084 | if (PressingUp) | ||
1085 | { | ||
1086 | if (m_AngularVelocity.Z <= (-FLY_ROLL_MAX_RADIANS)) | ||
1087 | m_AngularVelocity.Z += 0.6f; | ||
1088 | } | ||
1089 | // If we're at the max roll and pressing down, we want to swing MORE a bit | ||
1090 | if (PressingDown) | ||
1091 | { | ||
1092 | if (m_AngularVelocity.Z >= -FLY_ROLL_MAX_RADIANS - 0.6f) | ||
1093 | m_AngularVelocity.Z -= 0.6f; | ||
1094 | } | ||
1095 | } | ||
1060 | } | 1096 | } |
1061 | 1097 | ||
1062 | /// <summary> | 1098 | /// <summary> |
@@ -1572,26 +1608,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
1572 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 1608 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
1573 | 1609 | ||
1574 | 1610 | ||
1575 | 1611 | //m_log.Debug("[CONTROL]: " +flags); | |
1576 | // Applies a satisfying roll effect to the avatar when flying. | 1612 | // 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)) | 1613 | if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)) |
1578 | { | 1614 | { |
1579 | ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_SECOND); | 1615 | |
1616 | ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)); | ||
1617 | |||
1580 | 1618 | ||
1581 | } | 1619 | } |
1582 | else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) && | 1620 | else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) && |
1583 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)) | 1621 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)) |
1584 | { | 1622 | { |
1585 | ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_SECOND); | 1623 | ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)); |
1624 | |||
1586 | 1625 | ||
1587 | } | 1626 | } |
1588 | else | 1627 | else |
1589 | { | 1628 | { |
1590 | if (m_AngularVelocity.Z != 0) | 1629 | if (m_AngularVelocity.Z != 0) |
1591 | m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_SECOND); | 1630 | m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); |
1592 | 1631 | ||
1593 | } | 1632 | } |
1594 | 1633 | ||
1634 | |||
1595 | 1635 | ||
1596 | 1636 | ||
1597 | if (Flying && IsColliding && controlland) | 1637 | if (Flying && IsColliding && controlland) |