diff options
author | Sean McNamara | 2011-04-10 18:28:54 -0400 |
---|---|---|
committer | Sean McNamara | 2011-04-10 18:28:54 -0400 |
commit | 9c0f3c73b1fd56ac145e866af0316a3285ddb689 (patch) | |
tree | 03541a853c2ecf5829ac296537b14d4553ad4b2e /OpenSim/Region/Framework/Scenes/SceneGraph.cs | |
parent | Merge git://opensimulator.org/git/opensim (diff) | |
parent | minor: remove mono compiler warnings (diff) | |
download | opensim-SC-9c0f3c73b1fd56ac145e866af0316a3285ddb689.zip opensim-SC-9c0f3c73b1fd56ac145e866af0316a3285ddb689.tar.gz opensim-SC-9c0f3c73b1fd56ac145e866af0316a3285ddb689.tar.bz2 opensim-SC-9c0f3c73b1fd56ac145e866af0316a3285ddb689.tar.xz |
Merge git://opensimulator.org/git/opensim
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneGraph.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 119 |
1 files changed, 84 insertions, 35 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 734ba22..97af0a0 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> SceneObjectGroupsByLocalID = new Dictionary<uint, SceneObjectGroup>(); | 92 | /// <summary> |
93 | /// Index the SceneObjectGroup for each part by the root part's UUID. | ||
94 | /// </summary> | ||
93 | protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullID = new Dictionary<UUID, SceneObjectGroup>(); | 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> | ||
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 | ||
@@ -133,8 +145,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
133 | 145 | ||
134 | lock (SceneObjectGroupsByFullID) | 146 | lock (SceneObjectGroupsByFullID) |
135 | SceneObjectGroupsByFullID.Clear(); | 147 | SceneObjectGroupsByFullID.Clear(); |
136 | lock (SceneObjectGroupsByLocalID) | 148 | lock (SceneObjectGroupsByFullPartID) |
137 | SceneObjectGroupsByLocalID.Clear(); | 149 | SceneObjectGroupsByFullPartID.Clear(); |
150 | lock (SceneObjectGroupsByLocalPartID) | ||
151 | SceneObjectGroupsByLocalPartID.Clear(); | ||
138 | 152 | ||
139 | Entities.Clear(); | 153 | Entities.Clear(); |
140 | } | 154 | } |
@@ -349,6 +363,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
349 | 363 | ||
350 | if (Entities.ContainsKey(sceneObject.UUID)) | 364 | if (Entities.ContainsKey(sceneObject.UUID)) |
351 | return false; | 365 | return false; |
366 | |||
367 | // m_log.DebugFormat( | ||
368 | // "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}", | ||
369 | // sceneObject.Name, sceneObject.UUID, sceneObject.Parts.Length, m_parentScene.RegionInfo.RegionName); | ||
352 | 370 | ||
353 | SceneObjectPart[] children = sceneObject.Parts; | 371 | SceneObjectPart[] children = sceneObject.Parts; |
354 | 372 | ||
@@ -385,17 +403,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
385 | OnObjectCreate(sceneObject); | 403 | OnObjectCreate(sceneObject); |
386 | 404 | ||
387 | lock (SceneObjectGroupsByFullID) | 405 | lock (SceneObjectGroupsByFullID) |
388 | { | ||
389 | SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; | 406 | SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; |
407 | |||
408 | lock (SceneObjectGroupsByFullPartID) | ||
409 | { | ||
410 | SceneObjectGroupsByFullPartID[sceneObject.UUID] = sceneObject; | ||
390 | foreach (SceneObjectPart part in children) | 411 | foreach (SceneObjectPart part in children) |
391 | SceneObjectGroupsByFullID[part.UUID] = sceneObject; | 412 | SceneObjectGroupsByFullPartID[part.UUID] = sceneObject; |
392 | } | 413 | } |
393 | 414 | ||
394 | lock (SceneObjectGroupsByLocalID) | 415 | lock (SceneObjectGroupsByLocalPartID) |
395 | { | 416 | { |
396 | SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; | 417 | SceneObjectGroupsByLocalPartID[sceneObject.LocalId] = sceneObject; |
397 | foreach (SceneObjectPart part in children) | 418 | foreach (SceneObjectPart part in children) |
398 | SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; | 419 | SceneObjectGroupsByLocalPartID[part.LocalId] = sceneObject; |
399 | } | 420 | } |
400 | 421 | ||
401 | return true; | 422 | return true; |
@@ -426,21 +447,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
426 | 447 | ||
427 | if (OnObjectRemove != null) | 448 | if (OnObjectRemove != null) |
428 | OnObjectRemove(Entities[uuid]); | 449 | OnObjectRemove(Entities[uuid]); |
429 | 450 | ||
430 | lock (SceneObjectGroupsByFullID) | 451 | lock (SceneObjectGroupsByFullID) |
452 | SceneObjectGroupsByFullID.Remove(grp.UUID); | ||
453 | |||
454 | lock (SceneObjectGroupsByFullPartID) | ||
431 | { | 455 | { |
432 | SceneObjectPart[] parts = grp.Parts; | 456 | SceneObjectPart[] parts = grp.Parts; |
433 | for (int i = 0; i < parts.Length; i++) | 457 | for (int i = 0; i < parts.Length; i++) |
434 | SceneObjectGroupsByFullID.Remove(parts[i].UUID); | 458 | SceneObjectGroupsByFullPartID.Remove(parts[i].UUID); |
435 | SceneObjectGroupsByFullID.Remove(grp.RootPart.UUID); | 459 | SceneObjectGroupsByFullPartID.Remove(grp.RootPart.UUID); |
436 | } | 460 | } |
437 | 461 | ||
438 | lock (SceneObjectGroupsByLocalID) | 462 | lock (SceneObjectGroupsByLocalPartID) |
439 | { | 463 | { |
440 | SceneObjectPart[] parts = grp.Parts; | 464 | SceneObjectPart[] parts = grp.Parts; |
441 | for (int i = 0; i < parts.Length; i++) | 465 | for (int i = 0; i < parts.Length; i++) |
442 | SceneObjectGroupsByLocalID.Remove(parts[i].LocalId); | 466 | SceneObjectGroupsByLocalPartID.Remove(parts[i].LocalId); |
443 | SceneObjectGroupsByLocalID.Remove(grp.RootPart.LocalId); | 467 | SceneObjectGroupsByLocalPartID.Remove(grp.RootPart.LocalId); |
444 | } | 468 | } |
445 | 469 | ||
446 | return Entities.Remove(uuid); | 470 | return Entities.Remove(uuid); |
@@ -627,7 +651,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
627 | if (!Entities.Remove(agentID)) | 651 | if (!Entities.Remove(agentID)) |
628 | { | 652 | { |
629 | m_log.WarnFormat( | 653 | m_log.WarnFormat( |
630 | "[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list", | 654 | "[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list", |
631 | agentID); | 655 | agentID); |
632 | } | 656 | } |
633 | 657 | ||
@@ -650,7 +674,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
650 | } | 674 | } |
651 | else | 675 | else |
652 | { | 676 | { |
653 | m_log.WarnFormat("[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); | 677 | m_log.WarnFormat("[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); |
654 | } | 678 | } |
655 | } | 679 | } |
656 | } | 680 | } |
@@ -854,14 +878,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
854 | 878 | ||
855 | //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID); | 879 | //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID); |
856 | SceneObjectGroup sog; | 880 | SceneObjectGroup sog; |
857 | lock (SceneObjectGroupsByLocalID) | 881 | lock (SceneObjectGroupsByLocalPartID) |
858 | SceneObjectGroupsByLocalID.TryGetValue(localID, out sog); | 882 | SceneObjectGroupsByLocalPartID.TryGetValue(localID, out sog); |
859 | 883 | ||
860 | if (sog != null) | 884 | if (sog != null) |
861 | { | 885 | { |
862 | if (sog.HasChildPrim(localID)) | 886 | if (sog.HasChildPrim(localID)) |
863 | return sog; | 887 | return sog; |
864 | SceneObjectGroupsByLocalID.Remove(localID); | 888 | SceneObjectGroupsByLocalPartID.Remove(localID); |
865 | } | 889 | } |
866 | 890 | ||
867 | EntityBase[] entityList = GetEntities(); | 891 | EntityBase[] entityList = GetEntities(); |
@@ -873,8 +897,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
873 | sog = (SceneObjectGroup)ent; | 897 | sog = (SceneObjectGroup)ent; |
874 | if (sog.HasChildPrim(localID)) | 898 | if (sog.HasChildPrim(localID)) |
875 | { | 899 | { |
876 | lock (SceneObjectGroupsByLocalID) | 900 | lock (SceneObjectGroupsByLocalPartID) |
877 | SceneObjectGroupsByLocalID[localID] = sog; | 901 | SceneObjectGroupsByLocalPartID[localID] = sog; |
878 | return sog; | 902 | return sog; |
879 | } | 903 | } |
880 | } | 904 | } |
@@ -891,16 +915,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
891 | private SceneObjectGroup GetGroupByPrim(UUID fullID) | 915 | private SceneObjectGroup GetGroupByPrim(UUID fullID) |
892 | { | 916 | { |
893 | SceneObjectGroup sog; | 917 | SceneObjectGroup sog; |
894 | lock (SceneObjectGroupsByFullID) | 918 | lock (SceneObjectGroupsByFullPartID) |
895 | SceneObjectGroupsByFullID.TryGetValue(fullID, out sog); | 919 | SceneObjectGroupsByFullPartID.TryGetValue(fullID, out sog); |
896 | 920 | ||
897 | if (sog != null) | 921 | if (sog != null) |
898 | { | 922 | { |
899 | if (sog.ContainsPart(fullID)) | 923 | if (sog.ContainsPart(fullID)) |
900 | return sog; | 924 | return sog; |
901 | 925 | ||
902 | lock (SceneObjectGroupsByFullID) | 926 | lock (SceneObjectGroupsByFullPartID) |
903 | SceneObjectGroupsByFullID.Remove(fullID); | 927 | SceneObjectGroupsByFullPartID.Remove(fullID); |
904 | } | 928 | } |
905 | 929 | ||
906 | EntityBase[] entityList = GetEntities(); | 930 | EntityBase[] entityList = GetEntities(); |
@@ -911,8 +935,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
911 | sog = (SceneObjectGroup)ent; | 935 | sog = (SceneObjectGroup)ent; |
912 | if (sog.HasChildPrim(fullID)) | 936 | if (sog.HasChildPrim(fullID)) |
913 | { | 937 | { |
914 | lock (SceneObjectGroupsByFullID) | 938 | lock (SceneObjectGroupsByFullPartID) |
915 | SceneObjectGroupsByFullID[fullID] = sog; | 939 | SceneObjectGroupsByFullPartID[fullID] = sog; |
916 | return sog; | 940 | return sog; |
917 | } | 941 | } |
918 | } | 942 | } |
@@ -1064,11 +1088,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1064 | } | 1088 | } |
1065 | 1089 | ||
1066 | /// <summary> | 1090 | /// <summary> |
1067 | /// Performs action on all scene object groups. | 1091 | /// Performs action once on all scene object groups. |
1068 | /// </summary> | 1092 | /// </summary> |
1069 | /// <param name="action"></param> | 1093 | /// <param name="action"></param> |
1070 | protected internal void ForEachSOG(Action<SceneObjectGroup> action) | 1094 | protected internal void ForEachSOG(Action<SceneObjectGroup> action) |
1071 | { | 1095 | { |
1096 | // FIXME: Need to lock here, really. | ||
1072 | List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); | 1097 | List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); |
1073 | foreach (SceneObjectGroup obj in objlist) | 1098 | foreach (SceneObjectGroup obj in objlist) |
1074 | { | 1099 | { |
@@ -1079,11 +1104,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1079 | catch (Exception e) | 1104 | catch (Exception e) |
1080 | { | 1105 | { |
1081 | // Catch it and move on. This includes situations where splist has inconsistent info | 1106 | // Catch it and move on. This includes situations where splist has inconsistent info |
1082 | m_log.WarnFormat("[SCENE]: Problem processing action in ForEachSOG: ", e.ToString()); | 1107 | m_log.WarnFormat( |
1108 | "[SCENEGRAPH]: Problem processing action in ForEachSOG: {0} {1}", e.Message, e.StackTrace); | ||
1083 | } | 1109 | } |
1084 | } | 1110 | } |
1085 | } | 1111 | } |
1086 | |||
1087 | 1112 | ||
1088 | /// <summary> | 1113 | /// <summary> |
1089 | /// Performs action on all scene presences. This can ultimately run the actions in parallel but | 1114 | /// Performs action on all scene presences. This can ultimately run the actions in parallel but |
@@ -1103,8 +1128,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1103 | } | 1128 | } |
1104 | catch (Exception e) | 1129 | catch (Exception e) |
1105 | { | 1130 | { |
1106 | m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); | 1131 | m_log.Info("[SCENEGRAPH]: Error in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); |
1107 | m_log.Info("[BUG] Stack Trace: " + e.StackTrace); | 1132 | m_log.Info("[SCENEGRAPH]: Stack Trace: " + e.StackTrace); |
1108 | } | 1133 | } |
1109 | }); | 1134 | }); |
1110 | Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction); | 1135 | Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction); |
@@ -1119,7 +1144,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1119 | } | 1144 | } |
1120 | catch (Exception e) | 1145 | catch (Exception e) |
1121 | { | 1146 | { |
1122 | m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); | 1147 | m_log.Error("[SCENEGRAPH]: Error in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); |
1123 | } | 1148 | } |
1124 | } | 1149 | } |
1125 | } | 1150 | } |
@@ -1777,7 +1802,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1777 | /// <param name="rot"></param> | 1802 | /// <param name="rot"></param> |
1778 | public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) | 1803 | public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) |
1779 | { | 1804 | { |
1780 | //m_log.DebugFormat("[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", originalPrim, offset, AgentID); | 1805 | // m_log.DebugFormat( |
1806 | // "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", | ||
1807 | // originalPrimID, offset, AgentID); | ||
1808 | |||
1781 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); | 1809 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); |
1782 | if (original != null) | 1810 | if (original != null) |
1783 | { | 1811 | { |
@@ -1808,7 +1836,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1808 | copy.RootPart.SalePrice = 10; | 1836 | copy.RootPart.SalePrice = 10; |
1809 | } | 1837 | } |
1810 | 1838 | ||
1839 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() | ||
1811 | Entities.Add(copy); | 1840 | Entities.Add(copy); |
1841 | |||
1842 | lock (SceneObjectGroupsByFullID) | ||
1843 | SceneObjectGroupsByFullID[copy.UUID] = copy; | ||
1844 | |||
1845 | SceneObjectPart[] children = copy.Parts; | ||
1846 | |||
1847 | lock (SceneObjectGroupsByFullPartID) | ||
1848 | { | ||
1849 | SceneObjectGroupsByFullPartID[copy.UUID] = copy; | ||
1850 | foreach (SceneObjectPart part in children) | ||
1851 | SceneObjectGroupsByFullPartID[part.UUID] = copy; | ||
1852 | } | ||
1853 | |||
1854 | lock (SceneObjectGroupsByLocalPartID) | ||
1855 | { | ||
1856 | SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; | ||
1857 | foreach (SceneObjectPart part in children) | ||
1858 | SceneObjectGroupsByLocalPartID[part.LocalId] = copy; | ||
1859 | } | ||
1860 | // PROBABLE END OF FIXME | ||
1812 | 1861 | ||
1813 | // Since we copy from a source group that is in selected | 1862 | // Since we copy from a source group that is in selected |
1814 | // state, but the copy is shown deselected in the viewer, | 1863 | // state, but the copy is shown deselected in the viewer, |