aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-23 01:02:36 -0700
committerJohn Hurliman2009-10-23 01:02:36 -0700
commit588361e2a2398b963871762c2b5485c6a086cf47 (patch)
tree5be2c6705096817c599075da4e12a0e9b0a4c841 /OpenSim/Region/Framework/Scenes
parentAdded VS2010 support to Prebuild and created runprebuild2010.bat (diff)
downloadopensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.zip
opensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.tar.gz
opensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.tar.bz2
opensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.tar.xz
Experimental change to use an immutable array for iterating ScenePresences, avoiding locking and copying the list each time it is accessed
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs25
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs160
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs53
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs121
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs21
6 files changed, 198 insertions, 186 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 4b87f92..d5e3445 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -253,7 +253,7 @@ namespace OpenSim.Region.Framework.Scenes
253 protected int m_fps = 10; 253 protected int m_fps = 10;
254 protected int m_frame = 0; 254 protected int m_frame = 0;
255 protected float m_timespan = 0.089f; 255 protected float m_timespan = 0.089f;
256 protected DateTime m_lastupdate = DateTime.Now; 256 protected DateTime m_lastupdate = DateTime.UtcNow;
257 257
258 private int m_update_physics = 1; 258 private int m_update_physics = 1;
259 private int m_update_entitymovement = 1; 259 private int m_update_entitymovement = 1;
@@ -1014,7 +1014,7 @@ namespace OpenSim.Region.Framework.Scenes
1014//#endif 1014//#endif
1015 maintc = Environment.TickCount; 1015 maintc = Environment.TickCount;
1016 1016
1017 TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; 1017 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
1018 float physicsFPS = 0; 1018 float physicsFPS = 0;
1019 1019
1020 frameMS = Environment.TickCount; 1020 frameMS = Environment.TickCount;
@@ -1137,7 +1137,7 @@ namespace OpenSim.Region.Framework.Scenes
1137 } 1137 }
1138 m_timedilation = tmpval; 1138 m_timedilation = tmpval;
1139 1139
1140 m_lastupdate = DateTime.Now; 1140 m_lastupdate = DateTime.UtcNow;
1141 } 1141 }
1142 maintc = Environment.TickCount - maintc; 1142 maintc = Environment.TickCount - maintc;
1143 maintc = (int)(m_timespan * 1000) - maintc; 1143 maintc = (int)(m_timespan * 1000) - maintc;
@@ -3496,9 +3496,7 @@ namespace OpenSim.Region.Framework.Scenes
3496 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) 3496 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
3497 { 3497 {
3498 ScenePresence presence; 3498 ScenePresence presence;
3499 3499 m_sceneGraph.TryGetAvatar(agentID, out presence);
3500 lock (m_sceneGraph.ScenePresences)
3501 m_sceneGraph.ScenePresences.TryGetValue(agentID, out presence);
3502 3500
3503 if (presence != null) 3501 if (presence != null)
3504 { 3502 {
@@ -3709,8 +3707,7 @@ namespace OpenSim.Region.Framework.Scenes
3709 Vector3 lookAt, uint teleportFlags) 3707 Vector3 lookAt, uint teleportFlags)
3710 { 3708 {
3711 ScenePresence sp; 3709 ScenePresence sp;
3712 lock (m_sceneGraph.ScenePresences) 3710 m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp);
3713 m_sceneGraph.ScenePresences.TryGetValue(remoteClient.AgentId, out sp);
3714 3711
3715 if (sp != null) 3712 if (sp != null)
3716 { 3713 {
@@ -4112,7 +4109,7 @@ namespace OpenSim.Region.Framework.Scenes
4112 /// This list is a new object, so it can be iterated over without locking. 4109 /// This list is a new object, so it can be iterated over without locking.
4113 /// </summary> 4110 /// </summary>
4114 /// <returns></returns> 4111 /// <returns></returns>
4115 public List<ScenePresence> GetScenePresences() 4112 public ScenePresence[] GetScenePresences()
4116 { 4113 {
4117 return m_sceneGraph.GetScenePresences(); 4114 return m_sceneGraph.GetScenePresences();
4118 } 4115 }
@@ -4159,15 +4156,13 @@ namespace OpenSim.Region.Framework.Scenes
4159 public void ForEachScenePresence(Action<ScenePresence> action) 4156 public void ForEachScenePresence(Action<ScenePresence> action)
4160 { 4157 {
4161 // We don't want to try to send messages if there are no avatars. 4158 // We don't want to try to send messages if there are no avatars.
4162 if (m_sceneGraph != null && m_sceneGraph.ScenePresences != null) 4159 if (m_sceneGraph != null)
4163 { 4160 {
4164 try 4161 try
4165 { 4162 {
4166 List<ScenePresence> presenceList = GetScenePresences(); 4163 ScenePresence[] presences = GetScenePresences();
4167 foreach (ScenePresence presence in presenceList) 4164 for (int i = 0; i < presences.Length; i++)
4168 { 4165 action(presences[i]);
4169 action(presence);
4170 }
4171 } 4166 }
4172 catch (Exception e) 4167 catch (Exception e)
4173 { 4168 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index deee6c3..db055f9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -66,7 +66,9 @@ namespace OpenSim.Region.Framework.Scenes
66 66
67 #region Fields 67 #region Fields
68 68
69 protected internal Dictionary<UUID, ScenePresence> ScenePresences = new Dictionary<UUID, ScenePresence>(); 69 protected Dictionary<UUID, ScenePresence> m_scenePresences = new Dictionary<UUID, ScenePresence>();
70 protected ScenePresence[] m_scenePresenceArray = new ScenePresence[0];
71
70 // SceneObjects is not currently populated or used. 72 // SceneObjects is not currently populated or used.
71 //public Dictionary<UUID, SceneObjectGroup> SceneObjects; 73 //public Dictionary<UUID, SceneObjectGroup> SceneObjects;
72 protected internal EntityManager Entities = new EntityManager(); 74 protected internal EntityManager Entities = new EntityManager();
@@ -126,10 +128,12 @@ namespace OpenSim.Region.Framework.Scenes
126 128
127 protected internal void Close() 129 protected internal void Close()
128 { 130 {
129 lock (ScenePresences) 131 lock (m_scenePresences)
130 { 132 {
131 ScenePresences.Clear(); 133 m_scenePresences.Clear();
134 m_scenePresenceArray = new ScenePresence[0];
132 } 135 }
136
133 lock (m_dictionary_lock) 137 lock (m_dictionary_lock)
134 { 138 {
135 SceneObjectGroupsByFullID.Clear(); 139 SceneObjectGroupsByFullID.Clear();
@@ -157,11 +161,9 @@ namespace OpenSim.Region.Framework.Scenes
157 161
158 protected internal void UpdatePresences() 162 protected internal void UpdatePresences()
159 { 163 {
160 List<ScenePresence> updateScenePresences = GetScenePresences(); 164 ScenePresence[] updateScenePresences = GetScenePresences();
161 foreach (ScenePresence pres in updateScenePresences) 165 for (int i = 0; i < updateScenePresences.Length; i++)
162 { 166 updateScenePresences[i].Update();
163 pres.Update();
164 }
165 } 167 }
166 168
167 protected internal float UpdatePhysics(double elapsed) 169 protected internal float UpdatePhysics(double elapsed)
@@ -190,15 +192,9 @@ namespace OpenSim.Region.Framework.Scenes
190 192
191 protected internal void UpdateScenePresenceMovement() 193 protected internal void UpdateScenePresenceMovement()
192 { 194 {
193 List<ScenePresence> moveEntities = GetScenePresences(); 195 ScenePresence[] moveEntities = GetScenePresences();
194 196 for (int i = 0; i < moveEntities.Length; i++)
195 foreach (EntityBase entity in moveEntities) 197 moveEntities[i].UpdateMovement();
196 {
197 //cfk. This throws occaisional exceptions on a heavily used region
198 //and I added this null check to try to preclude the exception.
199 if (entity != null)
200 entity.UpdateMovement();
201 }
202 } 198 }
203 199
204 #endregion 200 #endregion
@@ -645,9 +641,34 @@ namespace OpenSim.Region.Framework.Scenes
645 641
646 Entities[presence.UUID] = presence; 642 Entities[presence.UUID] = presence;
647 643
648 lock (ScenePresences) 644 lock (m_scenePresences)
649 { 645 {
650 ScenePresences[presence.UUID] = presence; 646 if (!m_scenePresences.ContainsKey(presence.UUID))
647 {
648 m_scenePresences.Add(presence.UUID, presence);
649
650 // Create a new array of ScenePresence references
651 int oldLength = m_scenePresenceArray.Length;
652 ScenePresence[] newArray = new ScenePresence[oldLength + 1];
653 Array.Copy(m_scenePresenceArray, newArray, oldLength);
654 newArray[oldLength] = presence;
655 m_scenePresenceArray = newArray;
656 }
657 else
658 {
659 m_scenePresences[presence.UUID] = presence;
660
661 // Do a linear search through the array of ScenePresence references
662 // and update the modified entry
663 for (int i = 0; i < m_scenePresenceArray.Length; i++)
664 {
665 if (m_scenePresenceArray[i].UUID == presence.UUID)
666 {
667 m_scenePresenceArray[i] = presence;
668 break;
669 }
670 }
671 }
651 } 672 }
652 } 673 }
653 674
@@ -663,16 +684,30 @@ namespace OpenSim.Region.Framework.Scenes
663 agentID); 684 agentID);
664 } 685 }
665 686
666 lock (ScenePresences) 687 lock (m_scenePresences)
667 { 688 {
668 if (!ScenePresences.Remove(agentID)) 689 if (m_scenePresences.Remove(agentID))
690 {
691 // Copy all of the elements from the previous array
692 // into the new array except the removed element
693 int oldLength = m_scenePresenceArray.Length;
694 ScenePresence[] newArray = new ScenePresence[oldLength - 1];
695 int j = 0;
696 for (int i = 0; i < m_scenePresenceArray.Length; i++)
697 {
698 ScenePresence presence = m_scenePresenceArray[i];
699 if (presence.UUID != agentID)
700 {
701 newArray[j] = presence;
702 ++j;
703 }
704 }
705 m_scenePresenceArray = newArray;
706 }
707 else
669 { 708 {
670 m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); 709 m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID);
671 } 710 }
672// else
673// {
674// m_log.InfoFormat("[SCENE] Removed scene presence {0} from scene presences list", agentID);
675// }
676 } 711 }
677 } 712 }
678 713
@@ -704,20 +739,21 @@ namespace OpenSim.Region.Framework.Scenes
704 739
705 public void RecalculateStats() 740 public void RecalculateStats()
706 { 741 {
707 List<ScenePresence> SPList = GetScenePresences(); 742 ScenePresence[] presences = GetScenePresences();
708 int rootcount = 0; 743 int rootcount = 0;
709 int childcount = 0; 744 int childcount = 0;
710 745
711 foreach (ScenePresence user in SPList) 746 for (int i = 0; i < presences.Length; i++)
712 { 747 {
748 ScenePresence user = presences[i];
713 if (user.IsChildAgent) 749 if (user.IsChildAgent)
714 childcount++; 750 ++childcount;
715 else 751 else
716 rootcount++; 752 ++rootcount;
717 } 753 }
754
718 m_numRootAgents = rootcount; 755 m_numRootAgents = rootcount;
719 m_numChildAgents = childcount; 756 m_numChildAgents = childcount;
720
721 } 757 }
722 758
723 public int GetChildAgentCount() 759 public int GetChildAgentCount()
@@ -767,12 +803,9 @@ namespace OpenSim.Region.Framework.Scenes
767 /// locking is required to iterate over it. 803 /// locking is required to iterate over it.
768 /// </summary> 804 /// </summary>
769 /// <returns></returns> 805 /// <returns></returns>
770 protected internal List<ScenePresence> GetScenePresences() 806 protected internal ScenePresence[] GetScenePresences()
771 { 807 {
772 lock (ScenePresences) 808 return m_scenePresenceArray;
773 {
774 return new List<ScenePresence>(ScenePresences.Values);
775 }
776 } 809 }
777 810
778 protected internal List<ScenePresence> GetAvatars() 811 protected internal List<ScenePresence> GetAvatars()
@@ -817,14 +850,13 @@ namespace OpenSim.Region.Framework.Scenes
817 // No locking of scene presences here since we're passing back a list... 850 // No locking of scene presences here since we're passing back a list...
818 851
819 List<ScenePresence> result = new List<ScenePresence>(); 852 List<ScenePresence> result = new List<ScenePresence>();
820 List<ScenePresence> ScenePresencesList = GetScenePresences(); 853 ScenePresence[] scenePresences = GetScenePresences();
821 854
822 foreach (ScenePresence avatar in ScenePresencesList) 855 for (int i = 0; i < scenePresences.Length; i++)
823 { 856 {
857 ScenePresence avatar = scenePresences[i];
824 if (filter(avatar)) 858 if (filter(avatar))
825 {
826 result.Add(avatar); 859 result.Add(avatar);
827 }
828 } 860 }
829 861
830 return result; 862 return result;
@@ -839,9 +871,9 @@ namespace OpenSim.Region.Framework.Scenes
839 { 871 {
840 ScenePresence sp; 872 ScenePresence sp;
841 873
842 lock (ScenePresences) 874 lock (m_scenePresences)
843 { 875 {
844 ScenePresences.TryGetValue(agentID, out sp); 876 m_scenePresences.TryGetValue(agentID, out sp);
845 } 877 }
846 878
847 return sp; 879 return sp;
@@ -1000,48 +1032,24 @@ namespace OpenSim.Region.Framework.Scenes
1000 1032
1001 protected internal bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) 1033 protected internal bool TryGetAvatar(UUID avatarId, out ScenePresence avatar)
1002 { 1034 {
1003 ScenePresence presence; 1035 lock (m_scenePresences)
1004 1036 return m_scenePresences.TryGetValue(avatarId, out avatar);
1005 lock (ScenePresences)
1006 {
1007 if (ScenePresences.TryGetValue(avatarId, out presence))
1008 {
1009 avatar = presence;
1010 return true;
1011
1012 //if (!presence.IsChildAgent)
1013 //{
1014 // avatar = presence;
1015 // return true;
1016 //}
1017 //else
1018 //{
1019 // m_log.WarnFormat(
1020 // "[INNER SCENE]: Requested avatar {0} could not be found in scene {1} since it is only registered as a child agent!",
1021 // avatarId, m_parentScene.RegionInfo.RegionName);
1022 //}
1023 }
1024 }
1025
1026 avatar = null;
1027 return false;
1028 } 1037 }
1029 1038
1030 protected internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) 1039 protected internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
1031 { 1040 {
1032 lock (ScenePresences) 1041 ScenePresence[] presences = GetScenePresences();
1042
1043 for (int i = 0; i < presences.Length; i++)
1033 { 1044 {
1034 foreach (ScenePresence presence in ScenePresences.Values) 1045 ScenePresence presence = presences[i];
1046
1047 if (!presence.IsChildAgent)
1035 { 1048 {
1036 if (!presence.IsChildAgent) 1049 if (String.Compare(avatarName, presence.ControllingClient.Name, true) == 0)
1037 { 1050 {
1038 string name = presence.ControllingClient.Name; 1051 avatar = presence;
1039 1052 return true;
1040 if (String.Compare(avatarName, name, true) == 0)
1041 {
1042 avatar = presence;
1043 return true;
1044 }
1045 } 1053 }
1046 } 1054 }
1047 } 1055 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index 3097929..dfaa7ea 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -411,41 +411,46 @@ namespace OpenSim.Region.Framework.Scenes
411 /// <param name="newDebug"></param> 411 /// <param name="newDebug"></param>
412 public void SetDebugPacketLevelOnCurrentScene(int newDebug) 412 public void SetDebugPacketLevelOnCurrentScene(int newDebug)
413 { 413 {
414 ForEachCurrentScene(delegate(Scene scene) 414 ForEachCurrentScene(
415 { 415 delegate(Scene scene)
416 List<ScenePresence> scenePresences = scene.GetScenePresences(); 416 {
417 ScenePresence[] scenePresences = scene.GetScenePresences();
418
419 for (int i = 0; i < scenePresences.Length; i++)
420 {
421 ScenePresence scenePresence = scenePresences[i];
417 422
418 foreach (ScenePresence scenePresence in scenePresences) 423 if (!scenePresence.IsChildAgent)
419 { 424 {
420 if (!scenePresence.IsChildAgent) 425 m_log.ErrorFormat("Packet debug for {0} {1} set to {2}",
421 { 426 scenePresence.Firstname,
422 m_log.ErrorFormat("Packet debug for {0} {1} set to {2}", 427 scenePresence.Lastname,
423 scenePresence.Firstname, 428 newDebug);
424 scenePresence.Lastname,
425 newDebug);
426 429
427 scenePresence.ControllingClient.SetDebugPacketLevel(newDebug); 430 scenePresence.ControllingClient.SetDebugPacketLevel(newDebug);
428 } 431 }
429 } 432 }
430 }); 433 }
434 );
431 } 435 }
432 436
433 public List<ScenePresence> GetCurrentSceneAvatars() 437 public List<ScenePresence> GetCurrentSceneAvatars()
434 { 438 {
435 List<ScenePresence> avatars = new List<ScenePresence>(); 439 List<ScenePresence> avatars = new List<ScenePresence>();
436 440
437 ForEachCurrentScene(delegate(Scene scene) 441 ForEachCurrentScene(
438 { 442 delegate(Scene scene)
439 List<ScenePresence> scenePresences = scene.GetScenePresences();
440
441 foreach (ScenePresence scenePresence in scenePresences)
442 { 443 {
443 if (!scenePresence.IsChildAgent) 444 ScenePresence[] scenePresences = scene.GetScenePresences();
445
446 for (int i = 0; i < scenePresences.Length; i++)
444 { 447 {
445 avatars.Add(scenePresence); 448 ScenePresence scenePresence = scenePresences[i];
449 if (!scenePresence.IsChildAgent)
450 avatars.Add(scenePresence);
446 } 451 }
447 } 452 }
448 }); 453 );
449 454
450 return avatars; 455 return avatars;
451 } 456 }
@@ -456,7 +461,7 @@ namespace OpenSim.Region.Framework.Scenes
456 461
457 ForEachCurrentScene(delegate(Scene scene) 462 ForEachCurrentScene(delegate(Scene scene)
458 { 463 {
459 List<ScenePresence> scenePresences = scene.GetScenePresences(); 464 ScenePresence[] scenePresences = scene.GetScenePresences();
460 presences.AddRange(scenePresences); 465 presences.AddRange(scenePresences);
461 }); 466 });
462 467
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 69b3ded..4f19761 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1182,8 +1182,8 @@ namespace OpenSim.Region.Framework.Scenes
1182 { 1182 {
1183// part.Inventory.RemoveScriptInstances(); 1183// part.Inventory.RemoveScriptInstances();
1184 1184
1185 List<ScenePresence> avatars = Scene.GetScenePresences(); 1185 ScenePresence[] avatars = Scene.GetScenePresences();
1186 for (int i = 0; i < avatars.Count; i++) 1186 for (int i = 0; i < avatars.Length; i++)
1187 { 1187 {
1188 if (avatars[i].ParentID == LocalId) 1188 if (avatars[i].ParentID == LocalId)
1189 { 1189 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 32171a0..7193002 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1077,8 +1077,8 @@ if (m_shape != null) {
1077 1077
1078 private void SendObjectPropertiesToClient(UUID AgentID) 1078 private void SendObjectPropertiesToClient(UUID AgentID)
1079 { 1079 {
1080 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 1080 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
1081 for (int i = 0; i < avatars.Count; i++) 1081 for (int i = 0; i < avatars.Length; i++)
1082 { 1082 {
1083 // Ugly reference :( 1083 // Ugly reference :(
1084 if (avatars[i].UUID == AgentID) 1084 if (avatars[i].UUID == AgentID)
@@ -1140,8 +1140,8 @@ if (m_shape != null) {
1140 /// </summary> 1140 /// </summary>
1141 public void AddFullUpdateToAllAvatars() 1141 public void AddFullUpdateToAllAvatars()
1142 { 1142 {
1143 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 1143 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
1144 for (int i = 0; i < avatars.Count; i++) 1144 for (int i = 0; i < avatars.Length; i++)
1145 { 1145 {
1146 avatars[i].SceneViewer.QueuePartForUpdate(this); 1146 avatars[i].SceneViewer.QueuePartForUpdate(this);
1147 } 1147 }
@@ -1165,8 +1165,8 @@ if (m_shape != null) {
1165 /// Terse updates 1165 /// Terse updates
1166 public void AddTerseUpdateToAllAvatars() 1166 public void AddTerseUpdateToAllAvatars()
1167 { 1167 {
1168 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 1168 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
1169 for (int i = 0; i < avatars.Count; i++) 1169 for (int i = 0; i < avatars.Length; i++)
1170 { 1170 {
1171 avatars[i].SceneViewer.QueuePartForUpdate(this); 1171 avatars[i].SceneViewer.QueuePartForUpdate(this);
1172 } 1172 }
@@ -1894,24 +1894,24 @@ if (m_shape != null) {
1894 } 1894 }
1895 else 1895 else
1896 { 1896 {
1897 List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); 1897 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences();
1898 if (avlist != null) 1898
1899 for (int i = 0; i < avlist.Length; i++)
1899 { 1900 {
1900 foreach (ScenePresence av in avlist) 1901 ScenePresence av = avlist[i];
1902
1903 if (av.LocalId == localId)
1901 { 1904 {
1902 if (av.LocalId == localId) 1905 DetectedObject detobj = new DetectedObject();
1903 { 1906 detobj.keyUUID = av.UUID;
1904 DetectedObject detobj = new DetectedObject(); 1907 detobj.nameStr = av.ControllingClient.Name;
1905 detobj.keyUUID = av.UUID; 1908 detobj.ownerUUID = av.UUID;
1906 detobj.nameStr = av.ControllingClient.Name; 1909 detobj.posVector = av.AbsolutePosition;
1907 detobj.ownerUUID = av.UUID; 1910 detobj.rotQuat = av.Rotation;
1908 detobj.posVector = av.AbsolutePosition; 1911 detobj.velVector = av.Velocity;
1909 detobj.rotQuat = av.Rotation; 1912 detobj.colliderType = 0;
1910 detobj.velVector = av.Velocity; 1913 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
1911 detobj.colliderType = 0; 1914 colliding.Add(detobj);
1912 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
1913 colliding.Add(detobj);
1914 }
1915 } 1915 }
1916 } 1916 }
1917 } 1917 }
@@ -1965,26 +1965,25 @@ if (m_shape != null) {
1965 } 1965 }
1966 else 1966 else
1967 { 1967 {
1968 List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); 1968 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences();
1969 if (avlist != null) 1969
1970 for (int i = 0; i < avlist.Length; i++)
1970 { 1971 {
1971 foreach (ScenePresence av in avlist) 1972 ScenePresence av = avlist[i];
1973
1974 if (av.LocalId == localId)
1972 { 1975 {
1973 if (av.LocalId == localId) 1976 DetectedObject detobj = new DetectedObject();
1974 { 1977 detobj.keyUUID = av.UUID;
1975 DetectedObject detobj = new DetectedObject(); 1978 detobj.nameStr = av.Name;
1976 detobj.keyUUID = av.UUID; 1979 detobj.ownerUUID = av.UUID;
1977 detobj.nameStr = av.Name; 1980 detobj.posVector = av.AbsolutePosition;
1978 detobj.ownerUUID = av.UUID; 1981 detobj.rotQuat = av.Rotation;
1979 detobj.posVector = av.AbsolutePosition; 1982 detobj.velVector = av.Velocity;
1980 detobj.rotQuat = av.Rotation; 1983 detobj.colliderType = 0;
1981 detobj.velVector = av.Velocity; 1984 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
1982 detobj.colliderType = 0; 1985 colliding.Add(detobj);
1983 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
1984 colliding.Add(detobj);
1985 }
1986 } 1986 }
1987
1988 } 1987 }
1989 } 1988 }
1990 } 1989 }
@@ -2035,24 +2034,24 @@ if (m_shape != null) {
2035 } 2034 }
2036 else 2035 else
2037 { 2036 {
2038 List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); 2037 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences();
2039 if (avlist != null) 2038
2039 for (int i = 0; i < avlist.Length; i++)
2040 { 2040 {
2041 foreach (ScenePresence av in avlist) 2041 ScenePresence av = avlist[i];
2042
2043 if (av.LocalId == localId)
2042 { 2044 {
2043 if (av.LocalId == localId) 2045 DetectedObject detobj = new DetectedObject();
2044 { 2046 detobj.keyUUID = av.UUID;
2045 DetectedObject detobj = new DetectedObject(); 2047 detobj.nameStr = av.Name;
2046 detobj.keyUUID = av.UUID; 2048 detobj.ownerUUID = av.UUID;
2047 detobj.nameStr = av.Name; 2049 detobj.posVector = av.AbsolutePosition;
2048 detobj.ownerUUID = av.UUID; 2050 detobj.rotQuat = av.Rotation;
2049 detobj.posVector = av.AbsolutePosition; 2051 detobj.velVector = av.Velocity;
2050 detobj.rotQuat = av.Rotation; 2052 detobj.colliderType = 0;
2051 detobj.velVector = av.Velocity; 2053 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
2052 detobj.colliderType = 0; 2054 colliding.Add(detobj);
2053 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
2054 colliding.Add(detobj);
2055 }
2056 } 2055 }
2057 } 2056 }
2058 } 2057 }
@@ -2312,8 +2311,8 @@ if (m_shape != null) {
2312 /// </summary> 2311 /// </summary>
2313 public void SendFullUpdateToAllClients() 2312 public void SendFullUpdateToAllClients()
2314 { 2313 {
2315 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 2314 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2316 for (int i = 0; i < avatars.Count; i++) 2315 for (int i = 0; i < avatars.Length; i++)
2317 { 2316 {
2318 // Ugly reference :( 2317 // Ugly reference :(
2319 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, 2318 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this,
@@ -2323,8 +2322,8 @@ if (m_shape != null) {
2323 2322
2324 public void SendFullUpdateToAllClientsExcept(UUID agentID) 2323 public void SendFullUpdateToAllClientsExcept(UUID agentID)
2325 { 2324 {
2326 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 2325 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2327 for (int i = 0; i < avatars.Count; i++) 2326 for (int i = 0; i < avatars.Length; i++)
2328 { 2327 {
2329 // Ugly reference :( 2328 // Ugly reference :(
2330 if (avatars[i].UUID != agentID) 2329 if (avatars[i].UUID != agentID)
@@ -2467,8 +2466,8 @@ if (m_shape != null) {
2467 /// </summary> 2466 /// </summary>
2468 public void SendTerseUpdateToAllClients() 2467 public void SendTerseUpdateToAllClients()
2469 { 2468 {
2470 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 2469 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2471 for (int i = 0; i < avatars.Count; i++) 2470 for (int i = 0; i < avatars.Length; i++)
2472 { 2471 {
2473 SendTerseUpdateToClient(avatars[i].ControllingClient); 2472 SendTerseUpdateToClient(avatars[i].ControllingClient);
2474 } 2473 }
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index ccfffe7..77706ac 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -869,14 +869,16 @@ namespace OpenSim.Region.Framework.Scenes
869 869
870 m_isChildAgent = false; 870 m_isChildAgent = false;
871 871
872 List<ScenePresence> AnimAgents = m_scene.GetScenePresences(); 872 ScenePresence[] animAgents = m_scene.GetScenePresences();
873 foreach (ScenePresence p in AnimAgents) 873 for (int i = 0; i < animAgents.Length; i++)
874 { 874 {
875 if (p != this) 875 ScenePresence presence = animAgents[i];
876 p.SendAnimPackToClient(ControllingClient); 876
877 if (presence != this)
878 presence.SendAnimPackToClient(ControllingClient);
877 } 879 }
878 m_scene.EventManager.TriggerOnMakeRootAgent(this);
879 880
881 m_scene.EventManager.TriggerOnMakeRootAgent(this);
880 } 882 }
881 883
882 /// <summary> 884 /// <summary>
@@ -2533,9 +2535,12 @@ namespace OpenSim.Region.Framework.Scenes
2533 { 2535 {
2534 m_perfMonMS = Environment.TickCount; 2536 m_perfMonMS = Environment.TickCount;
2535 2537
2536 List<ScenePresence> avatars = m_scene.GetScenePresences(); 2538 ScenePresence[] avatars = m_scene.GetScenePresences();
2537 foreach (ScenePresence avatar in avatars) 2539
2540 for (int i = 0; i < avatars.Length; i++)
2538 { 2541 {
2542 ScenePresence avatar = avatars[i];
2543
2539 // only send if this is the root (children are only "listening posts" in a foreign region) 2544 // only send if this is the root (children are only "listening posts" in a foreign region)
2540 if (!IsChildAgent) 2545 if (!IsChildAgent)
2541 { 2546 {
@@ -2553,7 +2558,7 @@ namespace OpenSim.Region.Framework.Scenes
2553 } 2558 }
2554 } 2559 }
2555 2560
2556 m_scene.StatsReporter.AddAgentUpdates(avatars.Count); 2561 m_scene.StatsReporter.AddAgentUpdates(avatars.Length);
2557 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2562 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
2558 2563
2559 //SendAnimPack(); 2564 //SendAnimPack();