aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
authorMelanie2009-10-22 07:12:10 +0100
committerMelanie2009-10-22 07:12:10 +0100
commitc4969d47d9bbc22b37054451cd31451ca8d8c78a (patch)
tree788e3b034254bcf068ca950ee97a78b6aa07b386 /OpenSim/Region/Framework/Scenes/Scene.cs
parentMerge branch 'master' into vehicles (diff)
parentRemove the "mel_t" from version string (diff)
downloadopensim-SC-c4969d47d9bbc22b37054451cd31451ca8d8c78a.zip
opensim-SC-c4969d47d9bbc22b37054451cd31451ca8d8c78a.tar.gz
opensim-SC-c4969d47d9bbc22b37054451cd31451ca8d8c78a.tar.bz2
opensim-SC-c4969d47d9bbc22b37054451cd31451ca8d8c78a.tar.xz
Merge branch 'master' into vehicles
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs125
1 files changed, 71 insertions, 54 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index cc74f26..5005ac9 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -57,6 +57,12 @@ namespace OpenSim.Region.Framework.Scenes
57 57
58 public partial class Scene : SceneBase 58 public partial class Scene : SceneBase
59 { 59 {
60 public enum UpdatePrioritizationSchemes {
61 Time = 0,
62 Distance = 1,
63 SimpleAngularDistance = 2,
64 }
65
60 public delegate void SynchronizeSceneHandler(Scene scene); 66 public delegate void SynchronizeSceneHandler(Scene scene);
61 public SynchronizeSceneHandler SynchronizeScene = null; 67 public SynchronizeSceneHandler SynchronizeScene = null;
62 68
@@ -222,6 +228,10 @@ namespace OpenSim.Region.Framework.Scenes
222 protected IXMLRPC m_xmlrpcModule; 228 protected IXMLRPC m_xmlrpcModule;
223 protected IWorldComm m_worldCommModule; 229 protected IWorldComm m_worldCommModule;
224 protected IAvatarFactory m_AvatarFactory; 230 protected IAvatarFactory m_AvatarFactory;
231 public IAvatarFactory AvatarFactory
232 {
233 get { return m_AvatarFactory; }
234 }
225 protected IConfigSource m_config; 235 protected IConfigSource m_config;
226 protected IRegionSerialiserModule m_serialiser; 236 protected IRegionSerialiserModule m_serialiser;
227 protected IInterregionCommsOut m_interregionCommsOut; 237 protected IInterregionCommsOut m_interregionCommsOut;
@@ -269,9 +279,14 @@ namespace OpenSim.Region.Framework.Scenes
269 private volatile bool shuttingdown = false; 279 private volatile bool shuttingdown = false;
270 280
271 private int m_lastUpdate = Environment.TickCount; 281 private int m_lastUpdate = Environment.TickCount;
272 private int m_maxPrimsPerFrame = 200;
273 private bool m_firstHeartbeat = true; 282 private bool m_firstHeartbeat = true;
274 283
284 private UpdatePrioritizationSchemes m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time;
285 private bool m_reprioritization_enabled = true;
286 private double m_reprioritization_interval = 2000.0;
287 private double m_root_reprioritization_distance = 5.0;
288 private double m_child_reprioritization_distance = 10.0;
289
275 private object m_deleting_scene_object = new object(); 290 private object m_deleting_scene_object = new object();
276 291
277 // the minimum time that must elapse before a changed object will be considered for persisted 292 // the minimum time that must elapse before a changed object will be considered for persisted
@@ -283,6 +298,12 @@ namespace OpenSim.Region.Framework.Scenes
283 298
284 #region Properties 299 #region Properties
285 300
301 public UpdatePrioritizationSchemes UpdatePrioritizationScheme { get { return this.m_update_prioritization_scheme; } }
302 public bool IsReprioritizationEnabled { get { return m_reprioritization_enabled; } }
303 public double ReprioritizationInterval { get { return m_reprioritization_interval; } }
304 public double RootReprioritizationDistance { get { return m_root_reprioritization_distance; } }
305 public double ChildReprioritizationDistance { get { return m_child_reprioritization_distance; } }
306
286 public AgentCircuitManager AuthenticateHandler 307 public AgentCircuitManager AuthenticateHandler
287 { 308 {
288 get { return m_authenticateHandler; } 309 get { return m_authenticateHandler; }
@@ -327,12 +348,6 @@ namespace OpenSim.Region.Framework.Scenes
327 get { return m_sceneGraph.m_syncRoot; } 348 get { return m_sceneGraph.m_syncRoot; }
328 } 349 }
329 350
330 public int MaxPrimsPerFrame
331 {
332 get { return m_maxPrimsPerFrame; }
333 set { m_maxPrimsPerFrame = value; }
334 }
335
336 /// <summary> 351 /// <summary>
337 /// This is for llGetRegionFPS 352 /// This is for llGetRegionFPS
338 /// </summary> 353 /// </summary>
@@ -346,13 +361,6 @@ namespace OpenSim.Region.Framework.Scenes
346 get { return m_defaultScriptEngine; } 361 get { return m_defaultScriptEngine; }
347 } 362 }
348 363
349 // Reference to all of the agents in the scene (root and child)
350 protected Dictionary<UUID, ScenePresence> m_scenePresences
351 {
352 get { return m_sceneGraph.ScenePresences; }
353 set { m_sceneGraph.ScenePresences = value; }
354 }
355
356 public EntityManager Entities 364 public EntityManager Entities
357 { 365 {
358 get { return m_sceneGraph.Entities; } 366 get { return m_sceneGraph.Entities; }
@@ -510,7 +518,6 @@ namespace OpenSim.Region.Framework.Scenes
510 518
511 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "DotNetEngine"); 519 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "DotNetEngine");
512 520
513 m_maxPrimsPerFrame = startupConfig.GetInt("MaxPrimsPerFrame", 200);
514 IConfig packetConfig = m_config.Configs["PacketPool"]; 521 IConfig packetConfig = m_config.Configs["PacketPool"];
515 if (packetConfig != null) 522 if (packetConfig != null)
516 { 523 {
@@ -519,6 +526,35 @@ namespace OpenSim.Region.Framework.Scenes
519 } 526 }
520 527
521 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 528 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
529
530 IConfig interest_management_config = m_config.Configs["InterestManagement"];
531 if (interest_management_config != null)
532 {
533 string update_prioritization_scheme = interest_management_config.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower();
534 switch (update_prioritization_scheme)
535 {
536 case "time":
537 m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time;
538 break;
539 case "distance":
540 m_update_prioritization_scheme = UpdatePrioritizationSchemes.Distance;
541 break;
542 case "simpleangulardistance":
543 m_update_prioritization_scheme = UpdatePrioritizationSchemes.SimpleAngularDistance;
544 break;
545 default:
546 m_log.Warn("[SCENE]: UpdatePrioritizationScheme was not recognized, setting to default settomg of Time");
547 m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time;
548 break;
549 }
550
551 m_reprioritization_enabled = interest_management_config.GetBoolean("ReprioritizationEnabled", true);
552 m_reprioritization_interval = interest_management_config.GetDouble("ReprioritizationInterval", 5000.0);
553 m_root_reprioritization_distance = interest_management_config.GetDouble("RootReprioritizationDistance", 10.0);
554 m_child_reprioritization_distance = interest_management_config.GetDouble("ChildReprioritizationDistance", 20.0);
555 }
556
557 m_log.Info("[SCENE]: Using the " + m_update_prioritization_scheme + " prioritization scheme");
522 } 558 }
523 catch 559 catch
524 { 560 {
@@ -1144,14 +1180,13 @@ namespace OpenSim.Region.Framework.Scenes
1144 /// <param name="stats">Stats on the Simulator's performance</param> 1180 /// <param name="stats">Stats on the Simulator's performance</param>
1145 private void SendSimStatsPackets(SimStats stats) 1181 private void SendSimStatsPackets(SimStats stats)
1146 { 1182 {
1147 List<ScenePresence> StatSendAgents = GetScenePresences(); 1183 ForEachScenePresence(
1148 foreach (ScenePresence agent in StatSendAgents) 1184 delegate(ScenePresence agent)
1149 {
1150 if (!agent.IsChildAgent)
1151 { 1185 {
1152 agent.ControllingClient.SendSimStats(stats); 1186 if (!agent.IsChildAgent)
1187 agent.ControllingClient.SendSimStats(stats);
1153 } 1188 }
1154 } 1189 );
1155 } 1190 }
1156 1191
1157 /// <summary> 1192 /// <summary>
@@ -1200,15 +1235,6 @@ namespace OpenSim.Region.Framework.Scenes
1200 } 1235 }
1201 1236
1202 /// <summary> 1237 /// <summary>
1203 /// Perform delegate action on all clients subscribing to updates from this region.
1204 /// </summary>
1205 /// <returns></returns>
1206 public void Broadcast(Action<IClientAPI> whatToDo)
1207 {
1208 ForEachScenePresence(delegate(ScenePresence presence) { whatToDo(presence.ControllingClient); });
1209 }
1210
1211 /// <summary>
1212 /// Backup the scene. This acts as the main method of the backup thread. 1238 /// Backup the scene. This acts as the main method of the backup thread.
1213 /// </summary> 1239 /// </summary>
1214 /// <returns></returns> 1240 /// <returns></returns>
@@ -3054,17 +3080,13 @@ namespace OpenSim.Region.Framework.Scenes
3054 } 3080 }
3055 3081
3056 m_eventManager.TriggerOnRemovePresence(agentID); 3082 m_eventManager.TriggerOnRemovePresence(agentID);
3057 Broadcast(delegate(IClientAPI client) 3083 ForEachClient(
3058 { 3084 delegate(IClientAPI client)
3059 try 3085 {
3060 { 3086 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3061 client.SendKillObject(avatar.RegionHandle, avatar.LocalId); 3087 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); }
3062 } 3088 catch (NullReferenceException) { }
3063 catch (NullReferenceException) 3089 });
3064 {
3065 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
3066 }
3067 });
3068 3090
3069 ForEachScenePresence( 3091 ForEachScenePresence(
3070 delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); 3092 delegate(ScenePresence presence) { presence.CoarseLocationChange(); });
@@ -3149,7 +3171,7 @@ namespace OpenSim.Region.Framework.Scenes
3149 return; 3171 return;
3150 } 3172 }
3151 } 3173 }
3152 Broadcast(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3174 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); });
3153 } 3175 }
3154 3176
3155 #endregion 3177 #endregion
@@ -3475,10 +3497,8 @@ namespace OpenSim.Region.Framework.Scenes
3475 { 3497 {
3476 ScenePresence presence; 3498 ScenePresence presence;
3477 3499
3478 lock (m_scenePresences) 3500 lock (m_sceneGraph.ScenePresences)
3479 { 3501 m_sceneGraph.ScenePresences.TryGetValue(agentID, out presence);
3480 m_scenePresences.TryGetValue(agentID, out presence);
3481 }
3482 3502
3483 if (presence != null) 3503 if (presence != null)
3484 { 3504 {
@@ -3688,12 +3708,9 @@ namespace OpenSim.Region.Framework.Scenes
3688 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, 3708 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position,
3689 Vector3 lookAt, uint teleportFlags) 3709 Vector3 lookAt, uint teleportFlags)
3690 { 3710 {
3691 ScenePresence sp = null; 3711 ScenePresence sp;
3692 lock (m_scenePresences) 3712 lock (m_sceneGraph.ScenePresences)
3693 { 3713 m_sceneGraph.ScenePresences.TryGetValue(remoteClient.AgentId, out sp);
3694 if (m_scenePresences.ContainsKey(remoteClient.AgentId))
3695 sp = m_scenePresences[remoteClient.AgentId];
3696 }
3697 3714
3698 if (sp != null) 3715 if (sp != null)
3699 { 3716 {
@@ -4142,7 +4159,7 @@ namespace OpenSim.Region.Framework.Scenes
4142 public void ForEachScenePresence(Action<ScenePresence> action) 4159 public void ForEachScenePresence(Action<ScenePresence> action)
4143 { 4160 {
4144 // We don't want to try to send messages if there are no avatars. 4161 // We don't want to try to send messages if there are no avatars.
4145 if (m_scenePresences != null) 4162 if (m_sceneGraph != null && m_sceneGraph.ScenePresences != null)
4146 { 4163 {
4147 try 4164 try
4148 { 4165 {
@@ -4222,7 +4239,7 @@ namespace OpenSim.Region.Framework.Scenes
4222 4239
4223 public void ForEachClient(Action<IClientAPI> action) 4240 public void ForEachClient(Action<IClientAPI> action)
4224 { 4241 {
4225 m_sceneGraph.ForEachClient(action); 4242 ClientManager.ForEach(action);
4226 } 4243 }
4227 4244
4228 public void ForEachSOG(Action<SceneObjectGroup> action) 4245 public void ForEachSOG(Action<SceneObjectGroup> action)