aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs362
1 files changed, 294 insertions, 68 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index a9195f7..0ab267a 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; }
@@ -438,6 +441,8 @@ namespace OpenSim.Region.Framework.Scenes
438 get { return (IClientCore)ControllingClient; } 441 get { return (IClientCore)ControllingClient; }
439 } 442 }
440 443
444 public UUID COF { get; set; }
445
441// public Vector3 ParentPosition { get; set; } 446// public Vector3 ParentPosition { get; set; }
442 447
443 /// <summary> 448 /// <summary>
@@ -451,9 +456,9 @@ namespace OpenSim.Region.Framework.Scenes
451 { 456 {
452 m_pos = PhysicsActor.Position; 457 m_pos = PhysicsActor.Position;
453 458
454 //m_log.DebugFormat( 459// m_log.DebugFormat(
455 // "[SCENE PRESENCE]: Set position {0} for {1} in {2} via getting AbsolutePosition!", 460// "[SCENE PRESENCE]: Set position of {0} in {1} to {2} via getting AbsolutePosition!",
456 // m_pos, Name, Scene.RegionInfo.RegionName); 461// Name, Scene.Name, m_pos);
457 } 462 }
458 else 463 else
459 { 464 {
@@ -480,6 +485,9 @@ namespace OpenSim.Region.Framework.Scenes
480 } 485 }
481 set 486 set
482 { 487 {
488// m_log.DebugFormat("[SCENE PRESENCE]: Setting position of {0} in {1} to {2}", Name, Scene.Name, value);
489// Util.PrintCallStack();
490
483 if (PhysicsActor != null) 491 if (PhysicsActor != null)
484 { 492 {
485 try 493 try
@@ -585,27 +593,48 @@ namespace OpenSim.Region.Framework.Scenes
585*/ 593*/
586 private Quaternion m_bodyRot = Quaternion.Identity; 594 private Quaternion m_bodyRot = Quaternion.Identity;
587 595
596 /// <summary>
597 /// The rotation of the avatar.
598 /// </summary>
599 /// <remarks>
600 /// If the avatar is not sitting, this is with respect to the world
601 /// If the avatar is sitting, this is a with respect to the part that it's sitting upon (a local rotation).
602 /// If you always want the world rotation, use GetWorldRotation()
603 /// </remarks>
588 public Quaternion Rotation 604 public Quaternion Rotation
589 { 605 {
590 get { return m_bodyRot; } 606 get
607 {
608 return m_bodyRot;
609 }
610
591 set 611 set
592 { 612 {
593 m_bodyRot = value; 613 m_bodyRot = value;
594 // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); 614
595 if (PhysicsActor != null) 615 if (PhysicsActor != null)
596 { 616 {
597 try 617 try
598 { 618 {
599 PhysicsActor.Orientation = value; 619 PhysicsActor.Orientation = m_bodyRot;
600 } 620 }
601 catch (Exception e) 621 catch (Exception e)
602 { 622 {
603 m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); 623 m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message);
604 } 624 }
605 } 625 }
626// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot);
606 } 627 }
607 } 628 }
608 629
630 // Used for limited viewer 'fake' user rotations.
631 private Vector3 m_AngularVelocity = Vector3.Zero;
632
633 public Vector3 AngularVelocity
634 {
635 get { return m_AngularVelocity; }
636 }
637
609 public bool IsChildAgent { get; set; } 638 public bool IsChildAgent { get; set; }
610 public bool IsLoggingIn { get; set; } 639 public bool IsLoggingIn { get; set; }
611 640
@@ -641,6 +670,26 @@ namespace OpenSim.Region.Framework.Scenes
641 set { m_health = value; } 670 set { m_health = value; }
642 } 671 }
643 672
673 /// <summary>
674 /// Gets the world rotation of this presence.
675 /// </summary>
676 /// <remarks>
677 /// Unlike Rotation, this returns the world rotation no matter whether the avatar is sitting on a prim or not.
678 /// </remarks>
679 /// <returns></returns>
680 public Quaternion GetWorldRotation()
681 {
682 if (IsSatOnObject)
683 {
684 SceneObjectPart sitPart = ParentPart;
685
686 if (sitPart != null)
687 return sitPart.GetWorldRotation() * Rotation;
688 }
689
690 return Rotation;
691 }
692
644 public void AdjustKnownSeeds() 693 public void AdjustKnownSeeds()
645 { 694 {
646 Dictionary<ulong, string> seeds; 695 Dictionary<ulong, string> seeds;
@@ -690,6 +739,12 @@ namespace OpenSim.Region.Framework.Scenes
690 739
691 private bool m_inTransit; 740 private bool m_inTransit;
692 741
742 /// <summary>
743 /// This signals whether the presence is in transit between neighbouring regions.
744 /// </summary>
745 /// <remarks>
746 /// It is not set when the presence is teleporting or logging in/out directly to a region.
747 /// </remarks>
693 public bool IsInTransit 748 public bool IsInTransit
694 { 749 {
695 get { return m_inTransit; } 750 get { return m_inTransit; }
@@ -886,8 +941,6 @@ namespace OpenSim.Region.Framework.Scenes
886 "[SCENE]: Upgrading child to root agent for {0} in {1}", 941 "[SCENE]: Upgrading child to root agent for {0} in {1}",
887 Name, m_scene.RegionInfo.RegionName); 942 Name, m_scene.RegionInfo.RegionName);
888 943
889 bool wasChild = IsChildAgent;
890
891 if (ParentUUID != UUID.Zero) 944 if (ParentUUID != UUID.Zero)
892 { 945 {
893 m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); 946 m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID);
@@ -920,6 +973,9 @@ namespace OpenSim.Region.Framework.Scenes
920 IsLoggingIn = false; 973 IsLoggingIn = false;
921 } 974 }
922 975
976 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
977
978 IsChildAgent = false;
923 979
924 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 980 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
925 if (gm != null) 981 if (gm != null)
@@ -1013,6 +1069,13 @@ namespace OpenSim.Region.Framework.Scenes
1013 else 1069 else
1014 AddToPhysicalScene(isFlying); 1070 AddToPhysicalScene(isFlying);
1015 1071
1072 // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a
1073 // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it
1074 // since it requires a physics actor to be present. If it is left any later, then physics appears to reset
1075 // the value to a negative position which does not trigger the border cross.
1076 // This may not be the best location for this.
1077 CheckForBorderCrossing();
1078
1016 if (ForceFly) 1079 if (ForceFly)
1017 { 1080 {
1018 Flying = true; 1081 Flying = true;
@@ -1033,22 +1096,43 @@ namespace OpenSim.Region.Framework.Scenes
1033 // and it has already rezzed the attachments and started their scripts. 1096 // and it has already rezzed the attachments and started their scripts.
1034 // We do the following only for non-login agents, because their scripts 1097 // We do the following only for non-login agents, because their scripts
1035 // haven't started yet. 1098 // haven't started yet.
1036 lock (m_attachments) 1099 if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0)
1037 { 1100 {
1038 if (wasChild && HasAttachments()) 1101 // Viewers which have a current outfit folder will actually rez their own attachments. However,
1102 // viewers without (e.g. v1 viewers) will not, so we still need to make this call.
1103 if (Scene.AttachmentsModule != null)
1104 Util.FireAndForget(
1105 o =>
1106 {
1107// if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None)
1108// System.Threading.Thread.Sleep(7000);
1109
1110 Scene.AttachmentsModule.RezAttachments(this);
1111 });
1112 }
1113 else
1114 {
1115 // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT
1116 // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently
1117 // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are
1118 // not transporting the required data.
1119 lock (m_attachments)
1039 { 1120 {
1040 m_log.DebugFormat( 1121 if (HasAttachments())
1041 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); 1122 {
1042 1123 m_log.DebugFormat(
1043 // Resume scripts 1124 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
1044 Util.FireAndForget(delegate(object x) { 1125
1045 foreach (SceneObjectGroup sog in m_attachments) 1126 // Resume scripts
1046 { 1127 Util.FireAndForget(delegate(object x) {
1047 sog.ScheduleGroupForFullUpdate(); 1128 foreach (SceneObjectGroup sog in m_attachments)
1048 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); 1129 {
1049 sog.ResumeScripts(); 1130 sog.ScheduleGroupForFullUpdate();
1050 } 1131 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
1051 }); 1132 sog.ResumeScripts();
1133 }
1134 });
1135 }
1052 } 1136 }
1053 } 1137 }
1054 1138
@@ -1225,6 +1309,85 @@ namespace OpenSim.Region.Framework.Scenes
1225 ControllingClient.StopFlying(this); 1309 ControllingClient.StopFlying(this);
1226 } 1310 }
1227 1311
1312 /// <summary>
1313 /// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect.
1314 /// </summary>
1315 /// <param name="amount">Postive or negative roll amount in radians</param>
1316 private void ApplyFlyingRoll(float amount, bool PressingUp, bool PressingDown)
1317 {
1318
1319 float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS);
1320 m_AngularVelocity.Z = rollAmount;
1321
1322 // APPLY EXTRA consideration for flying up and flying down during this time.
1323 // if we're turning left
1324 if (amount > 0)
1325 {
1326
1327 // If we're at the max roll and pressing up, we want to swing BACK a bit
1328 // Automatically adds noise
1329 if (PressingUp)
1330 {
1331 if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS - 0.04f)
1332 m_AngularVelocity.Z -= 0.9f;
1333 }
1334 // If we're at the max roll and pressing down, we want to swing MORE a bit
1335 if (PressingDown)
1336 {
1337 if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS && m_AngularVelocity.Z < FLY_ROLL_MAX_RADIANS + 0.6f)
1338 m_AngularVelocity.Z += 0.6f;
1339 }
1340 }
1341 else // we're turning right.
1342 {
1343 // If we're at the max roll and pressing up, we want to swing BACK a bit
1344 // Automatically adds noise
1345 if (PressingUp)
1346 {
1347 if (m_AngularVelocity.Z <= (-FLY_ROLL_MAX_RADIANS))
1348 m_AngularVelocity.Z += 0.6f;
1349 }
1350 // If we're at the max roll and pressing down, we want to swing MORE a bit
1351 if (PressingDown)
1352 {
1353 if (m_AngularVelocity.Z >= -FLY_ROLL_MAX_RADIANS - 0.6f)
1354 m_AngularVelocity.Z -= 0.6f;
1355 }
1356 }
1357 }
1358
1359 /// <summary>
1360 /// incrementally sets roll amount to zero
1361 /// </summary>
1362 /// <param name="amount">Positive roll amount in radians</param>
1363 /// <returns></returns>
1364 private float CalculateFlyingRollResetToZero(float amount)
1365 {
1366 const float rollMinRadians = 0f;
1367
1368 if (m_AngularVelocity.Z > 0)
1369 {
1370
1371 float leftOverToMin = m_AngularVelocity.Z - rollMinRadians;
1372 if (amount > leftOverToMin)
1373 return -leftOverToMin;
1374 else
1375 return -amount;
1376
1377 }
1378 else
1379 {
1380
1381 float leftOverToMin = -m_AngularVelocity.Z - rollMinRadians;
1382 if (amount > leftOverToMin)
1383 return leftOverToMin;
1384 else
1385 return amount;
1386 }
1387 }
1388
1389
1390
1228 // neighbouring regions we have enabled a child agent in 1391 // neighbouring regions we have enabled a child agent in
1229 // holds the seed cap for the child agent in that region 1392 // holds the seed cap for the child agent in that region
1230 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); 1393 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>();
@@ -1398,6 +1561,15 @@ namespace OpenSim.Region.Framework.Scenes
1398 1561
1399 } 1562 }
1400 1563
1564 // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region
1565 // If we do it a little bit earlier (e.g. when converting the child to a root agent) then this does not work.
1566 // This may be due to viewer code or it may be something we're not doing properly simulator side.
1567 lock (m_attachments)
1568 {
1569 foreach (SceneObjectGroup sog in m_attachments)
1570 sog.ScheduleGroupForFullUpdate();
1571 }
1572
1401// m_log.DebugFormat( 1573// m_log.DebugFormat(
1402// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", 1574// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms",
1403// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); 1575// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds);
@@ -1430,17 +1602,42 @@ namespace OpenSim.Region.Framework.Scenes
1430 m_doingCamRayCast = false; 1602 m_doingCamRayCast = false;
1431 if (hitYN && localid != LocalId) 1603 if (hitYN && localid != LocalId)
1432 { 1604 {
1433 CameraConstraintActive = true; 1605 SceneObjectGroup group = m_scene.GetGroupByPrim(localid);
1434 pNormal.X = (float)Math.Round(pNormal.X, 2); 1606 bool IsPrim = group != null;
1435 pNormal.Y = (float)Math.Round(pNormal.Y, 2); 1607 if (IsPrim)
1436 pNormal.Z = (float)Math.Round(pNormal.Z, 2); 1608 {
1437 pNormal.Normalize(); 1609 SceneObjectPart part = group.GetPart(localid);
1438 collisionPoint.X = (float)Math.Round(collisionPoint.X, 1); 1610 if (part != null && !part.VolumeDetectActive)
1439 collisionPoint.Y = (float)Math.Round(collisionPoint.Y, 1); 1611 {
1440 collisionPoint.Z = (float)Math.Round(collisionPoint.Z, 1); 1612 CameraConstraintActive = true;
1441 1613 pNormal.X = (float) Math.Round(pNormal.X, 2);
1442 Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, Vector3.Dot(collisionPoint, pNormal)); 1614 pNormal.Y = (float) Math.Round(pNormal.Y, 2);
1443 UpdateCameraCollisionPlane(plane); 1615 pNormal.Z = (float) Math.Round(pNormal.Z, 2);
1616 pNormal.Normalize();
1617 collisionPoint.X = (float) Math.Round(collisionPoint.X, 1);
1618 collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1);
1619 collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1);
1620
1621 Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z,
1622 Vector3.Dot(collisionPoint, pNormal));
1623 UpdateCameraCollisionPlane(plane);
1624 }
1625 }
1626 else
1627 {
1628 CameraConstraintActive = true;
1629 pNormal.X = (float) Math.Round(pNormal.X, 2);
1630 pNormal.Y = (float) Math.Round(pNormal.Y, 2);
1631 pNormal.Z = (float) Math.Round(pNormal.Z, 2);
1632 pNormal.Normalize();
1633 collisionPoint.X = (float) Math.Round(collisionPoint.X, 1);
1634 collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1);
1635 collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1);
1636
1637 Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z,
1638 Vector3.Dot(collisionPoint, pNormal));
1639 UpdateCameraCollisionPlane(plane);
1640 }
1444 } 1641 }
1445 else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || 1642 else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
1446 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) 1643 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE))
@@ -1741,6 +1938,29 @@ namespace OpenSim.Region.Framework.Scenes
1741 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || 1938 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
1742 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 1939 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
1743 1940
1941 //m_log.Debug("[CONTROL]: " +flags);
1942 // Applies a satisfying roll effect to the avatar when flying.
1943 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
1944 {
1945 ApplyFlyingRoll(
1946 FLY_ROLL_RADIANS_PER_UPDATE,
1947 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
1948 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
1949 }
1950 else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 &&
1951 (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
1952 {
1953 ApplyFlyingRoll(
1954 -FLY_ROLL_RADIANS_PER_UPDATE,
1955 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
1956 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
1957 }
1958 else
1959 {
1960 if (m_AngularVelocity.Z != 0)
1961 m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE);
1962 }
1963
1744 if (Flying && IsColliding && controlland) 1964 if (Flying && IsColliding && controlland)
1745 { 1965 {
1746 // nesting this check because LengthSquared() is expensive and we don't 1966 // nesting this check because LengthSquared() is expensive and we don't
@@ -1954,7 +2174,11 @@ namespace OpenSim.Region.Framework.Scenes
1954 // Get terrain height for sub-region in a megaregion if necessary 2174 // Get terrain height for sub-region in a megaregion if necessary
1955 int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X); 2175 int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X);
1956 int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y); 2176 int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y);
1957 UUID target_regionID = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y).RegionID; 2177 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y);
2178 // If X and Y is NaN, target_region will be null
2179 if (target_region == null)
2180 return;
2181 UUID target_regionID = target_region.RegionID;
1958 Scene targetScene = m_scene; 2182 Scene targetScene = m_scene;
1959 2183
1960 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene)) 2184 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene))
@@ -2199,28 +2423,16 @@ namespace OpenSim.Region.Framework.Scenes
2199 2423
2200 if (ParentID != 0) 2424 if (ParentID != 0)
2201 { 2425 {
2426 if (ParentPart.UUID == targetID)
2427 return; // already sitting here, ignore
2428
2202 StandUp(); 2429 StandUp();
2203 } 2430 }
2204 2431
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); 2432 SceneObjectPart part = FindNextAvailableSitTarget(targetID);
2216 2433
2217 if (part != null) 2434 if (part != null)
2218 { 2435 {
2219 if (!String.IsNullOrEmpty(part.SitAnimation))
2220 {
2221 m_nextSitAnimation = part.SitAnimation;
2222 }
2223
2224 m_requestedSitTargetID = part.LocalId; 2436 m_requestedSitTargetID = part.LocalId;
2225 m_requestedSitTargetUUID = targetID; 2437 m_requestedSitTargetUUID = targetID;
2226 2438
@@ -2341,18 +2553,6 @@ namespace OpenSim.Region.Framework.Scenes
2341 2553
2342 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) 2554 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID)
2343 { 2555 {
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); 2556 SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID);
2357 2557
2358 if (part != null) 2558 if (part != null)
@@ -2422,10 +2622,15 @@ namespace OpenSim.Region.Framework.Scenes
2422 2622
2423 ParentPart = m_scene.GetSceneObjectPart(m_requestedSitTargetID); 2623 ParentPart = m_scene.GetSceneObjectPart(m_requestedSitTargetID);
2424 ParentID = m_requestedSitTargetID; 2624 ParentID = m_requestedSitTargetID;
2425 2625 m_AngularVelocity = Vector3.Zero;
2426 Velocity = Vector3.Zero; 2626 Velocity = Vector3.Zero;
2427 RemoveFromPhysicalScene(); 2627 RemoveFromPhysicalScene();
2428 2628
2629 String sitAnimation = "SIT";
2630 if (!String.IsNullOrEmpty(part.SitAnimation))
2631 {
2632 sitAnimation = part.SitAnimation;
2633 }
2429 Animator.TrySetMovementAnimation(sitAnimation); 2634 Animator.TrySetMovementAnimation(sitAnimation);
2430 SendAvatarDataToAllAgents(); 2635 SendAvatarDataToAllAgents();
2431 } 2636 }
@@ -2433,7 +2638,8 @@ namespace OpenSim.Region.Framework.Scenes
2433 2638
2434 public void HandleAgentSitOnGround() 2639 public void HandleAgentSitOnGround()
2435 { 2640 {
2436// m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. 2641// m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick..
2642 m_AngularVelocity = Vector3.Zero;
2437 Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); 2643 Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED");
2438 SitGround = true; 2644 SitGround = true;
2439 RemoveFromPhysicalScene(); 2645 RemoveFromPhysicalScene();
@@ -2455,7 +2661,7 @@ namespace OpenSim.Region.Framework.Scenes
2455 2661
2456 public void HandleStopAnim(IClientAPI remoteClient, UUID animID) 2662 public void HandleStopAnim(IClientAPI remoteClient, UUID animID)
2457 { 2663 {
2458 Animator.RemoveAnimation(animID); 2664 Animator.RemoveAnimation(animID, false);
2459 } 2665 }
2460 2666
2461 public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) 2667 public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack)
@@ -2471,7 +2677,8 @@ namespace OpenSim.Region.Framework.Scenes
2471 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> 2677 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param>
2472 public void AddNewMovement(Vector3 vec) 2678 public void AddNewMovement(Vector3 vec)
2473 { 2679 {
2474// m_log.DebugFormat("[SCENE PRESENCE]: Adding new movement {0} for {1}", vec, Name); 2680// m_log.DebugFormat(
2681// "[SCENE PRESENCE]: Adding new movement {0} with rotation {1} for {2}", vec, Rotation, Name);
2475 2682
2476 Vector3 direc = vec * Rotation; 2683 Vector3 direc = vec * Rotation;
2477 direc.Normalize(); 2684 direc.Normalize();
@@ -2491,6 +2698,8 @@ namespace OpenSim.Region.Framework.Scenes
2491 2698
2492 direc *= 0.03f * 128f * SpeedModifier; 2699 direc *= 0.03f * 128f * SpeedModifier;
2493 2700
2701// m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name);
2702
2494 if (PhysicsActor != null) 2703 if (PhysicsActor != null)
2495 { 2704 {
2496 if (Flying) 2705 if (Flying)
@@ -2524,6 +2733,8 @@ namespace OpenSim.Region.Framework.Scenes
2524 } 2733 }
2525 } 2734 }
2526 2735
2736// m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name);
2737
2527 // TODO: Add the force instead of only setting it to support multiple forces per frame? 2738 // TODO: Add the force instead of only setting it to support multiple forces per frame?
2528 m_forceToApply = direc; 2739 m_forceToApply = direc;
2529 Animator.UpdateMovementAnimations(); 2740 Animator.UpdateMovementAnimations();
@@ -2942,6 +3153,10 @@ namespace OpenSim.Region.Framework.Scenes
2942 3153
2943 if (!IsInTransit) 3154 if (!IsInTransit)
2944 { 3155 {
3156// m_log.DebugFormat(
3157// "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}",
3158// pos2, Name, Scene.Name);
3159
2945 // Checks if where it's headed exists a region 3160 // Checks if where it's headed exists a region
2946 bool needsTransit = false; 3161 bool needsTransit = false;
2947 if (m_scene.TestBorderCross(pos2, Cardinals.W)) 3162 if (m_scene.TestBorderCross(pos2, Cardinals.W))
@@ -4166,6 +4381,7 @@ namespace OpenSim.Region.Framework.Scenes
4166 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4381 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4167 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0) 4382 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)
4168 { 4383 {
4384
4169 if (GodLevel < 200 && 4385 if (GodLevel < 200 &&
4170 ((!m_scene.Permissions.IsGod(m_uuid) && 4386 ((!m_scene.Permissions.IsGod(m_uuid) &&
4171 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || 4387 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
@@ -4174,7 +4390,14 @@ namespace OpenSim.Region.Framework.Scenes
4174 { 4390 {
4175 SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray(); 4391 SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray();
4176 if (spawnPoints.Length == 0) 4392 if (spawnPoints.Length == 0)
4393 {
4394 if(m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid))
4395 {
4396 pos.X = 128.0f;
4397 pos.Y = 128.0f;
4398 }
4177 return; 4399 return;
4400 }
4178 4401
4179 int index; 4402 int index;
4180 bool selected = false; 4403 bool selected = false;
@@ -4183,6 +4406,8 @@ namespace OpenSim.Region.Framework.Scenes
4183 { 4406 {
4184 case "random": 4407 case "random":
4185 4408
4409 if (spawnPoints.Length == 0)
4410 return;
4186 do 4411 do
4187 { 4412 {
4188 index = Util.RandomClass.Next(spawnPoints.Length - 1); 4413 index = Util.RandomClass.Next(spawnPoints.Length - 1);
@@ -4194,6 +4419,7 @@ namespace OpenSim.Region.Framework.Scenes
4194 // SpawnPoint sp = spawnPoints[index]; 4419 // SpawnPoint sp = spawnPoints[index];
4195 4420
4196 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y); 4421 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4422
4197 if (land == null || land.IsEitherBannedOrRestricted(UUID)) 4423 if (land == null || land.IsEitherBannedOrRestricted(UUID))
4198 selected = false; 4424 selected = false;
4199 else 4425 else