aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneGraph.cs
diff options
context:
space:
mode:
authorMelanie2011-03-27 21:41:54 +0100
committerMelanie2011-03-27 21:41:54 +0100
commita62b435a396a5837fd1e26ac905520f895d8610a (patch)
tree743b8cb91fa101ce461b2fc8ebf7078165e3c7d1 /OpenSim/Region/Framework/Scenes/SceneGraph.cs
parentUpgrade terse to full update on root rotation change. Not entirely sure why, ... (diff)
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC_OLD-a62b435a396a5837fd1e26ac905520f895d8610a.zip
opensim-SC_OLD-a62b435a396a5837fd1e26ac905520f895d8610a.tar.gz
opensim-SC_OLD-a62b435a396a5837fd1e26ac905520f895d8610a.tar.bz2
opensim-SC_OLD-a62b435a396a5837fd1e26ac905520f895d8610a.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneGraph.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs125
1 files changed, 86 insertions, 39 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index e8cf4f4..62e7d36 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -97,9 +97,21 @@ namespace OpenSim.Region.Framework.Scenes
97 protected internal object m_syncRoot = new object(); 97 protected internal object m_syncRoot = new object();
98 98
99 protected internal PhysicsScene _PhyScene; 99 protected internal PhysicsScene _PhyScene;
100 100
101 protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalID = new Dictionary<uint, SceneObjectGroup>(); 101 /// <summary>
102 /// Index the SceneObjectGroup for each part by the root part's UUID.
103 /// </summary>
102 protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullID = new Dictionary<UUID, SceneObjectGroup>(); 104 protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullID = new Dictionary<UUID, SceneObjectGroup>();
105
106 /// <summary>
107 /// Index the SceneObjectGroup for each part by that part's UUID.
108 /// </summary>
109 protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullPartID = new Dictionary<UUID, SceneObjectGroup>();
110
111 /// <summary>
112 /// Index the SceneObjectGroup for each part by that part's local ID.
113 /// </summary>
114 protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>();
103 115
104 private Object m_updateLock = new Object(); 116 private Object m_updateLock = new Object();
105 117
@@ -147,8 +159,10 @@ namespace OpenSim.Region.Framework.Scenes
147 159
148 lock (SceneObjectGroupsByFullID) 160 lock (SceneObjectGroupsByFullID)
149 SceneObjectGroupsByFullID.Clear(); 161 SceneObjectGroupsByFullID.Clear();
150 lock (SceneObjectGroupsByLocalID) 162 lock (SceneObjectGroupsByFullPartID)
151 SceneObjectGroupsByLocalID.Clear(); 163 SceneObjectGroupsByFullPartID.Clear();
164 lock (SceneObjectGroupsByLocalPartID)
165 SceneObjectGroupsByLocalPartID.Clear();
152 166
153 Entities.Clear(); 167 Entities.Clear();
154 } 168 }
@@ -390,6 +404,10 @@ namespace OpenSim.Region.Framework.Scenes
390 404
391 if (Entities.ContainsKey(sceneObject.UUID)) 405 if (Entities.ContainsKey(sceneObject.UUID))
392 return false; 406 return false;
407
408// m_log.DebugFormat(
409// "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}",
410// sceneObject.Name, sceneObject.UUID, sceneObject.Parts.Length, m_parentScene.RegionInfo.RegionName);
393 411
394 SceneObjectPart[] children = sceneObject.Parts; 412 SceneObjectPart[] children = sceneObject.Parts;
395 413
@@ -426,17 +444,20 @@ namespace OpenSim.Region.Framework.Scenes
426 OnObjectCreate(sceneObject); 444 OnObjectCreate(sceneObject);
427 445
428 lock (SceneObjectGroupsByFullID) 446 lock (SceneObjectGroupsByFullID)
429 {
430 SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; 447 SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject;
448
449 lock (SceneObjectGroupsByFullPartID)
450 {
451 SceneObjectGroupsByFullPartID[sceneObject.UUID] = sceneObject;
431 foreach (SceneObjectPart part in children) 452 foreach (SceneObjectPart part in children)
432 SceneObjectGroupsByFullID[part.UUID] = sceneObject; 453 SceneObjectGroupsByFullPartID[part.UUID] = sceneObject;
433 } 454 }
434 455
435 lock (SceneObjectGroupsByLocalID) 456 lock (SceneObjectGroupsByLocalPartID)
436 { 457 {
437 SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; 458 SceneObjectGroupsByLocalPartID[sceneObject.LocalId] = sceneObject;
438 foreach (SceneObjectPart part in children) 459 foreach (SceneObjectPart part in children)
439 SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; 460 SceneObjectGroupsByLocalPartID[part.LocalId] = sceneObject;
440 } 461 }
441 462
442 return true; 463 return true;
@@ -467,21 +488,24 @@ namespace OpenSim.Region.Framework.Scenes
467 488
468 if (OnObjectRemove != null) 489 if (OnObjectRemove != null)
469 OnObjectRemove(Entities[uuid]); 490 OnObjectRemove(Entities[uuid]);
470 491
471 lock (SceneObjectGroupsByFullID) 492 lock (SceneObjectGroupsByFullID)
493 SceneObjectGroupsByFullID.Remove(grp.UUID);
494
495 lock (SceneObjectGroupsByFullPartID)
472 { 496 {
473 SceneObjectPart[] parts = grp.Parts; 497 SceneObjectPart[] parts = grp.Parts;
474 for (int i = 0; i < parts.Length; i++) 498 for (int i = 0; i < parts.Length; i++)
475 SceneObjectGroupsByFullID.Remove(parts[i].UUID); 499 SceneObjectGroupsByFullPartID.Remove(parts[i].UUID);
476 SceneObjectGroupsByFullID.Remove(grp.RootPart.UUID); 500 SceneObjectGroupsByFullPartID.Remove(grp.RootPart.UUID);
477 } 501 }
478 502
479 lock (SceneObjectGroupsByLocalID) 503 lock (SceneObjectGroupsByLocalPartID)
480 { 504 {
481 SceneObjectPart[] parts = grp.Parts; 505 SceneObjectPart[] parts = grp.Parts;
482 for (int i = 0; i < parts.Length; i++) 506 for (int i = 0; i < parts.Length; i++)
483 SceneObjectGroupsByLocalID.Remove(parts[i].LocalId); 507 SceneObjectGroupsByLocalPartID.Remove(parts[i].LocalId);
484 SceneObjectGroupsByLocalID.Remove(grp.RootPart.LocalId); 508 SceneObjectGroupsByLocalPartID.Remove(grp.RootPart.LocalId);
485 } 509 }
486 510
487 return Entities.Remove(uuid); 511 return Entities.Remove(uuid);
@@ -697,7 +721,7 @@ namespace OpenSim.Region.Framework.Scenes
697 if (!Entities.Remove(agentID)) 721 if (!Entities.Remove(agentID))
698 { 722 {
699 m_log.WarnFormat( 723 m_log.WarnFormat(
700 "[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list", 724 "[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list",
701 agentID); 725 agentID);
702 } 726 }
703 727
@@ -721,7 +745,7 @@ namespace OpenSim.Region.Framework.Scenes
721 } 745 }
722 else 746 else
723 { 747 {
724 m_log.WarnFormat("[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); 748 m_log.WarnFormat("[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID);
725 } 749 }
726 } 750 }
727 finally 751 finally
@@ -934,14 +958,14 @@ namespace OpenSim.Region.Framework.Scenes
934 958
935 //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID); 959 //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID);
936 SceneObjectGroup sog; 960 SceneObjectGroup sog;
937 lock (SceneObjectGroupsByLocalID) 961 lock (SceneObjectGroupsByLocalPartID)
938 SceneObjectGroupsByLocalID.TryGetValue(localID, out sog); 962 SceneObjectGroupsByLocalPartID.TryGetValue(localID, out sog);
939 963
940 if (sog != null) 964 if (sog != null)
941 { 965 {
942 if (sog.HasChildPrim(localID)) 966 if (sog.HasChildPrim(localID))
943 return sog; 967 return sog;
944 SceneObjectGroupsByLocalID.Remove(localID); 968 SceneObjectGroupsByLocalPartID.Remove(localID);
945 } 969 }
946 970
947 EntityBase[] entityList = GetEntities(); 971 EntityBase[] entityList = GetEntities();
@@ -953,8 +977,8 @@ namespace OpenSim.Region.Framework.Scenes
953 sog = (SceneObjectGroup)ent; 977 sog = (SceneObjectGroup)ent;
954 if (sog.HasChildPrim(localID)) 978 if (sog.HasChildPrim(localID))
955 { 979 {
956 lock (SceneObjectGroupsByLocalID) 980 lock (SceneObjectGroupsByLocalPartID)
957 SceneObjectGroupsByLocalID[localID] = sog; 981 SceneObjectGroupsByLocalPartID[localID] = sog;
958 return sog; 982 return sog;
959 } 983 }
960 } 984 }
@@ -971,16 +995,16 @@ namespace OpenSim.Region.Framework.Scenes
971 private SceneObjectGroup GetGroupByPrim(UUID fullID) 995 private SceneObjectGroup GetGroupByPrim(UUID fullID)
972 { 996 {
973 SceneObjectGroup sog; 997 SceneObjectGroup sog;
974 lock (SceneObjectGroupsByFullID) 998 lock (SceneObjectGroupsByFullPartID)
975 SceneObjectGroupsByFullID.TryGetValue(fullID, out sog); 999 SceneObjectGroupsByFullPartID.TryGetValue(fullID, out sog);
976 1000
977 if (sog != null) 1001 if (sog != null)
978 { 1002 {
979 if (sog.ContainsPart(fullID)) 1003 if (sog.ContainsPart(fullID))
980 return sog; 1004 return sog;
981 1005
982 lock (SceneObjectGroupsByFullID) 1006 lock (SceneObjectGroupsByFullPartID)
983 SceneObjectGroupsByFullID.Remove(fullID); 1007 SceneObjectGroupsByFullPartID.Remove(fullID);
984 } 1008 }
985 1009
986 EntityBase[] entityList = GetEntities(); 1010 EntityBase[] entityList = GetEntities();
@@ -991,8 +1015,8 @@ namespace OpenSim.Region.Framework.Scenes
991 sog = (SceneObjectGroup)ent; 1015 sog = (SceneObjectGroup)ent;
992 if (sog.HasChildPrim(fullID)) 1016 if (sog.HasChildPrim(fullID))
993 { 1017 {
994 lock (SceneObjectGroupsByFullID) 1018 lock (SceneObjectGroupsByFullPartID)
995 SceneObjectGroupsByFullID[fullID] = sog; 1019 SceneObjectGroupsByFullPartID[fullID] = sog;
996 return sog; 1020 return sog;
997 } 1021 }
998 } 1022 }
@@ -1144,16 +1168,15 @@ namespace OpenSim.Region.Framework.Scenes
1144 } 1168 }
1145 1169
1146 /// <summary> 1170 /// <summary>
1147 /// Performs action on all scene object groups. 1171 /// Performs action once on all scene object groups.
1148 /// </summary> 1172 /// </summary>
1149 /// <param name="action"></param> 1173 /// <param name="action"></param>
1150 protected internal void ForEachSOG(Action<SceneObjectGroup> action) 1174 protected internal void ForEachSOG(Action<SceneObjectGroup> action)
1151 { 1175 {
1152 EntityBase[] objlist = Entities.GetAllByType<SceneObjectGroup>(); 1176 // FIXME: Need to lock here, really.
1153 foreach (EntityBase ent in objlist) 1177 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
1178 foreach (SceneObjectGroup obj in objlist)
1154 { 1179 {
1155 SceneObjectGroup obj = (SceneObjectGroup)ent;
1156
1157 try 1180 try
1158 { 1181 {
1159 action(obj); 1182 action(obj);
@@ -1161,11 +1184,11 @@ namespace OpenSim.Region.Framework.Scenes
1161 catch (Exception e) 1184 catch (Exception e)
1162 { 1185 {
1163 // Catch it and move on. This includes situations where splist has inconsistent info 1186 // Catch it and move on. This includes situations where splist has inconsistent info
1164 m_log.WarnFormat("[SCENE]: Problem processing action in ForEachSOG: ", e.ToString()); 1187 m_log.WarnFormat(
1188 "[SCENEGRAPH]: Problem processing action in ForEachSOG: {0} {1}", e.Message, e.StackTrace);
1165 } 1189 }
1166 } 1190 }
1167 } 1191 }
1168
1169 1192
1170 /// <summary> 1193 /// <summary>
1171 /// Performs action on all scene presences. This can ultimately run the actions in parallel but 1194 /// Performs action on all scene presences. This can ultimately run the actions in parallel but
@@ -1185,8 +1208,8 @@ namespace OpenSim.Region.Framework.Scenes
1185 } 1208 }
1186 catch (Exception e) 1209 catch (Exception e)
1187 { 1210 {
1188 m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); 1211 m_log.Info("[SCENEGRAPH]: Error in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1189 m_log.Info("[BUG] Stack Trace: " + e.StackTrace); 1212 m_log.Info("[SCENEGRAPH]: Stack Trace: " + e.StackTrace);
1190 } 1213 }
1191 }); 1214 });
1192 Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction); 1215 Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction);
@@ -1201,7 +1224,7 @@ namespace OpenSim.Region.Framework.Scenes
1201 } 1224 }
1202 catch (Exception e) 1225 catch (Exception e)
1203 { 1226 {
1204 m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); 1227 m_log.Error("[SCENEGRAPH]: Error in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1205 } 1228 }
1206 } 1229 }
1207 } 1230 }
@@ -1884,7 +1907,10 @@ namespace OpenSim.Region.Framework.Scenes
1884 /// <param name="rot"></param> 1907 /// <param name="rot"></param>
1885 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) 1908 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot)
1886 { 1909 {
1887 //m_log.DebugFormat("[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", originalPrim, offset, AgentID); 1910// m_log.DebugFormat(
1911// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}",
1912// originalPrimID, offset, AgentID);
1913
1888 SceneObjectGroup original = GetGroupByPrim(originalPrimID); 1914 SceneObjectGroup original = GetGroupByPrim(originalPrimID);
1889 if (original != null) 1915 if (original != null)
1890 { 1916 {
@@ -1912,7 +1938,28 @@ namespace OpenSim.Region.Framework.Scenes
1912 } 1938 }
1913 } 1939 }
1914 1940
1941 // FIXME: This section needs to be refactored so that it just calls AddSceneObject()
1915 Entities.Add(copy); 1942 Entities.Add(copy);
1943
1944 lock (SceneObjectGroupsByFullID)
1945 SceneObjectGroupsByFullID[copy.UUID] = copy;
1946
1947 SceneObjectPart[] children = copy.Parts;
1948
1949 lock (SceneObjectGroupsByFullPartID)
1950 {
1951 SceneObjectGroupsByFullPartID[copy.UUID] = copy;
1952 foreach (SceneObjectPart part in children)
1953 SceneObjectGroupsByFullPartID[part.UUID] = copy;
1954 }
1955
1956 lock (SceneObjectGroupsByLocalPartID)
1957 {
1958 SceneObjectGroupsByLocalPartID[copy.LocalId] = copy;
1959 foreach (SceneObjectPart part in children)
1960 SceneObjectGroupsByLocalPartID[copy.LocalId] = copy;
1961 }
1962 // PROBABLE END OF FIXME
1916 1963
1917 // Since we copy from a source group that is in selected 1964 // Since we copy from a source group that is in selected
1918 // state, but the copy is shown deselected in the viewer, 1965 // state, but the copy is shown deselected in the viewer,