diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 166 |
1 files changed, 133 insertions, 33 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a9195f7..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; |
@@ -216,8 +221,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
216 | 221 | ||
217 | private Quaternion m_headrotation = Quaternion.Identity; | 222 | private Quaternion m_headrotation = Quaternion.Identity; |
218 | 223 | ||
219 | private string m_nextSitAnimation = String.Empty; | ||
220 | |||
221 | //PauPaw:Proper PID Controler for autopilot************ | 224 | //PauPaw:Proper PID Controler for autopilot************ |
222 | public bool MovingToTarget { get; private set; } | 225 | public bool MovingToTarget { get; private set; } |
223 | public Vector3 MoveToPositionTarget { get; private set; } | 226 | public Vector3 MoveToPositionTarget { get; private set; } |
@@ -591,21 +594,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
591 | set | 594 | set |
592 | { | 595 | { |
593 | m_bodyRot = value; | 596 | m_bodyRot = value; |
594 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); | ||
595 | if (PhysicsActor != null) | 597 | if (PhysicsActor != null) |
596 | { | 598 | { |
597 | try | 599 | try |
598 | { | 600 | { |
599 | PhysicsActor.Orientation = value; | 601 | PhysicsActor.Orientation = m_bodyRot; |
600 | } | 602 | } |
601 | catch (Exception e) | 603 | catch (Exception e) |
602 | { | 604 | { |
603 | m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); | 605 | m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); |
604 | } | 606 | } |
605 | } | 607 | } |
608 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); | ||
606 | } | 609 | } |
607 | } | 610 | } |
608 | 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 | |||
609 | public bool IsChildAgent { get; set; } | 620 | public bool IsChildAgent { get; set; } |
610 | public bool IsLoggingIn { get; set; } | 621 | public bool IsLoggingIn { get; set; } |
611 | 622 | ||
@@ -736,6 +747,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
736 | 747 | ||
737 | #endregion | 748 | #endregion |
738 | 749 | ||
750 | |||
751 | |||
739 | #region Constructor(s) | 752 | #region Constructor(s) |
740 | 753 | ||
741 | public ScenePresence( | 754 | public ScenePresence( |
@@ -1225,6 +1238,85 @@ namespace OpenSim.Region.Framework.Scenes | |||
1225 | ControllingClient.StopFlying(this); | 1238 | ControllingClient.StopFlying(this); |
1226 | } | 1239 | } |
1227 | 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 | |||
1228 | // neighbouring regions we have enabled a child agent in | 1320 | // neighbouring regions we have enabled a child agent in |
1229 | // holds the seed cap for the child agent in that region | 1321 | // holds the seed cap for the child agent in that region |
1230 | private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); | 1322 | private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); |
@@ -1741,6 +1833,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
1741 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || | 1833 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || |
1742 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 1834 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
1743 | 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 | |||
1744 | if (Flying && IsColliding && controlland) | 1863 | if (Flying && IsColliding && controlland) |
1745 | { | 1864 | { |
1746 | // nesting this check because LengthSquared() is expensive and we don't | 1865 | // nesting this check because LengthSquared() is expensive and we don't |
@@ -2199,28 +2318,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2199 | 2318 | ||
2200 | if (ParentID != 0) | 2319 | if (ParentID != 0) |
2201 | { | 2320 | { |
2321 | if (ParentPart.UUID == targetID) | ||
2322 | return; // already sitting here, ignore | ||
2323 | |||
2202 | StandUp(); | 2324 | StandUp(); |
2203 | } | 2325 | } |
2204 | 2326 | ||
2205 | // if (!String.IsNullOrEmpty(sitAnimation)) | ||
2206 | // { | ||
2207 | // m_nextSitAnimation = sitAnimation; | ||
2208 | // } | ||
2209 | // else | ||
2210 | // { | ||
2211 | m_nextSitAnimation = "SIT"; | ||
2212 | // } | ||
2213 | |||
2214 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | ||
2215 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 2327 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
2216 | 2328 | ||
2217 | if (part != null) | 2329 | if (part != null) |
2218 | { | 2330 | { |
2219 | if (!String.IsNullOrEmpty(part.SitAnimation)) | ||
2220 | { | ||
2221 | m_nextSitAnimation = part.SitAnimation; | ||
2222 | } | ||
2223 | |||
2224 | m_requestedSitTargetID = part.LocalId; | 2331 | m_requestedSitTargetID = part.LocalId; |
2225 | m_requestedSitTargetUUID = targetID; | 2332 | m_requestedSitTargetUUID = targetID; |
2226 | 2333 | ||
@@ -2341,18 +2448,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2341 | 2448 | ||
2342 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) | 2449 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) |
2343 | { | 2450 | { |
2344 | if (!String.IsNullOrEmpty(m_nextSitAnimation)) | ||
2345 | { | ||
2346 | HandleAgentSit(remoteClient, agentID, m_nextSitAnimation); | ||
2347 | } | ||
2348 | else | ||
2349 | { | ||
2350 | HandleAgentSit(remoteClient, agentID, "SIT"); | ||
2351 | } | ||
2352 | } | ||
2353 | |||
2354 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID, string sitAnimation) | ||
2355 | { | ||
2356 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); | 2451 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); |
2357 | 2452 | ||
2358 | if (part != null) | 2453 | if (part != null) |
@@ -2425,7 +2520,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2425 | 2520 | ||
2426 | Velocity = Vector3.Zero; | 2521 | Velocity = Vector3.Zero; |
2427 | RemoveFromPhysicalScene(); | 2522 | RemoveFromPhysicalScene(); |
2428 | 2523 | ||
2524 | String sitAnimation = "SIT"; | ||
2525 | if (!String.IsNullOrEmpty(part.SitAnimation)) | ||
2526 | { | ||
2527 | sitAnimation = part.SitAnimation; | ||
2528 | } | ||
2429 | Animator.TrySetMovementAnimation(sitAnimation); | 2529 | Animator.TrySetMovementAnimation(sitAnimation); |
2430 | SendAvatarDataToAllAgents(); | 2530 | SendAvatarDataToAllAgents(); |
2431 | } | 2531 | } |
@@ -2455,7 +2555,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2455 | 2555 | ||
2456 | public void HandleStopAnim(IClientAPI remoteClient, UUID animID) | 2556 | public void HandleStopAnim(IClientAPI remoteClient, UUID animID) |
2457 | { | 2557 | { |
2458 | Animator.RemoveAnimation(animID); | 2558 | Animator.RemoveAnimation(animID, false); |
2459 | } | 2559 | } |
2460 | 2560 | ||
2461 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | 2561 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) |