aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-03-26 00:53:19 +0000
committerJustin Clark-Casey (justincc)2011-03-26 00:53:19 +0000
commit26d16567e1e2bf28a3eafce6d3acf8d9646aaf84 (patch)
tree6e2f61a3e71b6442c8aae6b2554d1475b0964290
parentrefactor: rename SOG collections in SceneGraph to make it clearer that they a... (diff)
downloadopensim-SC_OLD-26d16567e1e2bf28a3eafce6d3acf8d9646aaf84.zip
opensim-SC_OLD-26d16567e1e2bf28a3eafce6d3acf8d9646aaf84.tar.gz
opensim-SC_OLD-26d16567e1e2bf28a3eafce6d3acf8d9646aaf84.tar.bz2
opensim-SC_OLD-26d16567e1e2bf28a3eafce6d3acf8d9646aaf84.tar.xz
Make SceneGraph.ForEachSOG() execute once for each SOG, not once for each prim (e.g. a SOG with 3 prims would have the action executed three times).
To do this, a new SceneObjectGroupsByFullID index in SceneGraph which just index's prims by their root part UUID, in order to avoid the inefficiency of filtering existing lists. Existing callers to SceneGraph.ForEachSOG() did not fail due to the multiple per SOG action executions - they were probably just much less efficient. Code suggests that no callers expected ForEachSOG() to execute actions on sog multiple times
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs30
1 files changed, 25 insertions, 5 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 345ed7a..1621398 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -88,9 +88,21 @@ namespace OpenSim.Region.Framework.Scenes
88 protected internal object m_syncRoot = new object(); 88 protected internal object m_syncRoot = new object();
89 89
90 protected internal PhysicsScene _PhyScene; 90 protected internal PhysicsScene _PhyScene;
91 91
92 protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>(); 92 /// <summary>
93 /// Index the SceneObjectGroup for each part by the root part's UUID.
94 /// </summary>
95 protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullID = new Dictionary<UUID, SceneObjectGroup>();
96
97 /// <summary>
98 /// Index the SceneObjectGroup for each part by that part's UUID.
99 /// </summary>
93 protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullPartID = new Dictionary<UUID, SceneObjectGroup>(); 100 protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullPartID = new Dictionary<UUID, SceneObjectGroup>();
101
102 /// <summary>
103 /// Index the SceneObjectGroup for each part by that part's local ID.
104 /// </summary>
105 protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>();
94 106
95 private Object m_updateLock = new Object(); 107 private Object m_updateLock = new Object();
96 108
@@ -131,6 +143,8 @@ namespace OpenSim.Region.Framework.Scenes
131 m_scenePresenceArray = newlist; 143 m_scenePresenceArray = newlist;
132 } 144 }
133 145
146 lock (SceneObjectGroupsByFullID)
147 SceneObjectGroupsByFullID.Clear();
134 lock (SceneObjectGroupsByFullPartID) 148 lock (SceneObjectGroupsByFullPartID)
135 SceneObjectGroupsByFullPartID.Clear(); 149 SceneObjectGroupsByFullPartID.Clear();
136 lock (SceneObjectGroupsByLocalPartID) 150 lock (SceneObjectGroupsByLocalPartID)
@@ -384,6 +398,9 @@ namespace OpenSim.Region.Framework.Scenes
384 if (OnObjectCreate != null) 398 if (OnObjectCreate != null)
385 OnObjectCreate(sceneObject); 399 OnObjectCreate(sceneObject);
386 400
401 lock (SceneObjectGroupsByFullID)
402 SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject;
403
387 lock (SceneObjectGroupsByFullPartID) 404 lock (SceneObjectGroupsByFullPartID)
388 { 405 {
389 SceneObjectGroupsByFullPartID[sceneObject.UUID] = sceneObject; 406 SceneObjectGroupsByFullPartID[sceneObject.UUID] = sceneObject;
@@ -426,6 +443,9 @@ namespace OpenSim.Region.Framework.Scenes
426 443
427 if (OnObjectRemove != null) 444 if (OnObjectRemove != null)
428 OnObjectRemove(Entities[uuid]); 445 OnObjectRemove(Entities[uuid]);
446
447 lock (SceneObjectGroupsByFullID)
448 SceneObjectGroupsByFullID.Remove(grp.UUID);
429 449
430 lock (SceneObjectGroupsByFullPartID) 450 lock (SceneObjectGroupsByFullPartID)
431 { 451 {
@@ -1064,12 +1084,13 @@ namespace OpenSim.Region.Framework.Scenes
1064 } 1084 }
1065 1085
1066 /// <summary> 1086 /// <summary>
1067 /// Performs action on all scene object groups. 1087 /// Performs action once on all scene object groups.
1068 /// </summary> 1088 /// </summary>
1069 /// <param name="action"></param> 1089 /// <param name="action"></param>
1070 protected internal void ForEachSOG(Action<SceneObjectGroup> action) 1090 protected internal void ForEachSOG(Action<SceneObjectGroup> action)
1071 { 1091 {
1072 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullPartID.Values); 1092 // FIXME: Need to lock here, really.
1093 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
1073 foreach (SceneObjectGroup obj in objlist) 1094 foreach (SceneObjectGroup obj in objlist)
1074 { 1095 {
1075 try 1096 try
@@ -1084,7 +1105,6 @@ namespace OpenSim.Region.Framework.Scenes
1084 } 1105 }
1085 } 1106 }
1086 } 1107 }
1087
1088 1108
1089 /// <summary> 1109 /// <summary>
1090 /// Performs action on all scene presences. This can ultimately run the actions in parallel but 1110 /// Performs action on all scene presences. This can ultimately run the actions in parallel but