diff options
Some more refactoring
Diffstat (limited to '')
7 files changed, 267 insertions, 195 deletions
diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs index f78c086..852dc8e 100644 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs | |||
@@ -178,6 +178,14 @@ namespace OpenSim.Region.Communications.Local | |||
178 | return false; | 178 | return false; |
179 | } | 179 | } |
180 | 180 | ||
181 | public void TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID) | ||
182 | { | ||
183 | if (m_regionListeners.ContainsKey(regionHandle)) | ||
184 | { | ||
185 | // m_regionListeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); | ||
186 | } | ||
187 | } | ||
188 | |||
181 | public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId) | 189 | public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId) |
182 | { | 190 | { |
183 | if (m_regionListeners.ContainsKey(regionHandle)) | 191 | if (m_regionListeners.ContainsKey(regionHandle)) |
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index d9af95b..7ae95f1 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | |||
@@ -472,6 +472,11 @@ namespace OpenSim.Region.Communications.OGS1 | |||
472 | } | 472 | } |
473 | } | 473 | } |
474 | 474 | ||
475 | public void TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID) | ||
476 | { | ||
477 | |||
478 | } | ||
479 | |||
475 | public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId) | 480 | public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId) |
476 | { | 481 | { |
477 | return m_localBackend.AcknowledgeAgentCrossed(regionHandle, agentId); | 482 | return m_localBackend.AcknowledgeAgentCrossed(regionHandle, agentId); |
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 3195991..f775e22 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using libsecondlife; | 4 | using libsecondlife; |
@@ -12,6 +12,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
12 | { | 12 | { |
13 | public class InnerScene | 13 | public class InnerScene |
14 | { | 14 | { |
15 | #region Fields | ||
15 | public Dictionary<LLUUID, ScenePresence> ScenePresences; | 16 | public Dictionary<LLUUID, ScenePresence> ScenePresences; |
16 | public Dictionary<LLUUID, SceneObjectGroup> SceneObjects; | 17 | public Dictionary<LLUUID, SceneObjectGroup> SceneObjects; |
17 | public Dictionary<LLUUID, EntityBase> Entities; | 18 | public Dictionary<LLUUID, EntityBase> Entities; |
@@ -19,11 +20,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
19 | public BasicQuadTreeNode QuadTree; | 20 | public BasicQuadTreeNode QuadTree; |
20 | 21 | ||
21 | protected RegionInfo m_regInfo; | 22 | protected RegionInfo m_regInfo; |
22 | |||
23 | protected Scene m_parentScene; | 23 | protected Scene m_parentScene; |
24 | public PhysicsScene PhyScene; | 24 | protected PermissionManager PermissionsMngr; |
25 | |||
26 | internal object m_syncRoot = new object(); | ||
25 | 27 | ||
26 | private PermissionManager PermissionsMngr; | 28 | public PhysicsScene PhyScene; |
29 | #endregion | ||
27 | 30 | ||
28 | public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr) | 31 | public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr) |
29 | { | 32 | { |
@@ -42,6 +45,51 @@ namespace OpenSim.Region.Environment.Scenes | |||
42 | Entities.Clear(); | 45 | Entities.Clear(); |
43 | } | 46 | } |
44 | 47 | ||
48 | #region Update Methods | ||
49 | internal void UpdatePreparePhysics() | ||
50 | { | ||
51 | // If we are using a threaded physics engine | ||
52 | // grab the latest scene from the engine before | ||
53 | // trying to process it. | ||
54 | |||
55 | // PhysX does this (runs in the background). | ||
56 | |||
57 | if (PhyScene.IsThreaded) | ||
58 | { | ||
59 | PhyScene.GetResults(); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | internal void UpdateEntities() | ||
64 | { | ||
65 | List<EntityBase> updateEntities = new List<EntityBase>(Entities.Values); | ||
66 | |||
67 | foreach (EntityBase entity in updateEntities) | ||
68 | { | ||
69 | entity.Update(); | ||
70 | } | ||
71 | } | ||
72 | |||
73 | internal void UpdatePhysics(double elapsed) | ||
74 | { | ||
75 | lock (m_syncRoot) | ||
76 | { | ||
77 | PhyScene.Simulate((float)elapsed); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | internal void UpdateEntityMovement() | ||
82 | { | ||
83 | List<EntityBase> moveEntities = new List<EntityBase>(Entities.Values); | ||
84 | |||
85 | foreach (EntityBase entity in moveEntities) | ||
86 | { | ||
87 | entity.UpdateMovement(); | ||
88 | } | ||
89 | } | ||
90 | #endregion | ||
91 | |||
92 | #region Entity Methods | ||
45 | public void AddEntityFromStorage(SceneObjectGroup sceneObject) | 93 | public void AddEntityFromStorage(SceneObjectGroup sceneObject) |
46 | { | 94 | { |
47 | sceneObject.RegionHandle = m_regInfo.RegionHandle; | 95 | sceneObject.RegionHandle = m_regInfo.RegionHandle; |
@@ -122,6 +170,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
122 | 170 | ||
123 | return newAvatar; | 171 | return newAvatar; |
124 | } | 172 | } |
173 | #endregion | ||
174 | |||
175 | #region Get Methods | ||
125 | 176 | ||
126 | /// <summary> | 177 | /// <summary> |
127 | /// Request a List of all m_scenePresences in this World | 178 | /// Request a List of all m_scenePresences in this World |
@@ -175,35 +226,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
175 | return null; | 226 | return null; |
176 | } | 227 | } |
177 | 228 | ||
178 | |||
179 | public LLUUID ConvertLocalIDToFullID(uint localID) | ||
180 | { | ||
181 | bool hasPrim = false; | ||
182 | foreach (EntityBase ent in Entities.Values) | ||
183 | { | ||
184 | if (ent is SceneObjectGroup) | ||
185 | { | ||
186 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | ||
187 | if (hasPrim != false) | ||
188 | { | ||
189 | return ((SceneObjectGroup)ent).GetPartsFullID(localID); | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | return LLUUID.Zero; | ||
194 | } | ||
195 | |||
196 | public void SendAllSceneObjectsToClient(ScenePresence presence) | ||
197 | { | ||
198 | foreach (EntityBase ent in Entities.Values) | ||
199 | { | ||
200 | if (ent is SceneObjectGroup) | ||
201 | { | ||
202 | ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); | ||
203 | } | ||
204 | } | ||
205 | } | ||
206 | |||
207 | public SceneObjectPart GetSceneObjectPart(uint localID) | 229 | public SceneObjectPart GetSceneObjectPart(uint localID) |
208 | { | 230 | { |
209 | bool hasPrim = false; | 231 | bool hasPrim = false; |
@@ -274,6 +296,37 @@ namespace OpenSim.Region.Environment.Scenes | |||
274 | return false; | 296 | return false; |
275 | } | 297 | } |
276 | 298 | ||
299 | #endregion | ||
300 | |||
301 | #region Other Methods | ||
302 | |||
303 | public LLUUID ConvertLocalIDToFullID(uint localID) | ||
304 | { | ||
305 | bool hasPrim = false; | ||
306 | foreach (EntityBase ent in Entities.Values) | ||
307 | { | ||
308 | if (ent is SceneObjectGroup) | ||
309 | { | ||
310 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | ||
311 | if (hasPrim != false) | ||
312 | { | ||
313 | return ((SceneObjectGroup)ent).GetPartsFullID(localID); | ||
314 | } | ||
315 | } | ||
316 | } | ||
317 | return LLUUID.Zero; | ||
318 | } | ||
319 | |||
320 | public void SendAllSceneObjectsToClient(ScenePresence presence) | ||
321 | { | ||
322 | foreach (EntityBase ent in Entities.Values) | ||
323 | { | ||
324 | if (ent is SceneObjectGroup) | ||
325 | { | ||
326 | ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); | ||
327 | } | ||
328 | } | ||
329 | } | ||
277 | 330 | ||
278 | internal void ForEachClient(Action<IClientAPI> action) | 331 | internal void ForEachClient(Action<IClientAPI> action) |
279 | { | 332 | { |
@@ -282,6 +335,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
282 | action(presence.ControllingClient); | 335 | action(presence.ControllingClient); |
283 | } | 336 | } |
284 | } | 337 | } |
338 | #endregion | ||
285 | 339 | ||
286 | #region Client Event handlers | 340 | #region Client Event handlers |
287 | /// <summary> | 341 | /// <summary> |
@@ -307,7 +361,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
307 | } | 361 | } |
308 | } | 362 | } |
309 | 363 | ||
310 | |||
311 | /// <summary> | 364 | /// <summary> |
312 | /// | 365 | /// |
313 | /// </summary> | 366 | /// </summary> |
@@ -395,7 +448,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
395 | } | 448 | } |
396 | } | 449 | } |
397 | 450 | ||
398 | |||
399 | /// <summary> | 451 | /// <summary> |
400 | /// | 452 | /// |
401 | /// </summary> | 453 | /// </summary> |
@@ -653,3 +705,4 @@ namespace OpenSim.Region.Environment.Scenes | |||
653 | #endregion | 705 | #endregion |
654 | } | 706 | } |
655 | } | 707 | } |
708 | |||
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 49d2268..8262478 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -75,6 +75,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
75 | public CommunicationsManager CommsManager; | 75 | public CommunicationsManager CommsManager; |
76 | // protected XferManager xferManager; | 76 | // protected XferManager xferManager; |
77 | protected SceneCommunicationService m_sceneGridService; | 77 | protected SceneCommunicationService m_sceneGridService; |
78 | protected SceneXmlLoader m_sceneXmlLoader; | ||
78 | 79 | ||
79 | protected Dictionary<LLUUID, Caps> m_capsHandlers = new Dictionary<LLUUID, Caps>(); | 80 | protected Dictionary<LLUUID, Caps> m_capsHandlers = new Dictionary<LLUUID, Caps>(); |
80 | protected BaseHttpServer httpListener; | 81 | protected BaseHttpServer httpListener; |
@@ -140,6 +141,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
140 | get { return (m_innerScene.PhyScene); } | 141 | get { return (m_innerScene.PhyScene); } |
141 | } | 142 | } |
142 | 143 | ||
144 | public object SyncRoot | ||
145 | { | ||
146 | get { return m_innerScene.m_syncRoot; } | ||
147 | } | ||
148 | |||
143 | public EstateManager EstateManager | 149 | public EstateManager EstateManager |
144 | { | 150 | { |
145 | get { return m_estateManager; } | 151 | get { return m_estateManager; } |
@@ -207,7 +213,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
207 | m_eventManager = new EventManager(); | 213 | m_eventManager = new EventManager(); |
208 | m_permissionManager = new PermissionManager(this); | 214 | m_permissionManager = new PermissionManager(this); |
209 | 215 | ||
210 | m_innerScene = new InnerScene(this, regInfo, m_permissionManager); | 216 | m_innerScene = new InnerScene(this, m_regInfo, m_permissionManager); |
217 | m_sceneXmlLoader = new SceneXmlLoader(this, m_innerScene, m_regInfo); | ||
211 | 218 | ||
212 | m_eventManager.OnParcelPrimCountAdd += | 219 | m_eventManager.OnParcelPrimCountAdd += |
213 | m_LandManager.addPrimToLandPrimCounts; | 220 | m_LandManager.addPrimToLandPrimCounts; |
@@ -292,18 +299,18 @@ namespace OpenSim.Region.Environment.Scenes | |||
292 | m_frame = 0; | 299 | m_frame = 0; |
293 | 300 | ||
294 | if (m_frame%m_update_physics == 0) | 301 | if (m_frame%m_update_physics == 0) |
295 | UpdatePreparePhysics(); | 302 | m_innerScene.UpdatePreparePhysics(); |
296 | 303 | ||
297 | if (m_frame%m_update_entitymovement == 0) | 304 | if (m_frame%m_update_entitymovement == 0) |
298 | UpdateEntityMovement(); | 305 | m_innerScene.UpdateEntityMovement(); |
299 | 306 | ||
300 | if (m_frame%m_update_physics == 0) | 307 | if (m_frame%m_update_physics == 0) |
301 | UpdatePhysics( | 308 | m_innerScene.UpdatePhysics( |
302 | Math.Max(SinceLastFrame.TotalSeconds, m_timespan) | 309 | Math.Max(SinceLastFrame.TotalSeconds, m_timespan) |
303 | ); | 310 | ); |
304 | 311 | ||
305 | if (m_frame%m_update_entities == 0) | 312 | if (m_frame%m_update_entities == 0) |
306 | UpdateEntities(); | 313 | m_innerScene.UpdateEntities(); |
307 | 314 | ||
308 | if (m_frame%m_update_events == 0) | 315 | if (m_frame%m_update_events == 0) |
309 | UpdateEvents(); | 316 | UpdateEvents(); |
@@ -337,20 +344,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
337 | } | 344 | } |
338 | } | 345 | } |
339 | 346 | ||
340 | private void UpdatePreparePhysics() | ||
341 | { | ||
342 | // If we are using a threaded physics engine | ||
343 | // grab the latest scene from the engine before | ||
344 | // trying to process it. | ||
345 | |||
346 | // PhysX does this (runs in the background). | ||
347 | |||
348 | if (phyScene.IsThreaded) | ||
349 | { | ||
350 | phyScene.GetResults(); | ||
351 | } | ||
352 | } | ||
353 | |||
354 | private void UpdateInWorldTime() | 347 | private void UpdateInWorldTime() |
355 | { | 348 | { |
356 | m_timeUpdateCount++; | 349 | m_timeUpdateCount++; |
@@ -388,7 +381,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
388 | 381 | ||
389 | lock (Terrain.heightmap) | 382 | lock (Terrain.heightmap) |
390 | { | 383 | { |
391 | lock (m_syncRoot) | 384 | lock (SyncRoot) |
392 | { | 385 | { |
393 | phyScene.SetTerrain(Terrain.GetHeights1D()); | 386 | phyScene.SetTerrain(Terrain.GetHeights1D()); |
394 | } | 387 | } |
@@ -427,34 +420,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
427 | m_eventManager.TriggerOnFrame(); | 420 | m_eventManager.TriggerOnFrame(); |
428 | } | 421 | } |
429 | 422 | ||
430 | private void UpdateEntities() | ||
431 | { | ||
432 | List<EntityBase> updateEntities = new List<EntityBase>(Entities.Values); | ||
433 | |||
434 | foreach (EntityBase entity in updateEntities) | ||
435 | { | ||
436 | entity.Update(); | ||
437 | } | ||
438 | } | ||
439 | |||
440 | private void UpdatePhysics(double elapsed) | ||
441 | { | ||
442 | lock (m_syncRoot) | ||
443 | { | ||
444 | phyScene.Simulate((float) elapsed); | ||
445 | } | ||
446 | } | ||
447 | |||
448 | private void UpdateEntityMovement() | ||
449 | { | ||
450 | List<EntityBase> moveEntities = new List<EntityBase>(Entities.Values); | ||
451 | |||
452 | foreach (EntityBase entity in moveEntities) | ||
453 | { | ||
454 | entity.UpdateMovement(); | ||
455 | } | ||
456 | } | ||
457 | |||
458 | /// <summary> | 423 | /// <summary> |
459 | /// Perform delegate action on all clients subscribing to updates from this region. | 424 | /// Perform delegate action on all clients subscribing to updates from this region. |
460 | /// </summary> | 425 | /// </summary> |
@@ -655,120 +620,22 @@ namespace OpenSim.Region.Environment.Scenes | |||
655 | 620 | ||
656 | public void LoadPrimsFromXml(string fileName) | 621 | public void LoadPrimsFromXml(string fileName) |
657 | { | 622 | { |
658 | XmlDocument doc = new XmlDocument(); | 623 | m_sceneXmlLoader.LoadPrimsFromXml(fileName); |
659 | XmlNode rootNode; | ||
660 | int primCount = 0; | ||
661 | if (fileName.StartsWith("http:") || File.Exists(fileName)) | ||
662 | { | ||
663 | XmlTextReader reader = new XmlTextReader(fileName); | ||
664 | reader.WhitespaceHandling = WhitespaceHandling.None; | ||
665 | doc.Load(reader); | ||
666 | reader.Close(); | ||
667 | rootNode = doc.FirstChild; | ||
668 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | ||
669 | { | ||
670 | SceneObjectGroup obj = new SceneObjectGroup(this, | ||
671 | m_regionHandle, aPrimNode.OuterXml); | ||
672 | //if we want this to be a import method then we need new uuids for the object to avoid any clashes | ||
673 | //obj.RegenerateFullIDs(); | ||
674 | AddEntity(obj); | ||
675 | |||
676 | SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); | ||
677 | bool UsePhysics = ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0); | ||
678 | if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) | ||
679 | rootPart.PhysActor = phyScene.AddPrimShape( | ||
680 | rootPart.Name, | ||
681 | rootPart.Shape, | ||
682 | new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, | ||
683 | rootPart.AbsolutePosition.Z), | ||
684 | new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), | ||
685 | new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, | ||
686 | rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); | ||
687 | primCount++; | ||
688 | } | ||
689 | } | ||
690 | else | ||
691 | { | ||
692 | throw new Exception("Could not open file " + fileName + " for reading"); | ||
693 | } | ||
694 | } | 624 | } |
695 | 625 | ||
696 | public void SavePrimsToXml(string fileName) | 626 | public void SavePrimsToXml(string fileName) |
697 | { | 627 | { |
698 | FileStream file = new FileStream(fileName, FileMode.Create); | 628 | m_sceneXmlLoader.SavePrimsToXml(fileName); |
699 | StreamWriter stream = new StreamWriter(file); | ||
700 | int primCount = 0; | ||
701 | stream.WriteLine("<scene>\n"); | ||
702 | foreach (EntityBase ent in Entities.Values) | ||
703 | { | ||
704 | if (ent is SceneObjectGroup) | ||
705 | { | ||
706 | stream.WriteLine(((SceneObjectGroup) ent).ToXmlString()); | ||
707 | primCount++; | ||
708 | } | ||
709 | } | ||
710 | stream.WriteLine("</scene>\n"); | ||
711 | stream.Close(); | ||
712 | file.Close(); | ||
713 | } | 629 | } |
714 | 630 | ||
715 | public void LoadPrimsFromXml2(string fileName) | 631 | public void LoadPrimsFromXml2(string fileName) |
716 | { | 632 | { |
717 | XmlDocument doc = new XmlDocument(); | 633 | m_sceneXmlLoader.LoadPrimsFromXml2(fileName); |
718 | XmlNode rootNode; | ||
719 | if (fileName.StartsWith("http:") || File.Exists(fileName)) | ||
720 | { | ||
721 | XmlTextReader reader = new XmlTextReader(fileName); | ||
722 | reader.WhitespaceHandling = WhitespaceHandling.None; | ||
723 | doc.Load(reader); | ||
724 | reader.Close(); | ||
725 | rootNode = doc.FirstChild; | ||
726 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | ||
727 | { | ||
728 | CreatePrimFromXml(aPrimNode.OuterXml); | ||
729 | } | ||
730 | } | ||
731 | else | ||
732 | { | ||
733 | throw new Exception("Could not open file " + fileName + " for reading"); | ||
734 | } | ||
735 | } | ||
736 | |||
737 | public void CreatePrimFromXml(string xmlData) | ||
738 | { | ||
739 | SceneObjectGroup obj = new SceneObjectGroup(xmlData); | ||
740 | AddEntityFromStorage(obj); | ||
741 | |||
742 | SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); | ||
743 | bool UsePhysics = ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0); | ||
744 | if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) | ||
745 | rootPart.PhysActor = phyScene.AddPrimShape( | ||
746 | rootPart.Name, | ||
747 | rootPart.Shape, | ||
748 | new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, | ||
749 | rootPart.AbsolutePosition.Z), | ||
750 | new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), | ||
751 | new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, | ||
752 | rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); | ||
753 | } | 634 | } |
754 | 635 | ||
755 | public void SavePrimsToXml2(string fileName) | 636 | public void SavePrimsToXml2(string fileName) |
756 | { | 637 | { |
757 | FileStream file = new FileStream(fileName, FileMode.Create); | 638 | m_sceneXmlLoader.SavePrimsToXml2(fileName); |
758 | StreamWriter stream = new StreamWriter(file); | ||
759 | int primCount = 0; | ||
760 | stream.WriteLine("<scene>\n"); | ||
761 | foreach (EntityBase ent in Entities.Values) | ||
762 | { | ||
763 | if (ent is SceneObjectGroup) | ||
764 | { | ||
765 | stream.WriteLine(((SceneObjectGroup) ent).ToXmlString2()); | ||
766 | primCount++; | ||
767 | } | ||
768 | } | ||
769 | stream.WriteLine("</scene>\n"); | ||
770 | stream.Close(); | ||
771 | file.Close(); | ||
772 | } | 639 | } |
773 | 640 | ||
774 | #endregion | 641 | #endregion |
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index b0ec352..ace1788 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs | |||
@@ -45,7 +45,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
45 | get { return m_clientManager; } | 45 | get { return m_clientManager; } |
46 | } | 46 | } |
47 | 47 | ||
48 | // public Dictionary<LLUUID, EntityBase> Entities; | ||
49 | protected ulong m_regionHandle; | 48 | protected ulong m_regionHandle; |
50 | protected string m_regionName; | 49 | protected string m_regionName; |
51 | protected RegionInfo m_regInfo; | 50 | protected RegionInfo m_regInfo; |
@@ -66,7 +65,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
66 | 65 | ||
67 | protected string m_datastore; | 66 | protected string m_datastore; |
68 | 67 | ||
69 | protected object m_syncRoot = new object(); | ||
70 | private uint m_nextLocalId = 8880000; | 68 | private uint m_nextLocalId = 8880000; |
71 | private AssetCache m_assetCache; | 69 | private AssetCache m_assetCache; |
72 | 70 | ||
@@ -132,11 +130,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
132 | get { return m_regInfo; } | 130 | get { return m_regInfo; } |
133 | } | 131 | } |
134 | 132 | ||
135 | public object SyncRoot | ||
136 | { | ||
137 | get { return m_syncRoot; } | ||
138 | } | ||
139 | |||
140 | public uint NextLocalId | 133 | public uint NextLocalId |
141 | { | 134 | { |
142 | get { return m_nextLocalId++; } | 135 | get { return m_nextLocalId++; } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index e67d413..fe8414d 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Net; | 3 | using System.Net; |
4 | using System.Text; | 4 | using System.Text; |
@@ -204,9 +204,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
204 | return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying); | 204 | return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying); |
205 | } | 205 | } |
206 | 206 | ||
207 | public void CloseAgentConnection(ScenePresence presence) | 207 | public void CloseChildAgentConnections(ScenePresence presence) |
208 | { | 208 | { |
209 | throw new Exception("The method or operation is not implemented."); | 209 | |
210 | } | 210 | } |
211 | } | 211 | } |
212 | } | 212 | } |
213 | |||
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs new file mode 100644 index 0000000..1176e13 --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs | |||
@@ -0,0 +1,145 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using System.Xml; | ||
5 | using System.IO; | ||
6 | using libsecondlife; | ||
7 | using Axiom.Math; | ||
8 | using OpenSim.Framework; | ||
9 | using OpenSim.Region.Physics.Manager; | ||
10 | |||
11 | namespace OpenSim.Region.Environment.Scenes | ||
12 | { | ||
13 | public class SceneXmlLoader //Most likely can move to a module | ||
14 | { | ||
15 | protected InnerScene m_innerScene; | ||
16 | protected RegionInfo m_regInfo; | ||
17 | protected Scene m_parentScene; | ||
18 | |||
19 | public SceneXmlLoader(Scene parentScene, InnerScene innerScene, RegionInfo regionInfo) | ||
20 | { | ||
21 | m_parentScene = parentScene; | ||
22 | m_innerScene = innerScene; | ||
23 | m_regInfo = regionInfo; | ||
24 | } | ||
25 | |||
26 | public void LoadPrimsFromXml(string fileName) | ||
27 | { | ||
28 | XmlDocument doc = new XmlDocument(); | ||
29 | XmlNode rootNode; | ||
30 | int primCount = 0; | ||
31 | if (fileName.StartsWith("http:") || File.Exists(fileName)) | ||
32 | { | ||
33 | XmlTextReader reader = new XmlTextReader(fileName); | ||
34 | reader.WhitespaceHandling = WhitespaceHandling.None; | ||
35 | doc.Load(reader); | ||
36 | reader.Close(); | ||
37 | rootNode = doc.FirstChild; | ||
38 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | ||
39 | { | ||
40 | SceneObjectGroup obj = new SceneObjectGroup(m_parentScene, | ||
41 | m_regInfo.RegionHandle, aPrimNode.OuterXml); | ||
42 | //if we want this to be a import method then we need new uuids for the object to avoid any clashes | ||
43 | //obj.RegenerateFullIDs(); | ||
44 | m_innerScene.AddEntity(obj); | ||
45 | |||
46 | SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); | ||
47 | bool UsePhysics = ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0); | ||
48 | if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) | ||
49 | rootPart.PhysActor = m_innerScene.PhyScene.AddPrimShape( | ||
50 | rootPart.Name, | ||
51 | rootPart.Shape, | ||
52 | new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, | ||
53 | rootPart.AbsolutePosition.Z), | ||
54 | new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), | ||
55 | new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, | ||
56 | rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); | ||
57 | primCount++; | ||
58 | } | ||
59 | } | ||
60 | else | ||
61 | { | ||
62 | throw new Exception("Could not open file " + fileName + " for reading"); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | public void SavePrimsToXml(string fileName) | ||
67 | { | ||
68 | FileStream file = new FileStream(fileName, FileMode.Create); | ||
69 | StreamWriter stream = new StreamWriter(file); | ||
70 | int primCount = 0; | ||
71 | stream.WriteLine("<scene>\n"); | ||
72 | foreach (EntityBase ent in m_innerScene.Entities.Values) | ||
73 | { | ||
74 | if (ent is SceneObjectGroup) | ||
75 | { | ||
76 | stream.WriteLine(((SceneObjectGroup)ent).ToXmlString()); | ||
77 | primCount++; | ||
78 | } | ||
79 | } | ||
80 | stream.WriteLine("</scene>\n"); | ||
81 | stream.Close(); | ||
82 | file.Close(); | ||
83 | } | ||
84 | |||
85 | public void LoadPrimsFromXml2(string fileName) | ||
86 | { | ||
87 | XmlDocument doc = new XmlDocument(); | ||
88 | XmlNode rootNode; | ||
89 | if (fileName.StartsWith("http:") || File.Exists(fileName)) | ||
90 | { | ||
91 | XmlTextReader reader = new XmlTextReader(fileName); | ||
92 | reader.WhitespaceHandling = WhitespaceHandling.None; | ||
93 | doc.Load(reader); | ||
94 | reader.Close(); | ||
95 | rootNode = doc.FirstChild; | ||
96 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | ||
97 | { | ||
98 | CreatePrimFromXml(aPrimNode.OuterXml); | ||
99 | } | ||
100 | } | ||
101 | else | ||
102 | { | ||
103 | throw new Exception("Could not open file " + fileName + " for reading"); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | public void CreatePrimFromXml(string xmlData) | ||
108 | { | ||
109 | SceneObjectGroup obj = new SceneObjectGroup(xmlData); | ||
110 | m_innerScene.AddEntityFromStorage(obj); | ||
111 | |||
112 | SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); | ||
113 | bool UsePhysics = ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0); | ||
114 | if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) | ||
115 | rootPart.PhysActor = m_innerScene.PhyScene.AddPrimShape( | ||
116 | rootPart.Name, | ||
117 | rootPart.Shape, | ||
118 | new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, | ||
119 | rootPart.AbsolutePosition.Z), | ||
120 | new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), | ||
121 | new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, | ||
122 | rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); | ||
123 | } | ||
124 | |||
125 | public void SavePrimsToXml2(string fileName) | ||
126 | { | ||
127 | FileStream file = new FileStream(fileName, FileMode.Create); | ||
128 | StreamWriter stream = new StreamWriter(file); | ||
129 | int primCount = 0; | ||
130 | stream.WriteLine("<scene>\n"); | ||
131 | foreach (EntityBase ent in m_innerScene.Entities.Values) | ||
132 | { | ||
133 | if (ent is SceneObjectGroup) | ||
134 | { | ||
135 | stream.WriteLine(((SceneObjectGroup)ent).ToXmlString2()); | ||
136 | primCount++; | ||
137 | } | ||
138 | } | ||
139 | stream.WriteLine("</scene>\n"); | ||
140 | stream.Close(); | ||
141 | file.Close(); | ||
142 | } | ||
143 | |||
144 | } | ||
145 | } | ||