aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs115
1 files changed, 50 insertions, 65 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 0f351ce..9f14761 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -117,6 +117,8 @@ namespace OpenSim.Region.Framework.Scenes
117 private volatile bool m_backingup = false; 117 private volatile bool m_backingup = false;
118 118
119 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 119 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
120
121 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>();
120 122
121 protected string m_simulatorVersion = "OpenSimulator Server"; 123 protected string m_simulatorVersion = "OpenSimulator Server";
122 124
@@ -246,8 +248,7 @@ namespace OpenSim.Region.Framework.Scenes
246 248
247 private int m_update_physics = 1; 249 private int m_update_physics = 1;
248 private int m_update_entitymovement = 1; 250 private int m_update_entitymovement = 1;
249 private int m_update_entities = 1; // Run through all objects checking for updates 251 private int m_update_objects = 1; // Update objects which have scheduled themselves for updates
250 private int m_update_entitiesquick = 200; // Run through objects that have scheduled updates checking for updates
251 private int m_update_presences = 1; // Update scene presence movements 252 private int m_update_presences = 1; // Update scene presence movements
252 private int m_update_events = 1; 253 private int m_update_events = 1;
253 private int m_update_backup = 200; 254 private int m_update_backup = 200;
@@ -867,7 +868,7 @@ namespace OpenSim.Region.Framework.Scenes
867 Thread.Sleep(500); 868 Thread.Sleep(500);
868 869
869 // Stop all client threads. 870 // Stop all client threads.
870 ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(true); }); 871 ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); });
871 872
872 // Stop updating the scene objects and agents. 873 // Stop updating the scene objects and agents.
873 //m_heartbeatTimer.Close(); 874 //m_heartbeatTimer.Close();
@@ -979,28 +980,7 @@ namespace OpenSim.Region.Framework.Scenes
979 maintc = Environment.TickCount; 980 maintc = Environment.TickCount;
980 981
981 TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; 982 TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate;
982 // Aquire a lock so only one update call happens at once
983 //updateLock.WaitOne();
984 float physicsFPS = 0; 983 float physicsFPS = 0;
985 //m_log.Info("sadfadf" + m_neighbours.Count.ToString());
986 int agentsInScene = m_sceneGraph.GetRootAgentCount() + m_sceneGraph.GetChildAgentCount();
987
988 if (agentsInScene > 21)
989 {
990 if (m_update_entities == 1)
991 {
992 m_update_entities = 5;
993 StatsReporter.SetUpdateMS(6000);
994 }
995 }
996 else
997 {
998 if (m_update_entities == 5)
999 {
1000 m_update_entities = 1;
1001 StatsReporter.SetUpdateMS(3000);
1002 }
1003 }
1004 984
1005 frameMS = Environment.TickCount; 985 frameMS = Environment.TickCount;
1006 try 986 try
@@ -1013,30 +993,17 @@ namespace OpenSim.Region.Framework.Scenes
1013 m_frame = 0; 993 m_frame = 0;
1014 994
1015 otherMS = Environment.TickCount; 995 otherMS = Environment.TickCount;
1016 // run through all entities looking for updates (slow)
1017 if (m_frame % m_update_entities == 0)
1018 {
1019 /* // Adam Experimental
1020 if (m_updateEntitiesThread == null)
1021 {
1022 m_updateEntitiesThread = new Thread(m_sceneGraph.UpdateEntities);
1023
1024 ThreadTracker.Add(m_updateEntitiesThread);
1025 }
1026
1027 if (m_updateEntitiesThread.ThreadState == ThreadState.Stopped)
1028 m_updateEntitiesThread.Start();
1029 */
1030 996
1031 m_sceneGraph.UpdateEntities(); 997 // Check if any objects have reached their targets
1032 } 998 CheckAtTargets();
999
1000 // Update SceneObjectGroups that have scheduled themselves for updates
1001 // Objects queue their updates onto all scene presences
1002 if (m_frame % m_update_objects == 0)
1003 m_sceneGraph.UpdateObjectGroups();
1033 1004
1034 // run through entities that have scheduled themselves for 1005 // Run through all ScenePresences looking for updates
1035 // updates looking for updates(faster) 1006 // Presence updates and queued object updates for each presence are sent to clients
1036 if (m_frame % m_update_entitiesquick == 0)
1037 m_sceneGraph.ProcessUpdates();
1038
1039 // Run through scenepresences looking for updates
1040 if (m_frame % m_update_presences == 0) 1007 if (m_frame % m_update_presences == 0)
1041 m_sceneGraph.UpdatePresences(); 1008 m_sceneGraph.UpdatePresences();
1042 1009
@@ -1140,6 +1107,31 @@ namespace OpenSim.Region.Framework.Scenes
1140 } 1107 }
1141 } 1108 }
1142 1109
1110
1111 public void AddGroupTarget(SceneObjectGroup grp)
1112 {
1113 lock(m_groupsWithTargets)
1114 m_groupsWithTargets[grp.UUID] = grp;
1115 }
1116
1117 public void RemoveGroupTarget(SceneObjectGroup grp)
1118 {
1119 lock(m_groupsWithTargets)
1120 m_groupsWithTargets.Remove(grp.UUID);
1121 }
1122
1123 private void CheckAtTargets()
1124 {
1125 lock (m_groupsWithTargets)
1126 {
1127 foreach (KeyValuePair<UUID, SceneObjectGroup> kvp in m_groupsWithTargets)
1128 {
1129 kvp.Value.checkAtTargets();
1130 }
1131 }
1132 }
1133
1134
1143 /// <summary> 1135 /// <summary>
1144 /// Send out simstats data to all clients 1136 /// Send out simstats data to all clients
1145 /// </summary> 1137 /// </summary>
@@ -1186,10 +1178,10 @@ namespace OpenSim.Region.Framework.Scenes
1186 if (!m_backingup) 1178 if (!m_backingup)
1187 { 1179 {
1188 m_backingup = true; 1180 m_backingup = true;
1189 Thread backupthread = new Thread(Backup); 1181
1190 backupthread.Name = "BackupWriter"; 1182 System.ComponentModel.BackgroundWorker backupWorker = new System.ComponentModel.BackgroundWorker();
1191 backupthread.IsBackground = true; 1183 backupWorker.DoWork += delegate(object sender, System.ComponentModel.DoWorkEventArgs e) { Backup(); };
1192 backupthread.Start(); 1184 backupWorker.RunWorkerAsync();
1193 } 1185 }
1194 } 1186 }
1195 1187
@@ -2435,6 +2427,8 @@ namespace OpenSim.Region.Framework.Scenes
2435 /// <param name="client"></param> 2427 /// <param name="client"></param>
2436 public override void AddNewClient(IClientAPI client) 2428 public override void AddNewClient(IClientAPI client)
2437 { 2429 {
2430 ClientManager.Add(client);
2431
2438 CheckHeartbeat(); 2432 CheckHeartbeat();
2439 SubscribeToClientEvents(client); 2433 SubscribeToClientEvents(client);
2440 ScenePresence presence; 2434 ScenePresence presence;
@@ -2644,6 +2638,7 @@ namespace OpenSim.Region.Framework.Scenes
2644 public virtual void SubscribeToClientNetworkEvents(IClientAPI client) 2638 public virtual void SubscribeToClientNetworkEvents(IClientAPI client)
2645 { 2639 {
2646 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats; 2640 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats;
2641 client.OnViewerEffect += ProcessViewerEffect;
2647 } 2642 }
2648 2643
2649 protected virtual void UnsubscribeToClientEvents(IClientAPI client) 2644 protected virtual void UnsubscribeToClientEvents(IClientAPI client)
@@ -2798,11 +2793,9 @@ namespace OpenSim.Region.Framework.Scenes
2798 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client) 2793 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client)
2799 { 2794 {
2800 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats; 2795 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats;
2796 client.OnViewerEffect -= ProcessViewerEffect;
2801 } 2797 }
2802 2798
2803
2804
2805
2806 /// <summary> 2799 /// <summary>
2807 /// Teleport an avatar to their home region 2800 /// Teleport an avatar to their home region
2808 /// </summary> 2801 /// </summary>
@@ -3075,7 +3068,9 @@ namespace OpenSim.Region.Framework.Scenes
3075 agentTransactions.RemoveAgentAssetTransactions(agentID); 3068 agentTransactions.RemoveAgentAssetTransactions(agentID);
3076 } 3069 }
3077 3070
3071 // Remove the avatar from the scene
3078 m_sceneGraph.RemoveScenePresence(agentID); 3072 m_sceneGraph.RemoveScenePresence(agentID);
3073 ClientManager.Remove(agentID);
3079 3074
3080 try 3075 try
3081 { 3076 {
@@ -3125,16 +3120,6 @@ namespace OpenSim.Region.Framework.Scenes
3125 } 3120 }
3126 3121
3127 /// <summary> 3122 /// <summary>
3128 /// Closes all endpoints with the circuitcode provided.
3129 /// </summary>
3130 /// <param name="circuitcode">Circuit Code of the endpoint to close</param>
3131 public override void CloseAllAgents(uint circuitcode)
3132 {
3133 // Called by ClientView to kill all circuit codes
3134 ClientManager.CloseAllAgents(circuitcode);
3135 }
3136
3137 /// <summary>
3138 /// Inform all other ScenePresences on this Scene that someone else has changed position on the minimap. 3123 /// Inform all other ScenePresences on this Scene that someone else has changed position on the minimap.
3139 /// </summary> 3124 /// </summary>
3140 public void NotifyMyCoarseLocationChange() 3125 public void NotifyMyCoarseLocationChange()
@@ -3455,7 +3440,7 @@ namespace OpenSim.Region.Framework.Scenes
3455 loggingOffUser.ControllingClient.Kick(message); 3440 loggingOffUser.ControllingClient.Kick(message);
3456 // Give them a second to receive the message! 3441 // Give them a second to receive the message!
3457 Thread.Sleep(1000); 3442 Thread.Sleep(1000);
3458 loggingOffUser.ControllingClient.Close(true); 3443 loggingOffUser.ControllingClient.Close();
3459 } 3444 }
3460 else 3445 else
3461 { 3446 {
@@ -3626,7 +3611,7 @@ namespace OpenSim.Region.Framework.Scenes
3626 presence.ControllingClient.SendShutdownConnectionNotice(); 3611 presence.ControllingClient.SendShutdownConnectionNotice();
3627 } 3612 }
3628 3613
3629 presence.ControllingClient.Close(true); 3614 presence.ControllingClient.Close();
3630 return true; 3615 return true;
3631 } 3616 }
3632 3617