aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs115
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs28
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs5
6 files changed, 91 insertions, 100 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 4ae4dc3..ac89f7b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -390,6 +390,32 @@ namespace OpenSim.Region.Framework.Scenes
390 EventManager.TriggerScriptReset(part.LocalId, itemID); 390 EventManager.TriggerScriptReset(part.LocalId, itemID);
391 } 391 }
392 } 392 }
393
394 void ProcessViewerEffect(IClientAPI remoteClient, List<ViewerEffectEventHandlerArg> args)
395 {
396 // TODO: don't create new blocks if recycling an old packet
397 List<ViewerEffectPacket.EffectBlock> effectBlock = new List<ViewerEffectPacket.EffectBlock>();
398 for (int i = 0; i < args.Count; i++)
399 {
400 ViewerEffectPacket.EffectBlock effect = new ViewerEffectPacket.EffectBlock();
401 effect.AgentID = args[i].AgentID;
402 effect.Color = args[i].Color;
403 effect.Duration = args[i].Duration;
404 effect.ID = args[i].ID;
405 effect.Type = args[i].Type;
406 effect.TypeData = args[i].TypeData;
407 effectBlock.Add(effect);
408 }
409 ViewerEffectPacket.EffectBlock[] effectBlockArray = effectBlock.ToArray();
410
411 ClientManager.ForEach(
412 delegate(IClientAPI client)
413 {
414 if (client.AgentId != remoteClient.AgentId)
415 client.SendViewerEffect(effectBlockArray);
416 }
417 );
418 }
393 419
394 /// <summary> 420 /// <summary>
395 /// Handle a fetch inventory request from the client 421 /// Handle a fetch inventory request from the client
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 04eb93f..14e4534 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
@@ -2436,6 +2428,8 @@ namespace OpenSim.Region.Framework.Scenes
2436 /// <param name="client"></param> 2428 /// <param name="client"></param>
2437 public override void AddNewClient(IClientAPI client) 2429 public override void AddNewClient(IClientAPI client)
2438 { 2430 {
2431 ClientManager.Add(client);
2432
2439 CheckHeartbeat(); 2433 CheckHeartbeat();
2440 SubscribeToClientEvents(client); 2434 SubscribeToClientEvents(client);
2441 ScenePresence presence; 2435 ScenePresence presence;
@@ -2645,6 +2639,7 @@ namespace OpenSim.Region.Framework.Scenes
2645 public virtual void SubscribeToClientNetworkEvents(IClientAPI client) 2639 public virtual void SubscribeToClientNetworkEvents(IClientAPI client)
2646 { 2640 {
2647 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats; 2641 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats;
2642 client.OnViewerEffect += ProcessViewerEffect;
2648 } 2643 }
2649 2644
2650 protected virtual void UnsubscribeToClientEvents(IClientAPI client) 2645 protected virtual void UnsubscribeToClientEvents(IClientAPI client)
@@ -2799,11 +2794,9 @@ namespace OpenSim.Region.Framework.Scenes
2799 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client) 2794 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client)
2800 { 2795 {
2801 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats; 2796 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats;
2797 client.OnViewerEffect -= ProcessViewerEffect;
2802 } 2798 }
2803 2799
2804
2805
2806
2807 /// <summary> 2800 /// <summary>
2808 /// Teleport an avatar to their home region 2801 /// Teleport an avatar to their home region
2809 /// </summary> 2802 /// </summary>
@@ -3076,7 +3069,9 @@ namespace OpenSim.Region.Framework.Scenes
3076 agentTransactions.RemoveAgentAssetTransactions(agentID); 3069 agentTransactions.RemoveAgentAssetTransactions(agentID);
3077 } 3070 }
3078 3071
3072 // Remove the avatar from the scene
3079 m_sceneGraph.RemoveScenePresence(agentID); 3073 m_sceneGraph.RemoveScenePresence(agentID);
3074 ClientManager.Remove(agentID);
3080 3075
3081 try 3076 try
3082 { 3077 {
@@ -3126,16 +3121,6 @@ namespace OpenSim.Region.Framework.Scenes
3126 } 3121 }
3127 3122
3128 /// <summary> 3123 /// <summary>
3129 /// Closes all endpoints with the circuitcode provided.
3130 /// </summary>
3131 /// <param name="circuitcode">Circuit Code of the endpoint to close</param>
3132 public override void CloseAllAgents(uint circuitcode)
3133 {
3134 // Called by ClientView to kill all circuit codes
3135 ClientManager.CloseAllAgents(circuitcode);
3136 }
3137
3138 /// <summary>
3139 /// Inform all other ScenePresences on this Scene that someone else has changed position on the minimap. 3124 /// Inform all other ScenePresences on this Scene that someone else has changed position on the minimap.
3140 /// </summary> 3125 /// </summary>
3141 public void NotifyMyCoarseLocationChange() 3126 public void NotifyMyCoarseLocationChange()
@@ -3456,7 +3441,7 @@ namespace OpenSim.Region.Framework.Scenes
3456 loggingOffUser.ControllingClient.Kick(message); 3441 loggingOffUser.ControllingClient.Kick(message);
3457 // Give them a second to receive the message! 3442 // Give them a second to receive the message!
3458 Thread.Sleep(1000); 3443 Thread.Sleep(1000);
3459 loggingOffUser.ControllingClient.Close(true); 3444 loggingOffUser.ControllingClient.Close();
3460 } 3445 }
3461 else 3446 else
3462 { 3447 {
@@ -3627,7 +3612,7 @@ namespace OpenSim.Region.Framework.Scenes
3627 presence.ControllingClient.SendShutdownConnectionNotice(); 3612 presence.ControllingClient.SendShutdownConnectionNotice();
3628 } 3613 }
3629 3614
3630 presence.ControllingClient.Close(true); 3615 presence.ControllingClient.Close();
3631 return true; 3616 return true;
3632 } 3617 }
3633 3618
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 0ac4ed4..cf5c3c8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -196,8 +196,6 @@ namespace OpenSim.Region.Framework.Scenes
196 /// <param name="agentID"></param> 196 /// <param name="agentID"></param>
197 public abstract void RemoveClient(UUID agentID); 197 public abstract void RemoveClient(UUID agentID);
198 198
199 public abstract void CloseAllAgents(uint circuitcode);
200
201 #endregion 199 #endregion
202 200
203 /// <summary> 201 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 54ac792..9cd2247 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -77,7 +77,7 @@ namespace OpenSim.Region.Framework.Scenes
77 77
78 protected RegionInfo m_regInfo; 78 protected RegionInfo m_regInfo;
79 protected Scene m_parentScene; 79 protected Scene m_parentScene;
80 protected Dictionary<UUID, EntityBase> m_updateList = new Dictionary<UUID, EntityBase>(); 80 protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>();
81 protected int m_numRootAgents = 0; 81 protected int m_numRootAgents = 0;
82 protected int m_numPrim = 0; 82 protected int m_numPrim = 0;
83 protected int m_numChildAgents = 0; 83 protected int m_numChildAgents = 0;
@@ -155,16 +155,6 @@ namespace OpenSim.Region.Framework.Scenes
155 } 155 }
156 } 156 }
157 157
158 protected internal void UpdateEntities()
159 {
160 List<EntityBase> updateEntities = GetEntities();
161
162 foreach (EntityBase entity in updateEntities)
163 {
164 entity.Update();
165 }
166 }
167
168 protected internal void UpdatePresences() 158 protected internal void UpdatePresences()
169 { 159 {
170 List<ScenePresence> updateScenePresences = GetScenePresences(); 160 List<ScenePresence> updateScenePresences = GetScenePresences();
@@ -365,12 +355,12 @@ namespace OpenSim.Region.Framework.Scenes
365 } 355 }
366 356
367 /// <summary> 357 /// <summary>
368 /// Add an entity to the list of prims to process on the next update 358 /// Add an object to the list of prims to process on the next update
369 /// </summary> 359 /// </summary>
370 /// <param name="obj"> 360 /// <param name="obj">
371 /// A <see cref="EntityBase"/> 361 /// A <see cref="SceneObjectGroup"/>
372 /// </param> 362 /// </param>
373 protected internal void AddToUpdateList(EntityBase obj) 363 protected internal void AddToUpdateList(SceneObjectGroup obj)
374 { 364 {
375 lock (m_updateList) 365 lock (m_updateList)
376 { 366 {
@@ -381,18 +371,18 @@ namespace OpenSim.Region.Framework.Scenes
381 /// <summary> 371 /// <summary>
382 /// Process all pending updates 372 /// Process all pending updates
383 /// </summary> 373 /// </summary>
384 protected internal void ProcessUpdates() 374 protected internal void UpdateObjectGroups()
385 { 375 {
386 Dictionary<UUID, EntityBase> updates; 376 Dictionary<UUID, SceneObjectGroup> updates;
387 // Some updates add more updates to the updateList. 377 // Some updates add more updates to the updateList.
388 // Get the current list of updates and clear the list before iterating 378 // Get the current list of updates and clear the list before iterating
389 lock (m_updateList) 379 lock (m_updateList)
390 { 380 {
391 updates = new Dictionary<UUID, EntityBase>(m_updateList); 381 updates = new Dictionary<UUID, SceneObjectGroup>(m_updateList);
392 m_updateList.Clear(); 382 m_updateList.Clear();
393 } 383 }
394 // Go through all timers 384 // Go through all updates
395 foreach (KeyValuePair<UUID, EntityBase> kvp in updates) 385 foreach (KeyValuePair<UUID, SceneObjectGroup> kvp in updates)
396 { 386 {
397 // Don't abort the whole update if one entity happens to give us an exception. 387 // Don't abort the whole update if one entity happens to give us an exception.
398 try 388 try
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 6a10618..d4cef7d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1234,6 +1234,7 @@ namespace OpenSim.Region.Framework.Scenes
1234 { 1234 {
1235 lock (m_targets) 1235 lock (m_targets)
1236 m_targets.Clear(); 1236 m_targets.Clear();
1237 m_scene.RemoveGroupTarget(this);
1237 } 1238 }
1238 1239
1239 ScheduleGroupForFullUpdate(); 1240 ScheduleGroupForFullUpdate();
@@ -1864,12 +1865,6 @@ namespace OpenSim.Region.Framework.Scenes
1864 m_rootPart.UpdateFlag = 1; 1865 m_rootPart.UpdateFlag = 1;
1865 lastPhysGroupPos = AbsolutePosition; 1866 lastPhysGroupPos = AbsolutePosition;
1866 } 1867 }
1867 //foreach (SceneObjectPart part in m_parts.Values)
1868 //{
1869 //if (part.UpdateFlag == 0) part.UpdateFlag = 1;
1870 //}
1871
1872 checkAtTargets();
1873 1868
1874 if (UsePhysics && ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) 1869 if (UsePhysics && ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1)
1875 || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) 1870 || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1)
@@ -3114,6 +3109,7 @@ namespace OpenSim.Region.Framework.Scenes
3114 { 3109 {
3115 m_targets.Add(handle, waypoint); 3110 m_targets.Add(handle, waypoint);
3116 } 3111 }
3112 m_scene.AddGroupTarget(this);
3117 return (int)handle; 3113 return (int)handle;
3118 } 3114 }
3119 3115
@@ -3121,12 +3117,13 @@ namespace OpenSim.Region.Framework.Scenes
3121 { 3117 {
3122 lock (m_targets) 3118 lock (m_targets)
3123 { 3119 {
3124 if (m_targets.ContainsKey((uint)handle)) 3120 m_targets.Remove((uint)handle);
3125 m_targets.Remove((uint)handle); 3121 if (m_targets.Count == 0)
3122 m_scene.RemoveGroupTarget(this);
3126 } 3123 }
3127 } 3124 }
3128 3125
3129 private void checkAtTargets() 3126 public void checkAtTargets()
3130 { 3127 {
3131 if (m_scriptListens_atTarget || m_scriptListens_notAtTarget) 3128 if (m_scriptListens_atTarget || m_scriptListens_notAtTarget)
3132 { 3129 {
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
index 5c9e66f..8230f32 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
@@ -61,11 +61,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
61 throw new NotImplementedException(); 61 throw new NotImplementedException();
62 } 62 }
63 63
64 public override void CloseAllAgents(uint circuitcode)
65 {
66 throw new NotImplementedException();
67 }
68
69 public override void OtherRegionUp(GridRegion otherRegion) 64 public override void OtherRegionUp(GridRegion otherRegion)
70 { 65 {
71 throw new NotImplementedException(); 66 throw new NotImplementedException();