From b82b16c954a0f3921efbdcfe7d7eb378f71e96be Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 27 Aug 2015 15:01:15 +0100 Subject: take taints check terrain out of Onframe event and add a new event for it. Slow it down to 1/4 heartbeat rate (once every 363ms aprox) --- .../CoreModules/World/Terrain/TerrainModule.cs | 9 +++---- OpenSim/Region/Framework/Scenes/EventManager.cs | 23 +++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 29 +++++++++++++++++----- 3 files changed, 50 insertions(+), 11 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 0209d16..fa357f5 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -229,11 +229,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain } m_scene.RegisterModuleInterface(this); - m_scene.EventManager.OnFrame += EventManager_OnFrame; m_scene.EventManager.OnNewClient += EventManager_OnNewClient; m_scene.EventManager.OnClientClosed += EventManager_OnClientClosed; m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick; + m_scene.EventManager.OnTerrainCheckUpdates += EventManager_TerrainCheckUpdates; } InstallDefaultEffects(); @@ -272,7 +272,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain // remove the commands m_scene.UnregisterModuleCommander(m_commander.Name); // remove the event-handlers - m_scene.EventManager.OnFrame -= EventManager_OnFrame; + m_scene.EventManager.OnTerrainCheckUpdates -= EventManager_TerrainCheckUpdates; m_scene.EventManager.OnTerrainTick -= EventManager_OnTerrainTick; m_scene.EventManager.OnPluginConsole -= EventManager_OnPluginConsole; m_scene.EventManager.OnClientClosed -= EventManager_OnClientClosed; @@ -759,13 +759,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain } /// - /// Called before processing of every simulation frame. /// This is used to check to see of any of the terrain is tainted and, if so, schedule /// updates for all the presences. /// This also checks to see if there are updates that need to be sent for each presence. /// This is where the logic is to send terrain updates to clients. /// - private void EventManager_OnFrame() + private void EventManager_TerrainCheckUpdates() { // this needs fixing TerrainData terrData = m_channel.GetTerrainData(); @@ -775,7 +774,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain { for (int y = 0; y < terrData.SizeY; y += Constants.TerrainPatchSize) { - if (terrData.IsTaintedAt(x, y)) + if (terrData.IsTaintedAt(x, y,true)) { // Found a patch that was modified. Push this flag into the clients. SendToClients(terrData, x, y); diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 692e0c9..24fbef9 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -80,6 +80,7 @@ namespace OpenSim.Region.Framework.Scenes public event OnTerrainTaintedDelegate OnTerrainTainted; public delegate void OnTerrainTickDelegate(); + public delegate void OnTerrainCheckUpdatesDelegate(); /// /// Triggered if the terrain has been edited @@ -89,6 +90,7 @@ namespace OpenSim.Region.Framework.Scenes /// but is used by core solely to update the physics engine. /// public event OnTerrainTickDelegate OnTerrainTick; + public event OnTerrainCheckUpdatesDelegate OnTerrainCheckUpdates; public delegate void OnTerrainUpdateDelegate(); @@ -1484,6 +1486,27 @@ namespace OpenSim.Region.Framework.Scenes } } + public void TriggerTerrainCheckUpdates() + { + OnTerrainCheckUpdatesDelegate TerrainCheckUpdates = OnTerrainCheckUpdates; + if (TerrainCheckUpdates != null) + { + foreach (OnTerrainCheckUpdatesDelegate d in TerrainCheckUpdates.GetInvocationList()) + { + try + { + d(); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TerrainCheckUpdates failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } + public void TriggerTerrainTainted() { OnTerrainTaintedDelegate handlerTerrainTainted = OnTerrainTainted; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d6a1fab..41f8871 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -245,8 +245,8 @@ namespace OpenSim.Region.Framework.Scenes get { return m_defaultDrawDistance; } } -// protected float m_maxDrawDistance = 512.0f; - protected float m_maxDrawDistance = 256.0f; + protected float m_maxDrawDistance = 512.0f; +// protected float m_maxDrawDistance = 256.0f; public float MaxDrawDistance { get { return m_maxDrawDistance; } @@ -1581,13 +1581,20 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerRegionHeartbeatStart(this); // Apply taints in terrain module to terrain in physics scene + + tmpMS = Util.EnvironmentTickCount(); + if (Frame % 4 == 0) + { + CheckTerrainUpdates(); + } + if (Frame % m_update_terrain == 0) { - tmpMS = Util.EnvironmentTickCount(); UpdateTerrain(); - terrainMS = Util.EnvironmentTickCountSubtract(tmpMS); } + terrainMS = Util.EnvironmentTickCountSubtract(tmpMS); + tmpMS = Util.EnvironmentTickCount(); if (PhysicsEnabled && Frame % m_update_physics == 0) m_sceneGraph.UpdatePreparePhysics(); @@ -1809,6 +1816,11 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerTerrainTick(); } + private void CheckTerrainUpdates() + { + EventManager.TriggerTerrainCheckUpdates(); + } + /// /// Back up queued up changes /// @@ -5880,11 +5892,12 @@ Environment.Exit(1); /// or corssing the broder walking, but will NOT prevent /// child agent creation, thereby emulating the SL behavior. /// - /// + /// The visitor's User ID + /// The visitor's Home URI (may be null) /// /// /// - public bool QueryAccess(UUID agentID, Vector3 position, out string reason) + public bool QueryAccess(UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string reason) { reason = "You are banned from the region"; @@ -5894,6 +5907,10 @@ Environment.Exit(1); return true; } + +// if (!AllowAvatarCrossing && !viaTeleport) +// return false; + // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. // However, the long term fix is to make sure root agent count is always accurate. m_sceneGraph.RecalculateStats(); -- cgit v1.1