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.cs420
1 files changed, 345 insertions, 75 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 19dab32..ed3a7f1 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -92,7 +92,7 @@ namespace OpenSim.Region.Framework.Scenes
92 /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis 92 /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis
93 /// issue #1716 93 /// issue #1716
94 /// </summary> 94 /// </summary>
95 public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); 95 public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f);
96 96
97 /// <summary> 97 /// <summary>
98 /// Movement updates for agents in neighboring regions are sent directly to clients. 98 /// Movement updates for agents in neighboring regions are sent directly to clients.
@@ -169,6 +169,7 @@ namespace OpenSim.Region.Framework.Scenes
169// private int m_lastColCount = -1; //KF: Look for Collision chnages 169// private int m_lastColCount = -1; //KF: Look for Collision chnages
170// private int m_updateCount = 0; //KF: Update Anims for a while 170// private int m_updateCount = 0; //KF: Update Anims for a while
171// private static readonly int UPDATE_COUNT = 10; // how many frames to update for 171// private static readonly int UPDATE_COUNT = 10; // how many frames to update for
172 private List<uint> m_lastColliders = new List<uint>();
172 173
173 private TeleportFlags m_teleportFlags; 174 private TeleportFlags m_teleportFlags;
174 public TeleportFlags TeleportFlags 175 public TeleportFlags TeleportFlags
@@ -230,6 +231,13 @@ namespace OpenSim.Region.Framework.Scenes
230 //private int m_moveToPositionStateStatus; 231 //private int m_moveToPositionStateStatus;
231 //***************************************************** 232 //*****************************************************
232 233
234 private bool m_collisionEventFlag = false;
235 private object m_collisionEventLock = new Object();
236
237 private int m_movementAnimationUpdateCounter = 0;
238
239 private Vector3 m_prevSitOffset;
240
233 protected AvatarAppearance m_appearance; 241 protected AvatarAppearance m_appearance;
234 242
235 public AvatarAppearance Appearance 243 public AvatarAppearance Appearance
@@ -569,6 +577,13 @@ namespace OpenSim.Region.Framework.Scenes
569 /// </summary> 577 /// </summary>
570 public uint ParentID { get; set; } 578 public uint ParentID { get; set; }
571 579
580 public UUID ParentUUID
581 {
582 get { return m_parentUUID; }
583 set { m_parentUUID = value; }
584 }
585 private UUID m_parentUUID = UUID.Zero;
586
572 /// <summary> 587 /// <summary>
573 /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null. 588 /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null.
574 /// </summary> 589 /// </summary>
@@ -729,6 +744,26 @@ namespace OpenSim.Region.Framework.Scenes
729 Appearance = appearance; 744 Appearance = appearance;
730 } 745 }
731 746
747 private void RegionHeartbeatEnd(Scene scene)
748 {
749 if (IsChildAgent)
750 return;
751
752 m_movementAnimationUpdateCounter ++;
753 if (m_movementAnimationUpdateCounter >= 2)
754 {
755 m_movementAnimationUpdateCounter = 0;
756 if (Animator != null)
757 {
758 Animator.UpdateMovementAnimations();
759 }
760 else
761 {
762 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
763 }
764 }
765 }
766
732 public void RegisterToEvents() 767 public void RegisterToEvents()
733 { 768 {
734 ControllingClient.OnCompleteMovementToRegion += CompleteMovement; 769 ControllingClient.OnCompleteMovementToRegion += CompleteMovement;
@@ -798,10 +833,38 @@ namespace OpenSim.Region.Framework.Scenes
798 "[SCENE]: Upgrading child to root agent for {0} in {1}", 833 "[SCENE]: Upgrading child to root agent for {0} in {1}",
799 Name, m_scene.RegionInfo.RegionName); 834 Name, m_scene.RegionInfo.RegionName);
800 835
801 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
802
803 bool wasChild = IsChildAgent; 836 bool wasChild = IsChildAgent;
804 IsChildAgent = false; 837
838 if (ParentUUID != UUID.Zero)
839 {
840 m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID);
841 SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID);
842 if (part == null)
843 {
844 m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID);
845 }
846 else
847 {
848 part.ParentGroup.AddAvatar(UUID);
849 if (part.SitTargetPosition != Vector3.Zero)
850 part.SitTargetAvatar = UUID;
851 ParentPosition = part.GetWorldPosition();
852 ParentID = part.LocalId;
853 ParentPart = part;
854 m_pos = m_prevSitOffset;
855 pos = ParentPosition;
856 }
857 ParentUUID = UUID.Zero;
858
859 IsChildAgent = false;
860
861 Animator.TrySetMovementAnimation("SIT");
862 }
863 else
864 {
865 IsChildAgent = false;
866 }
867
805 868
806 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 869 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
807 if (gm != null) 870 if (gm != null)
@@ -811,62 +874,64 @@ namespace OpenSim.Region.Framework.Scenes
811 874
812 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); 875 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene);
813 876
814 // Moved this from SendInitialData to ensure that Appearance is initialized 877 if (ParentID == 0)
815 // before the inventory is processed in MakeRootAgent. This fixes a race condition
816 // related to the handling of attachments
817 //m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
818 if (m_scene.TestBorderCross(pos, Cardinals.E))
819 { 878 {
820 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); 879 // Moved this from SendInitialData to ensure that Appearance is initialized
821 pos.X = crossedBorder.BorderLine.Z - 1; 880 // before the inventory is processed in MakeRootAgent. This fixes a race condition
822 } 881 // related to the handling of attachments
882 //m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
883 if (m_scene.TestBorderCross(pos, Cardinals.E))
884 {
885 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E);
886 pos.X = crossedBorder.BorderLine.Z - 1;
887 }
823 888
824 if (m_scene.TestBorderCross(pos, Cardinals.N)) 889 if (m_scene.TestBorderCross(pos, Cardinals.N))
825 { 890 {
826 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); 891 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N);
827 pos.Y = crossedBorder.BorderLine.Z - 1; 892 pos.Y = crossedBorder.BorderLine.Z - 1;
828 } 893 }
829 894
830 CheckAndAdjustLandingPoint(ref pos); 895 CheckAndAdjustLandingPoint(ref pos);
831 896
832 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 897 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
833 { 898 {
834 m_log.WarnFormat( 899 m_log.WarnFormat(
835 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", 900 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping",
836 pos, Name, UUID); 901 pos, Name, UUID);
837 902
838 if (pos.X < 0f) pos.X = 0f; 903 if (pos.X < 0f) pos.X = 0f;
839 if (pos.Y < 0f) pos.Y = 0f; 904 if (pos.Y < 0f) pos.Y = 0f;
840 if (pos.Z < 0f) pos.Z = 0f; 905 if (pos.Z < 0f) pos.Z = 0f;
841 } 906 }
842 907
843 float localAVHeight = 1.56f; 908 float localAVHeight = 1.56f;
844 if (Appearance.AvatarHeight > 0) 909 if (Appearance.AvatarHeight > 0)
845 localAVHeight = Appearance.AvatarHeight; 910 localAVHeight = Appearance.AvatarHeight;
846 911
847 float posZLimit = 0; 912 float posZLimit = 0;
848 913
849 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) 914 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize)
850 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 915 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
851 916
852 float newPosZ = posZLimit + localAVHeight / 2; 917 float newPosZ = posZLimit + localAVHeight / 2;
853 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) 918 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
854 { 919 {
855 pos.Z = newPosZ; 920 pos.Z = newPosZ;
856 } 921 }
857 AbsolutePosition = pos; 922 AbsolutePosition = pos;
858 923
859 AddToPhysicalScene(isFlying); 924 AddToPhysicalScene(isFlying);
860 925
861 if (ForceFly) 926 if (ForceFly)
862 { 927 {
863 Flying = true; 928 Flying = true;
864 } 929 }
865 else if (FlyDisabled) 930 else if (FlyDisabled)
866 { 931 {
867 Flying = false; 932 Flying = false;
933 }
868 } 934 }
869
870 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying 935 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
871 // avatar to return to the standing position in mid-air. On login it looks like this is being sent 936 // avatar to return to the standing position in mid-air. On login it looks like this is being sent
872 // elsewhere anyway 937 // elsewhere anyway
@@ -884,14 +949,19 @@ namespace OpenSim.Region.Framework.Scenes
884 { 949 {
885 m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); 950 m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments...");
886 // Resume scripts 951 // Resume scripts
887 foreach (SceneObjectGroup sog in m_attachments) 952 Util.FireAndForget(delegate(object x) {
888 { 953 foreach (SceneObjectGroup sog in m_attachments)
889 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); 954 {
890 sog.ResumeScripts(); 955 sog.ScheduleGroupForFullUpdate();
891 } 956 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
957 sog.ResumeScripts();
958 }
959 });
892 } 960 }
893 } 961 }
894 962
963 SendAvatarDataToAllAgents();
964
895 // send the animations of the other presences to me 965 // send the animations of the other presences to me
896 m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) 966 m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
897 { 967 {
@@ -905,6 +975,8 @@ namespace OpenSim.Region.Framework.Scenes
905 MovementFlag = 0; 975 MovementFlag = 0;
906 976
907 m_scene.EventManager.TriggerOnMakeRootAgent(this); 977 m_scene.EventManager.TriggerOnMakeRootAgent(this);
978
979 m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd;
908 } 980 }
909 981
910 public int GetStateSource() 982 public int GetStateSource()
@@ -932,6 +1004,8 @@ namespace OpenSim.Region.Framework.Scenes
932 /// </remarks> 1004 /// </remarks>
933 public void MakeChildAgent() 1005 public void MakeChildAgent()
934 { 1006 {
1007 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
1008
935 m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); 1009 m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName);
936 1010
937 // Reset these so that teleporting in and walking out isn't seen 1011 // Reset these so that teleporting in and walking out isn't seen
@@ -1689,9 +1763,9 @@ namespace OpenSim.Region.Framework.Scenes
1689 if (pos.Z - terrainHeight < 0.2) 1763 if (pos.Z - terrainHeight < 0.2)
1690 pos.Z = terrainHeight; 1764 pos.Z = terrainHeight;
1691 1765
1692 m_log.DebugFormat( 1766// m_log.DebugFormat(
1693 "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", 1767// "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}",
1694 Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); 1768// Name, pos, terrainHeight, m_scene.RegionInfo.RegionName);
1695 1769
1696 if (noFly) 1770 if (noFly)
1697 Flying = false; 1771 Flying = false;
@@ -1748,8 +1822,11 @@ namespace OpenSim.Region.Framework.Scenes
1748// m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); 1822// m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name);
1749 1823
1750 SitGround = false; 1824 SitGround = false;
1825
1826/* move this down so avatar gets physical in the new position and not where it is siting
1751 if (PhysicsActor == null) 1827 if (PhysicsActor == null)
1752 AddToPhysicalScene(false); 1828 AddToPhysicalScene(false);
1829 */
1753 1830
1754 if (ParentID != 0) 1831 if (ParentID != 0)
1755 { 1832 {
@@ -1773,6 +1850,7 @@ namespace OpenSim.Region.Framework.Scenes
1773 if (part.SitTargetAvatar == UUID) 1850 if (part.SitTargetAvatar == UUID)
1774 part.SitTargetAvatar = UUID.Zero; 1851 part.SitTargetAvatar = UUID.Zero;
1775 1852
1853 part.ParentGroup.DeleteAvatar(UUID);
1776 ParentPosition = part.GetWorldPosition(); 1854 ParentPosition = part.GetWorldPosition();
1777 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 1855 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
1778 1856
@@ -1781,6 +1859,10 @@ namespace OpenSim.Region.Framework.Scenes
1781 1859
1782 ParentID = 0; 1860 ParentID = 0;
1783 ParentPart = null; 1861 ParentPart = null;
1862
1863 if (PhysicsActor == null)
1864 AddToPhysicalScene(false);
1865
1784 SendAvatarDataToAllAgents(); 1866 SendAvatarDataToAllAgents();
1785 m_requestedSitTargetID = 0; 1867 m_requestedSitTargetID = 0;
1786 1868
@@ -1788,6 +1870,9 @@ namespace OpenSim.Region.Framework.Scenes
1788 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 1870 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
1789 } 1871 }
1790 1872
1873 else if (PhysicsActor == null)
1874 AddToPhysicalScene(false);
1875
1791 Animator.TrySetMovementAnimation("STAND"); 1876 Animator.TrySetMovementAnimation("STAND");
1792 } 1877 }
1793 1878
@@ -1911,7 +1996,7 @@ namespace OpenSim.Region.Framework.Scenes
1911 forceMouselook = part.GetForceMouselook(); 1996 forceMouselook = part.GetForceMouselook();
1912 1997
1913 ControllingClient.SendSitResponse( 1998 ControllingClient.SendSitResponse(
1914 targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); 1999 part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook);
1915 2000
1916 m_requestedSitTargetUUID = targetID; 2001 m_requestedSitTargetUUID = targetID;
1917 2002
@@ -2193,14 +2278,36 @@ namespace OpenSim.Region.Framework.Scenes
2193 2278
2194 //Quaternion result = (sitTargetOrient * vq) * nq; 2279 //Quaternion result = (sitTargetOrient * vq) * nq;
2195 2280
2196 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; 2281 double x, y, z, m;
2282
2283 Quaternion r = sitTargetOrient;
2284 m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W;
2285
2286 if (Math.Abs(1.0 - m) > 0.000001)
2287 {
2288 m = 1.0 / Math.Sqrt(m);
2289 r.X *= (float)m;
2290 r.Y *= (float)m;
2291 r.Z *= (float)m;
2292 r.W *= (float)m;
2293 }
2294
2295 x = 2 * (r.X * r.Z + r.Y * r.W);
2296 y = 2 * (-r.X * r.W + r.Y * r.Z);
2297 z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W;
2298
2299 Vector3 up = new Vector3((float)x, (float)y, (float)z);
2300 Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f;
2301 m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT;
2197 Rotation = sitTargetOrient; 2302 Rotation = sitTargetOrient;
2198 ParentPosition = part.AbsolutePosition; 2303 ParentPosition = part.AbsolutePosition;
2304 part.ParentGroup.AddAvatar(UUID);
2199 } 2305 }
2200 else 2306 else
2201 { 2307 {
2202 m_pos -= part.AbsolutePosition; 2308 m_pos -= part.AbsolutePosition;
2203 ParentPosition = part.AbsolutePosition; 2309 ParentPosition = part.AbsolutePosition;
2310 part.ParentGroup.AddAvatar(UUID);
2204 2311
2205// m_log.DebugFormat( 2312// m_log.DebugFormat(
2206// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", 2313// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target",
@@ -2298,14 +2405,15 @@ namespace OpenSim.Region.Framework.Scenes
2298 direc.Z *= 2.6f; 2405 direc.Z *= 2.6f;
2299 2406
2300 // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. 2407 // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored.
2301 Animator.TrySetMovementAnimation("PREJUMP"); 2408// Animator.TrySetMovementAnimation("PREJUMP");
2302 Animator.TrySetMovementAnimation("JUMP"); 2409// Animator.TrySetMovementAnimation("JUMP");
2303 } 2410 }
2304 } 2411 }
2305 } 2412 }
2306 2413
2307 // TODO: Add the force instead of only setting it to support multiple forces per frame? 2414 // TODO: Add the force instead of only setting it to support multiple forces per frame?
2308 m_forceToApply = direc; 2415 m_forceToApply = direc;
2416 Animator.UpdateMovementAnimations();
2309 } 2417 }
2310 2418
2311 #endregion 2419 #endregion
@@ -3039,6 +3147,9 @@ namespace OpenSim.Region.Framework.Scenes
3039 cAgent.AlwaysRun = SetAlwaysRun; 3147 cAgent.AlwaysRun = SetAlwaysRun;
3040 3148
3041 cAgent.Appearance = new AvatarAppearance(Appearance); 3149 cAgent.Appearance = new AvatarAppearance(Appearance);
3150
3151 cAgent.ParentPart = ParentUUID;
3152 cAgent.SitOffset = m_pos;
3042 3153
3043 lock (scriptedcontrols) 3154 lock (scriptedcontrols)
3044 { 3155 {
@@ -3098,6 +3209,8 @@ namespace OpenSim.Region.Framework.Scenes
3098 CameraAtAxis = cAgent.AtAxis; 3209 CameraAtAxis = cAgent.AtAxis;
3099 CameraLeftAxis = cAgent.LeftAxis; 3210 CameraLeftAxis = cAgent.LeftAxis;
3100 CameraUpAxis = cAgent.UpAxis; 3211 CameraUpAxis = cAgent.UpAxis;
3212 ParentUUID = cAgent.ParentPart;
3213 m_prevSitOffset = cAgent.SitOffset;
3101 3214
3102 // When we get to the point of re-computing neighbors everytime this 3215 // When we get to the point of re-computing neighbors everytime this
3103 // changes, then start using the agent's drawdistance rather than the 3216 // changes, then start using the agent's drawdistance rather than the
@@ -3250,18 +3363,6 @@ namespace OpenSim.Region.Framework.Scenes
3250 if (IsChildAgent) 3363 if (IsChildAgent)
3251 return; 3364 return;
3252 3365
3253 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
3254 // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents(
3255 // as of this comment the interval is set in AddToPhysicalScene
3256 if (Animator != null)
3257 {
3258// if (m_updateCount > 0)
3259// {
3260 Animator.UpdateMovementAnimations();
3261// m_updateCount--;
3262// }
3263 }
3264
3265 CollisionEventUpdate collisionData = (CollisionEventUpdate)e; 3366 CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
3266 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; 3367 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList;
3267 3368
@@ -3304,6 +3405,8 @@ namespace OpenSim.Region.Framework.Scenes
3304 } 3405 }
3305 } 3406 }
3306 3407
3408 RaiseCollisionScriptEvents(coldata);
3409
3307 if (Invulnerable) 3410 if (Invulnerable)
3308 return; 3411 return;
3309 3412
@@ -3815,6 +3918,12 @@ namespace OpenSim.Region.Framework.Scenes
3815 3918
3816 private void CheckAndAdjustLandingPoint(ref Vector3 pos) 3919 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
3817 { 3920 {
3921 string reason;
3922
3923 // Honor bans
3924 if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y))
3925 return;
3926
3818 SceneObjectGroup telehub = null; 3927 SceneObjectGroup telehub = null;
3819 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) 3928 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null)
3820 { 3929 {
@@ -3854,11 +3963,173 @@ namespace OpenSim.Region.Framework.Scenes
3854 pos = land.LandData.UserLocation; 3963 pos = land.LandData.UserLocation;
3855 } 3964 }
3856 } 3965 }
3857 3966
3858 land.SendLandUpdateToClient(ControllingClient); 3967 land.SendLandUpdateToClient(ControllingClient);
3859 } 3968 }
3860 } 3969 }
3861 3970
3971 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
3972 {
3973 lock(m_collisionEventLock)
3974 {
3975 if (m_collisionEventFlag)
3976 return;
3977 m_collisionEventFlag = true;
3978 }
3979
3980 Util.FireAndForget(delegate(object x)
3981 {
3982 try
3983 {
3984 List<uint> thisHitColliders = new List<uint>();
3985 List<uint> endedColliders = new List<uint>();
3986 List<uint> startedColliders = new List<uint>();
3987
3988 foreach (uint localid in coldata.Keys)
3989 {
3990 thisHitColliders.Add(localid);
3991 if (!m_lastColliders.Contains(localid))
3992 {
3993 startedColliders.Add(localid);
3994 }
3995 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
3996 }
3997
3998 // calculate things that ended colliding
3999 foreach (uint localID in m_lastColliders)
4000 {
4001 if (!thisHitColliders.Contains(localID))
4002 {
4003 endedColliders.Add(localID);
4004 }
4005 }
4006 //add the items that started colliding this time to the last colliders list.
4007 foreach (uint localID in startedColliders)
4008 {
4009 m_lastColliders.Add(localID);
4010 }
4011 // remove things that ended colliding from the last colliders list
4012 foreach (uint localID in endedColliders)
4013 {
4014 m_lastColliders.Remove(localID);
4015 }
4016
4017 // do event notification
4018 if (startedColliders.Count > 0)
4019 {
4020 ColliderArgs StartCollidingMessage = new ColliderArgs();
4021 List<DetectedObject> colliding = new List<DetectedObject>();
4022 foreach (uint localId in startedColliders)
4023 {
4024 if (localId == 0)
4025 continue;
4026
4027 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
4028 string data = "";
4029 if (obj != null)
4030 {
4031 DetectedObject detobj = new DetectedObject();
4032 detobj.keyUUID = obj.UUID;
4033 detobj.nameStr = obj.Name;
4034 detobj.ownerUUID = obj.OwnerID;
4035 detobj.posVector = obj.AbsolutePosition;
4036 detobj.rotQuat = obj.GetWorldRotation();
4037 detobj.velVector = obj.Velocity;
4038 detobj.colliderType = 0;
4039 detobj.groupUUID = obj.GroupID;
4040 colliding.Add(detobj);
4041 }
4042 }
4043
4044 if (colliding.Count > 0)
4045 {
4046 StartCollidingMessage.Colliders = colliding;
4047
4048 foreach (SceneObjectGroup att in GetAttachments())
4049 Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage);
4050 }
4051 }
4052
4053 if (endedColliders.Count > 0)
4054 {
4055 ColliderArgs EndCollidingMessage = new ColliderArgs();
4056 List<DetectedObject> colliding = new List<DetectedObject>();
4057 foreach (uint localId in endedColliders)
4058 {
4059 if (localId == 0)
4060 continue;
4061
4062 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
4063 string data = "";
4064 if (obj != null)
4065 {
4066 DetectedObject detobj = new DetectedObject();
4067 detobj.keyUUID = obj.UUID;
4068 detobj.nameStr = obj.Name;
4069 detobj.ownerUUID = obj.OwnerID;
4070 detobj.posVector = obj.AbsolutePosition;
4071 detobj.rotQuat = obj.GetWorldRotation();
4072 detobj.velVector = obj.Velocity;
4073 detobj.colliderType = 0;
4074 detobj.groupUUID = obj.GroupID;
4075 colliding.Add(detobj);
4076 }
4077 }
4078
4079 if (colliding.Count > 0)
4080 {
4081 EndCollidingMessage.Colliders = colliding;
4082
4083 foreach (SceneObjectGroup att in GetAttachments())
4084 Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage);
4085 }
4086 }
4087
4088 if (thisHitColliders.Count > 0)
4089 {
4090 ColliderArgs CollidingMessage = new ColliderArgs();
4091 List<DetectedObject> colliding = new List<DetectedObject>();
4092 foreach (uint localId in thisHitColliders)
4093 {
4094 if (localId == 0)
4095 continue;
4096
4097 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
4098 string data = "";
4099 if (obj != null)
4100 {
4101 DetectedObject detobj = new DetectedObject();
4102 detobj.keyUUID = obj.UUID;
4103 detobj.nameStr = obj.Name;
4104 detobj.ownerUUID = obj.OwnerID;
4105 detobj.posVector = obj.AbsolutePosition;
4106 detobj.rotQuat = obj.GetWorldRotation();
4107 detobj.velVector = obj.Velocity;
4108 detobj.colliderType = 0;
4109 detobj.groupUUID = obj.GroupID;
4110 colliding.Add(detobj);
4111 }
4112 }
4113
4114 if (colliding.Count > 0)
4115 {
4116 CollidingMessage.Colliders = colliding;
4117
4118 lock (m_attachments)
4119 {
4120 foreach (SceneObjectGroup att in m_attachments)
4121 Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
4122 }
4123 }
4124 }
4125 }
4126 finally
4127 {
4128 m_collisionEventFlag = false;
4129 }
4130 });
4131 }
4132
3862 private void TeleportFlagsDebug() { 4133 private void TeleportFlagsDebug() {
3863 4134
3864 // Some temporary debugging help to show all the TeleportFlags we have... 4135 // Some temporary debugging help to show all the TeleportFlags we have...
@@ -3883,6 +4154,5 @@ namespace OpenSim.Region.Framework.Scenes
3883 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); 4154 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************");
3884 4155
3885 } 4156 }
3886
3887 } 4157 }
3888} 4158}