* Added comments to many methods in the listed files.

afrisby
Teravus Ovares 2007-12-10 21:12:38 +00:00
parent eac9bc6889
commit 2349dc2e27
4 changed files with 187 additions and 64 deletions

View File

@ -40,6 +40,9 @@ namespace OpenSim.Framework
[Serializable] [Serializable]
public class SearializableRegionInfo public class SearializableRegionInfo
{ {
/// <summary>
/// This is a serializable version of RegionInfo
/// </summary>
public SearializableRegionInfo() public SearializableRegionInfo()
{ {
} }

View File

@ -130,20 +130,20 @@ namespace OpenSim.Region.Environment.Scenes
} }
protected readonly LandManager m_LandManager; protected readonly LandManager m_LandManager;
// LandManager object instance that manages land related things. Parcel, primcounts etc..
public LandManager LandManager public LandManager LandManager
{ {
get { return m_LandManager; } get { return m_LandManager; }
} }
protected readonly EstateManager m_estateManager; protected readonly EstateManager m_estateManager;
// an instance to the physics plugin's Scene object.
public PhysicsScene PhysicsScene public PhysicsScene PhysicsScene
{ {
set { m_innerScene.PhysicsScene = value; } set { m_innerScene.PhysicsScene = value; }
get { return (m_innerScene.PhysicsScene); } get { return (m_innerScene.PhysicsScene); }
} }
// This gets locked so things stay thread safe.
public object SyncRoot public object SyncRoot
{ {
get { return m_innerScene.m_syncRoot; } get { return m_innerScene.m_syncRoot; }
@ -160,6 +160,8 @@ namespace OpenSim.Region.Environment.Scenes
} }
protected readonly PermissionManager m_permissionManager; protected readonly PermissionManager m_permissionManager;
// This is the instance to the permissions manager.
// This manages permissions to clients on in world objects
public PermissionManager PermissionsMngr public PermissionManager PermissionsMngr
{ {
@ -171,11 +173,13 @@ namespace OpenSim.Region.Environment.Scenes
get { return m_timePhase; } get { return m_timePhase; }
} }
// Local reference to the objects in the scene (which are held in innerScene)
public Dictionary<LLUUID, SceneObjectGroup> Objects public Dictionary<LLUUID, SceneObjectGroup> Objects
{ {
get { return m_innerScene.SceneObjects; } get { return m_innerScene.SceneObjects; }
} }
// Reference to all of the agents in the scene (root and child)
protected Dictionary<LLUUID, ScenePresence> m_scenePresences protected Dictionary<LLUUID, ScenePresence> m_scenePresences
{ {
get { return m_innerScene.ScenePresences; } get { return m_innerScene.ScenePresences; }
@ -267,9 +271,10 @@ namespace OpenSim.Region.Environment.Scenes
public override bool OtherRegionUp(RegionInfo otherRegion) public override bool OtherRegionUp(RegionInfo otherRegion)
{ {
// Another region is up. // Another region is up.
// We have to tell all our ScenePresences about it.. // Gets called from Grid Comms (SceneCommunicationService<---RegionListener<----LocalBackEnd<----OGS1)
// and add it to the neighbor list. // We have to tell all our ScenePresences about it..
// and add it to the neighbor list.
// We only add it to the neighbor list if it's within 1 region from here. // We only add it to the neighbor list if it's within 1 region from here.
// Agents may have draw distance values that cross two regions though, so // Agents may have draw distance values that cross two regions though, so
@ -324,8 +329,15 @@ namespace OpenSim.Region.Environment.Scenes
return true; return true;
} }
// Given float seconds, this will restart the region.
public virtual void Restart(float seconds) public virtual void Restart(float seconds)
{ {
// notifications are done in 15 second increments
// so .. if the number of seconds is less then 15 seconds, it's not really a restart request
// It's a 'Cancel restart' request.
// RestartNow() does immediate restarting.
if (seconds < 15) if (seconds < 15)
{ {
m_restartTimer.Stop(); m_restartTimer.Stop();
@ -333,6 +345,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
else else
{ {
// Now we figure out what to set the timer to that does the notifications and calls, RestartNow()
m_restartTimer.Interval = 15000; m_restartTimer.Interval = 15000;
m_incrementsof15seconds = (int) seconds/15; m_incrementsof15seconds = (int) seconds/15;
m_RestartTimerCounter = 0; m_RestartTimerCounter = 0;
@ -344,6 +357,10 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
// The Restart timer has occured.
// We have to figure out if this is a notification or if the number of seconds specified in Restart
// have elapsed.
// If they have elapsed, call RestartNow()
public void RestartTimer_Elapsed(object sender, ElapsedEventArgs e) public void RestartTimer_Elapsed(object sender, ElapsedEventArgs e)
{ {
m_RestartTimerCounter++; m_RestartTimerCounter++;
@ -360,6 +377,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
// This causes the region to restart immediatley.
public void RestartNow() public void RestartNow()
{ {
MainLog.Instance.Error("REGION", "Closing"); MainLog.Instance.Error("REGION", "Closing");
@ -368,6 +386,11 @@ namespace OpenSim.Region.Environment.Scenes
base.Restart(0); base.Restart(0);
} }
// This is a helper function that notifies root agents in this region that a new sim near them has come up
// This is in the form of a timer because when an instance of OpenSim.exe is started,
// Even though the sims initialize, they don't listen until 'all of the sims are initialized'
// If we tell an agent about a sim that's not listening yet, the agent will not be able to connect to it.
// subsequently the agent will never see the region come back online.
public void RestartNotifyWaitElapsed(object sender, ElapsedEventArgs e) public void RestartNotifyWaitElapsed(object sender, ElapsedEventArgs e)
{ {
m_restartWaitTimer.Stop(); m_restartWaitTimer.Stop();
@ -378,6 +401,7 @@ namespace OpenSim.Region.Environment.Scenes
ForEachScenePresence(delegate(ScenePresence agent) ForEachScenePresence(delegate(ScenePresence agent)
{ {
// If agent is a root agent.
if (!agent.IsChildAgent) if (!agent.IsChildAgent)
{ {
//agent.ControllingClient.new //agent.ControllingClient.new
@ -391,14 +415,18 @@ namespace OpenSim.Region.Environment.Scenes
catch (System.NullReferenceException) catch (System.NullReferenceException)
{ {
// This means that we're not booted up completely yet. // This means that we're not booted up completely yet.
// This shouldn't happen too often anymore.
} }
} }
// Reset list to nothing. // Reset list to nothing.
m_regionRestartNotifyList.Clear(); m_regionRestartNotifyList.Clear();
} }
// This is the method that shuts down the scene.
public override void Close() public override void Close()
{ {
// Kick all ROOT agents with the message, 'The simulator is going down'
ForEachScenePresence(delegate(ScenePresence avatar) ForEachScenePresence(delegate(ScenePresence avatar)
{ {
if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle))
@ -409,18 +437,23 @@ namespace OpenSim.Region.Environment.Scenes
avatar.ControllingClient.OutPacket(new libsecondlife.Packets.DisableSimulatorPacket(), ThrottleOutPacketType.Task); avatar.ControllingClient.OutPacket(new libsecondlife.Packets.DisableSimulatorPacket(), ThrottleOutPacketType.Task);
}); });
// Wait here, or the kick messages won't actually get to the agents before the scene terminates.
Thread.Sleep(500); Thread.Sleep(500);
// Stop all client threads.
ForEachScenePresence(delegate(ScenePresence avatar) ForEachScenePresence(delegate(ScenePresence avatar)
{ {
avatar.ControllingClient.Stop(); avatar.ControllingClient.Stop();
}); });
// Stop updating the scene objects and agents.
m_heartbeatTimer.Close(); m_heartbeatTimer.Close();
// close the inner scene
m_innerScene.Close(); m_innerScene.Close();
// De-register with region communications (events cleanup)
UnRegisterReginWithComms(); UnRegisterReginWithComms();
// Shut down all non shared modules.
foreach (IRegionModule module in Modules.Values) foreach (IRegionModule module in Modules.Values)
{ {
if (!module.IsSharedModule) if (!module.IsSharedModule)
@ -430,6 +463,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
Modules.Clear(); Modules.Clear();
// call the base class Close method.
base.Close(); base.Close();
} }
@ -530,7 +564,7 @@ namespace OpenSim.Region.Environment.Scenes
m_lastupdate = DateTime.Now; m_lastupdate = DateTime.Now;
} }
} }
//Updates the time in the viewer.
private void UpdateInWorldTime() private void UpdateInWorldTime()
{ {
m_timeUpdateCount++; m_timeUpdateCount++;
@ -1234,7 +1268,7 @@ namespace OpenSim.Region.Environment.Scenes
return true; return true;
} }
/// <summary> /// <summary>
/// /// Tell a single agent to disconnect from the region.
/// </summary> /// </summary>
/// <param name="regionHandle"></param> /// <param name="regionHandle"></param>
/// <param name="agentID"></param> /// <param name="agentID"></param>
@ -1245,6 +1279,7 @@ namespace OpenSim.Region.Environment.Scenes
ScenePresence presence = m_innerScene.GetScenePresence(agentID); ScenePresence presence = m_innerScene.GetScenePresence(agentID);
if (presence != null) if (presence != null)
{ {
// Tell a single agent to disconnect from the region.
libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket();
presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task); presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task);
} }
@ -1252,6 +1287,11 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// Tell neighboring regions about this agent
/// When the regions respond with a true value,
/// tell the agents about the region.
///
/// We have to tell the regions about the agents first otherwise it'll deny them access
/// ///
/// </summary> /// </summary>
/// <param name="presence"></param> /// <param name="presence"></param>
@ -1261,7 +1301,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// Tell a neighboring region about this agent
/// </summary> /// </summary>
/// <param name="presence"></param> /// <param name="presence"></param>
/// <param name="region"></param> /// <param name="region"></param>
@ -1271,7 +1311,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// Requests information about this region from gridcomms
/// </summary> /// </summary>
/// <param name="regionHandle"></param> /// <param name="regionHandle"></param>
/// <returns></returns> /// <returns></returns>
@ -1281,7 +1321,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// Requests textures for map from minimum region to maximum region in world cordinates
/// </summary> /// </summary>
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
/// <param name="minX"></param> /// <param name="minX"></param>
@ -1294,7 +1334,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// Tries to teleport agent to other region.
/// </summary> /// </summary>
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
/// <param name="regionHandle"></param> /// <param name="regionHandle"></param>
@ -1311,7 +1351,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// Agent is crossing the border into a neighbouring region. Tell the neighbour about it!
/// </summary> /// </summary>
/// <param name="regionHandle"></param> /// <param name="regionHandle"></param>
/// <param name="agentID"></param> /// <param name="agentID"></param>
@ -1641,7 +1681,7 @@ namespace OpenSim.Region.Environment.Scenes
#endregion #endregion
/// <summary> /// <summary>
/// /// Causes all clients to get a full object update on all of the objects in the scene.
/// </summary> /// </summary>
public void ForceClientUpdate() public void ForceClientUpdate()
{ {
@ -1655,7 +1695,8 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// This is currently only used for scale (to scale to MegaPrim size)
/// There is a console command that calls this in OpenSimMain
/// </summary> /// </summary>
/// <param name="cmdparams"></param> /// <param name="cmdparams"></param>
public void HandleEditCommand(string[] cmdparams) public void HandleEditCommand(string[] cmdparams)
@ -1682,7 +1723,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// Shows various details about the sim based on the parameters supplied by the console command in openSimMain.
/// </summary> /// </summary>
/// <param name="showWhat"></param> /// <param name="showWhat"></param>
public void Show(string showWhat) public void Show(string showWhat)
@ -1726,7 +1767,7 @@ namespace OpenSim.Region.Environment.Scenes
#region Script Handling Methods #region Script Handling Methods
/// <summary> /// <summary>
/// /// Console command handler to send script command to script engine.
/// </summary> /// </summary>
/// <param name="args"></param> /// <param name="args"></param>
public void SendCommandToPlugins(string[] args) public void SendCommandToPlugins(string[] args)

View File

@ -189,7 +189,8 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// This informs all neighboring regions about agent "avatar".
/// Calls an asynchronous method to do so.. so it doesn't lag the sim.
/// </summary> /// </summary>
public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours) public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
{ {
@ -222,6 +223,10 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
} }
/// <summary>
/// This informs a single neighboring region about agent "avatar".
/// Calls an asynchronous method to do so.. so it doesn't lag the sim.
/// </summary>
public void InformNeighborChildAgent(ScenePresence avatar, RegionInfo region, List<RegionInfo> neighbours) public void InformNeighborChildAgent(ScenePresence avatar, RegionInfo region, List<RegionInfo> neighbours)
{ {
AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
@ -260,7 +265,10 @@ namespace OpenSim.Region.Environment.Scenes
MainLog.Instance.Notice("INTERGRID", "Failed to inform neighbors that I'm here"); MainLog.Instance.Notice("INTERGRID", "Failed to inform neighbors that I'm here");
} }
} }
/// <summary>
/// Called by scene when region is initialized (not always when it's listening for agents)
/// This is an inter-region message that informs the surrounding neighbors that the sim is up.
/// </summary>
public void InformNeighborsThatRegionisUp(RegionInfo region) public void InformNeighborsThatRegionisUp(RegionInfo region)
{ {
//MainLog.Instance.Verbose("INTER", debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); //MainLog.Instance.Verbose("INTER", debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
@ -286,6 +294,13 @@ namespace OpenSim.Region.Environment.Scenes
} }
public delegate void SendChildAgentDataUpdateDelegate(ulong regionHandle, ChildAgentDataUpdate cAgentData); public delegate void SendChildAgentDataUpdateDelegate(ulong regionHandle, ChildAgentDataUpdate cAgentData);
/// <summary>
/// This informs all neighboring regions about the settings of it's child agent.
/// Calls an asynchronous method to do so.. so it doesn't lag the sim.
///
/// This contains information, such as, Draw Distance, Camera location, Current Position, Current throttle settings, etc.
///
/// </summary>
private void SendChildAgentDataUpdateAsync(ulong regionHandle, ChildAgentDataUpdate cAgentData) private void SendChildAgentDataUpdateAsync(ulong regionHandle, ChildAgentDataUpdate cAgentData)
{ {
MainLog.Instance.Notice("INTERGRID", "Informing a neighbor about my agent."); MainLog.Instance.Notice("INTERGRID", "Informing a neighbor about my agent.");
@ -317,7 +332,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary> /// <summary>
/// /// Helper function to request neighbors from grid-comms
/// </summary> /// </summary>
/// <param name="regionHandle"></param> /// <param name="regionHandle"></param>
/// <returns></returns> /// <returns></returns>
@ -328,7 +343,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
/// </summary> /// </summary>
/// <param name="minX"></param> /// <param name="minX"></param>
/// <param name="minY"></param> /// <param name="minY"></param>

View File

@ -61,10 +61,13 @@ namespace OpenSim.Region.Environment.Scenes
public bool IsRestrictedToRegion = false; public bool IsRestrictedToRegion = false;
// Agent moves with a PID controller causing a force to be exerted.
private bool m_newForce = false; private bool m_newForce = false;
private bool m_newAvatar = false; private bool m_newAvatar = false;
private bool m_newCoarseLocations = true; private bool m_newCoarseLocations = true;
private bool m_gotAllObjectsInScene = false; private bool m_gotAllObjectsInScene = false;
// Default AV Height
private float m_avHeight = 127.0f; private float m_avHeight = 127.0f;
protected RegionInfo m_regionInfo; protected RegionInfo m_regionInfo;
@ -73,7 +76,7 @@ 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();
// Position of agent's camera in world // Position of agent's camera in world (region cordinates)
protected Vector3 m_CameraCenter = new Vector3(0, 0, 0); protected Vector3 m_CameraCenter = new Vector3(0, 0, 0);
// Use these three vectors to figure out what the agent is looking at // Use these three vectors to figure out what the agent is looking at
@ -88,7 +91,11 @@ namespace OpenSim.Region.Environment.Scenes
protected AvatarAppearance m_appearance; protected AvatarAppearance m_appearance;
private readonly List<ulong> m_knownChildRegions = new List<ulong>(); //neighbouring regions we have enabled a child agent in private readonly List<ulong> m_knownChildRegions = new List<ulong>(); //neighbouring regions we have enabled a child agent in
/// <summary>
/// Implemented Control Flags
/// </summary>
private enum Dir_ControlFlags private enum Dir_ControlFlags
{ {
DIR_CONTROL_FLAG_FOWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, DIR_CONTROL_FLAG_FOWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS,
@ -114,7 +121,7 @@ namespace OpenSim.Region.Environment.Scenes
#region Properties #region Properties
/// <summary> /// <summary>
/// /// Physical scene representation of this Avatar.
/// </summary> /// </summary>
public PhysicsActor PhysicsActor public PhysicsActor PhysicsActor
{ {
@ -166,6 +173,10 @@ namespace OpenSim.Region.Environment.Scenes
set { m_allowMovement = value; } set { m_allowMovement = value; }
} }
/// <summary>
/// This works out to be the ClientView object associated with this avatar, or it's UDP connection manager
/// </summary>
private readonly IClientAPI m_controllingClient; private readonly IClientAPI m_controllingClient;
protected PhysicsActor m_physicsActor; protected PhysicsActor m_physicsActor;
@ -176,6 +187,9 @@ namespace OpenSim.Region.Environment.Scenes
protected LLVector3 m_parentPosition = new LLVector3(); protected LLVector3 m_parentPosition = new LLVector3();
/// <summary>
/// Absolute position of this avatar in 'region cordinates'
/// </summary>
public override LLVector3 AbsolutePosition public override LLVector3 AbsolutePosition
{ {
get get
@ -209,7 +223,9 @@ namespace OpenSim.Region.Environment.Scenes
m_pos = value; m_pos = value;
} }
} }
/// <summary>
/// Current Velocity of the avatar.
/// </summary>
public override LLVector3 Velocity public override LLVector3 Velocity
{ {
get get
@ -244,6 +260,12 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
/// <summary>
/// If this is true, agent doesn't have a representation in this scene.
/// this is an agent 'looking into' this scene from a nearby scene(region)
///
/// if False, this agent has a representation in this scene
/// </summary>
private bool m_isChildAgent = true; private bool m_isChildAgent = true;
public bool IsChildAgent public bool IsChildAgent
@ -260,6 +282,9 @@ namespace OpenSim.Region.Environment.Scenes
set { m_parentID = value; } set { m_parentID = value; }
} }
/// <summary>
/// These are the region handles known by the avatar.
/// </summary>
public List<ulong> KnownChildRegions public List<ulong> KnownChildRegions
{ {
get { return m_knownChildRegions; } get { return m_knownChildRegions; }
@ -461,7 +486,11 @@ namespace OpenSim.Region.Environment.Scenes
} }
#region Status Methods #region Status Methods
/// <summary>
/// This turns a child agent, into a root agent
/// This is called when an agent teleports into a region, or if an
/// agent crosses into this region from a neighbor over the border
/// </summary>
public void MakeRootAgent(LLVector3 pos, bool isFlying) public void MakeRootAgent(LLVector3 pos, bool isFlying)
{ {
@ -481,7 +510,13 @@ namespace OpenSim.Region.Environment.Scenes
//} //}
} }
/// <summary>
/// This turns a root agent into a child agent
/// when an agent departs this region for a neighbor, this gets called.
///
/// It doesn't get called for a teleport. Reason being, an agent that
/// teleports out may not be anywhere near this region
/// </summary>
public void MakeChildAgent() public void MakeChildAgent()
{ {
Velocity = new LLVector3(0, 0, 0); Velocity = new LLVector3(0, 0, 0);
@ -492,6 +527,9 @@ namespace OpenSim.Region.Environment.Scenes
//this.Pos = new LLVector3(128, 128, 70); //this.Pos = new LLVector3(128, 128, 70);
} }
/// <summary>
/// Removes physics plugin scene representation of this agent if it exists.
/// </summary>
private void RemoveFromPhysicalScene() private void RemoveFromPhysicalScene()
{ {
if (PhysicsActor != null) if (PhysicsActor != null)
@ -538,7 +576,9 @@ namespace OpenSim.Region.Environment.Scenes
#endregion #endregion
#region Event Handlers #region Event Handlers
/// <summary>
/// Sets avatar height in the phyiscs plugin
/// </summary>
internal void SetHeight(float height) internal void SetHeight(float height)
{ {
m_avHeight = height; m_avHeight = height;
@ -570,7 +610,9 @@ namespace OpenSim.Region.Environment.Scenes
MakeRootAgent(AbsolutePosition, false); MakeRootAgent(AbsolutePosition, false);
} }
} }
/// <summary>
/// This is the event handler for client movement. If a client is moving, this event is triggering.
/// </summary>
public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdatePacket agentData) public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdatePacket agentData)
{ {
//if (m_isChildAgent) //if (m_isChildAgent)
@ -608,26 +650,6 @@ namespace OpenSim.Region.Environment.Scenes
// The Agent's Draw distance setting // The Agent's Draw distance setting
m_DrawDistance = agentData.AgentData.Far; m_DrawDistance = agentData.AgentData.Far;
// We don't know the agent's draw distance until the first agentUpdate packet
//if (m_DrawDistance > 0)
//{
//if (!m_gotAllObjectsInScene && m_DrawDistance > 0)
//{
// This will need to end up being a space based invalidator
// where we send object updates on spaces in 3d space (possibily a cube)
// that the avatar hasn't been surrounding it's draw distance.
// It would be better if the distance increased incrementally
// until there was no space to update because either the avatar's draw
// distance is smaller then the space they've been or the avatar has explored
// all the space in the sim.
//m_scene.SendAllSceneObjectsToClient(this);
//m_gotAllObjectsInScene = true;
//}
//}
//MainLog.Instance.Verbose("CAMERA", "AtAxis:" + m_CameraAtAxis.ToString() + " Center:" + m_CameraCenter.ToString() + " LeftAxis:" + m_CameraLeftAxis.ToString() + " UpAxis:" + m_CameraUpAxis.ToString() + " Far:" + m_CameraFar);
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
{ {
StandUp(); StandUp();
@ -793,7 +815,10 @@ namespace OpenSim.Region.Environment.Scenes
SetMovementAnimation(Animations.AnimsLLUUID["SIT"], 1); SetMovementAnimation(Animations.AnimsLLUUID["SIT"], 1);
SendFullUpdateToAllClients(); SendFullUpdateToAllClients();
} }
/// <summary>
/// Event handler for the 'Always run' setting on the client
/// Tells the physics plugin to increase speed of movement.
/// </summary>
public void HandleSetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun) public void HandleSetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun)
{ {
m_setAlwaysRun = SetAlwaysRun; m_setAlwaysRun = SetAlwaysRun;
@ -853,13 +878,18 @@ namespace OpenSim.Region.Environment.Scenes
SendAnimPack(); SendAnimPack();
} }
} }
/// <summary>
/// This method handles agent movement related animations
/// </summary>
protected void UpdateMovementAnimations(bool update_movementflag) protected void UpdateMovementAnimations(bool update_movementflag)
{ {
if (update_movementflag) if (update_movementflag)
{ {
// Are we moving?
if (m_movementflag != 0) if (m_movementflag != 0)
{ {
// We are moving
// Are we flying
if (m_physicsActor.Flying) if (m_physicsActor.Flying)
{ {
SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1); SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1);
@ -867,18 +897,22 @@ namespace OpenSim.Region.Environment.Scenes
else if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && else if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) &&
PhysicsActor.IsColliding) PhysicsActor.IsColliding)
{ {
// Client is pressing the page down button and moving and is colliding with something
SetMovementAnimation(Animations.AnimsLLUUID["CROUCHWALK"], 1); SetMovementAnimation(Animations.AnimsLLUUID["CROUCHWALK"], 1);
} }
else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6) else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6)
{ {
// Client is moving and falling at a velocity greater then 6 meters per unit
SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1);
} }
else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
{ {
// client is moving, and colliding and pressing the page up button but isn't flying
SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1);
} }
else if (m_setAlwaysRun) else if (m_setAlwaysRun)
{ {
// We are running
SetMovementAnimation(Animations.AnimsLLUUID["RUN"], 1); SetMovementAnimation(Animations.AnimsLLUUID["RUN"], 1);
} }
else else
@ -886,29 +920,39 @@ namespace OpenSim.Region.Environment.Scenes
} }
else else
{ {
// Not moving
if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) &&
PhysicsActor.IsColliding) PhysicsActor.IsColliding)
{ {
// Client pressing the page down button
SetMovementAnimation(Animations.AnimsLLUUID["CROUCH"], 1); SetMovementAnimation(Animations.AnimsLLUUID["CROUCH"], 1);
} }
else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6 && !m_physicsActor.Flying) else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6 && !m_physicsActor.Flying)
{ {
// Not colliding, and we're not flying and we're falling at a speed of 6m per unit
SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1);
} }
else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
{ {
// This is the standing jump
SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1);
} }
else if (m_physicsActor.Flying) else if (m_physicsActor.Flying)
{ {
// This should probably be HOVER and not Fly
// We're not moving and flying
SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1); SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1);
} }
else else
SetMovementAnimation(Animations.AnimsLLUUID["STAND"], 1); SetMovementAnimation(Animations.AnimsLLUUID["STAND"], 1);
// We're not moving.. and we're not doing anything.. so play the stand animation
} }
} }
} }
/// <summary>
/// Adds a new movement
/// </summary>
protected void AddNewMovement(Vector3 vec, Quaternion rotation) protected void AddNewMovement(Vector3 vec, Quaternion rotation)
{ {
if (m_isChildAgent) if (m_isChildAgent)
@ -935,6 +979,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
direc.z *= 3; direc.z *= 3;
//System.Console.WriteLine("Jump"); //System.Console.WriteLine("Jump");
// PreJump and jump happen too quickly. Many times prejump gets ignored.
SetMovementAnimation(Animations.AnimsLLUUID["PREJUMP"], 1); SetMovementAnimation(Animations.AnimsLLUUID["PREJUMP"], 1);
SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1);
} }
@ -946,7 +991,9 @@ namespace OpenSim.Region.Environment.Scenes
newVelocity.Z = direc.z; newVelocity.Z = direc.z;
m_forcesList.Add(newVelocity); m_forcesList.Add(newVelocity);
} }
/// <summary>
/// Sets whether or not the agent is typing.
/// </summary>
public void setTyping(bool typing) public void setTyping(bool typing)
{ {
if (m_isChildAgent) if (m_isChildAgent)
@ -1010,7 +1057,7 @@ namespace OpenSim.Region.Environment.Scenes
#region Update Client(s) #region Update Client(s)
/// <summary> /// <summary>
/// /// Sends a location update to the client connected to this scenePresence
/// </summary> /// </summary>
/// <param name="RemoteClient"></param> /// <param name="RemoteClient"></param>
public void SendTerseUpdateToClient(IClientAPI RemoteClient) public void SendTerseUpdateToClient(IClientAPI RemoteClient)
@ -1027,7 +1074,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// Send a location/velocity/accelleration update to all agents in scene
/// </summary> /// </summary>
public void SendTerseUpdateToAllClients() public void SendTerseUpdateToAllClients()
{ {
@ -1055,7 +1102,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar)
/// </summary> /// </summary>
/// <param name="remoteAvatar"></param> /// <param name="remoteAvatar"></param>
public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
@ -1063,7 +1110,9 @@ namespace OpenSim.Region.Environment.Scenes
remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid,
LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), m_parentID); LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), m_parentID);
} }
/// <summary>
/// Tell *ALL* agents about this agent
/// </summary>
public void SendFullUpdateToAllClients() public void SendFullUpdateToAllClients()
{ {
List<ScenePresence> avatars = m_scene.GetScenePresences(); List<ScenePresence> avatars = m_scene.GetScenePresences();
@ -1167,7 +1216,9 @@ namespace OpenSim.Region.Environment.Scenes
#endregion #endregion
#region Significant Movement Method #region Significant Movement Method
/// <summary>
/// This checks for a significant movement and sends a courselocationchange update
/// </summary>
protected void CheckForSignificantMovement() protected void CheckForSignificantMovement()
{ {
if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.02) if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.02)
@ -1186,7 +1237,7 @@ namespace OpenSim.Region.Environment.Scenes
#region Border Crossing Methods #region Border Crossing Methods
/// <summary> /// <summary>
/// /// Checks to see if the avatar is in range of a border and calls CrossToNewRegion
/// </summary> /// </summary>
protected void CheckForBorderCrossing() protected void CheckForBorderCrossing()
{ {
@ -1210,7 +1261,10 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// Moves the agent outside the region bounds
/// Tells neighbor region that we're crossing to it
/// If the neighbor accepts, remove the agent's viewable avatar from this scene
/// set them to a child agent.
/// </summary> /// </summary>
protected void CrossToNewRegion() protected void CrossToNewRegion()
{ {
@ -1262,7 +1316,10 @@ namespace OpenSim.Region.Environment.Scenes
} }
#endregion #endregion
/// <summary>
/// This allows the Sim owner the abiility to kick users from their sim currently.
/// It tells the client that the agent has permission to do so.
/// </summary>
public void GrantGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token) public void GrantGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token)
{ {
GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket(); GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
@ -1279,6 +1336,10 @@ namespace OpenSim.Region.Environment.Scenes
respondPacket.AgentData = adb; respondPacket.AgentData = adb;
ControllingClient.OutPacket(respondPacket, ThrottleOutPacketType.Task); ControllingClient.OutPacket(respondPacket, ThrottleOutPacketType.Task);
} }
/// <summary>
/// This updates important decision making data about a child agent
/// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region
/// </summary>
public void ChildAgentDataUpdate(ChildAgentDataUpdate cAgentData) public void ChildAgentDataUpdate(ChildAgentDataUpdate cAgentData)
{ {
// //
@ -1301,7 +1362,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// handles part of the PID controller function for moving an avatar.
/// </summary> /// </summary>
public override void UpdateMovement() public override void UpdateMovement()
{ {
@ -1363,6 +1424,9 @@ namespace OpenSim.Region.Environment.Scenes
throw new Exception("Can't set Text on avatar."); throw new Exception("Can't set Text on avatar.");
} }
/// <summary>
/// Adds a physical representation of the avatar to the Physics plugin
/// </summary>
public void AddToPhysicalScene() public void AddToPhysicalScene()
{ {
PhysicsScene scene = m_scene.PhysicsScene; PhysicsScene scene = m_scene.PhysicsScene;
@ -1375,7 +1439,7 @@ namespace OpenSim.Region.Environment.Scenes
m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
} }
// Event called by the physics plugin to tell the avatar about a collision.
private void PhysicsCollisionUpdate(EventArgs e) private void PhysicsCollisionUpdate(EventArgs e)
{ {
bool isUserMoving = Velocity.X > 0 || Velocity.Y > 0; bool isUserMoving = Velocity.X > 0 || Velocity.Y > 0;