* First example of moving stuff to a Region layer

* Also, changed RegionPresence to 'RegionSubscription' - let's just see where we land with this...
afrisby
lbsa71 2007-09-21 04:58:40 +00:00
parent 409bcd999d
commit b9808f8314
8 changed files with 77 additions and 65 deletions

View File

@ -1,15 +1,44 @@
using System.Collections.Generic; using System.Collections.Generic;
using libsecondlife; using libsecondlife;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Terrain;
using OpenSim.Framework.Interfaces;
using System;
namespace OpenSim.Region.Environment.Regions namespace OpenSim.Region.Environment.Regions
{ {
public class Region public class Region
{ {
private Dictionary<LLUUID, RegionPresence> m_regionPresences; // This is a temporary (and real ugly) construct to emulate us really having a separate list
// of region subscribers. It should be removed ASAP, like.
public Region() private readonly Scene m_scene;
private Dictionary<LLUUID, RegionSubscription> m_regionSubscriptions
{ {
m_regionPresences = new Dictionary<LLUUID, RegionPresence>( ); get
{
Dictionary<LLUUID, RegionSubscription> subscriptions = new Dictionary<LLUUID, RegionSubscription>( );
foreach( ScenePresence presence in m_scene.GetScenePresences() )
{
subscriptions.Add( presence.UUID, new RegionSubscription( presence.ControllingClient ));
}
return subscriptions;
}
}
public Region( Scene scene )
{
m_scene = scene; // The Scene reference should be removed.
}
internal void Broadcast( Action<IClientAPI> whatToDo )
{
foreach (RegionSubscription subscription in m_regionSubscriptions.Values )
{
whatToDo(subscription.Client);
}
} }
} }
} }

View File

@ -1,14 +0,0 @@
using OpenSim.Framework.Interfaces;
namespace OpenSim.Region.Environment.Regions
{
public class RegionPresence
{
private IClientAPI m_client;
public RegionPresence(IClientAPI client )
{
m_client = client;
}
}
}

View File

@ -0,0 +1,19 @@
using OpenSim.Framework.Interfaces;
namespace OpenSim.Region.Environment.Regions
{
public class RegionSubscription
{
private readonly IClientAPI m_client;
public RegionSubscription(IClientAPI client )
{
m_client = client;
}
public IClientAPI Client
{
get { return m_client; }
}
}
}

View File

