diff options
author | Melanie | 2009-10-22 07:12:10 +0100 |
---|---|---|
committer | Melanie | 2009-10-22 07:12:10 +0100 |
commit | c4969d47d9bbc22b37054451cd31451ca8d8c78a (patch) | |
tree | 788e3b034254bcf068ca950ee97a78b6aa07b386 /OpenSim/Region/Framework | |
parent | Merge branch 'master' into vehicles (diff) | |
parent | Remove the "mel_t" from version string (diff) | |
download | opensim-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')
-rw-r--r-- | OpenSim/Region/Framework/Interfaces/ISceneViewer.cs | 1 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/EntityManager.cs | 69 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 21 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 125 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 32 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 76 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 26 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 26 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 299 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneViewer.cs | 23 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scripting/IScriptHost.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scripting/NullScriptHost.cs | 4 |
12 files changed, 412 insertions, 294 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 627034a..4d76b4ef 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 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) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index ba5119f..deee6c3 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 b8bd9b4..69b3ded 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -906,7 +906,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
906 | SetAttachmentPoint(Convert.ToByte(attachmentpoint)); | 906 | SetAttachmentPoint(Convert.ToByte(attachmentpoint)); |
907 | 907 | ||
908 | avatar.AddAttachment(this); | 908 | avatar.AddAttachment(this); |
909 | m_log.DebugFormat("[SOG]: Added att {0} to avie {1}", UUID, avatar.UUID); | 909 | m_log.Debug("[SOG]: Added attachment " + UUID + " to avatar " + avatar.UUID); |
910 | 910 | ||
911 | if (!silent) | 911 | if (!silent) |
912 | { | 912 | { |
@@ -1824,7 +1824,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1824 | public void ServiceObjectPropertiesFamilyRequest(IClientAPI remoteClient, UUID AgentID, uint RequestFlags) | 1824 | public void ServiceObjectPropertiesFamilyRequest(IClientAPI remoteClient, UUID AgentID, uint RequestFlags) |
1825 | { | 1825 | { |
1826 | 1826 | ||
1827 | remoteClient.SendObjectPropertiesFamilyData(RequestFlags, RootPart.UUID, RootPart.ObjectOwner, RootPart.GroupID, RootPart.BaseMask, | 1827 | remoteClient.SendObjectPropertiesFamilyData(RequestFlags, RootPart.UUID, RootPart.OwnerID, RootPart.GroupID, RootPart.BaseMask, |
1828 | RootPart.OwnerMask, RootPart.GroupMask, RootPart.EveryoneMask, RootPart.NextOwnerMask, | 1828 | RootPart.OwnerMask, RootPart.GroupMask, RootPart.EveryoneMask, RootPart.NextOwnerMask, |
1829 | RootPart.OwnershipCost, RootPart.ObjectSaleType, RootPart.SalePrice, RootPart.Category, | 1829 | RootPart.OwnershipCost, RootPart.ObjectSaleType, RootPart.SalePrice, RootPart.Category, |
1830 | RootPart.CreatorID, RootPart.Name, RootPart.Description); | 1830 | RootPart.CreatorID, RootPart.Name, RootPart.Description); |
@@ -3355,5 +3355,77 @@ namespace OpenSim.Region.Framework.Scenes | |||
3355 | 3355 | ||
3356 | return true; | 3356 | return true; |
3357 | } | 3357 | } |
3358 | |||
3359 | public double GetUpdatePriority(IClientAPI client) | ||
3360 | { | ||
3361 | switch (Scene.UpdatePrioritizationScheme) | ||
3362 | { | ||
3363 | case Scene.UpdatePrioritizationSchemes.Time: | ||
3364 | return GetPriorityByTime(); | ||
3365 | case Scene.UpdatePrioritizationSchemes.Distance: | ||
3366 | return GetPriorityByDistance(client); | ||
3367 | case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: | ||
3368 | return GetPriorityBySimpleAngularDistance(client); | ||
3369 | default: | ||
3370 | throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); | ||
3371 | } | ||
3372 | } | ||
3373 | |||
3374 | private double GetPriorityByTime() | ||
3375 | { | ||
3376 | return DateTime.Now.ToOADate(); | ||
3377 | } | ||
3378 | |||
3379 | private double GetPriorityByDistance(IClientAPI client) | ||
3380 | { | ||
3381 | ScenePresence presence = Scene.GetScenePresence(client.AgentId); | ||
3382 | if (presence != null) | ||
3383 | { | ||
3384 | return GetPriorityByDistance((presence.IsChildAgent) ? | ||
3385 | presence.AbsolutePosition : presence.CameraPosition); | ||
3386 | } | ||
3387 | return double.NaN; | ||
3388 | } | ||
3389 | |||
3390 | private double GetPriorityBySimpleAngularDistance(IClientAPI client) | ||
3391 | { | ||
3392 | ScenePresence presence = Scene.GetScenePresence(client.AgentId); | ||
3393 | if (presence != null) | ||
3394 | { | ||
3395 | return GetPriorityBySimpleAngularDistance((presence.IsChildAgent) ? | ||
3396 | presence.AbsolutePosition : presence.CameraPosition); | ||
3397 | } | ||
3398 | return double.NaN; | ||
3399 | } | ||
3400 | |||
3401 | public double GetPriorityByDistance(Vector3 position) | ||
3402 | { | ||
3403 | return Vector3.Distance(AbsolutePosition, position); | ||
3404 | } | ||
3405 | |||
3406 | public double GetPriorityBySimpleAngularDistance(Vector3 position) | ||
3407 | { | ||
3408 | double distance = Vector3.Distance(position, AbsolutePosition); | ||
3409 | if (distance >= double.Epsilon) | ||
3410 | { | ||
3411 | float height; | ||
3412 | Vector3 box = GetAxisAlignedBoundingBox(out height); | ||
3413 | |||
3414 | double angle = box.X / distance; | ||
3415 | double max = angle; | ||
3416 | |||
3417 | angle = box.Y / distance; | ||
3418 | if (max < angle) | ||
3419 | max = angle; | ||
3420 | |||
3421 | angle = box.Z / distance; | ||
3422 | if (max < angle) | ||
3423 | max = angle; | ||
3424 | |||
3425 | return -max; | ||
3426 | } | ||
3427 | else | ||
3428 | return double.MinValue; | ||
3429 | } | ||
3358 | } | 3430 | } |
3359 | } | 3431 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 23a7021..32171a0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -841,16 +841,6 @@ if (m_shape != null) { | |||
841 | return m_offsetPosition + m_groupPosition; } | 841 | return m_offsetPosition + m_groupPosition; } |
842 | } | 842 | } |
843 | 843 | ||
844 | public UUID ObjectCreator | ||
845 | { | ||
846 | get { return _creatorID; } | ||
847 | } | ||
848 | |||
849 | public UUID ObjectOwner | ||
850 | { | ||
851 | get { return _ownerID; } | ||
852 | } | ||
853 | |||
854 | public SceneObjectGroup ParentGroup | 844 | public SceneObjectGroup ParentGroup |
855 | { | 845 | { |
856 | get { return m_parentGroup; } | 846 | get { return m_parentGroup; } |
@@ -1427,7 +1417,7 @@ if (m_shape != null) { | |||
1427 | // Move afterwards ResetIDs as it clears the localID | 1417 | // Move afterwards ResetIDs as it clears the localID |
1428 | dupe.LocalId = localID; | 1418 | dupe.LocalId = localID; |
1429 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. | 1419 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. |
1430 | dupe._lastOwnerID = ObjectOwner; | 1420 | dupe._lastOwnerID = OwnerID; |
1431 | 1421 | ||
1432 | byte[] extraP = new byte[Shape.ExtraParams.Length]; | 1422 | byte[] extraP = new byte[Shape.ExtraParams.Length]; |
1433 | Array.Copy(Shape.ExtraParams, extraP, extraP.Length); | 1423 | Array.Copy(Shape.ExtraParams, extraP, extraP.Length); |
@@ -2388,10 +2378,10 @@ if (m_shape != null) { | |||
2388 | //isattachment = ParentGroup.RootPart.IsAttachment; | 2378 | //isattachment = ParentGroup.RootPart.IsAttachment; |
2389 | 2379 | ||
2390 | byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; | 2380 | byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; |
2391 | remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, | 2381 | remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, |
2392 | lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID, | 2382 | lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID, |
2393 | m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, | 2383 | m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, |
2394 | AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius); | 2384 | AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient))); |
2395 | } | 2385 | } |
2396 | 2386 | ||
2397 | /// <summary> | 2387 | /// <summary> |
@@ -3764,13 +3754,15 @@ if (m_shape != null) { | |||
3764 | if (ParentGroup.RootPart == this) | 3754 | if (ParentGroup.RootPart == this) |
3765 | lPos = AbsolutePosition; | 3755 | lPos = AbsolutePosition; |
3766 | } | 3756 | } |
3767 | 3757 | ||
3768 | remoteClient.SendPrimTerseUpdate(m_regionHandle, | 3758 | // Causes this thread to dig into the Client Thread Data. |
3759 | // Remember your locking here! | ||
3760 | remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle, | ||
3769 | (ushort)(m_parentGroup.GetTimeDilation() * | 3761 | (ushort)(m_parentGroup.GetTimeDilation() * |
3770 | (float)ushort.MaxValue), LocalId, lPos, | 3762 | (float)ushort.MaxValue), LocalId, lPos, |
3771 | RotationOffset, Velocity, | 3763 | RotationOffset, Velocity, Acceleration, |
3772 | RotationalVelocity, state, FromItemID, | 3764 | RotationalVelocity, state, FromItemID, |
3773 | OwnerID, (int)AttachmentPoint); | 3765 | OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient))); |
3774 | } | 3766 | } |
3775 | 3767 | ||
3776 | public void AddScriptLPS(int count) | 3768 | public void AddScriptLPS(int count) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 098e010..f4ca877 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -871,12 +871,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
871 | { | 871 | { |
872 | foreach (IScriptModule e in engines) | 872 | foreach (IScriptModule e in engines) |
873 | { | 873 | { |
874 | string n = e.GetAssemblyName(item.ItemID); | 874 | if (e != null) |
875 | if (n != "") | ||
876 | { | 875 | { |
877 | if (!ret.Contains(n)) | 876 | string n = e.GetAssemblyName(item.ItemID); |
878 | ret.Add(n); | 877 | if (n != String.Empty) |
879 | break; | 878 | { |
879 | if (!ret.Contains(n)) | ||
880 | ret.Add(n); | ||
881 | break; | ||
882 | } | ||
880 | } | 883 | } |
881 | } | 884 | } |
882 | } | 885 | } |
@@ -898,12 +901,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
898 | { | 901 | { |
899 | foreach (IScriptModule e in engines) | 902 | foreach (IScriptModule e in engines) |
900 | { | 903 | { |
901 | string n = e.GetXMLState(item.ItemID); | 904 | if (e != null) |
902 | if (n != "") | ||
903 | { | 905 | { |
904 | if (!ret.ContainsKey(item.ItemID)) | 906 | string n = e.GetXMLState(item.ItemID); |
905 | ret[item.ItemID] = n; | 907 | if (n != String.Empty) |
906 | break; | 908 | { |
909 | if (!ret.ContainsKey(item.ItemID)) | ||
910 | ret[item.ItemID] = n; | ||
911 | break; | ||
912 | } | ||
907 | } | 913 | } |
908 | } | 914 | } |
909 | } | 915 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c25fa55..d7113bf 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Timers; | ||
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
32 | using log4net; | 33 | using log4net; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
@@ -127,8 +128,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
127 | 128 | ||
128 | private bool m_setAlwaysRun; | 129 | private bool m_setAlwaysRun; |
129 | 130 | ||
130 | private bool m_updatesAllowed = true; | ||
131 | private List<AgentUpdateArgs> m_agentUpdates = new List<AgentUpdateArgs>(); | ||
132 | private string m_movementAnimation = "DEFAULT"; | 131 | private string m_movementAnimation = "DEFAULT"; |
133 | private long m_animPersistUntil = 0; | 132 | private long m_animPersistUntil = 0; |
134 | private bool m_allowFalling = false; | 133 | private bool m_allowFalling = false; |
@@ -172,6 +171,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
172 | 171 | ||
173 | // Position of agent's camera in world (region cordinates) | 172 | // Position of agent's camera in world (region cordinates) |
174 | protected Vector3 m_CameraCenter = Vector3.Zero; | 173 | protected Vector3 m_CameraCenter = Vector3.Zero; |
174 | protected Vector3 m_lastCameraCenter = Vector3.Zero; | ||
175 | |||
176 | protected Timer m_reprioritization_timer; | ||
177 | protected bool m_reprioritizing = false; | ||
178 | protected bool m_reprioritization_called = false; | ||
175 | 179 | ||
176 | // Use these three vectors to figure out what the agent is looking at | 180 | // Use these three vectors to figure out what the agent is looking at |
177 | // Convert it to a Matrix and/or Quaternion | 181 | // Convert it to a Matrix and/or Quaternion |
@@ -403,12 +407,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
403 | set { m_parentPosition = value; } | 407 | set { m_parentPosition = value; } |
404 | } | 408 | } |
405 | 409 | ||
406 | public int MaxPrimsPerFrame | ||
407 | { | ||
408 | get { return m_sceneViewer.MaxPrimsPerFrame; } | ||
409 | set { m_sceneViewer.MaxPrimsPerFrame = value; } | ||
410 | } | ||
411 | |||
412 | /// <summary> | 410 | /// <summary> |
413 | /// Absolute position of this avatar in 'region cordinates' | 411 | /// Absolute position of this avatar in 'region cordinates' |
414 | /// </summary> | 412 | /// </summary> |
@@ -645,7 +643,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
645 | 643 | ||
646 | m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); | 644 | m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); |
647 | 645 | ||
648 | AbsolutePosition = m_controllingClient.StartPos; | 646 | AbsolutePosition = posLastSignificantMove = m_CameraCenter = |
647 | m_lastCameraCenter = m_controllingClient.StartPos; | ||
648 | |||
649 | m_reprioritization_timer = new Timer(world.ReprioritizationInterval); | ||
650 | m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); | ||
651 | m_reprioritization_timer.AutoReset = false; | ||
652 | |||
653 | |||
649 | AdjustKnownSeeds(); | 654 | AdjustKnownSeeds(); |
650 | 655 | ||
651 | TrySetMovementAnimation("STAND"); // TODO: I think, this won't send anything, as we are still a child here... | 656 | TrySetMovementAnimation("STAND"); // TODO: I think, this won't send anything, as we are still a child here... |
@@ -1083,34 +1088,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1083 | 1088 | ||
1084 | } | 1089 | } |
1085 | 1090 | ||
1086 | // These methods allow to queue up agent updates (like key presses) | ||
1087 | // until all attachment scripts are running and the animations from | ||
1088 | // AgentDataUpdate have been started. It is essential for combat | ||
1089 | // devices, weapons and AOs that keypresses are not processed | ||
1090 | // until scripts that are potentially interested in them are | ||
1091 | // up and running and that animations a script knows to be running | ||
1092 | // from before a crossing are running again | ||
1093 | // | ||
1094 | public void LockAgentUpdates() | ||
1095 | { | ||
1096 | m_updatesAllowed = false; | ||
1097 | } | ||
1098 | |||
1099 | public void UnlockAgentUpdates() | ||
1100 | { | ||
1101 | lock (m_agentUpdates) | ||
1102 | { | ||
1103 | if (m_updatesAllowed == false) | ||
1104 | { | ||
1105 | foreach (AgentUpdateArgs a in m_agentUpdates) | ||
1106 | RealHandleAgentUpdate(ControllingClient, a); | ||
1107 | m_agentUpdates.Clear(); | ||
1108 | m_updatesAllowed = true; | ||
1109 | } | ||
1110 | } | ||
1111 | } | ||
1112 | |||
1113 | |||
1114 | /// <summary> | 1091 | /// <summary> |
1115 | /// Callback for the Camera view block check. Gets called with the results of the camera view block test | 1092 | /// Callback for the Camera view block check. Gets called with the results of the camera view block test |
1116 | /// hitYN is true when there's something in the way. | 1093 | /// hitYN is true when there's something in the way. |
@@ -1148,43 +1125,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
1148 | } | 1125 | } |
1149 | } | 1126 | } |
1150 | 1127 | ||
1128 | Array m_dirControlFlags = Enum.GetValues(typeof(Dir_ControlFlags)); | ||
1129 | |||
1151 | /// <summary> | 1130 | /// <summary> |
1152 | /// This is the event handler for client movement. If a client is moving, this event is triggering. | 1131 | /// This is the event handler for client movement. If a client is moving, this event is triggering. |
1153 | /// </summary> | 1132 | /// </summary> |
1154 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | 1133 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) |
1155 | { | 1134 | { |
1156 | lock (m_agentUpdates) | ||
1157 | { | ||
1158 | if (m_updatesAllowed) | ||
1159 | { | ||
1160 | RealHandleAgentUpdate(remoteClient, agentData); | ||
1161 | return; | ||
1162 | } | ||
1163 | |||
1164 | m_agentUpdates.Add(agentData); | ||
1165 | } | ||
1166 | } | ||
1167 | |||
1168 | private void RealHandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | ||
1169 | { | ||
1170 | //if (m_isChildAgent) | 1135 | //if (m_isChildAgent) |
1171 | //{ | 1136 | //{ |
1172 | // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); | 1137 | // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); |
1173 | // return; | 1138 | // return; |
1174 | //} | 1139 | //} |
1175 | 1140 | ||
1176 | 1141 | m_perfMonMS = Environment.TickCount; | |
1177 | m_movementUpdateCount++; | ||
1178 | if (m_movementUpdateCount >= int.MaxValue) | ||
1179 | m_movementUpdateCount = 1; | ||
1180 | 1142 | ||
1143 | ++m_movementUpdateCount; | ||
1144 | if (m_movementUpdateCount < 1) | ||
1145 | m_movementUpdateCount = 1; | ||
1181 | 1146 | ||
1182 | // Must check for standing up even when PhysicsActor is null, | 1147 | // Must check for standing up even when PhysicsActor is null, |
1183 | // since sitting currently removes avatar from physical scene | 1148 | // since sitting currently removes avatar from physical scene |
1184 | //m_log.Debug("agentPos:" + AbsolutePosition.ToString()); | 1149 | //m_log.Debug("agentPos:" + AbsolutePosition.ToString()); |
1185 | 1150 | ||
1186 | // This is irritating. Really. | 1151 | // This is irritating. Really. |
1187 | |||
1188 | if (!AbsolutePosition.IsFinite()) | 1152 | if (!AbsolutePosition.IsFinite()) |
1189 | { | 1153 | { |
1190 | RemoveFromPhysicalScene(); | 1154 | RemoveFromPhysicalScene(); |
@@ -1205,19 +1169,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1205 | { | 1169 | { |
1206 | m_LastFinitePos = m_pos; | 1170 | m_LastFinitePos = m_pos; |
1207 | } | 1171 | } |
1208 | //m_physicsActor.AddForce(new PhysicsVector(999999999, 99999999, 999999999999999), true); | ||
1209 | 1172 | ||
1173 | //m_physicsActor.AddForce(new PhysicsVector(999999999, 99999999, 999999999999999), true); | ||
1210 | 1174 | ||
1211 | //ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | 1175 | //ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); |
1212 | //if (land != null) | 1176 | //if (land != null) |
1213 | //{ | 1177 | //{ |
1214 | //if (land.landData.landingType == (byte)1 && land.landData.userLocation != Vector3.Zero) | 1178 | //if (land.landData.landingType == (byte)1 && land.landData.userLocation != Vector3.Zero) |
1215 | //{ | 1179 | //{ |
1216 | // agent.startpos = land.landData.userLocation; | 1180 | // agent.startpos = land.landData.userLocation; |
1217 | //} | 1181 | //} |
1218 | //} | 1182 | //} |
1219 | |||
1220 | m_perfMonMS = Environment.TickCount; | ||
1221 | 1183 | ||
1222 | uint flags = agentData.ControlFlags; | 1184 | uint flags = agentData.ControlFlags; |
1223 | Quaternion bodyRotation = agentData.BodyRotation; | 1185 | Quaternion bodyRotation = agentData.BodyRotation; |
@@ -1225,6 +1187,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1225 | // Camera location in world. We'll need to raytrace | 1187 | // Camera location in world. We'll need to raytrace |
1226 | // from this location from time to time. | 1188 | // from this location from time to time. |
1227 | m_CameraCenter = agentData.CameraCenter; | 1189 | m_CameraCenter = agentData.CameraCenter; |
1190 | if (Vector3.Distance(m_lastCameraCenter, m_CameraCenter) >= Scene.RootReprioritizationDistance) | ||
1191 | { | ||
1192 | ReprioritizeUpdates(); | ||
1193 | m_lastCameraCenter = m_CameraCenter; | ||
1194 | } | ||
1228 | 1195 | ||
1229 | // Use these three vectors to figure out what the agent is looking at | 1196 | // Use these three vectors to figure out what the agent is looking at |
1230 | // Convert it to a Matrix and/or Quaternion | 1197 | // Convert it to a Matrix and/or Quaternion |
@@ -1235,7 +1202,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1235 | // The Agent's Draw distance setting | 1202 | // The Agent's Draw distance setting |
1236 | m_DrawDistance = agentData.Far; | 1203 | m_DrawDistance = agentData.Far; |
1237 | 1204 | ||
1238 | if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) | 1205 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) |
1239 | { | 1206 | { |
1240 | StandUp(); | 1207 | StandUp(); |
1241 | } | 1208 | } |
@@ -1243,14 +1210,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1243 | // Check if Client has camera in 'follow cam' or 'build' mode. | 1210 | // Check if Client has camera in 'follow cam' or 'build' mode. |
1244 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); | 1211 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); |
1245 | 1212 | ||
1246 | m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) | 1213 | m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) |
1247 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; | 1214 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; |
1248 | 1215 | ||
1249 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); | 1216 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); |
1250 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view | 1217 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view |
1251 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) | 1218 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) |
1252 | { | 1219 | { |
1253 | |||
1254 | if (m_followCamAuto) | 1220 | if (m_followCamAuto) |
1255 | { | 1221 | { |
1256 | Vector3 headadjustment = new Vector3(0, 0, 0.3f); | 1222 | Vector3 headadjustment = new Vector3(0, 0, 0.3f); |
@@ -1258,24 +1224,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1258 | } | 1224 | } |
1259 | } | 1225 | } |
1260 | 1226 | ||
1261 | m_mouseLook = (flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; | 1227 | m_mouseLook = (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; |
1262 | |||
1263 | |||
1264 | |||
1265 | m_leftButtonDown = (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; | 1228 | m_leftButtonDown = (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; |
1266 | 1229 | ||
1267 | |||
1268 | |||
1269 | lock (scriptedcontrols) | 1230 | lock (scriptedcontrols) |
1270 | { | 1231 | { |
1271 | if (scriptedcontrols.Count > 0) | 1232 | if (scriptedcontrols.Count > 0) |
1272 | { | 1233 | { |
1273 | SendControlToScripts(flags); | 1234 | SendControlToScripts(flags); |
1274 | flags = RemoveIgnoredControls(flags, IgnoredControls); | 1235 | flags = RemoveIgnoredControls(flags, IgnoredControls); |
1275 | |||
1276 | } | 1236 | } |
1277 | } | 1237 | } |
1278 | 1238 | ||
1279 | if (PhysicsActor == null) | 1239 | if (PhysicsActor == null) |
1280 | { | 1240 | { |
1281 | return; | 1241 | return; |
@@ -1284,7 +1244,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1284 | if (m_autopilotMoving) | 1244 | if (m_autopilotMoving) |
1285 | CheckAtSitTarget(); | 1245 | CheckAtSitTarget(); |
1286 | 1246 | ||
1287 | if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1247 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1288 | { | 1248 | { |
1289 | // TODO: This doesn't prevent the user from walking yet. | 1249 | // TODO: This doesn't prevent the user from walking yet. |
1290 | // Setting parent ID would fix this, if we knew what value | 1250 | // Setting parent ID would fix this, if we knew what value |
@@ -1317,13 +1277,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1317 | PhysicsActor.Flying = false; | 1277 | PhysicsActor.Flying = false; |
1318 | else | 1278 | else |
1319 | PhysicsActor.Flying = ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1279 | PhysicsActor.Flying = ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1320 | 1280 | ||
1321 | if (PhysicsActor.Flying != oldflying) | 1281 | if (PhysicsActor.Flying != oldflying) |
1322 | { | 1282 | { |
1323 | update_movementflag = true; | 1283 | update_movementflag = true; |
1324 | } | 1284 | } |
1325 | } | 1285 | } |
1326 | 1286 | ||
1327 | if (q != m_bodyRot) | 1287 | if (q != m_bodyRot) |
1328 | { | 1288 | { |
1329 | m_bodyRot = q; | 1289 | m_bodyRot = q; |
@@ -1339,15 +1299,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1339 | 1299 | ||
1340 | // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying | 1300 | // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying |
1341 | // this prevents 'jumping' in inappropriate situations. | 1301 | // this prevents 'jumping' in inappropriate situations. |
1342 | if ((m_mouseLook && !m_physicsActor.Flying) || (m_leftButtonDown && !m_physicsActor.Flying)) | 1302 | if ((m_mouseLook && !m_physicsActor.Flying) || (m_leftButtonDown && !m_physicsActor.Flying)) |
1343 | dirVectors = GetWalkDirectionVectors(); | 1303 | dirVectors = GetWalkDirectionVectors(); |
1344 | else | 1304 | else |
1345 | dirVectors = Dir_Vectors; | 1305 | dirVectors = Dir_Vectors; |
1346 | 1306 | ||
1347 | 1307 | ||
1348 | foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof (Dir_ControlFlags))) | 1308 | foreach (Dir_ControlFlags DCF in m_dirControlFlags) |
1349 | { | 1309 | { |
1350 | if ((flags & (uint) DCF) != 0) | 1310 | if ((flags & (uint)DCF) != 0) |
1351 | { | 1311 | { |
1352 | bResetMoveToPosition = true; | 1312 | bResetMoveToPosition = true; |
1353 | DCFlagKeyPressed = true; | 1313 | DCFlagKeyPressed = true; |
@@ -1359,18 +1319,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1359 | { | 1319 | { |
1360 | // Why did I get this? | 1320 | // Why did I get this? |
1361 | } | 1321 | } |
1362 | 1322 | ||
1363 | if ((m_movementflag & (uint) DCF) == 0) | 1323 | if ((m_movementflag & (uint)DCF) == 0) |
1364 | { | 1324 | { |
1365 | m_movementflag += (byte) (uint) DCF; | 1325 | m_movementflag += (byte)(uint)DCF; |
1366 | update_movementflag = true; | 1326 | update_movementflag = true; |
1367 | } | 1327 | } |
1368 | } | 1328 | } |
1369 | else | 1329 | else |
1370 | { | 1330 | { |
1371 | if ((m_movementflag & (uint) DCF) != 0) | 1331 | if ((m_movementflag & (uint)DCF) != 0) |
1372 | { | 1332 | { |
1373 | m_movementflag -= (byte) (uint) DCF; | 1333 | m_movementflag -= (byte)(uint)DCF; |
1374 | update_movementflag = true; | 1334 | update_movementflag = true; |
1375 | } | 1335 | } |
1376 | else | 1336 | else |
@@ -1461,14 +1421,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1461 | } | 1421 | } |
1462 | catch (Exception) | 1422 | catch (Exception) |
1463 | { | 1423 | { |
1464 | |||
1465 | //Avoid system crash, can be slower but... | 1424 | //Avoid system crash, can be slower but... |
1466 | } | 1425 | } |
1467 | |||
1468 | } | 1426 | } |
1469 | } | 1427 | } |
1470 | } | 1428 | } |
1471 | 1429 | ||
1472 | // Cause the avatar to stop flying if it's colliding | 1430 | // Cause the avatar to stop flying if it's colliding |
1473 | // with something with the down arrow pressed. | 1431 | // with something with the down arrow pressed. |
1474 | 1432 | ||
@@ -1476,8 +1434,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1476 | if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) | 1434 | if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) |
1477 | { | 1435 | { |
1478 | // Are the landing controls requirements filled? | 1436 | // Are the landing controls requirements filled? |
1479 | bool controlland = (((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || | 1437 | bool controlland = (((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || |
1480 | ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 1438 | ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
1481 | 1439 | ||
1482 | // Are the collision requirements fulfilled? | 1440 | // Are the collision requirements fulfilled? |
1483 | bool colliding = (m_physicsActor.IsColliding == true); | 1441 | bool colliding = (m_physicsActor.IsColliding == true); |
@@ -1490,10 +1448,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1490 | 1448 | ||
1491 | if (update_movementflag || (update_rotation && DCFlagKeyPressed)) | 1449 | if (update_movementflag || (update_rotation && DCFlagKeyPressed)) |
1492 | { | 1450 | { |
1493 | // m_log.DebugFormat("{0} {1}", update_movementflag, (update_rotation && DCFlagKeyPressed)); | 1451 | // m_log.DebugFormat("{0} {1}", update_movementflag, (update_rotation && DCFlagKeyPressed)); |
1494 | // m_log.DebugFormat( | 1452 | // m_log.DebugFormat( |
1495 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); | 1453 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); |
1496 | 1454 | ||
1497 | AddNewMovement(agent_control_v3, q); | 1455 | AddNewMovement(agent_control_v3, q); |
1498 | 1456 | ||
1499 | if (update_movementflag) | 1457 | if (update_movementflag) |
@@ -2456,11 +2414,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2456 | m_perfMonMS = Environment.TickCount; | 2414 | m_perfMonMS = Environment.TickCount; |
2457 | 2415 | ||
2458 | Vector3 pos = m_pos; | 2416 | Vector3 pos = m_pos; |
2459 | Vector3 vel = Velocity; | ||
2460 | Quaternion rot = m_bodyRot; | ||
2461 | pos.Z -= m_appearance.HipOffset; | 2417 | 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), | 2418 | |
2463 | new Vector3(vel.X, vel.Y, vel.Z), rot, m_uuid); | 2419 | remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, |
2420 | pos, m_velocity, Vector3.Zero, m_rotation, Vector4.Zero, m_uuid, null, GetUpdatePriority(remoteClient))); | ||
2464 | 2421 | ||
2465 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2422 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); |
2466 | m_scene.StatsReporter.AddAgentUpdates(1); | 2423 | m_scene.StatsReporter.AddAgentUpdates(1); |
@@ -2474,7 +2431,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2474 | { | 2431 | { |
2475 | m_perfMonMS = Environment.TickCount; | 2432 | m_perfMonMS = Environment.TickCount; |
2476 | 2433 | ||
2477 | m_scene.Broadcast(SendTerseUpdateToClient); | 2434 | m_scene.ForEachClient(SendTerseUpdateToClient); |
2478 | 2435 | ||
2479 | m_lastVelocity = m_velocity; | 2436 | m_lastVelocity = m_velocity; |
2480 | lastPhysPos = AbsolutePosition; | 2437 | lastPhysPos = AbsolutePosition; |
@@ -2566,9 +2523,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2566 | Vector3 pos = m_pos; | 2523 | Vector3 pos = m_pos; |
2567 | pos.Z -= m_appearance.HipOffset; | 2524 | pos.Z -= m_appearance.HipOffset; |
2568 | 2525 | ||
2569 | remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, | 2526 | 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(), | 2527 | LocalId, m_pos, m_appearance.Texture.GetBytes(), |
2571 | m_parentID, rot); | 2528 | m_parentID, rot)); |
2572 | m_scene.StatsReporter.AddAgentUpdates(1); | 2529 | m_scene.StatsReporter.AddAgentUpdates(1); |
2573 | } | 2530 | } |
2574 | 2531 | ||
@@ -2637,8 +2594,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2637 | Vector3 pos = m_pos; | 2594 | Vector3 pos = m_pos; |
2638 | pos.Z -= m_appearance.HipOffset; | 2595 | pos.Z -= m_appearance.HipOffset; |
2639 | 2596 | ||
2640 | m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, | 2597 | 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); | 2598 | m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot)); |
2642 | 2599 | ||
2643 | if (!m_isChildAgent) | 2600 | if (!m_isChildAgent) |
2644 | { | 2601 | { |
@@ -2744,8 +2701,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2744 | } | 2701 | } |
2745 | 2702 | ||
2746 | Quaternion rot = m_bodyRot; | 2703 | Quaternion rot = m_bodyRot; |
2747 | m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, | 2704 | 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); | 2705 | m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot)); |
2749 | 2706 | ||
2750 | } | 2707 | } |
2751 | 2708 | ||
@@ -2776,7 +2733,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2776 | if (m_isChildAgent) | 2733 | if (m_isChildAgent) |
2777 | return; | 2734 | return; |
2778 | 2735 | ||
2779 | m_scene.Broadcast( | 2736 | m_scene.ForEachClient( |
2780 | delegate(IClientAPI client) { client.SendAnimations(animations, seqs, m_controllingClient.AgentId, objectIDs); }); | 2737 | delegate(IClientAPI client) { client.SendAnimations(animations, seqs, m_controllingClient.AgentId, objectIDs); }); |
2781 | } | 2738 | } |
2782 | 2739 | ||
@@ -2830,7 +2787,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2830 | } | 2787 | } |
2831 | 2788 | ||
2832 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m | 2789 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m |
2833 | if (Util.GetDistanceTo(AbsolutePosition,m_LastChildAgentUpdatePosition) > 32) | 2790 | if (Util.GetDistanceTo(AbsolutePosition, m_LastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance) |
2834 | { | 2791 | { |
2835 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); | 2792 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); |
2836 | cadu.ActiveGroupID = UUID.Zero.Guid; | 2793 | cadu.ActiveGroupID = UUID.Zero.Guid; |
@@ -3125,6 +3082,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3125 | if (cAgentData.Position != new Vector3(-1, -1, -1)) // UGH!! | 3082 | 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); | 3083 | m_pos = new Vector3(cAgentData.Position.X + shiftx, cAgentData.Position.Y + shifty, cAgentData.Position.Z); |
3127 | 3084 | ||
3085 | if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) | ||
3086 | { | ||
3087 | posLastSignificantMove = AbsolutePosition; | ||
3088 | ReprioritizeUpdates(); | ||
3089 | } | ||
3090 | |||
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 | 3091 | // 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; | 3092 | m_CameraCenter = cAgentData.Center; |
3130 | 3093 | ||
@@ -3487,7 +3450,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3487 | 3450 | ||
3488 | public void Close() | 3451 | public void Close() |
3489 | { | 3452 | { |
3490 | |||
3491 | lock (m_attachments) | 3453 | lock (m_attachments) |
3492 | { | 3454 | { |
3493 | // Delete attachments from scene | 3455 | // Delete attachments from scene |
@@ -3505,10 +3467,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
3505 | { | 3467 | { |
3506 | m_knownChildRegions.Clear(); | 3468 | m_knownChildRegions.Clear(); |
3507 | } | 3469 | } |
3470 | |||
3471 | lock (m_reprioritization_timer) | ||
3472 | { | ||
3473 | m_reprioritization_timer.Enabled = false; | ||
3474 | m_reprioritization_timer.Elapsed -= new ElapsedEventHandler(Reprioritize); | ||
3475 | } | ||
3476 | // I don't get it but mono crashes when you try to dispose of this timer, | ||
3477 | // unsetting the elapsed callback should be enough to allow for cleanup however. | ||
3478 | //m_reprioritizationTimer.Dispose(); | ||
3479 | |||
3508 | m_sceneViewer.Close(); | 3480 | m_sceneViewer.Close(); |
3509 | 3481 | ||
3510 | RemoveFromPhysicalScene(); | 3482 | RemoveFromPhysicalScene(); |
3511 | GC.Collect(); | ||
3512 | } | 3483 | } |
3513 | 3484 | ||
3514 | public ScenePresence() | 3485 | public ScenePresence() |
@@ -3884,5 +3855,115 @@ namespace OpenSim.Region.Framework.Scenes | |||
3884 | } | 3855 | } |
3885 | } | 3856 | } |
3886 | } | 3857 | } |
3858 | |||
3859 | public double GetUpdatePriority(IClientAPI client) | ||
3860 | { | ||
3861 | switch (Scene.UpdatePrioritizationScheme) | ||
3862 | { | ||
3863 | case Scene.UpdatePrioritizationSchemes.Time: | ||
3864 | return GetPriorityByTime(); | ||
3865 | case Scene.UpdatePrioritizationSchemes.Distance: | ||
3866 | return GetPriorityByDistance(client); | ||
3867 | case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: | ||
3868 | return GetPriorityByDistance(client); | ||
3869 | default: | ||
3870 | throw new InvalidOperationException("UpdatePrioritizationScheme not defined."); | ||
3871 | } | ||
3872 | } | ||
3873 | |||
3874 | private double GetPriorityByTime() | ||
3875 | { | ||
3876 | return DateTime.Now.ToOADate(); | ||
3877 | } | ||
3878 | |||
3879 | private double GetPriorityByDistance(IClientAPI client) | ||
3880 | { | ||
3881 | ScenePresence presence = Scene.GetScenePresence(client.AgentId); | ||
3882 | if (presence != null) | ||
3883 | { | ||
3884 | return GetPriorityByDistance((presence.IsChildAgent) ? | ||
3885 | presence.AbsolutePosition : presence.CameraPosition); | ||
3886 | } | ||
3887 | return double.NaN; | ||
3888 | } | ||
3889 | |||
3890 | private double GetPriorityByDistance(Vector3 position) | ||
3891 | { | ||
3892 | return Vector3.Distance(AbsolutePosition, position); | ||
3893 | } | ||
3894 | |||
3895 | private double GetSOGUpdatePriority(SceneObjectGroup sog) | ||
3896 | { | ||
3897 | switch (Scene.UpdatePrioritizationScheme) | ||
3898 | { | ||
3899 | case Scene.UpdatePrioritizationSchemes.Time: | ||
3900 | throw new InvalidOperationException("UpdatePrioritizationScheme for time not supported for reprioritization"); | ||
3901 | case Scene.UpdatePrioritizationSchemes.Distance: | ||
3902 | return sog.GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); | ||
3903 | case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: | ||
3904 | return sog.GetPriorityBySimpleAngularDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); | ||
3905 | default: | ||
3906 | throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); | ||
3907 | } | ||
3908 | } | ||
3909 | |||
3910 | private double UpdatePriority(UpdatePriorityData data) | ||
3911 | { | ||
3912 | EntityBase entity; | ||
3913 | SceneObjectGroup group; | ||
3914 | |||
3915 | if (Scene.Entities.TryGetValue(data.localID, out entity)) | ||
3916 | { | ||
3917 | group = entity as SceneObjectGroup; | ||
3918 | if (group != null) | ||
3919 | return GetSOGUpdatePriority(group); | ||
3920 | |||
3921 | ScenePresence presence = entity as ScenePresence; | ||
3922 | if (presence == null) | ||
3923 | throw new InvalidOperationException("entity found is neither SceneObjectGroup nor ScenePresence"); | ||
3924 | switch (Scene.UpdatePrioritizationScheme) | ||
3925 | { | ||
3926 | case Scene.UpdatePrioritizationSchemes.Time: | ||
3927 | throw new InvalidOperationException("UpdatePrioritization for time not supported for reprioritization"); | ||
3928 | case Scene.UpdatePrioritizationSchemes.Distance: | ||
3929 | case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: | ||
3930 | return GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); | ||
3931 | default: | ||
3932 | throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); | ||
3933 | } | ||
3934 | } | ||
3935 | else | ||
3936 | { | ||
3937 | group = Scene.SceneGraph.GetGroupByPrim(data.localID); | ||
3938 | if (group != null) | ||
3939 | return GetSOGUpdatePriority(group); | ||
3940 | } | ||
3941 | return double.NaN; | ||
3942 | } | ||
3943 | |||
3944 | private void ReprioritizeUpdates() | ||
3945 | { | ||
3946 | if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != Scene.UpdatePrioritizationSchemes.Time) | ||
3947 | { | ||
3948 | lock (m_reprioritization_timer) | ||
3949 | { | ||
3950 | if (!m_reprioritizing) | ||
3951 | m_reprioritization_timer.Enabled = m_reprioritizing = true; | ||
3952 | else | ||
3953 | m_reprioritization_called = true; | ||
3954 | } | ||
3955 | } | ||
3956 | } | ||
3957 | |||
3958 | private void Reprioritize(object sender, ElapsedEventArgs e) | ||
3959 | { | ||
3960 | m_controllingClient.ReprioritizeUpdates(StateUpdateTypes.All, UpdatePriority); | ||
3961 | |||
3962 | lock (m_reprioritization_timer) | ||
3963 | { | ||
3964 | m_reprioritization_timer.Enabled = m_reprioritizing = m_reprioritization_called; | ||
3965 | m_reprioritization_called = false; | ||
3966 | } | ||
3967 | } | ||
3887 | } | 3968 | } |
3888 | } | 3969 | } |
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 | } |