diff options
author | lbsa71 | 2007-09-21 04:58:40 +0000 |
---|---|---|
committer | lbsa71 | 2007-09-21 04:58:40 +0000 |
commit | b9808f831428876ec9ede8ce87a159566b97a850 (patch) | |
tree | 749ef670d6c4e6051a844d4c9c12073bebfe1e59 /OpenSim/Region | |
parent | * Continuing refactoring of presence (diff) | |
download | opensim-SC-b9808f831428876ec9ede8ce87a159566b97a850.zip opensim-SC-b9808f831428876ec9ede8ce87a159566b97a850.tar.gz opensim-SC-b9808f831428876ec9ede8ce87a159566b97a850.tar.bz2 opensim-SC-b9808f831428876ec9ede8ce87a159566b97a850.tar.xz |
* First example of moving stuff to a Region layer
* Also, changed RegionPresence to 'RegionSubscription' - let's just see where we land with this...
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Environment/Regions/Region.cs | 35 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Regions/RegionPresence.cs | 14 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Regions/RegionSubscription.cs | 19 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Regions/RegionSubscriptionManager.cs (renamed from OpenSim/Region/Environment/Regions/RegionManager.cs) | 4 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 16 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneBase.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | 9 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/ScenePresence.cs | 34 |
8 files changed, 77 insertions, 65 deletions
diff --git a/OpenSim/Region/Environment/Regions/Region.cs b/OpenSim/Region/Environment/Regions/Region.cs index f7669a9..e95d9dc 100644 --- a/OpenSim/Region/Environment/Regions/Region.cs +++ b/OpenSim/Region/Environment/Regions/Region.cs | |||
@@ -1,15 +1,44 @@ | |||
1 | using System.Collections.Generic; | 1 | using System.Collections.Generic; |
2 | using libsecondlife; | 2 | using libsecondlife; |
3 | using OpenSim.Region.Environment.Scenes; | ||
4 | using OpenSim.Region.Terrain; | ||
5 | using OpenSim.Framework.Interfaces; | ||
6 | using System; | ||
3 | 7 | ||
4 | namespace OpenSim.Region.Environment.Regions | 8 | namespace OpenSim.Region.Environment.Regions |
5 | { | 9 | { |
6 | public class Region | 10 | public class Region |
7 | { | 11 | { |
8 | private Dictionary<LLUUID, RegionPresence> m_regionPresences; | 12 | // This is a temporary (and real ugly) construct to emulate us really having a separate list |
13 | // of region subscribers. It should be removed ASAP, like. | ||
9 | 14 | ||
10 | public Region() | 15 | private readonly Scene m_scene; |
16 | private Dictionary<LLUUID, RegionSubscription> m_regionSubscriptions | ||
11 | { | 17 | { |
12 | m_regionPresences = new Dictionary<LLUUID, RegionPresence>( ); | 18 | get |
19 | { | ||
20 | Dictionary<LLUUID, RegionSubscription> subscriptions = new Dictionary<LLUUID, RegionSubscription>( ); | ||
21 | |||
22 | foreach( ScenePresence presence in m_scene.GetScenePresences() ) | ||
23 | { | ||
24 | subscriptions.Add( presence.UUID, new RegionSubscription( presence.ControllingClient )); | ||
25 | } | ||
26 | |||
27 | return subscriptions; | ||
28 | } | ||
29 | } | ||
30 | |||
31 | public Region( Scene scene ) | ||
32 | { | ||
33 | m_scene = scene; // The Scene reference should be removed. | ||
34 | } | ||
35 | |||
36 | internal void Broadcast( Action<IClientAPI> whatToDo ) | ||
37 | { | ||
38 | foreach (RegionSubscription subscription in m_regionSubscriptions.Values ) | ||
39 | { | ||
40 | whatToDo(subscription.Client); | ||
41 | } | ||
13 | } | 42 | } |
14 | } | 43 | } |
15 | } | 44 | } |
diff --git a/OpenSim/Region/Environment/Regions/RegionPresence.cs b/OpenSim/Region/Environment/Regions/RegionPresence.cs deleted file mode 100644 index 9720bb3..0000000 --- a/OpenSim/Region/Environment/Regions/RegionPresence.cs +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | using OpenSim.Framework.Interfaces; | ||
2 | |||
3 | namespace OpenSim.Region.Environment.Regions | ||
4 | { | ||
5 | public class RegionPresence | ||
6 | { | ||
7 | private IClientAPI m_client; | ||
8 | |||
9 | public RegionPresence(IClientAPI client ) | ||
10 | { | ||
11 | m_client = client; | ||
12 | } | ||
13 | } | ||
14 | } | ||
diff --git a/OpenSim/Region/Environment/Regions/RegionSubscription.cs b/OpenSim/Region/Environment/Regions/RegionSubscription.cs new file mode 100644 index 0000000..13cd0d5 --- /dev/null +++ b/OpenSim/Region/Environment/Regions/RegionSubscription.cs | |||
@@ -0,0 +1,19 @@ | |||
1 | using OpenSim.Framework.Interfaces; | ||
2 | |||
3 | namespace OpenSim.Region.Environment.Regions | ||
4 | { | ||
5 | public class RegionSubscription | ||
6 | { | ||
7 | private readonly IClientAPI m_client; | ||
8 | |||
9 | public RegionSubscription(IClientAPI client ) | ||
10 | { | ||
11 | m_client = client; | ||
12 | } | ||
13 | |||
14 | public IClientAPI Client | ||
15 | { | ||
16 | get { return m_client; } | ||
17 | } | ||
18 | } | ||
19 | } | ||
diff --git a/OpenSim/Region/Environment/Regions/RegionManager.cs b/OpenSim/Region/Environment/Regions/RegionSubscriptionManager.cs index ab5b97c..97d2591 100644 --- a/OpenSim/Region/Environment/Regions/RegionManager.cs +++ b/OpenSim/Region/Environment/Regions/RegionSubscriptionManager.cs | |||
@@ -4,11 +4,11 @@ using System.Text; | |||
4 | 4 | ||
5 | namespace OpenSim.Region.Environment.Regions | 5 | namespace OpenSim.Region.Environment.Regions |
6 | { | 6 | { |
7 | public class RegionManager | 7 | public class RegionSubscriptionManager |
8 | { | 8 | { |
9 | private Dictionary<uint, Region> m_regions; | 9 | private Dictionary<uint, Region> m_regions; |
10 | 10 | ||
11 | public RegionManager( ) | 11 | public RegionSubscriptionManager( ) |
12 | { | 12 | { |
13 | m_regions = new Dictionary<uint, Region>( ); | 13 | m_regions = new Dictionary<uint, Region>( ); |
14 | } | 14 | } |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 55d760e..62e7941 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -49,6 +49,7 @@ using OpenSim.Region.Environment.Types; | |||
49 | using OpenSim.Region.Physics.Manager; | 49 | using OpenSim.Region.Physics.Manager; |
50 | using OpenSim.Region.Terrain; | 50 | using OpenSim.Region.Terrain; |
51 | using Timer = System.Timers.Timer; | 51 | using Timer = System.Timers.Timer; |
52 | using OpenSim.Region.Environment.Regions; | ||
52 | 53 | ||
53 | namespace OpenSim.Region.Environment.Scenes | 54 | namespace OpenSim.Region.Environment.Scenes |
54 | { | 55 | { |
@@ -63,6 +64,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
63 | /// publicized so it can be accessed from SceneObjectGroup. | 64 | /// publicized so it can be accessed from SceneObjectGroup. |
64 | protected float timeStep = 0.1f; | 65 | protected float timeStep = 0.1f; |
65 | 66 | ||
67 | private Regions.Region m_region; | ||
68 | |||
66 | private Random Rand = new Random(); | 69 | private Random Rand = new Random(); |
67 | private uint _primCount = 702000; | 70 | private uint _primCount = 702000; |
68 | private readonly Mutex _primAllocateMutex = new Mutex(false); | 71 | private readonly Mutex _primAllocateMutex = new Mutex(false); |
@@ -159,6 +162,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
159 | { | 162 | { |
160 | updateLock = new Mutex(false); | 163 | updateLock = new Mutex(false); |
161 | 164 | ||
165 | m_region = new Regions.Region(this); | ||
166 | |||
162 | m_moduleLoader = moduleLoader; | 167 | m_moduleLoader = moduleLoader; |
163 | authenticateHandler = authen; | 168 | authenticateHandler = authen; |
164 | commsManager = commsMan; | 169 | commsManager = commsMan; |
@@ -302,7 +307,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
302 | 307 | ||
303 | float[] terData = Terrain.GetHeights1D(); | 308 | float[] terData = Terrain.GetHeights1D(); |
304 | 309 | ||
305 | ForEachScenePresence(delegate(ScenePresence presence) | 310 | Broadcast( delegate( IClientAPI client ) |
306 | { | 311 | { |
307 | for (int x = 0; x < 16; x++) | 312 | for (int x = 0; x < 16; x++) |
308 | { | 313 | { |
@@ -310,8 +315,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
310 | { | 315 | { |
311 | if (Terrain.Tainted(x * 16, y * 16)) | 316 | if (Terrain.Tainted(x * 16, y * 16)) |
312 | { | 317 | { |
313 | SendLayerData(x, y, presence.ControllingClient, | 318 | client.SendLayerData(x, y, terData); |
314 | terData); | ||
315 | } | 319 | } |
316 | } | 320 | } |
317 | } | 321 | } |
@@ -366,6 +370,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
366 | updateLock.ReleaseMutex(); | 370 | updateLock.ReleaseMutex(); |
367 | } | 371 | } |
368 | 372 | ||
373 | internal void Broadcast(Action<IClientAPI> whatToDo) | ||
374 | { | ||
375 | m_region.Broadcast( whatToDo ); | ||
376 | } | ||
369 | /// <summary> | 377 | /// <summary> |
370 | /// | 378 | /// |
371 | /// </summary> | 379 | /// </summary> |
@@ -396,7 +404,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
396 | 404 | ||
397 | storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); | 405 | storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); |
398 | 406 | ||
399 | ForEachScenePresence(delegate(ScenePresence presence) { SendLayerData(presence.ControllingClient); }); | 407 | Broadcast(delegate(IClientAPI client ) { SendLayerData( client ); }); |
400 | 408 | ||
401 | foreach (LLUUID UUID in Entities.Keys) | 409 | foreach (LLUUID UUID in Entities.Keys) |
402 | { | 410 | { |
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index 7b2e17f..fc81d5f 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs | |||
@@ -88,17 +88,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
88 | RemoteClient.SendLayerData(Terrain.GetHeights1D()); | 88 | RemoteClient.SendLayerData(Terrain.GetHeights1D()); |
89 | } | 89 | } |
90 | 90 | ||
91 | /// <summary> | ||
92 | /// Sends a specified patch to a client | ||
93 | /// </summary> | ||
94 | /// <param name="px">Patch coordinate (x) 0..16</param> | ||
95 | /// <param name="py">Patch coordinate (y) 0..16</param> | ||
96 | /// <param name="RemoteClient">The client to send to</param> | ||
97 | public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient, float[] terrain) | ||
98 | { | ||
99 | RemoteClient.SendLayerData(px, py, terrain); | ||
100 | } | ||
101 | |||
102 | #endregion | 91 | #endregion |
103 | 92 | ||
104 | #region Add/Remove Agent/Avatar | 93 | #region Add/Remove Agent/Avatar |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 468def0..406db9b 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -777,10 +777,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
777 | m_parentGroup.SendPartTerseUpdate(remoteClient, this); | 777 | m_parentGroup.SendPartTerseUpdate(remoteClient, this); |
778 | } | 778 | } |
779 | 779 | ||
780 | /// <summary> | ||
781 | /// | ||
782 | /// </summary> | ||
783 | /// <param name="RemoteClient"></param> | ||
784 | public void SendTerseUpdateToClient(IClientAPI remoteClient) | 780 | public void SendTerseUpdateToClient(IClientAPI remoteClient) |
785 | { | 781 | { |
786 | LLVector3 lPos; | 782 | LLVector3 lPos; |
@@ -789,11 +785,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
789 | remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); | 785 | remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); |
790 | } | 786 | } |
791 | 787 | ||
792 | /// <summary> | ||
793 | /// | ||
794 | /// </summary> | ||
795 | /// <param name="remoteClient"></param> | ||
796 | /// <param name="lPos"></param> | ||
797 | public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) | 788 | public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) |
798 | { | 789 | { |
799 | LLQuaternion mRot = RotationOffset; | 790 | LLQuaternion mRot = RotationOffset; |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 23e1035..41e555a 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -69,8 +69,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
69 | private readonly Vector3[] Dir_Vectors = new Vector3[6]; | 69 | private readonly Vector3[] Dir_Vectors = new Vector3[6]; |
70 | private LLVector3 lastPhysPos = new LLVector3(); | 70 | private LLVector3 lastPhysPos = new LLVector3(); |
71 | 71 | ||
72 | private RegionPresence m_regionPresence; | ||
73 | |||
74 | private enum Dir_ControlFlags | 72 | private enum Dir_ControlFlags |
75 | { | 73 | { |
76 | DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS, | 74 | DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS, |
@@ -216,6 +214,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
216 | set { m_isChildAgent = value; } | 214 | set { m_isChildAgent = value; } |
217 | } | 215 | } |
218 | 216 | ||
217 | private RegionSubscription m_regionSubscription; | ||
218 | |||
219 | public RegionSubscription RegionSubscription | ||
220 | { | ||
221 | get { return m_regionSubscription; } | ||
222 | } | ||
223 | |||
219 | #endregion | 224 | #endregion |
220 | 225 | ||
221 | #region Constructor(s) | 226 | #region Constructor(s) |
@@ -229,7 +234,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
229 | /// <param name="regionDat"></param> | 234 | /// <param name="regionDat"></param> |
230 | public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) | 235 | public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) |
231 | { | 236 | { |
232 | m_regionPresence = new RegionPresence( client ); | 237 | m_regionSubscription = new RegionSubscription( client ); |
233 | 238 | ||
234 | m_scene = world; | 239 | m_scene = world; |
235 | m_uuid = client.AgentId; | 240 | m_uuid = client.AgentId; |
@@ -331,21 +336,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
331 | 336 | ||
332 | #region Status Methods | 337 | #region Status Methods |
333 | 338 | ||
334 | /// <summary> | ||
335 | /// Not Used, most likely can be deleted | ||
336 | /// </summary> | ||
337 | /// <param name="status"></param> | ||
338 | public void ChildStatusChange(bool status) | ||
339 | { | ||
340 | m_isChildAgent = status; | ||
341 | |||
342 | if (m_isChildAgent == true) | ||
343 | { | ||
344 | Velocity = new LLVector3(0, 0, 0); | ||
345 | AbsolutePosition = new LLVector3(128, 128, 70); | ||
346 | } | ||
347 | } | ||
348 | |||
349 | public void MakeAvatarPhysical(LLVector3 pos, bool isFlying) | 339 | public void MakeAvatarPhysical(LLVector3 pos, bool isFlying) |
350 | { | 340 | { |
351 | newAvatar = true; | 341 | newAvatar = true; |
@@ -425,7 +415,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
425 | { | 415 | { |
426 | look = new LLVector3(0.99f, 0.042f, 0); | 416 | look = new LLVector3(0.99f, 0.042f, 0); |
427 | } | 417 | } |
418 | |||
428 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); | 419 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); |
420 | |||
429 | if (m_isChildAgent) | 421 | if (m_isChildAgent) |
430 | { | 422 | { |
431 | m_isChildAgent = false; | 423 | m_isChildAgent = false; |
@@ -434,10 +426,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
434 | } | 426 | } |
435 | } | 427 | } |
436 | 428 | ||
437 | /// <summary> | ||
438 | /// | ||
439 | /// </summary> | ||
440 | /// <param name="pack"></param> | ||
441 | public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) | 429 | public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) |
442 | { | 430 | { |
443 | if (m_isChildAgent) | 431 | if (m_isChildAgent) |
@@ -445,6 +433,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
445 | Console.WriteLine("DEBUG: HandleAgentUpdate: child agent"); | 433 | Console.WriteLine("DEBUG: HandleAgentUpdate: child agent"); |
446 | return; | 434 | return; |
447 | } | 435 | } |
436 | |||
448 | if(PhysicsActor==null) { | 437 | if(PhysicsActor==null) { |
449 | Console.WriteLine("DEBUG: HandleAgentUpdate: null PhysicsActor!"); | 438 | Console.WriteLine("DEBUG: HandleAgentUpdate: null PhysicsActor!"); |
450 | return; | 439 | return; |
@@ -526,6 +515,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
526 | Console.WriteLine("DEBUG: AddNewMovement: child agent"); | 515 | Console.WriteLine("DEBUG: AddNewMovement: child agent"); |
527 | return; | 516 | return; |
528 | } | 517 | } |
518 | |||
529 | NewForce newVelocity = new NewForce(); | 519 | NewForce newVelocity = new NewForce(); |
530 | Vector3 direc = rotation*vec; | 520 | Vector3 direc = rotation*vec; |
531 | direc.Normalize(); | 521 | direc.Normalize(); |