aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISceneViewer.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/EntityManager.cs69
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs21
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs125
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs32
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs76
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs24
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs197
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneViewer.cs23
-rw-r--r--OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Scripting/NullScriptHost.cs4
11 files changed, 373 insertions, 203 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs b/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs
index 8e3f4a0..7251d57 100644
--- a/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs
@@ -34,7 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces
34 { 34 {
35 void Reset(); 35 void Reset();
36 void Close(); 36 void Close();
37 int MaxPrimsPerFrame { get; set; }
38 void QueuePartForUpdate(SceneObjectPart part); 37 void QueuePartForUpdate(SceneObjectPart part);
39 void SendPrimUpdates(); 38 void SendPrimUpdates();
40 } 39 }
diff --git a/OpenSim/Region/Framework/Scenes/EntityManager.cs b/OpenSim/Region/Framework/Scenes/EntityManager.cs
index 0ceef39..099fcce 100644
--- a/OpenSim/Region/Framework/Scenes/EntityManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EntityManager.cs
@@ -93,40 +93,31 @@ namespace OpenSim.Region.Framework.Scenes
93 { 93 {
94 get 94 get
95 { 95 {
96 lock (m_lock) 96 return m_eb_uuid.Count;
97 {
98 return m_eb_uuid.Count;
99 }
100 } 97 }
101 } 98 }
102 99
103 public bool ContainsKey(UUID id) 100 public bool ContainsKey(UUID id)
104 { 101 {
105 lock (m_lock) 102 try
106 { 103 {
107 try 104 return m_eb_uuid.ContainsKey(id);
108 { 105 }
109 return m_eb_uuid.ContainsKey(id); 106 catch
110 } 107 {
111 catch 108 return false;
112 {
113 return false;
114 }
115 } 109 }
116 } 110 }
117 111
118 public bool ContainsKey(uint localID) 112 public bool ContainsKey(uint localID)
119 { 113 {
120 lock (m_lock) 114 try
121 { 115 {
122 try 116 return m_eb_localID.ContainsKey(localID);
123 { 117 }
124 return m_eb_localID.ContainsKey(localID); 118 catch
125 } 119 {
126 catch 120 return false;
127 {
128 return false;
129 }
130 } 121 }
131 } 122 }
132 123
@@ -136,7 +127,11 @@ namespace OpenSim.Region.Framework.Scenes
136 { 127 {
137 try 128 try
138 { 129 {
139 bool a = m_eb_uuid.Remove(m_eb_localID[localID].UUID); 130 bool a = false;
131 EntityBase entity;
132 if (m_eb_localID.TryGetValue(localID, out entity))
133 a = m_eb_uuid.Remove(entity.UUID);
134
140 bool b = m_eb_localID.Remove(localID); 135 bool b = m_eb_localID.Remove(localID);
141 return a && b; 136 return a && b;
142 } 137 }
@@ -154,7 +149,11 @@ namespace OpenSim.Region.Framework.Scenes
154 { 149 {
155 try 150 try
156 { 151 {
157 bool a = m_eb_localID.Remove(m_eb_uuid[id].LocalId); 152 bool a = false;
153 EntityBase entity;
154 if (m_eb_uuid.TryGetValue(id, out entity))
155 a = m_eb_localID.Remove(entity.LocalId);
156
158 bool b = m_eb_uuid.Remove(id); 157 bool b = m_eb_uuid.Remove(id);
159 return a && b; 158 return a && b;
160 } 159 }
@@ -206,14 +205,11 @@ namespace OpenSim.Region.Framework.Scenes
206 { 205 {
207 lock (m_lock) 206 lock (m_lock)
208 { 207 {
209 try 208 EntityBase entity;
210 { 209 if (m_eb_uuid.TryGetValue(id, out entity))
211 return m_eb_uuid[id]; 210 return entity;
212 } 211 else
213 catch
214 {
215 return null; 212 return null;
216 }
217 } 213 }
218 } 214 }
219 set 215 set
@@ -228,14 +224,11 @@ namespace OpenSim.Region.Framework.Scenes
228 { 224 {
229 lock (m_lock) 225 lock (m_lock)
230 { 226 {
231 try 227 EntityBase entity;
232 { 228 if (m_eb_localID.TryGetValue(localID, out entity))
233 return m_eb_localID[localID]; 229 return entity;
234 } 230 else
235 catch
236 {
237 return null; 231 return null;
238 }
239 } 232 }
240 } 233 }
241 set 234 set
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index c44c4c7..c2b9e73 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -2351,12 +2351,6 @@ namespace OpenSim.Region.Framework.Scenes
2351 item = InventoryService.GetItem(item); 2351 item = InventoryService.GetItem(item);
2352 2352
2353 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); 2353 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
2354 IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
2355 if (ava != null)
2356 {
2357 ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
2358 }
2359
2360 } 2354 }
2361 return att.UUID; 2355 return att.UUID;
2362 } 2356 }
@@ -2402,12 +2396,6 @@ namespace OpenSim.Region.Framework.Scenes
2402 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 2396 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2403 item = InventoryService.GetItem(item); 2397 item = InventoryService.GetItem(item);
2404 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); 2398 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
2405
2406 if (m_AvatarFactory != null)
2407 {
2408 m_log.InfoFormat("[SCENE INVENTORY]: Saving avatar attachment. AgentID:{0} ItemID:{1} AttachmentPoint:{2}", remoteClient.AgentId, itemID, AttachmentPt);
2409 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
2410 }
2411 } 2399 }
2412 } 2400 }
2413 2401
@@ -2447,12 +2435,13 @@ namespace OpenSim.Region.Framework.Scenes
2447 if (TryGetAvatar(remoteClient.AgentId, out presence)) 2435 if (TryGetAvatar(remoteClient.AgentId, out presence))
2448 { 2436 {
2449 presence.Appearance.DetachAttachment(itemID); 2437 presence.Appearance.DetachAttachment(itemID);
2450 IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>(); 2438
2451 if (ava != null) 2439 // Save avatar attachment information
2440 if (m_AvatarFactory != null)
2452 { 2441 {
2453 ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 2442 m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID);
2443 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
2454 } 2444 }
2455
2456 } 2445 }
2457 2446
2458 m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient); 2447 m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 151df27..2dbc090 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)
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 9cd2247..e51f6ef 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -467,7 +467,6 @@ namespace OpenSim.Region.Framework.Scenes
467 protected internal void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent) 467 protected internal void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent)
468 { 468 {
469 // If we can't take it, we can't attach it! 469 // If we can't take it, we can't attach it!
470 //
471 SceneObjectPart part = m_parentScene.GetSceneObjectPart(objectLocalID); 470 SceneObjectPart part = m_parentScene.GetSceneObjectPart(objectLocalID);
472 if (part == null) 471 if (part == null)
473 return; 472 return;
@@ -477,9 +476,16 @@ namespace OpenSim.Region.Framework.Scenes
477 return; 476 return;
478 477
479 // Calls attach with a Zero position 478 // Calls attach with a Zero position
480 //
481 AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false); 479 AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false);
482 m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); 480 m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId);
481
482 // Save avatar attachment information
483 ScenePresence presence;
484 if (m_parentScene.AvatarFactory != null && m_parentScene.TryGetAvatar(remoteClient.AgentId, out presence))
485 {
486 m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", AttachmentPoint: " + AttachmentPt);
487 m_parentScene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
488 }
483 } 489 }
484 490
485 public SceneObjectGroup RezSingleAttachment( 491 public SceneObjectGroup RezSingleAttachment(
@@ -574,7 +580,7 @@ namespace OpenSim.Region.Framework.Scenes
574 } 580 }
575 581
576 582
577 group.SetAttachmentPoint(Convert.ToByte(AttachmentPt)); 583 group.SetAttachmentPoint((byte)AttachmentPt);
578 group.AbsolutePosition = attachPos; 584 group.AbsolutePosition = attachPos;
579 585
580 // Saves and gets itemID 586 // Saves and gets itemID
@@ -613,7 +619,6 @@ namespace OpenSim.Region.Framework.Scenes
613 619
614 newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, appearance); 620 newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, appearance);
615 newAvatar.IsChildAgent = true; 621 newAvatar.IsChildAgent = true;
616 newAvatar.MaxPrimsPerFrame = m_parentScene.MaxPrimsPerFrame;
617 622
618 AddScenePresence(newAvatar); 623 AddScenePresence(newAvatar);
619 624
@@ -847,7 +852,7 @@ namespace OpenSim.Region.Framework.Scenes
847 /// </summary> 852 /// </summary>
848 /// <param name="localID"></param> 853 /// <param name="localID"></param>
849 /// <returns>null if no scene object group containing that prim is found</returns> 854 /// <returns>null if no scene object group containing that prim is found</returns>
850 private SceneObjectGroup GetGroupByPrim(uint localID) 855 public SceneObjectGroup GetGroupByPrim(uint localID)
851 { 856 {
852 if (Entities.ContainsKey(localID)) 857 if (Entities.ContainsKey(localID))
853 return Entities[localID] as SceneObjectGroup; 858 return Entities[localID] as SceneObjectGroup;
@@ -1107,23 +1112,6 @@ namespace OpenSim.Region.Framework.Scenes
1107 return UUID.Zero; 1112 return UUID.Zero;
1108 } 1113 }
1109 1114
1110 protected internal void ForEachClient(Action<IClientAPI> action)
1111 {
1112 List<ScenePresence> splist = GetScenePresences();
1113 foreach (ScenePresence presence in splist)
1114 {
1115 try
1116 {
1117 action(presence.ControllingClient);
1118 }
1119 catch (Exception e)
1120 {
1121 // Catch it and move on. This includes situations where splist has inconsistent info
1122 m_log.WarnFormat("[SCENE]: Problem processing action in ForEachClient: ", e.Message);
1123 }
1124 }
1125 }
1126
1127 protected internal void ForEachSOG(Action<SceneObjectGroup> action) 1115 protected internal void ForEachSOG(Action<SceneObjectGroup> action)
1128 { 1116 {
1129 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); 1117 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index d4cef7d..810dfd1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -899,7 +899,7 @@ namespace OpenSim.Region.Framework.Scenes
899 SetAttachmentPoint(Convert.ToByte(attachmentpoint)); 899 SetAttachmentPoint(Convert.ToByte(attachmentpoint));
900 900
901 avatar.AddAttachment(this); 901 avatar.AddAttachment(this);
902 m_log.DebugFormat("[SOG]: Added att {0} to avie {1}", UUID, avatar.UUID); 902 m_log.Debug("[SOG]: Added attachment " + UUID + " to avatar " + avatar.UUID);
903 903
904 if (!silent) 904 if (!silent)
905 { 905 {
@@ -1817,7 +1817,7 @@ namespace OpenSim.Region.Framework.Scenes
1817 public void ServiceObjectPropertiesFamilyRequest(IClientAPI remoteClient, UUID AgentID, uint RequestFlags) 1817 public void ServiceObjectPropertiesFamilyRequest(IClientAPI remoteClient, UUID AgentID, uint RequestFlags)
1818 { 1818 {
1819 1819
1820 remoteClient.SendObjectPropertiesFamilyData(RequestFlags, RootPart.UUID, RootPart.ObjectOwner, RootPart.GroupID, RootPart.BaseMask, 1820 remoteClient.SendObjectPropertiesFamilyData(RequestFlags, RootPart.UUID, RootPart.OwnerID, RootPart.GroupID, RootPart.BaseMask,
1821 RootPart.OwnerMask, RootPart.GroupMask, RootPart.EveryoneMask, RootPart.NextOwnerMask, 1821 RootPart.OwnerMask, RootPart.GroupMask, RootPart.EveryoneMask, RootPart.NextOwnerMask,
1822 RootPart.OwnershipCost, RootPart.ObjectSaleType, RootPart.SalePrice, RootPart.Category, 1822 RootPart.OwnershipCost, RootPart.ObjectSaleType, RootPart.SalePrice, RootPart.Category,
1823 RootPart.CreatorID, RootPart.Name, RootPart.Description); 1823 RootPart.CreatorID, RootPart.Name, RootPart.Description);
@@ -3343,5 +3343,77 @@ namespace OpenSim.Region.Framework.Scenes
3343 3343
3344 return true; 3344 return true;
3345 } 3345 }
3346
3347 public double GetUpdatePriority(IClientAPI client)
3348 {
3349 switch (Scene.UpdatePrioritizationScheme)
3350 {
3351 case Scene.UpdatePrioritizationSchemes.Time:
3352 return GetPriorityByTime();
3353 case Scene.UpdatePrioritizationSchemes.Distance:
3354 return GetPriorityByDistance(client);
3355 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3356 return GetPriorityBySimpleAngularDistance(client);
3357 default:
3358 throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
3359 }
3360 }
3361
3362 private double GetPriorityByTime()
3363 {
3364 return DateTime.Now.ToOADate();
3365 }
3366
3367 private double GetPriorityByDistance(IClientAPI client)
3368 {
3369 ScenePresence presence = Scene.GetScenePresence(client.AgentId);
3370 if (presence != null)
3371 {
3372 return GetPriorityByDistance((presence.IsChildAgent) ?
3373 presence.AbsolutePosition : presence.CameraPosition);
3374 }
3375 return double.NaN;
3376 }
3377
3378 private double GetPriorityBySimpleAngularDistance(IClientAPI client)
3379 {
3380 ScenePresence presence = Scene.GetScenePresence(client.AgentId);
3381 if (presence != null)
3382 {
3383 return GetPriorityBySimpleAngularDistance((presence.IsChildAgent) ?
3384 presence.AbsolutePosition : presence.CameraPosition);
3385 }
3386 return double.NaN;
3387 }
3388
3389 public double GetPriorityByDistance(Vector3 position)
3390 {
3391 return Vector3.Distance(AbsolutePosition, position);
3392 }
3393
3394 public double GetPriorityBySimpleAngularDistance(Vector3 position)
3395 {
3396 double distance = Vector3.Distance(position, AbsolutePosition);
3397 if (distance >= double.Epsilon)
3398 {
3399 float height;
3400 Vector3 box = GetAxisAlignedBoundingBox(out height);
3401
3402 double angle = box.X / distance;
3403 double max = angle;
3404
3405 angle = box.Y / distance;
3406 if (max < angle)
3407 max = angle;
3408
3409 angle = box.Z / distance;
3410 if (max < angle)
3411 max = angle;
3412
3413 return -max;
3414 }
3415 else
3416 return double.MinValue;
3417 }
3346 } 3418 }
3347} 3419}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 801a7db..a078b3d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -853,16 +853,6 @@ if (m_shape != null) {
853 return m_offsetPosition + m_groupPosition; } 853 return m_offsetPosition + m_groupPosition; }
854 } 854 }
855 855
856 public UUID ObjectCreator
857 {
858 get { return _creatorID; }
859 }
860
861 public UUID ObjectOwner
862 {
863 get { return _ownerID; }
864 }
865
866 public SceneObjectGroup ParentGroup 856 public SceneObjectGroup ParentGroup
867 { 857 {
868 get { return m_parentGroup; } 858 get { return m_parentGroup; }
@@ -1440,7 +1430,7 @@ if (m_shape != null) {
1440 // Move afterwards ResetIDs as it clears the localID 1430 // Move afterwards ResetIDs as it clears the localID
1441 dupe.LocalId = localID; 1431 dupe.LocalId = localID;
1442 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1432 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1443 dupe._lastOwnerID = ObjectOwner; 1433 dupe._lastOwnerID = OwnerID;
1444 1434
1445 byte[] extraP = new byte[Shape.ExtraParams.Length]; 1435 byte[] extraP = new byte[Shape.ExtraParams.Length];
1446 Array.Copy(Shape.ExtraParams, extraP, extraP.Length); 1436 Array.Copy(Shape.ExtraParams, extraP, extraP.Length);
@@ -2410,10 +2400,10 @@ if (m_shape != null) {
2410 //isattachment = ParentGroup.RootPart.IsAttachment; 2400 //isattachment = ParentGroup.RootPart.IsAttachment;
2411 2401
2412 byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; 2402 byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A};
2413 remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, 2403 remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape,
2414 lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID, 2404 lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID,
2415 m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, 2405 m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment,
2416 AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius); 2406 AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient)));
2417 } 2407 }
2418 2408
2419 /// <summary> 2409 /// <summary>
@@ -3801,15 +3791,15 @@ if (m_shape != null) {
3801 if (ParentGroup.RootPart == this) 3791 if (ParentGroup.RootPart == this)
3802 lPos = AbsolutePosition; 3792 lPos = AbsolutePosition;
3803 } 3793 }
3804 3794
3805 // Causes this thread to dig into the Client Thread Data. 3795 // Causes this thread to dig into the Client Thread Data.
3806 // Remember your locking here! 3796 // Remember your locking here!
3807 remoteClient.SendPrimTerseUpdate(m_regionHandle, 3797 remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle,
3808 (ushort)(m_parentGroup.GetTimeDilation() * 3798 (ushort)(m_parentGroup.GetTimeDilation() *
3809 (float)ushort.MaxValue), LocalId, lPos, 3799 (float)ushort.MaxValue), LocalId, lPos,
3810 RotationOffset, Velocity, 3800 RotationOffset, Velocity, Acceleration,
3811 RotationalVelocity, state, FromItemID, 3801 RotationalVelocity, state, FromItemID,
3812 OwnerID, (int)AttachmentPoint); 3802 OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient)));
3813 } 3803 }
3814 3804
3815 public void AddScriptLPS(int count) 3805 public void AddScriptLPS(int count)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index c25fa55..bdd80c6 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Timers;
31using OpenMetaverse; 32using OpenMetaverse;
32using log4net; 33using log4net;
33using OpenSim.Framework; 34using OpenSim.Framework;
@@ -172,6 +173,11 @@ namespace OpenSim.Region.Framework.Scenes
172 173
173 // Position of agent's camera in world (region cordinates) 174 // Position of agent's camera in world (region cordinates)
174 protected Vector3 m_CameraCenter = Vector3.Zero; 175 protected Vector3 m_CameraCenter = Vector3.Zero;
176 protected Vector3 m_lastCameraCenter = Vector3.Zero;
177
178 protected Timer m_reprioritization_timer;
179 protected bool m_reprioritizing = false;
180 protected bool m_reprioritization_called = false;
175 181
176 // Use these three vectors to figure out what the agent is looking at 182 // Use these three vectors to figure out what the agent is looking at
177 // Convert it to a Matrix and/or Quaternion 183 // Convert it to a Matrix and/or Quaternion
@@ -403,12 +409,6 @@ namespace OpenSim.Region.Framework.Scenes
403 set { m_parentPosition = value; } 409 set { m_parentPosition = value; }
404 } 410 }
405 411
406 public int MaxPrimsPerFrame
407 {
408 get { return m_sceneViewer.MaxPrimsPerFrame; }
409 set { m_sceneViewer.MaxPrimsPerFrame = value; }
410 }
411
412 /// <summary> 412 /// <summary>
413 /// Absolute position of this avatar in 'region cordinates' 413 /// Absolute position of this avatar in 'region cordinates'
414 /// </summary> 414 /// </summary>
@@ -645,7 +645,14 @@ namespace OpenSim.Region.Framework.Scenes
645 645
646 m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); 646 m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>();
647 647
648 AbsolutePosition = m_controllingClient.StartPos; 648 AbsolutePosition = posLastSignificantMove = m_CameraCenter =
649 m_lastCameraCenter = m_controllingClient.StartPos;
650
651 m_reprioritization_timer = new Timer(world.ReprioritizationInterval);
652 m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize);
653 m_reprioritization_timer.AutoReset = false;
654
655
649 AdjustKnownSeeds(); 656 AdjustKnownSeeds();
650 657
651 TrySetMovementAnimation("STAND"); // TODO: I think, this won't send anything, as we are still a child here... 658 TrySetMovementAnimation("STAND"); // TODO: I think, this won't send anything, as we are still a child here...
@@ -1153,15 +1160,21 @@ namespace OpenSim.Region.Framework.Scenes
1153 /// </summary> 1160 /// </summary>
1154 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 1161 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
1155 { 1162 {
1156 lock (m_agentUpdates) 1163 const int AGENT_UPDATE_TIMEOUT_MS = 1000 * 3;
1164
1165 if (System.Threading.Monitor.TryEnter(m_agentUpdates, AGENT_UPDATE_TIMEOUT_MS))
1157 { 1166 {
1158 if (m_updatesAllowed) 1167 try
1159 { 1168 {
1160 RealHandleAgentUpdate(remoteClient, agentData); 1169 if (m_updatesAllowed)
1161 return; 1170 {
1171 RealHandleAgentUpdate(remoteClient, agentData);
1172 return;
1173 }
1174
1175 m_agentUpdates.Add(agentData);
1162 } 1176 }
1163 1177 finally { System.Threading.Monitor.Exit(m_agentUpdates); }
1164 m_agentUpdates.Add(agentData);
1165 } 1178 }
1166 } 1179 }
1167 1180
@@ -1225,6 +1238,11 @@ namespace OpenSim.Region.Framework.Scenes
1225 // Camera location in world. We'll need to raytrace 1238 // Camera location in world. We'll need to raytrace
1226 // from this location from time to time. 1239 // from this location from time to time.
1227 m_CameraCenter = agentData.CameraCenter; 1240 m_CameraCenter = agentData.CameraCenter;
1241 if (Vector3.Distance(m_lastCameraCenter, m_CameraCenter) >= Scene.RootReprioritizationDistance)
1242 {
1243 ReprioritizeUpdates();
1244 m_lastCameraCenter = m_CameraCenter;
1245 }
1228 1246
1229 // Use these three vectors to figure out what the agent is looking at 1247 // Use these three vectors to figure out what the agent is looking at
1230 // Convert it to a Matrix and/or Quaternion 1248 // Convert it to a Matrix and/or Quaternion
@@ -2456,11 +2474,10 @@ namespace OpenSim.Region.Framework.Scenes
2456 m_perfMonMS = Environment.TickCount; 2474 m_perfMonMS = Environment.TickCount;
2457 2475
2458 Vector3 pos = m_pos; 2476 Vector3 pos = m_pos;
2459 Vector3 vel = Velocity;
2460 Quaternion rot = m_bodyRot;
2461 pos.Z -= m_appearance.HipOffset; 2477 pos.Z -= m_appearance.HipOffset;
2462 remoteClient.SendAvatarTerseUpdate(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, new Vector3(pos.X, pos.Y, pos.Z), 2478
2463 new Vector3(vel.X, vel.Y, vel.Z), rot, m_uuid); 2479 remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
2480 pos, m_velocity, Vector3.Zero, m_rotation, Vector4.Zero, m_uuid, null, GetUpdatePriority(remoteClient)));
2464 2481
2465 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2482 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
2466 m_scene.StatsReporter.AddAgentUpdates(1); 2483 m_scene.StatsReporter.AddAgentUpdates(1);
@@ -2474,7 +2491,7 @@ namespace OpenSim.Region.Framework.Scenes
2474 { 2491 {
2475 m_perfMonMS = Environment.TickCount; 2492 m_perfMonMS = Environment.TickCount;
2476 2493
2477 m_scene.Broadcast(SendTerseUpdateToClient); 2494 m_scene.ForEachClient(SendTerseUpdateToClient);
2478 2495
2479 m_lastVelocity = m_velocity; 2496 m_lastVelocity = m_velocity;
2480 lastPhysPos = AbsolutePosition; 2497 lastPhysPos = AbsolutePosition;
@@ -2566,9 +2583,9 @@ namespace OpenSim.Region.Framework.Scenes
2566 Vector3 pos = m_pos; 2583 Vector3 pos = m_pos;
2567 pos.Z -= m_appearance.HipOffset; 2584 pos.Z -= m_appearance.HipOffset;
2568 2585
2569 remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, 2586 remoteAvatar.m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid,
2570 LocalId, m_pos, m_appearance.Texture.GetBytes(), 2587 LocalId, m_pos, m_appearance.Texture.GetBytes(),
2571 m_parentID, rot); 2588 m_parentID, rot));
2572 m_scene.StatsReporter.AddAgentUpdates(1); 2589 m_scene.StatsReporter.AddAgentUpdates(1);
2573 } 2590 }
2574 2591
@@ -2637,8 +2654,8 @@ namespace OpenSim.Region.Framework.Scenes
2637 Vector3 pos = m_pos; 2654 Vector3 pos = m_pos;
2638 pos.Z -= m_appearance.HipOffset; 2655 pos.Z -= m_appearance.HipOffset;
2639 2656
2640 m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, 2657 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
2641 m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot); 2658 m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot));
2642 2659
2643 if (!m_isChildAgent) 2660 if (!m_isChildAgent)
2644 { 2661 {
@@ -2744,8 +2761,8 @@ namespace OpenSim.Region.Framework.Scenes
2744 } 2761 }
2745 2762
2746 Quaternion rot = m_bodyRot; 2763 Quaternion rot = m_bodyRot;
2747 m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, 2764 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
2748 m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot); 2765 m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot));
2749 2766
2750 } 2767 }
2751 2768
@@ -2776,7 +2793,7 @@ namespace OpenSim.Region.Framework.Scenes
2776 if (m_isChildAgent) 2793 if (m_isChildAgent)
2777 return; 2794 return;
2778 2795
2779 m_scene.Broadcast( 2796 m_scene.ForEachClient(
2780 delegate(IClientAPI client) { client.SendAnimations(animations, seqs, m_controllingClient.AgentId, objectIDs); }); 2797 delegate(IClientAPI client) { client.SendAnimations(animations, seqs, m_controllingClient.AgentId, objectIDs); });
2781 } 2798 }
2782 2799
@@ -2830,7 +2847,7 @@ namespace OpenSim.Region.Framework.Scenes
2830 } 2847 }
2831 2848
2832 // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m 2849 // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m
2833 if (Util.GetDistanceTo(AbsolutePosition,m_LastChildAgentUpdatePosition) > 32) 2850 if (Util.GetDistanceTo(AbsolutePosition, m_LastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance)
2834 { 2851 {
2835 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); 2852 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
2836 cadu.ActiveGroupID = UUID.Zero.Guid; 2853 cadu.ActiveGroupID = UUID.Zero.Guid;
@@ -3125,6 +3142,12 @@ namespace OpenSim.Region.Framework.Scenes
3125 if (cAgentData.Position != new Vector3(-1, -1, -1)) // UGH!! 3142 if (cAgentData.Position != new Vector3(-1, -1, -1)) // UGH!!
3126 m_pos = new Vector3(cAgentData.Position.X + shiftx, cAgentData.Position.Y + shifty, cAgentData.Position.Z); 3143 m_pos = new Vector3(cAgentData.Position.X + shiftx, cAgentData.Position.Y + shifty, cAgentData.Position.Z);
3127 3144
3145 if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance)
3146 {
3147 posLastSignificantMove = AbsolutePosition;
3148 ReprioritizeUpdates();
3149 }
3150
3128 // It's hard to say here.. We can't really tell where the camera position is unless it's in world cordinates from the sending region 3151 // It's hard to say here.. We can't really tell where the camera position is unless it's in world cordinates from the sending region
3129 m_CameraCenter = cAgentData.Center; 3152 m_CameraCenter = cAgentData.Center;
3130 3153
@@ -3487,7 +3510,6 @@ namespace OpenSim.Region.Framework.Scenes
3487 3510
3488 public void Close() 3511 public void Close()
3489 { 3512 {
3490
3491 lock (m_attachments) 3513 lock (m_attachments)
3492 { 3514 {
3493 // Delete attachments from scene 3515 // Delete attachments from scene
@@ -3505,10 +3527,19 @@ namespace OpenSim.Region.Framework.Scenes
3505 { 3527 {
3506 m_knownChildRegions.Clear(); 3528 m_knownChildRegions.Clear();
3507 } 3529 }
3530
3531 lock (m_reprioritization_timer)
3532 {
3533 m_reprioritization_timer.Enabled = false;
3534 m_reprioritization_timer.Elapsed -= new ElapsedEventHandler(Reprioritize);
3535 }
3536 // I don't get it but mono crashes when you try to dispose of this timer,
3537 // unsetting the elapsed callback should be enough to allow for cleanup however.
3538 //m_reprioritizationTimer.Dispose();
3539
3508 m_sceneViewer.Close(); 3540 m_sceneViewer.Close();
3509 3541
3510 RemoveFromPhysicalScene(); 3542 RemoveFromPhysicalScene();
3511 GC.Collect();
3512 } 3543 }
3513 3544
3514 public ScenePresence() 3545 public ScenePresence()
@@ -3884,5 +3915,115 @@ namespace OpenSim.Region.Framework.Scenes
3884 } 3915 }
3885 } 3916 }
3886 } 3917 }
3918
3919 public double GetUpdatePriority(IClientAPI client)
3920 {
3921 switch (Scene.UpdatePrioritizationScheme)
3922 {
3923 case Scene.UpdatePrioritizationSchemes.Time:
3924 return GetPriorityByTime();
3925 case Scene.UpdatePrioritizationSchemes.Distance:
3926 return GetPriorityByDistance(client);
3927 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3928 return GetPriorityByDistance(client);
3929 default:
3930 throw new InvalidOperationException("UpdatePrioritizationScheme not defined.");
3931 }
3932 }
3933
3934 private double GetPriorityByTime()
3935 {
3936 return DateTime.Now.ToOADate();
3937 }
3938
3939 private double GetPriorityByDistance(IClientAPI client)
3940 {
3941 ScenePresence presence = Scene.GetScenePresence(client.AgentId);
3942 if (presence != null)
3943 {
3944 return GetPriorityByDistance((presence.IsChildAgent) ?
3945 presence.AbsolutePosition : presence.CameraPosition);
3946 }
3947 return double.NaN;
3948 }
3949
3950 private double GetPriorityByDistance(Vector3 position)
3951 {
3952 return Vector3.Distance(AbsolutePosition, position);
3953 }
3954
3955 private double GetSOGUpdatePriority(SceneObjectGroup sog)
3956 {
3957 switch (Scene.UpdatePrioritizationScheme)
3958 {
3959 case Scene.UpdatePrioritizationSchemes.Time:
3960 throw new InvalidOperationException("UpdatePrioritizationScheme for time not supported for reprioritization");
3961 case Scene.UpdatePrioritizationSchemes.Distance:
3962 return sog.GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
3963 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3964 return sog.GetPriorityBySimpleAngularDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
3965 default:
3966 throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
3967 }
3968 }
3969
3970 private double UpdatePriority(UpdatePriorityData data)
3971 {
3972 EntityBase entity;
3973 SceneObjectGroup group;
3974
3975 if (Scene.Entities.TryGetValue(data.localID, out entity))
3976 {
3977 group = entity as SceneObjectGroup;
3978 if (group != null)
3979 return GetSOGUpdatePriority(group);
3980
3981 ScenePresence presence = entity as ScenePresence;
3982 if (presence == null)
3983 throw new InvalidOperationException("entity found is neither SceneObjectGroup nor ScenePresence");
3984 switch (Scene.UpdatePrioritizationScheme)
3985 {
3986 case Scene.UpdatePrioritizationSchemes.Time:
3987 throw new InvalidOperationException("UpdatePrioritization for time not supported for reprioritization");
3988 case Scene.UpdatePrioritizationSchemes.Distance:
3989 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3990 return GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
3991 default:
3992 throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
3993 }
3994 }
3995 else
3996 {
3997 group = Scene.SceneGraph.GetGroupByPrim(data.localID);
3998 if (group != null)
3999 return GetSOGUpdatePriority(group);
4000 }
4001 return double.NaN;
4002 }
4003
4004 private void ReprioritizeUpdates()
4005 {
4006 if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != Scene.UpdatePrioritizationSchemes.Time)
4007 {
4008 lock (m_reprioritization_timer)
4009 {
4010 if (!m_reprioritizing)
4011 m_reprioritization_timer.Enabled = m_reprioritizing = true;
4012 else
4013 m_reprioritization_called = true;
4014 }
4015 }
4016 }
4017
4018 private void Reprioritize(object sender, ElapsedEventArgs e)
4019 {
4020 m_controllingClient.ReprioritizeUpdates(StateUpdateTypes.All, UpdatePriority);
4021
4022 lock (m_reprioritization_timer)
4023 {
4024 m_reprioritization_timer.Enabled = m_reprioritizing = m_reprioritization_called;
4025 m_reprioritization_called = false;
4026 }
4027 }
3887 } 4028 }
3888} 4029}
diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
index 8ab0552..e4296ef 100644
--- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
@@ -45,14 +45,6 @@ namespace OpenSim.Region.Framework.Scenes
45 45
46 protected Dictionary<UUID, ScenePartUpdate> m_updateTimes = new Dictionary<UUID, ScenePartUpdate>(); 46 protected Dictionary<UUID, ScenePartUpdate> m_updateTimes = new Dictionary<UUID, ScenePartUpdate>();
47 47
48 protected int m_maxPrimsPerFrame = 200;
49
50 public int MaxPrimsPerFrame
51 {
52 get { return m_maxPrimsPerFrame; }
53 set { m_maxPrimsPerFrame = value; }
54 }
55
56 public SceneViewer() 48 public SceneViewer()
57 { 49 {
58 } 50 }
@@ -82,16 +74,7 @@ namespace OpenSim.Region.Framework.Scenes
82 { 74 {
83 m_pendingObjects = new Queue<SceneObjectGroup>(); 75 m_pendingObjects = new Queue<SceneObjectGroup>();
84 76
85 List<EntityBase> ents = new List<EntityBase>(m_presence.Scene.Entities); 77 foreach (EntityBase e in m_presence.Scene.Entities)
86 if (!m_presence.IsChildAgent) // Proximity sort makes no sense for
87 { // Child agents
88 ents.Sort(delegate(EntityBase a, EntityBase b)
89 {
90 return Vector3.Distance(m_presence.AbsolutePosition, a.AbsolutePosition).CompareTo(Vector3.Distance(m_presence.AbsolutePosition, b.AbsolutePosition));
91 });
92 }
93
94 foreach (EntityBase e in ents)
95 { 78 {
96 if (e is SceneObjectGroup) 79 if (e is SceneObjectGroup)
97 m_pendingObjects.Enqueue((SceneObjectGroup)e); 80 m_pendingObjects.Enqueue((SceneObjectGroup)e);
@@ -99,7 +82,7 @@ namespace OpenSim.Region.Framework.Scenes
99 } 82 }
100 } 83 }
101 84
102 while (m_pendingObjects != null && m_pendingObjects.Count > 0 && m_partsUpdateQueue.Count < m_maxPrimsPerFrame) 85 while (m_pendingObjects != null && m_pendingObjects.Count > 0)
103 { 86 {
104 SceneObjectGroup g = m_pendingObjects.Dequeue(); 87 SceneObjectGroup g = m_pendingObjects.Dequeue();
105 88
@@ -183,8 +166,6 @@ namespace OpenSim.Region.Framework.Scenes
183 m_presence.GenerateClientFlags(part.UUID)); 166 m_presence.GenerateClientFlags(part.UUID));
184 } 167 }
185 } 168 }
186
187 m_presence.ControllingClient.FlushPrimUpdates();
188 } 169 }
189 170
190 public void Reset() 171 public void Reset()
diff --git a/OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs b/OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs
index 29c4672..f3be028 100644
--- a/OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs
+++ b/OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs
@@ -35,8 +35,8 @@ namespace OpenSim.Region.Framework.Scenes.Scripting
35 string Description { get; set; } 35 string Description { get; set; }
36 36
37 UUID UUID { get; } 37 UUID UUID { get; }
38 UUID ObjectOwner { get; } 38 UUID OwnerID { get; }
39 UUID ObjectCreator { get; } 39 UUID CreatorID { get; }
40 Vector3 AbsolutePosition { get; } 40 Vector3 AbsolutePosition { get; }
41 41
42 string SitName { get; set; } 42 string SitName { get; set; }
diff --git a/OpenSim/Region/Framework/Scenes/Scripting/NullScriptHost.cs b/OpenSim/Region/Framework/Scenes/Scripting/NullScriptHost.cs
index af18a98..d7198f0 100644
--- a/OpenSim/Region/Framework/Scenes/Scripting/NullScriptHost.cs
+++ b/OpenSim/Region/Framework/Scenes/Scripting/NullScriptHost.cs
@@ -68,12 +68,12 @@ namespace OpenSim.Region.Framework.Scenes.Scripting
68 get { return UUID.Zero; } 68 get { return UUID.Zero; }
69 } 69 }
70 70
71 public UUID ObjectOwner 71 public UUID OwnerID
72 { 72 {
73 get { return UUID.Zero; } 73 get { return UUID.Zero; }
74 } 74 }
75 75
76 public UUID ObjectCreator 76 public UUID CreatorID
77 { 77 {
78 get { return UUID.Zero; } 78 get { return UUID.Zero; }
79 } 79 }