@ -4,11 +4,11 @@ using System.Text;
namespace OpenSim.Region.Environment.Regions namespace OpenSim.Region.Environment.Regions
{ {
public class RegionManager public class RegionSubscriptionManager
{ {
private Dictionary<uint, Region> m_regions; private Dictionary<uint, Region> m_regions;
public RegionManager( ) public RegionSubscriptionManager( )
{ {
m_regions = new Dictionary<uint, Region>( ); m_regions = new Dictionary<uint, Region>( );
} }

View File

@ -49,6 +49,7 @@ using OpenSim.Region.Environment.Types;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using OpenSim.Region.Terrain; using OpenSim.Region.Terrain;
using Timer = System.Timers.Timer; using Timer = System.Timers.Timer;
using OpenSim.Region.Environment.Regions;
namespace OpenSim.Region.Environment.Scenes namespace OpenSim.Region.Environment.Scenes
{ {
@ -63,6 +64,8 @@ namespace OpenSim.Region.Environment.Scenes
/// publicized so it can be accessed from SceneObjectGroup. /// publicized so it can be accessed from SceneObjectGroup.
protected float timeStep = 0.1f; protected float timeStep = 0.1f;
private Regions.Region m_region;
private Random Rand = new Random(); private Random Rand = new Random();
private uint _primCount = 702000; private uint _primCount = 702000;
private readonly Mutex _primAllocateMutex = new Mutex(false); private readonly Mutex _primAllocateMutex = new Mutex(false);
@ -159,6 +162,8 @@ namespace OpenSim.Region.Environment.Scenes
{ {
updateLock = new Mutex(false); updateLock = new Mutex(false);
m_region = new Regions.Region(this);
m_moduleLoader = moduleLoader; m_moduleLoader = moduleLoader;
authenticateHandler = authen; authenticateHandler = authen;
commsManager = commsMan; commsManager = commsMan;
@ -302,7 +307,7 @@ namespace OpenSim.Region.Environment.Scenes
float[] terData = Terrain.GetHeights1D(); float[] terData = Terrain.GetHeights1D();
ForEachScenePresence(delegate(ScenePresence presence) Broadcast( delegate( IClientAPI client )
{ {
for (int x = 0; x < 16; x++) for (int x = 0; x < 16; x++)
{ {
@ -310,8 +315,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (Terrain.Tainted(x * 16, y * 16)) if (Terrain.Tainted(x * 16, y * 16))
{ {
SendLayerData(x, y, presence.ControllingClient, client.SendLayerData(x, y, terData);
terData);
} }
} }
} }
@ -366,6 +370,10 @@ namespace OpenSim.Region.Environment.Scenes
updateLock.ReleaseMutex(); updateLock.ReleaseMutex();
} }
internal void Broadcast(Action<IClientAPI> whatToDo)
{
m_region.Broadcast( whatToDo );
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -396,7 +404,7 @@ namespace OpenSim.Region.Environment.Scenes
storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD());
ForEachScenePresence(delegate(ScenePresence presence) { SendLayerData(presence.ControllingClient); }); Broadcast(delegate(IClientAPI client ) { SendLayerData( client ); });
foreach (LLUUID UUID in Entities.Keys) foreach (LLUUID UUID in Entities.Keys)
{ {

View File

@ -88,17 +88,6 @@ namespace OpenSim.Region.Environment.Scenes
RemoteClient.SendLayerData(Terrain.GetHeights1D()); RemoteClient.SendLayerData(Terrain.GetHeights1D());
} }
/// <summary>
/// Sends a specified patch to a client
/// </summary>
/// <param name="px">Patch coordinate (x) 0..16</param>
/// <param name="py">Patch coordinate (y) 0..16</param>
/// <param name="RemoteClient">The client to send to</param>
public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient, float[] terrain)
{
RemoteClient.SendLayerData(px, py, terrain);
}
#endregion #endregion
#region Add/Remove Agent/Avatar #region Add/Remove Agent/Avatar

View File

@ -777,10 +777,6 @@ namespace OpenSim.Region.Environment.Scenes
m_parentGroup.SendPartTerseUpdate(remoteClient, this); m_parentGroup.SendPartTerseUpdate(remoteClient, this);
} }
/// <summary>
///
/// </summary>
/// <param name="RemoteClient"></param>
public void SendTerseUpdateToClient(IClientAPI remoteClient) public void SendTerseUpdateToClient(IClientAPI remoteClient)
{ {
LLVector3 lPos; LLVector3 lPos;
@ -789,11 +785,6 @@ namespace OpenSim.Region.Environment.Scenes
remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot);
} }
/// <summary>
///
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="lPos"></param>
public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos)
{ {
LLQuaternion mRot = RotationOffset; LLQuaternion mRot = RotationOffset;

View File

@ -69,8 +69,6 @@ namespace OpenSim.Region.Environment.Scenes
private readonly Vector3[] Dir_Vectors = new Vector3[6]; private readonly Vector3[] Dir_Vectors = new Vector3[6];
private LLVector3 lastPhysPos = new LLVector3(); private LLVector3 lastPhysPos = new LLVector3();
private RegionPresence m_regionPresence;
private enum Dir_ControlFlags private enum Dir_ControlFlags
{ {
DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS, DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS,
@ -216,6 +214,13 @@ namespace OpenSim.Region.Environment.Scenes
set { m_isChildAgent = value; } set { m_isChildAgent = value; }
} }
private RegionSubscription m_regionSubscription;
public RegionSubscription RegionSubscription
{
get { return m_regionSubscription; }
}
#endregion #endregion
#region Constructor(s) #region Constructor(s)
@ -229,7 +234,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="regionDat"></param> /// <param name="regionDat"></param>
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo)
{ {
m_regionPresence = new RegionPresence( client ); m_regionSubscription = new RegionSubscription( client );
m_scene = world; m_scene = world;
m_uuid = client.AgentId; m_uuid = client.AgentId;
@ -331,21 +336,6 @@ namespace OpenSim.Region.Environment.Scenes
#region Status Methods #region Status Methods
/// <summary>
/// Not Used, most likely can be deleted
/// </summary>
/// <param name="status"></param>
public void ChildStatusChange(bool status)
{
m_isChildAgent = status;
if (m_isChildAgent == true)
{
Velocity = new LLVector3(0, 0, 0);
AbsolutePosition = new LLVector3(128, 128, 70);
}
}
public void MakeAvatarPhysical(LLVector3 pos, bool isFlying) public void MakeAvatarPhysical(LLVector3 pos, bool isFlying)
{ {
newAvatar = true; newAvatar = true;
@ -425,7 +415,9 @@ namespace OpenSim.Region.Environment.Scenes
{ {
look = new LLVector3(0.99f, 0.042f, 0); look = new LLVector3(0.99f, 0.042f, 0);
} }
m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
if (m_isChildAgent) if (m_isChildAgent)
{ {
m_isChildAgent = false; m_isChildAgent = false;
@ -434,10 +426,6 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
/// <summary>
///
/// </summary>
/// <param name="pack"></param>
public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
{ {
if (m_isChildAgent) if (m_isChildAgent)
@ -445,6 +433,7 @@ namespace OpenSim.Region.Environment.Scenes
Console.WriteLine("DEBUG: HandleAgentUpdate: child agent"); Console.WriteLine("DEBUG: HandleAgentUpdate: child agent");
return; return;
} }
if(PhysicsActor==null) { if(PhysicsActor==null) {
Console.WriteLine("DEBUG: HandleAgentUpdate: null PhysicsActor!"); Console.WriteLine("DEBUG: HandleAgentUpdate: null PhysicsActor!");
return; return;
@ -526,6 +515,7 @@ namespace OpenSim.Region.Environment.Scenes
Console.WriteLine("DEBUG: AddNewMovement: child agent"); Console.WriteLine("DEBUG: AddNewMovement: child agent");
return; return;
} }
NewForce newVelocity = new NewForce(); NewForce newVelocity = new NewForce();
Vector3 direc = rotation*vec; Vector3 direc = rotation*vec;
direc.Normalize(); direc.Normalize();