From d56ed8fe9c6428a4ac3288190be303b5813b0b91 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 4 Nov 2007 22:22:53 +0000 Subject: Some more refactoring --- OpenSim/Region/Environment/Scenes/InnerScene.cs | 123 +++++++++++++++++------- 1 file changed, 88 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes/InnerScene.cs') 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 @@ -using System; +using System; using System.Collections.Generic; using System.Text; using libsecondlife; @@ -12,6 +12,7 @@ namespace OpenSim.Region.Environment.Scenes { public class InnerScene { + #region Fields public Dictionary ScenePresences; public Dictionary SceneObjects; public Dictionary Entities; @@ -19,11 +20,13 @@ namespace OpenSim.Region.Environment.Scenes public BasicQuadTreeNode QuadTree; protected RegionInfo m_regInfo; - protected Scene m_parentScene; - public PhysicsScene PhyScene; + protected PermissionManager PermissionsMngr; + + internal object m_syncRoot = new object(); - private PermissionManager PermissionsMngr; + public PhysicsScene PhyScene; + #endregion public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr) { @@ -42,6 +45,51 @@ namespace OpenSim.Region.Environment.Scenes Entities.Clear(); } + #region Update Methods + internal void UpdatePreparePhysics() + { + // If we are using a threaded physics engine + // grab the latest scene from the engine before + // trying to process it. + + // PhysX does this (runs in the background). + + if (PhyScene.IsThreaded) + { + PhyScene.GetResults(); + } + } + + internal void UpdateEntities() + { + List updateEntities = new List(Entities.Values); + + foreach (EntityBase entity in updateEntities) + { + entity.Update(); + } + } + + internal void UpdatePhysics(double elapsed) + { + lock (m_syncRoot) + { + PhyScene.Simulate((float)elapsed); + } + } + + internal void UpdateEntityMovement() + { + List moveEntities = new List(Entities.Values); + + foreach (EntityBase entity in moveEntities) + { + entity.UpdateMovement(); + } + } + #endregion + + #region Entity Methods public void AddEntityFromStorage(SceneObjectGroup sceneObject) { sceneObject.RegionHandle = m_regInfo.RegionHandle; @@ -122,6 +170,9 @@ namespace OpenSim.Region.Environment.Scenes return newAvatar; } + #endregion + + #region Get Methods /// /// Request a List of all m_scenePresences in this World @@ -175,35 +226,6 @@ namespace OpenSim.Region.Environment.Scenes return null; } - - public LLUUID ConvertLocalIDToFullID(uint localID) - { - bool hasPrim = false; - foreach (EntityBase ent in Entities.Values) - { - if (ent is SceneObjectGroup) - { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); - if (hasPrim != false) - { - return ((SceneObjectGroup)ent).GetPartsFullID(localID); - } - } - } - return LLUUID.Zero; - } - - public void SendAllSceneObjectsToClient(ScenePresence presence) - { - foreach (EntityBase ent in Entities.Values) - { - if (ent is SceneObjectGroup) - { - ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); - } - } - } - public SceneObjectPart GetSceneObjectPart(uint localID) { bool hasPrim = false; @@ -274,6 +296,37 @@ namespace OpenSim.Region.Environment.Scenes return false; } + #endregion + + #region Other Methods + + public LLUUID ConvertLocalIDToFullID(uint localID) + { + bool hasPrim = false; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObjectGroup) + { + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + if (hasPrim != false) + { + return ((SceneObjectGroup)ent).GetPartsFullID(localID); + } + } + } + return LLUUID.Zero; + } + + public void SendAllSceneObjectsToClient(ScenePresence presence) + { + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObjectGroup) + { + ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); + } + } + } internal void ForEachClient(Action action) { @@ -282,6 +335,7 @@ namespace OpenSim.Region.Environment.Scenes action(presence.ControllingClient); } } + #endregion #region Client Event handlers /// @@ -307,7 +361,6 @@ namespace OpenSim.Region.Environment.Scenes } } - /// /// /// @@ -395,7 +448,6 @@ namespace OpenSim.Region.Environment.Scenes } } - /// /// /// @@ -653,3 +705,4 @@ namespace OpenSim.Region.Environment.Scenes #endregion } } + -- cgit v1.1