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.cs464
1 files changed, 389 insertions, 75 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 7e49a5e..5e275f6 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -93,7 +93,7 @@ namespace OpenSim.Region.Framework.Scenes
93 /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis 93 /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis
94 /// issue #1716 94 /// issue #1716
95 /// </summary> 95 /// </summary>
96 public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); 96 public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f);
97 97
98 /// <summary> 98 /// <summary>
99 /// Movement updates for agents in neighboring regions are sent directly to clients. 99 /// Movement updates for agents in neighboring regions are sent directly to clients.
@@ -170,6 +170,7 @@ namespace OpenSim.Region.Framework.Scenes
170// private int m_lastColCount = -1; //KF: Look for Collision chnages 170// private int m_lastColCount = -1; //KF: Look for Collision chnages
171// private int m_updateCount = 0; //KF: Update Anims for a while 171// private int m_updateCount = 0; //KF: Update Anims for a while
172// private static readonly int UPDATE_COUNT = 10; // how many frames to update for 172// private static readonly int UPDATE_COUNT = 10; // how many frames to update for
173 private List<uint> m_lastColliders = new List<uint>();
173 174
174 private TeleportFlags m_teleportFlags; 175 private TeleportFlags m_teleportFlags;
175 public TeleportFlags TeleportFlags 176 public TeleportFlags TeleportFlags
@@ -231,6 +232,13 @@ namespace OpenSim.Region.Framework.Scenes
231 //private int m_moveToPositionStateStatus; 232 //private int m_moveToPositionStateStatus;
232 //***************************************************** 233 //*****************************************************
233 234
235 private bool m_collisionEventFlag = false;
236 private object m_collisionEventLock = new Object();
237
238 private int m_movementAnimationUpdateCounter = 0;
239
240 private Vector3 m_prevSitOffset;
241
234 protected AvatarAppearance m_appearance; 242 protected AvatarAppearance m_appearance;
235 243
236 public AvatarAppearance Appearance 244 public AvatarAppearance Appearance
@@ -570,6 +578,13 @@ namespace OpenSim.Region.Framework.Scenes
570 /// </summary> 578 /// </summary>
571 public uint ParentID { get; set; } 579 public uint ParentID { get; set; }
572 580
581 public UUID ParentUUID
582 {
583 get { return m_parentUUID; }
584 set { m_parentUUID = value; }
585 }
586 private UUID m_parentUUID = UUID.Zero;
587
573 /// <summary> 588 /// <summary>
574 /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null. 589 /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null.
575 /// </summary> 590 /// </summary>
@@ -730,6 +745,27 @@ namespace OpenSim.Region.Framework.Scenes
730 Appearance = appearance; 745 Appearance = appearance;
731 } 746 }
732 747
748 private void RegionHeartbeatEnd(Scene scene)
749 {
750 if (IsChildAgent)
751 return;
752
753 m_movementAnimationUpdateCounter ++;
754 if (m_movementAnimationUpdateCounter >= 2)
755 {
756 m_movementAnimationUpdateCounter = 0;
757 if (Animator != null)
758 {
759 if(ParentID == 0 && !SitGround) // skip it if sitting
760 Animator.UpdateMovementAnimations();
761 }
762 else
763 {
764 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
765 }
766 }
767 }
768
733 public void RegisterToEvents() 769 public void RegisterToEvents()
734 { 770 {
735 ControllingClient.OnCompleteMovementToRegion += CompleteMovement; 771 ControllingClient.OnCompleteMovementToRegion += CompleteMovement;
@@ -799,10 +835,38 @@ namespace OpenSim.Region.Framework.Scenes
799 "[SCENE]: Upgrading child to root agent for {0} in {1}", 835 "[SCENE]: Upgrading child to root agent for {0} in {1}",
800 Name, m_scene.RegionInfo.RegionName); 836 Name, m_scene.RegionInfo.RegionName);
801 837
802 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
803
804 bool wasChild = IsChildAgent; 838 bool wasChild = IsChildAgent;
805 IsChildAgent = false; 839
840 if (ParentUUID != UUID.Zero)
841 {
842 m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID);
843 SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID);
844 if (part == null)
845 {
846 m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID);
847 }
848 else
849 {
850 part.ParentGroup.AddAvatar(UUID);
851 if (part.SitTargetPosition != Vector3.Zero)
852 part.SitTargetAvatar = UUID;
853 ParentPosition = part.GetWorldPosition();
854 ParentID = part.LocalId;
855 ParentPart = part;
856 m_pos = m_prevSitOffset;
857 pos = ParentPosition;
858 }
859 ParentUUID = UUID.Zero;
860
861 IsChildAgent = false;
862
863 Animator.TrySetMovementAnimation("SIT");
864 }
865 else
866 {
867 IsChildAgent = false;
868 }
869
806 870
807 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 871 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
808 if (gm != null) 872 if (gm != null)
@@ -812,62 +876,64 @@ namespace OpenSim.Region.Framework.Scenes
812 876
813 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); 877 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene);
814 878
815 // Moved this from SendInitialData to ensure that Appearance is initialized 879 if (ParentID == 0)
816 // before the inventory is processed in MakeRootAgent. This fixes a race condition
817 // related to the handling of attachments
818 //m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
819 if (m_scene.TestBorderCross(pos, Cardinals.E))
820 { 880 {
821 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); 881 // Moved this from SendInitialData to ensure that Appearance is initialized
822 pos.X = crossedBorder.BorderLine.Z - 1; 882 // before the inventory is processed in MakeRootAgent. This fixes a race condition
823 } 883 // related to the handling of attachments
884 //m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
885 if (m_scene.TestBorderCross(pos, Cardinals.E))
886 {
887 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E);
888 pos.X = crossedBorder.BorderLine.Z - 1;
889 }
824 890
825 if (m_scene.TestBorderCross(pos, Cardinals.N)) 891 if (m_scene.TestBorderCross(pos, Cardinals.N))
826 { 892 {
827 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); 893 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N);
828 pos.Y = crossedBorder.BorderLine.Z - 1; 894 pos.Y = crossedBorder.BorderLine.Z - 1;
829 } 895 }
830 896
831 CheckAndAdjustLandingPoint(ref pos); 897 CheckAndAdjustLandingPoint(ref pos);
832 898
833 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 899 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
834 { 900 {
835 m_log.WarnFormat( 901 m_log.WarnFormat(
836 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", 902 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping",
837 pos, Name, UUID); 903 pos, Name, UUID);
838 904
839 if (pos.X < 0f) pos.X = 0f; 905 if (pos.X < 0f) pos.X = 0f;
840 if (pos.Y < 0f) pos.Y = 0f; 906 if (pos.Y < 0f) pos.Y = 0f;
841 if (pos.Z < 0f) pos.Z = 0f; 907 if (pos.Z < 0f) pos.Z = 0f;
842 } 908 }
843 909
844 float localAVHeight = 1.56f; 910 float localAVHeight = 1.56f;
845 if (Appearance.AvatarHeight > 0) 911 if (Appearance.AvatarHeight > 0)
846 localAVHeight = Appearance.AvatarHeight; 912 localAVHeight = Appearance.AvatarHeight;
847 913
848 float posZLimit = 0; 914 float posZLimit = 0;
849 915
850 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) 916 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize)
851 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 917 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
852 918
853 float newPosZ = posZLimit + localAVHeight / 2; 919 float newPosZ = posZLimit + localAVHeight / 2;
854 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) 920 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
855 { 921 {
856 pos.Z = newPosZ; 922 pos.Z = newPosZ;
857 } 923 }
858 AbsolutePosition = pos; 924 AbsolutePosition = pos;
859 925
860 AddToPhysicalScene(isFlying); 926 AddToPhysicalScene(isFlying);
861 927
862 if (ForceFly) 928 if (ForceFly)
863 { 929 {
864 Flying = true; 930 Flying = true;
865 } 931 }
866 else if (FlyDisabled) 932 else if (FlyDisabled)
867 { 933 {
868 Flying = false; 934 Flying = false;
935 }
869 } 936 }
870
871 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying 937 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
872 // avatar to return to the standing position in mid-air. On login it looks like this is being sent 938 // avatar to return to the standing position in mid-air. On login it looks like this is being sent
873 // elsewhere anyway 939 // elsewhere anyway
@@ -885,14 +951,19 @@ namespace OpenSim.Region.Framework.Scenes
885 { 951 {
886 m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); 952 m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments...");
887 // Resume scripts 953 // Resume scripts
888 foreach (SceneObjectGroup sog in m_attachments) 954 Util.FireAndForget(delegate(object x) {
889 { 955 foreach (SceneObjectGroup sog in m_attachments)
890 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); 956 {
891 sog.ResumeScripts(); 957 sog.ScheduleGroupForFullUpdate();
892 } 958 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
959 sog.ResumeScripts();
960 }
961 });
893 } 962 }
894 } 963 }
895 964
965 SendAvatarDataToAllAgents();
966
896 // send the animations of the other presences to me 967 // send the animations of the other presences to me
897 m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) 968 m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
898 { 969 {
@@ -906,6 +977,8 @@ namespace OpenSim.Region.Framework.Scenes
906 MovementFlag = 0; 977 MovementFlag = 0;
907 978
908 m_scene.EventManager.TriggerOnMakeRootAgent(this); 979 m_scene.EventManager.TriggerOnMakeRootAgent(this);
980
981 m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd;
909 } 982 }
910 983
911 public int GetStateSource() 984 public int GetStateSource()
@@ -933,6 +1006,8 @@ namespace OpenSim.Region.Framework.Scenes
933 /// </remarks> 1006 /// </remarks>
934 public void MakeChildAgent() 1007 public void MakeChildAgent()
935 { 1008 {
1009 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
1010
936 m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); 1011 m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName);
937 1012
938 // Reset these so that teleporting in and walking out isn't seen 1013 // Reset these so that teleporting in and walking out isn't seen
@@ -991,7 +1066,7 @@ namespace OpenSim.Region.Framework.Scenes
991 /// <param name="pos"></param> 1066 /// <param name="pos"></param>
992 public void Teleport(Vector3 pos) 1067 public void Teleport(Vector3 pos)
993 { 1068 {
994 TeleportWithMomentum(pos, null); 1069 TeleportWithMomentum(pos, Vector3.Zero);
995 } 1070 }
996 1071
997 public void TeleportWithMomentum(Vector3 pos, Vector3? v) 1072 public void TeleportWithMomentum(Vector3 pos, Vector3? v)
@@ -1013,6 +1088,41 @@ namespace OpenSim.Region.Framework.Scenes
1013 SendTerseUpdateToAllClients(); 1088 SendTerseUpdateToAllClients();
1014 } 1089 }
1015 1090
1091 public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY)
1092 {
1093 CheckLandingPoint(ref newpos);
1094 AbsolutePosition = newpos;
1095
1096 if (newvel.HasValue)
1097 {
1098 if ((Vector3)newvel == Vector3.Zero)
1099 {
1100 if (PhysicsActor != null)
1101 PhysicsActor.SetMomentum(Vector3.Zero);
1102 m_velocity = Vector3.Zero;
1103 }
1104 else
1105 {
1106 if (PhysicsActor != null)
1107 PhysicsActor.SetMomentum((Vector3)newvel);
1108 m_velocity = (Vector3)newvel;
1109
1110 if (rotateToVelXY)
1111 {
1112 Vector3 lookAt = (Vector3)newvel;
1113 lookAt.Z = 0;
1114 lookAt.Normalize();
1115 ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation);
1116 return;
1117 }
1118 }
1119 }
1120
1121 SendTerseUpdateToAllClients();
1122 }
1123
1124
1125
1016 public void StopFlying() 1126 public void StopFlying()
1017 { 1127 {
1018 ControllingClient.StopFlying(this); 1128 ControllingClient.StopFlying(this);
@@ -1322,8 +1432,18 @@ namespace OpenSim.Region.Framework.Scenes
1322 { 1432 {
1323 if (m_followCamAuto) 1433 if (m_followCamAuto)
1324 { 1434 {
1325 Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; 1435 // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT;
1326 m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); 1436 // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback);
1437
1438 Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT;
1439 Vector3 distTocam = CameraPosition - posAdjusted;
1440 float distTocamlen = distTocam.Length();
1441 if (distTocamlen > 0)
1442 {
1443 distTocam *= 1.0f / distTocamlen;
1444 m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback);
1445 }
1446
1327 } 1447 }
1328 } 1448 }
1329 1449
@@ -1756,8 +1876,11 @@ namespace OpenSim.Region.Framework.Scenes
1756// m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); 1876// m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name);
1757 1877
1758 SitGround = false; 1878 SitGround = false;
1879
1880/* move this down so avatar gets physical in the new position and not where it is siting
1759 if (PhysicsActor == null) 1881 if (PhysicsActor == null)
1760 AddToPhysicalScene(false); 1882 AddToPhysicalScene(false);
1883 */
1761 1884
1762 if (ParentID != 0) 1885 if (ParentID != 0)
1763 { 1886 {
@@ -1781,6 +1904,7 @@ namespace OpenSim.Region.Framework.Scenes
1781 if (part.SitTargetAvatar == UUID) 1904 if (part.SitTargetAvatar == UUID)
1782 part.SitTargetAvatar = UUID.Zero; 1905 part.SitTargetAvatar = UUID.Zero;
1783 1906
1907 part.ParentGroup.DeleteAvatar(UUID);
1784 ParentPosition = part.GetWorldPosition(); 1908 ParentPosition = part.GetWorldPosition();
1785 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 1909 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
1786 1910
@@ -1789,6 +1913,10 @@ namespace OpenSim.Region.Framework.Scenes
1789 1913
1790 ParentID = 0; 1914 ParentID = 0;
1791 ParentPart = null; 1915 ParentPart = null;
1916
1917 if (PhysicsActor == null)
1918 AddToPhysicalScene(false);
1919
1792 SendAvatarDataToAllAgents(); 1920 SendAvatarDataToAllAgents();
1793 m_requestedSitTargetID = 0; 1921 m_requestedSitTargetID = 0;
1794 1922
@@ -1796,6 +1924,9 @@ namespace OpenSim.Region.Framework.Scenes
1796 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 1924 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
1797 } 1925 }
1798 1926
1927 else if (PhysicsActor == null)
1928 AddToPhysicalScene(false);
1929
1799 Animator.TrySetMovementAnimation("STAND"); 1930 Animator.TrySetMovementAnimation("STAND");
1800 } 1931 }
1801 1932
@@ -1919,7 +2050,7 @@ namespace OpenSim.Region.Framework.Scenes
1919 forceMouselook = part.GetForceMouselook(); 2050 forceMouselook = part.GetForceMouselook();
1920 2051
1921 ControllingClient.SendSitResponse( 2052 ControllingClient.SendSitResponse(
1922 targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); 2053 part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook);
1923 2054
1924 m_requestedSitTargetUUID = targetID; 2055 m_requestedSitTargetUUID = targetID;
1925 2056
@@ -2201,14 +2332,36 @@ namespace OpenSim.Region.Framework.Scenes
2201 2332
2202 //Quaternion result = (sitTargetOrient * vq) * nq; 2333 //Quaternion result = (sitTargetOrient * vq) * nq;
2203 2334
2204 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; 2335 double x, y, z, m;
2336
2337 Quaternion r = sitTargetOrient;
2338 m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W;
2339
2340 if (Math.Abs(1.0 - m) > 0.000001)
2341 {
2342 m = 1.0 / Math.Sqrt(m);
2343 r.X *= (float)m;
2344 r.Y *= (float)m;
2345 r.Z *= (float)m;
2346 r.W *= (float)m;
2347 }
2348
2349 x = 2 * (r.X * r.Z + r.Y * r.W);
2350 y = 2 * (-r.X * r.W + r.Y * r.Z);
2351 z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W;
2352
2353 Vector3 up = new Vector3((float)x, (float)y, (float)z);
2354 Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f;
2355 m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT;
2205 Rotation = sitTargetOrient; 2356 Rotation = sitTargetOrient;
2206 ParentPosition = part.AbsolutePosition; 2357 ParentPosition = part.AbsolutePosition;
2358 part.ParentGroup.AddAvatar(UUID);
2207 } 2359 }
2208 else 2360 else
2209 { 2361 {
2210 m_pos -= part.AbsolutePosition; 2362 m_pos -= part.AbsolutePosition;
2211 ParentPosition = part.AbsolutePosition; 2363 ParentPosition = part.AbsolutePosition;
2364 part.ParentGroup.AddAvatar(UUID);
2212 2365
2213// m_log.DebugFormat( 2366// m_log.DebugFormat(
2214// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", 2367// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target",
@@ -2306,14 +2459,15 @@ namespace OpenSim.Region.Framework.Scenes
2306 direc.Z *= 2.6f; 2459 direc.Z *= 2.6f;
2307 2460
2308 // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. 2461 // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored.
2309 Animator.TrySetMovementAnimation("PREJUMP"); 2462// Animator.TrySetMovementAnimation("PREJUMP");
2310 Animator.TrySetMovementAnimation("JUMP"); 2463// Animator.TrySetMovementAnimation("JUMP");
2311 } 2464 }
2312 } 2465 }
2313 } 2466 }
2314 2467
2315 // TODO: Add the force instead of only setting it to support multiple forces per frame? 2468 // TODO: Add the force instead of only setting it to support multiple forces per frame?
2316 m_forceToApply = direc; 2469 m_forceToApply = direc;
2470 Animator.UpdateMovementAnimations();
2317 } 2471 }
2318 2472
2319 #endregion 2473 #endregion
@@ -3047,6 +3201,9 @@ namespace OpenSim.Region.Framework.Scenes
3047 cAgent.AlwaysRun = SetAlwaysRun; 3201 cAgent.AlwaysRun = SetAlwaysRun;
3048 3202
3049 cAgent.Appearance = new AvatarAppearance(Appearance); 3203 cAgent.Appearance = new AvatarAppearance(Appearance);
3204
3205 cAgent.ParentPart = ParentUUID;
3206 cAgent.SitOffset = m_pos;
3050 3207
3051 lock (scriptedcontrols) 3208 lock (scriptedcontrols)
3052 { 3209 {
@@ -3106,6 +3263,8 @@ namespace OpenSim.Region.Framework.Scenes
3106 CameraAtAxis = cAgent.AtAxis; 3263 CameraAtAxis = cAgent.AtAxis;
3107 CameraLeftAxis = cAgent.LeftAxis; 3264 CameraLeftAxis = cAgent.LeftAxis;
3108 CameraUpAxis = cAgent.UpAxis; 3265 CameraUpAxis = cAgent.UpAxis;
3266 ParentUUID = cAgent.ParentPart;
3267 m_prevSitOffset = cAgent.SitOffset;
3109 3268
3110 // When we get to the point of re-computing neighbors everytime this 3269 // When we get to the point of re-computing neighbors everytime this
3111 // changes, then start using the agent's drawdistance rather than the 3270 // changes, then start using the agent's drawdistance rather than the
@@ -3258,18 +3417,6 @@ namespace OpenSim.Region.Framework.Scenes
3258 if (IsChildAgent) 3417 if (IsChildAgent)
3259 return; 3418 return;
3260 3419
3261 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
3262 // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents(
3263 // as of this comment the interval is set in AddToPhysicalScene
3264 if (Animator != null)
3265 {
3266// if (m_updateCount > 0)
3267// {
3268 Animator.UpdateMovementAnimations();
3269// m_updateCount--;
3270// }
3271 }
3272
3273 CollisionEventUpdate collisionData = (CollisionEventUpdate)e; 3420 CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
3274 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; 3421 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList;
3275 3422
@@ -3950,6 +4097,12 @@ namespace OpenSim.Region.Framework.Scenes
3950 4097
3951 private void CheckAndAdjustLandingPoint(ref Vector3 pos) 4098 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
3952 { 4099 {
4100 string reason;
4101
4102 // Honor bans
4103 if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y))
4104 return;
4105
3953 SceneObjectGroup telehub = null; 4106 SceneObjectGroup telehub = null;
3954 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) 4107 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null)
3955 { 4108 {
@@ -3989,11 +4142,173 @@ namespace OpenSim.Region.Framework.Scenes
3989 pos = land.LandData.UserLocation; 4142 pos = land.LandData.UserLocation;
3990 } 4143 }
3991 } 4144 }
3992 4145
3993 land.SendLandUpdateToClient(ControllingClient); 4146 land.SendLandUpdateToClient(ControllingClient);
3994 } 4147 }
3995 } 4148 }
3996 4149
4150 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
4151 {
4152 lock(m_collisionEventLock)
4153 {
4154 if (m_collisionEventFlag)
4155 return;
4156 m_collisionEventFlag = true;
4157 }
4158
4159 Util.FireAndForget(delegate(object x)
4160 {
4161 try
4162 {
4163 List<uint> thisHitColliders = new List<uint>();
4164 List<uint> endedColliders = new List<uint>();
4165 List<uint> startedColliders = new List<uint>();
4166
4167 foreach (uint localid in coldata.Keys)
4168 {
4169 thisHitColliders.Add(localid);
4170 if (!m_lastColliders.Contains(localid))
4171 {
4172 startedColliders.Add(localid);
4173 }
4174 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
4175 }
4176
4177 // calculate things that ended colliding
4178 foreach (uint localID in m_lastColliders)
4179 {
4180 if (!thisHitColliders.Contains(localID))
4181 {
4182 endedColliders.Add(localID);
4183 }
4184 }
4185 //add the items that started colliding this time to the last colliders list.
4186 foreach (uint localID in startedColliders)
4187 {
4188 m_lastColliders.Add(localID);
4189 }
4190 // remove things that ended colliding from the last colliders list
4191 foreach (uint localID in endedColliders)
4192 {
4193 m_lastColliders.Remove(localID);
4194 }
4195
4196 // do event notification
4197 if (startedColliders.Count > 0)
4198 {
4199 ColliderArgs StartCollidingMessage = new ColliderArgs();
4200 List<DetectedObject> colliding = new List<DetectedObject>();
4201 foreach (uint localId in startedColliders)
4202 {
4203 if (localId == 0)
4204 continue;
4205
4206 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
4207 string data = "";
4208 if (obj != null)
4209 {
4210 DetectedObject detobj = new DetectedObject();
4211 detobj.keyUUID = obj.UUID;
4212 detobj.nameStr = obj.Name;
4213 detobj.ownerUUID = obj.OwnerID;
4214 detobj.posVector = obj.AbsolutePosition;
4215 detobj.rotQuat = obj.GetWorldRotation();
4216 detobj.velVector = obj.Velocity;
4217 detobj.colliderType = 0;
4218 detobj.groupUUID = obj.GroupID;
4219 colliding.Add(detobj);
4220 }
4221 }
4222
4223 if (colliding.Count > 0)
4224 {
4225 StartCollidingMessage.Colliders = colliding;
4226
4227 foreach (SceneObjectGroup att in GetAttachments())
4228 Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage);
4229 }
4230 }
4231
4232 if (endedColliders.Count > 0)
4233 {
4234 ColliderArgs EndCollidingMessage = new ColliderArgs();
4235 List<DetectedObject> colliding = new List<DetectedObject>();
4236 foreach (uint localId in endedColliders)
4237 {
4238 if (localId == 0)
4239 continue;
4240
4241 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
4242 string data = "";
4243 if (obj != null)
4244 {
4245 DetectedObject detobj = new DetectedObject();
4246 detobj.keyUUID = obj.UUID;
4247 detobj.nameStr = obj.Name;
4248 detobj.ownerUUID = obj.OwnerID;
4249 detobj.posVector = obj.AbsolutePosition;
4250 detobj.rotQuat = obj.GetWorldRotation();
4251 detobj.velVector = obj.Velocity;
4252 detobj.colliderType = 0;
4253 detobj.groupUUID = obj.GroupID;
4254 colliding.Add(detobj);
4255 }
4256 }
4257
4258 if (colliding.Count > 0)
4259 {
4260 EndCollidingMessage.Colliders = colliding;
4261
4262 foreach (SceneObjectGroup att in GetAttachments())
4263 Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage);
4264 }
4265 }
4266
4267 if (thisHitColliders.Count > 0)
4268 {
4269 ColliderArgs CollidingMessage = new ColliderArgs();
4270 List<DetectedObject> colliding = new List<DetectedObject>();
4271 foreach (uint localId in thisHitColliders)
4272 {
4273 if (localId == 0)
4274 continue;
4275
4276 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
4277 string data = "";
4278 if (obj != null)
4279 {
4280 DetectedObject detobj = new DetectedObject();
4281 detobj.keyUUID = obj.UUID;
4282 detobj.nameStr = obj.Name;
4283 detobj.ownerUUID = obj.OwnerID;
4284 detobj.posVector = obj.AbsolutePosition;
4285 detobj.rotQuat = obj.GetWorldRotation();
4286 detobj.velVector = obj.Velocity;
4287 detobj.colliderType = 0;
4288 detobj.groupUUID = obj.GroupID;
4289 colliding.Add(detobj);
4290 }
4291 }
4292
4293 if (colliding.Count > 0)
4294 {
4295 CollidingMessage.Colliders = colliding;
4296
4297 lock (m_attachments)
4298 {
4299 foreach (SceneObjectGroup att in m_attachments)
4300 Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
4301 }
4302 }
4303 }
4304 }
4305 finally
4306 {
4307 m_collisionEventFlag = false;
4308 }
4309 });
4310 }
4311
3997 private void TeleportFlagsDebug() { 4312 private void TeleportFlagsDebug() {
3998 4313
3999 // Some temporary debugging help to show all the TeleportFlags we have... 4314 // Some temporary debugging help to show all the TeleportFlags we have...
@@ -4018,6 +4333,5 @@ namespace OpenSim.Region.Framework.Scenes
4018 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); 4333 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************");
4019 4334
4020 } 4335 }
4021
4022 } 4336 }
4023} 4337}