aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs167
1 files changed, 17 insertions, 150 deletions
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