aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/SerializableRegionInfo.cs3
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs79
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs23
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs146
4 files changed, 187 insertions, 64 deletions
diff --git a/OpenSim/Framework/SerializableRegionInfo.cs b/OpenSim/Framework/SerializableRegionInfo.cs
index 4f20940..5df22cd 100644
--- a/OpenSim/Framework/SerializableRegionInfo.cs
+++ b/OpenSim/Framework/SerializableRegionInfo.cs
@@ -40,6 +40,9 @@ namespace OpenSim.Framework
40 [Serializable] 40 [Serializable]
41 public class SearializableRegionInfo 41 public class SearializableRegionInfo
42 { 42 {
43 /// <summary>
44 /// This is a serializable version of RegionInfo
45 /// </summary>
43 public SearializableRegionInfo() 46 public SearializableRegionInfo()
44 { 47 {
45 } 48 }
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 587d940..d808a88 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -130,20 +130,20 @@ namespace OpenSim.Region.Environment.Scenes
130 } 130 }
131 131
132 protected readonly LandManager m_LandManager; 132 protected readonly LandManager m_LandManager;
133 133 // LandManager object instance that manages land related things. Parcel, primcounts etc..
134 public LandManager LandManager 134 public LandManager LandManager
135 { 135 {
136 get { return m_LandManager; } 136 get { return m_LandManager; }
137 } 137 }
138 138
139 protected readonly EstateManager m_estateManager; 139 protected readonly EstateManager m_estateManager;
140 140 // an instance to the physics plugin's Scene object.
141 public PhysicsScene PhysicsScene 141 public PhysicsScene PhysicsScene
142 { 142 {
143 set { m_innerScene.PhysicsScene = value; } 143 set { m_innerScene.PhysicsScene = value; }
144 get { return (m_innerScene.PhysicsScene); } 144 get { return (m_innerScene.PhysicsScene); }
145 } 145 }
146 146 // This gets locked so things stay thread safe.
147 public object SyncRoot 147 public object SyncRoot
148 { 148 {
149 get { return m_innerScene.m_syncRoot; } 149 get { return m_innerScene.m_syncRoot; }
@@ -160,6 +160,8 @@ namespace OpenSim.Region.Environment.Scenes
160 } 160 }
161 161
162 protected readonly PermissionManager m_permissionManager; 162 protected readonly PermissionManager m_permissionManager;
163 // This is the instance to the permissions manager.
164 // This manages permissions to clients on in world objects
163 165
164 public PermissionManager PermissionsMngr 166 public PermissionManager PermissionsMngr
165 { 167 {
@@ -171,11 +173,13 @@ namespace OpenSim.Region.Environment.Scenes
171 get { return m_timePhase; } 173 get { return m_timePhase; }
172 } 174 }
173 175
176 // Local reference to the objects in the scene (which are held in innerScene)
174 public Dictionary<LLUUID, SceneObjectGroup> Objects 177 public Dictionary<LLUUID, SceneObjectGroup> Objects
175 { 178 {
176 get { return m_innerScene.SceneObjects; } 179 get { return m_innerScene.SceneObjects; }
177 } 180 }
178 181
182 // Reference to all of the agents in the scene (root and child)
179 protected Dictionary<LLUUID, ScenePresence> m_scenePresences 183 protected Dictionary<LLUUID, ScenePresence> m_scenePresences
180 { 184 {
181 get { return m_innerScene.ScenePresences; } 185 get { return m_innerScene.ScenePresences; }
@@ -267,9 +271,10 @@ namespace OpenSim.Region.Environment.Scenes
267 271
268 public override bool OtherRegionUp(RegionInfo otherRegion) 272 public override bool OtherRegionUp(RegionInfo otherRegion)
269 { 273 {
270 // Another region is up. 274 // Another region is up.
271 // We have to tell all our ScenePresences about it.. 275 // Gets called from Grid Comms (SceneCommunicationService<---RegionListener<----LocalBackEnd<----OGS1)
272 // and add it to the neighbor list. 276 // We have to tell all our ScenePresences about it..
277 // and add it to the neighbor list.
273 278
274 // We only add it to the neighbor list if it's within 1 region from here. 279 // We only add it to the neighbor list if it's within 1 region from here.
275 // Agents may have draw distance values that cross two regions though, so 280 // Agents may have draw distance values that cross two regions though, so
@@ -324,8 +329,15 @@ namespace OpenSim.Region.Environment.Scenes
324 return true; 329 return true;
325 } 330 }
326 331
332 // Given float seconds, this will restart the region.
333
327 public virtual void Restart(float seconds) 334 public virtual void Restart(float seconds)
328 { 335 {
336 // notifications are done in 15 second increments
337 // so .. if the number of seconds is less then 15 seconds, it's not really a restart request
338 // It's a 'Cancel restart' request.
339
340 // RestartNow() does immediate restarting.
329 if (seconds < 15) 341 if (seconds < 15)
330 { 342 {
331 m_restartTimer.Stop(); 343 m_restartTimer.Stop();
@@ -333,6 +345,7 @@ namespace OpenSim.Region.Environment.Scenes
333 } 345 }
334 else 346 else
335 { 347 {
348 // Now we figure out what to set the timer to that does the notifications and calls, RestartNow()
336 m_restartTimer.Interval = 15000; 349 m_restartTimer.Interval = 15000;
337 m_incrementsof15seconds = (int) seconds/15; 350 m_incrementsof15seconds = (int) seconds/15;
338 m_RestartTimerCounter = 0; 351 m_RestartTimerCounter = 0;
@@ -344,6 +357,10 @@ namespace OpenSim.Region.Environment.Scenes
344 } 357 }
345 } 358 }
346 359
360 // The Restart timer has occured.
361 // We have to figure out if this is a notification or if the number of seconds specified in Restart
362 // have elapsed.
363 // If they have elapsed, call RestartNow()
347 public void RestartTimer_Elapsed(object sender, ElapsedEventArgs e) 364 public void RestartTimer_Elapsed(object sender, ElapsedEventArgs e)
348 { 365 {
349 m_RestartTimerCounter++; 366 m_RestartTimerCounter++;
@@ -360,6 +377,7 @@ namespace OpenSim.Region.Environment.Scenes
360 } 377 }
361 } 378 }
362 379
380 // This causes the region to restart immediatley.
363 public void RestartNow() 381 public void RestartNow()
364 { 382 {
365 MainLog.Instance.Error("REGION", "Closing"); 383 MainLog.Instance.Error("REGION", "Closing");
@@ -368,6 +386,11 @@ namespace OpenSim.Region.Environment.Scenes
368 base.Restart(0); 386 base.Restart(0);
369 } 387 }
370 388
389 // This is a helper function that notifies root agents in this region that a new sim near them has come up
390 // This is in the form of a timer because when an instance of OpenSim.exe is started,
391 // Even though the sims initialize, they don't listen until 'all of the sims are initialized'
392 // If we tell an agent about a sim that's not listening yet, the agent will not be able to connect to it.
393 // subsequently the agent will never see the region come back online.
371 public void RestartNotifyWaitElapsed(object sender, ElapsedEventArgs e) 394 public void RestartNotifyWaitElapsed(object sender, ElapsedEventArgs e)
372 { 395 {
373 m_restartWaitTimer.Stop(); 396 m_restartWaitTimer.Stop();
@@ -378,6 +401,7 @@ namespace OpenSim.Region.Environment.Scenes
378 401
379 ForEachScenePresence(delegate(ScenePresence agent) 402 ForEachScenePresence(delegate(ScenePresence agent)
380 { 403 {
404 // If agent is a root agent.
381 if (!agent.IsChildAgent) 405 if (!agent.IsChildAgent)
382 { 406 {
383 //agent.ControllingClient.new 407 //agent.ControllingClient.new
@@ -391,14 +415,18 @@ namespace OpenSim.Region.Environment.Scenes
391 catch (System.NullReferenceException) 415 catch (System.NullReferenceException)
392 { 416 {
393 // This means that we're not booted up completely yet. 417 // This means that we're not booted up completely yet.
418 // This shouldn't happen too often anymore.
394 } 419 }
395 } 420 }
421
396 // Reset list to nothing. 422 // Reset list to nothing.
397 m_regionRestartNotifyList.Clear(); 423 m_regionRestartNotifyList.Clear();
398 } 424 }
399 425
426 // This is the method that shuts down the scene.
400 public override void Close() 427 public override void Close()
401 { 428 {
429 // Kick all ROOT agents with the message, 'The simulator is going down'
402 ForEachScenePresence(delegate(ScenePresence avatar) 430 ForEachScenePresence(delegate(ScenePresence avatar)
403 { 431 {
404 if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) 432 if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle))
@@ -409,18 +437,23 @@ namespace OpenSim.Region.Environment.Scenes
409 437
410 avatar.ControllingClient.OutPacket(new libsecondlife.Packets.DisableSimulatorPacket(), ThrottleOutPacketType.Task); 438 avatar.ControllingClient.OutPacket(new libsecondlife.Packets.DisableSimulatorPacket(), ThrottleOutPacketType.Task);
411 }); 439 });
412 440
441 // Wait here, or the kick messages won't actually get to the agents before the scene terminates.
413 Thread.Sleep(500); 442 Thread.Sleep(500);
414 443
444 // Stop all client threads.
415 ForEachScenePresence(delegate(ScenePresence avatar) 445 ForEachScenePresence(delegate(ScenePresence avatar)
416 { 446 {
417 avatar.ControllingClient.Stop(); 447 avatar.ControllingClient.Stop();
418 }); 448 });
419 449 // Stop updating the scene objects and agents.
420 m_heartbeatTimer.Close(); 450 m_heartbeatTimer.Close();
451 // close the inner scene
421 m_innerScene.Close(); 452 m_innerScene.Close();
453 // De-register with region communications (events cleanup)
422 UnRegisterReginWithComms(); 454 UnRegisterReginWithComms();
423 455
456 // Shut down all non shared modules.
424 foreach (IRegionModule module in Modules.Values) 457 foreach (IRegionModule module in Modules.Values)
425 { 458 {
426 if (!module.IsSharedModule) 459 if (!module.IsSharedModule)
@@ -430,6 +463,7 @@ namespace OpenSim.Region.Environment.Scenes
430 } 463 }
431 Modules.Clear(); 464 Modules.Clear();
432 465
466 // call the base class Close method.
433 base.Close(); 467 base.Close();
434 } 468 }
435 469
@@ -530,7 +564,7 @@ namespace OpenSim.Region.Environment.Scenes
530 m_lastupdate = DateTime.Now; 564 m_lastupdate = DateTime.Now;
531 } 565 }
532 } 566 }
533 567 //Updates the time in the viewer.
534 private void UpdateInWorldTime() 568 private void UpdateInWorldTime()
535 { 569 {
536 m_timeUpdateCount++; 570 m_timeUpdateCount++;
@@ -1234,7 +1268,7 @@ namespace OpenSim.Region.Environment.Scenes
1234 return true; 1268 return true;
1235 } 1269 }
1236 /// <summary> 1270 /// <summary>
1237 /// 1271 /// Tell a single agent to disconnect from the region.
1238 /// </summary> 1272 /// </summary>
1239 /// <param name="regionHandle"></param> 1273 /// <param name="regionHandle"></param>
1240 /// <param name="agentID"></param> 1274 /// <param name="agentID"></param>
@@ -1245,6 +1279,7 @@ namespace OpenSim.Region.Environment.Scenes
1245 ScenePresence presence = m_innerScene.GetScenePresence(agentID); 1279 ScenePresence presence = m_innerScene.GetScenePresence(agentID);
1246 if (presence != null) 1280 if (presence != null)
1247 { 1281 {
1282 // Tell a single agent to disconnect from the region.
1248 libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); 1283 libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket();
1249 presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task); 1284 presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task);
1250 } 1285 }
@@ -1252,6 +1287,11 @@ namespace OpenSim.Region.Environment.Scenes
1252 } 1287 }
1253 1288
1254 /// <summary> 1289 /// <summary>
1290 /// Tell neighboring regions about this agent
1291 /// When the regions respond with a true value,
1292 /// tell the agents about the region.
1293 ///
1294 /// We have to tell the regions about the agents first otherwise it'll deny them access
1255 /// 1295 ///
1256 /// </summary> 1296 /// </summary>
1257 /// <param name="presence"></param> 1297 /// <param name="presence"></param>
@@ -1261,7 +1301,7 @@ namespace OpenSim.Region.Environment.Scenes
1261 } 1301 }
1262 1302
1263 /// <summary> 1303 /// <summary>
1264 /// 1304 /// Tell a neighboring region about this agent
1265 /// </summary> 1305 /// </summary>
1266 /// <param name="presence"></param> 1306 /// <param name="presence"></param>
1267 /// <param name="region"></param> 1307 /// <param name="region"></param>
@@ -1271,7 +1311,7 @@ namespace OpenSim.Region.Environment.Scenes
1271 } 1311 }
1272 1312
1273 /// <summary> 1313 /// <summary>
1274 /// 1314 /// Requests information about this region from gridcomms
1275 /// </summary> 1315 /// </summary>
1276 /// <param name="regionHandle"></param> 1316 /// <param name="regionHandle"></param>
1277 /// <returns></returns> 1317 /// <returns></returns>
@@ -1281,7 +1321,7 @@ namespace OpenSim.Region.Environment.Scenes
1281 } 1321 }
1282 1322
1283 /// <summary> 1323 /// <summary>
1284 /// 1324 /// Requests textures for map from minimum region to maximum region in world cordinates
1285 /// </summary> 1325 /// </summary>
1286 /// <param name="remoteClient"></param> 1326 /// <param name="remoteClient"></param>
1287 /// <param name="minX"></param> 1327 /// <param name="minX"></param>
@@ -1294,7 +1334,7 @@ namespace OpenSim.Region.Environment.Scenes
1294 } 1334 }
1295 1335
1296 /// <summary> 1336 /// <summary>
1297 /// 1337 /// Tries to teleport agent to other region.
1298 /// </summary> 1338 /// </summary>
1299 /// <param name="remoteClient"></param> 1339 /// <param name="remoteClient"></param>
1300 /// <param name="regionHandle"></param> 1340 /// <param name="regionHandle"></param>
@@ -1311,7 +1351,7 @@ namespace OpenSim.Region.Environment.Scenes
1311 } 1351 }
1312 1352
1313 /// <summary> 1353 /// <summary>
1314 /// 1354 /// Agent is crossing the border into a neighbouring region. Tell the neighbour about it!
1315 /// </summary> 1355 /// </summary>
1316 /// <param name="regionHandle"></param> 1356 /// <param name="regionHandle"></param>
1317 /// <param name="agentID"></param> 1357 /// <param name="agentID"></param>
@@ -1641,7 +1681,7 @@ namespace OpenSim.Region.Environment.Scenes
1641 #endregion 1681 #endregion
1642 1682
1643 /// <summary> 1683 /// <summary>
1644 /// 1684 /// Causes all clients to get a full object update on all of the objects in the scene.
1645 /// </summary> 1685 /// </summary>
1646 public void ForceClientUpdate() 1686 public void ForceClientUpdate()
1647 { 1687 {
@@ -1655,7 +1695,8 @@ namespace OpenSim.Region.Environment.Scenes
1655 } 1695 }
1656 1696
1657 /// <summary> 1697 /// <summary>
1658 /// 1698 /// This is currently only used for scale (to scale to MegaPrim size)
1699 /// There is a console command that calls this in OpenSimMain
1659 /// </summary> 1700 /// </summary>
1660 /// <param name="cmdparams"></param> 1701 /// <param name="cmdparams"></param>
1661 public void HandleEditCommand(string[] cmdparams) 1702 public void HandleEditCommand(string[] cmdparams)
@@ -1682,7 +1723,7 @@ namespace OpenSim.Region.Environment.Scenes
1682 } 1723 }
1683 1724
1684 /// <summary> 1725 /// <summary>
1685 /// 1726 /// Shows various details about the sim based on the parameters supplied by the console command in openSimMain.
1686 /// </summary> 1727 /// </summary>
1687 /// <param name="showWhat"></param> 1728 /// <param name="showWhat"></param>
1688 public void Show(string showWhat) 1729 public void Show(string showWhat)
@@ -1726,7 +1767,7 @@ namespace OpenSim.Region.Environment.Scenes
1726 #region Script Handling Methods 1767 #region Script Handling Methods
1727 1768
1728 /// <summary> 1769 /// <summary>
1729 /// 1770 /// Console command handler to send script command to script engine.
1730 /// </summary> 1771 /// </summary>
1731 /// <param name="args"></param> 1772 /// <param name="args"></param>
1732 public void SendCommandToPlugins(string[] args) 1773 public void SendCommandToPlugins(string[] args)
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
index 68bb3b5..ba9bf7b 100644
--- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
@@ -189,7 +189,8 @@ namespace OpenSim.Region.Environment.Scenes
189 } 189 }
190 190
191 /// <summary> 191 /// <summary>
192 /// 192 /// This informs all neighboring regions about agent "avatar".
193 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
193 /// </summary> 194 /// </summary>
194 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours) 195 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
195 { 196 {
@@ -222,6 +223,10 @@ namespace OpenSim.Region.Environment.Scenes
222 } 223 }
223 } 224 }
224 } 225 }
226 /// <summary>
227 /// This informs a single neighboring region about agent "avatar".
228 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
229 /// </summary>
225 public void InformNeighborChildAgent(ScenePresence avatar, RegionInfo region, List<RegionInfo> neighbours) 230 public void InformNeighborChildAgent(ScenePresence avatar, RegionInfo region, List<RegionInfo> neighbours)
226 { 231 {
227 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); 232 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
@@ -260,7 +265,10 @@ namespace OpenSim.Region.Environment.Scenes
260 MainLog.Instance.Notice("INTERGRID", "Failed to inform neighbors that I'm here"); 265 MainLog.Instance.Notice("INTERGRID", "Failed to inform neighbors that I'm here");
261 } 266 }
262 } 267 }
263 268 /// <summary>
269 /// Called by scene when region is initialized (not always when it's listening for agents)
270 /// This is an inter-region message that informs the surrounding neighbors that the sim is up.
271 /// </summary>
264 public void InformNeighborsThatRegionisUp(RegionInfo region) 272 public void InformNeighborsThatRegionisUp(RegionInfo region)
265 { 273 {
266 //MainLog.Instance.Verbose("INTER", debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); 274 //MainLog.Instance.Verbose("INTER", debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
@@ -286,6 +294,13 @@ namespace OpenSim.Region.Environment.Scenes
286 } 294 }
287 public delegate void SendChildAgentDataUpdateDelegate(ulong regionHandle, ChildAgentDataUpdate cAgentData); 295 public delegate void SendChildAgentDataUpdateDelegate(ulong regionHandle, ChildAgentDataUpdate cAgentData);
288 296
297 /// <summary>
298 /// This informs all neighboring regions about the settings of it's child agent.
299 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
300 ///
301 /// This contains information, such as, Draw Distance, Camera location, Current Position, Current throttle settings, etc.
302 ///
303 /// </summary>
289 private void SendChildAgentDataUpdateAsync(ulong regionHandle, ChildAgentDataUpdate cAgentData) 304 private void SendChildAgentDataUpdateAsync(ulong regionHandle, ChildAgentDataUpdate cAgentData)
290 { 305 {
291 MainLog.Instance.Notice("INTERGRID", "Informing a neighbor about my agent."); 306 MainLog.Instance.Notice("INTERGRID", "Informing a neighbor about my agent.");
@@ -317,7 +332,7 @@ namespace OpenSim.Region.Environment.Scenes
317 332
318 333
319 /// <summary> 334 /// <summary>
320 /// 335 /// Helper function to request neighbors from grid-comms
321 /// </summary> 336 /// </summary>
322 /// <param name="regionHandle"></param> 337 /// <param name="regionHandle"></param>
323 /// <returns></returns> 338 /// <returns></returns>
@@ -328,7 +343,7 @@ namespace OpenSim.Region.Environment.Scenes
328 } 343 }
329 344
330 /// <summary> 345 /// <summary>
331 /// 346 /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
332 /// </summary> 347 /// </summary>
333 /// <param name="minX"></param> 348 /// <param name="minX"></param>
334 /// <param name="minY"></param> 349 /// <param name="minY"></param>
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index c277011..201a547 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -61,10 +61,13 @@ namespace OpenSim.Region.Environment.Scenes
61 61
62 public bool IsRestrictedToRegion = false; 62 public bool IsRestrictedToRegion = false;
63 63
64 // Agent moves with a PID controller causing a force to be exerted.
64 private bool m_newForce = false; 65 private bool m_newForce = false;
65 private bool m_newAvatar = false; 66 private bool m_newAvatar = false;
66 private bool m_newCoarseLocations = true; 67 private bool m_newCoarseLocations = true;
67 private bool m_gotAllObjectsInScene = false; 68 private bool m_gotAllObjectsInScene = false;
69
70 // Default AV Height
68 private float m_avHeight = 127.0f; 71 private float m_avHeight = 127.0f;
69 72
70 protected RegionInfo m_regionInfo; 73 protected RegionInfo m_regionInfo;
@@ -73,7 +76,7 @@ namespace OpenSim.Region.Environment.Scenes
73 private readonly Vector3[] Dir_Vectors = new Vector3[6]; 76 private readonly Vector3[] Dir_Vectors = new Vector3[6];
74 private LLVector3 lastPhysPos = new LLVector3(); 77 private LLVector3 lastPhysPos = new LLVector3();
75 78
76 // Position of agent's camera in world 79 // Position of agent's camera in world (region cordinates)
77 protected Vector3 m_CameraCenter = new Vector3(0, 0, 0); 80 protected Vector3 m_CameraCenter = new Vector3(0, 0, 0);
78 81
79 // Use these three vectors to figure out what the agent is looking at 82 // Use these three vectors to figure out what the agent is looking at
@@ -88,7 +91,11 @@ namespace OpenSim.Region.Environment.Scenes
88 protected AvatarAppearance m_appearance; 91 protected AvatarAppearance m_appearance;
89 92
90 private readonly List<ulong> m_knownChildRegions = new List<ulong>(); //neighbouring regions we have enabled a child agent in 93 private readonly List<ulong> m_knownChildRegions = new List<ulong>(); //neighbouring regions we have enabled a child agent in
94
91 95
96 /// <summary>
97 /// Implemented Control Flags
98 /// </summary>
92 private enum Dir_ControlFlags 99 private enum Dir_ControlFlags
93 { 100 {
94 DIR_CONTROL_FLAG_FOWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, 101 DIR_CONTROL_FLAG_FOWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS,
@@ -114,7 +121,7 @@ namespace OpenSim.Region.Environment.Scenes
114 #region Properties 121 #region Properties
115 122
116 /// <summary> 123 /// <summary>
117 /// 124 /// Physical scene representation of this Avatar.
118 /// </summary> 125 /// </summary>
119 public PhysicsActor PhysicsActor 126 public PhysicsActor PhysicsActor
120 { 127 {
@@ -166,6 +173,10 @@ namespace OpenSim.Region.Environment.Scenes
166 set { m_allowMovement = value; } 173 set { m_allowMovement = value; }
167 } 174 }
168 175
176 /// <summary>
177 /// This works out to be the ClientView object associated with this avatar, or it's UDP connection manager
178 /// </summary>
179
169 private readonly IClientAPI m_controllingClient; 180 private readonly IClientAPI m_controllingClient;
170 protected PhysicsActor m_physicsActor; 181 protected PhysicsActor m_physicsActor;
171 182
@@ -176,6 +187,9 @@ namespace OpenSim.Region.Environment.Scenes
176 187
177 protected LLVector3 m_parentPosition = new LLVector3(); 188 protected LLVector3 m_parentPosition = new LLVector3();
178 189
190 /// <summary>
191 /// Absolute position of this avatar in 'region cordinates'
192 /// </summary>
179 public override LLVector3 AbsolutePosition 193 public override LLVector3 AbsolutePosition
180 { 194 {
181 get 195 get
@@ -209,7 +223,9 @@ namespace OpenSim.Region.Environment.Scenes
209 m_pos = value; 223 m_pos = value;
210 } 224 }
211 } 225 }
212 226 /// <summary>
227 /// Current Velocity of the avatar.
228 /// </summary>
213 public override LLVector3 Velocity 229 public override LLVector3 Velocity
214 { 230 {
215 get 231 get
@@ -244,6 +260,12 @@ namespace OpenSim.Region.Environment.Scenes
244 } 260 }
245 } 261 }
246 262
263 /// <summary>
264 /// If this is true, agent doesn't have a representation in this scene.
265 /// this is an agent 'looking into' this scene from a nearby scene(region)
266 ///
267 /// if False, this agent has a representation in this scene
268 /// </summary>
247 private bool m_isChildAgent = true; 269 private bool m_isChildAgent = true;
248 270
249 public bool IsChildAgent 271 public bool IsChildAgent
@@ -260,6 +282,9 @@ namespace OpenSim.Region.Environment.Scenes
260 set { m_parentID = value; } 282 set { m_parentID = value; }
261 } 283 }
262 284
285 /// <summary>
286 /// These are the region handles known by the avatar.
287 /// </summary>
263 public List<ulong> KnownChildRegions 288 public List<ulong> KnownChildRegions
264 { 289 {
265 get { return m_knownChildRegions; } 290 get { return m_knownChildRegions; }
@@ -461,7 +486,11 @@ namespace OpenSim.Region.Environment.Scenes
461 } 486 }
462 487
463 #region Status Methods 488 #region Status Methods
464 489 /// <summary>
490 /// This turns a child agent, into a root agent
491 /// This is called when an agent teleports into a region, or if an
492 /// agent crosses into this region from a neighbor over the border
493 /// </summary>
465 public void MakeRootAgent(LLVector3 pos, bool isFlying) 494 public void MakeRootAgent(LLVector3 pos, bool isFlying)
466 { 495 {
467 496
@@ -481,7 +510,13 @@ namespace OpenSim.Region.Environment.Scenes
481 //} 510 //}
482 511
483 } 512 }
484 513 /// <summary>
514 /// This turns a root agent into a child agent
515 /// when an agent departs this region for a neighbor, this gets called.
516 ///
517 /// It doesn't get called for a teleport. Reason being, an agent that
518 /// teleports out may not be anywhere near this region
519 /// </summary>
485 public void MakeChildAgent() 520 public void MakeChildAgent()
486 { 521 {
487 Velocity = new LLVector3(0, 0, 0); 522 Velocity = new LLVector3(0, 0, 0);
@@ -492,6 +527,9 @@ namespace OpenSim.Region.Environment.Scenes
492 //this.Pos = new LLVector3(128, 128, 70); 527 //this.Pos = new LLVector3(128, 128, 70);
493 } 528 }
494 529
530 /// <summary>
531 /// Removes physics plugin scene representation of this agent if it exists.
532 /// </summary>
495 private void RemoveFromPhysicalScene() 533 private void RemoveFromPhysicalScene()
496 { 534 {
497 if (PhysicsActor != null) 535 if (PhysicsActor != null)
@@ -538,7 +576,9 @@ namespace OpenSim.Region.Environment.Scenes
538 #endregion 576 #endregion
539 577
540 #region Event Handlers 578 #region Event Handlers
541 579 /// <summary>
580 /// Sets avatar height in the phyiscs plugin
581 /// </summary>
542 internal void SetHeight(float height) 582 internal void SetHeight(float height)
543 { 583 {
544 m_avHeight = height; 584 m_avHeight = height;
@@ -570,7 +610,9 @@ namespace OpenSim.Region.Environment.Scenes
570 MakeRootAgent(AbsolutePosition, false); 610 MakeRootAgent(AbsolutePosition, false);
571 } 611 }
572 } 612 }
573 613 /// <summary>
614 /// This is the event handler for client movement. If a client is moving, this event is triggering.
615 /// </summary>
574 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdatePacket agentData) 616 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdatePacket agentData)
575 { 617 {
576 //if (m_isChildAgent) 618 //if (m_isChildAgent)
@@ -608,26 +650,6 @@ namespace OpenSim.Region.Environment.Scenes
608 // The Agent's Draw distance setting 650 // The Agent's Draw distance setting
609 m_DrawDistance = agentData.AgentData.Far; 651 m_DrawDistance = agentData.AgentData.Far;
610 652
611 // We don't know the agent's draw distance until the first agentUpdate packet
612 //if (m_DrawDistance > 0)
613 //{
614 //if (!m_gotAllObjectsInScene && m_DrawDistance > 0)
615 //{
616 // This will need to end up being a space based invalidator
617 // where we send object updates on spaces in 3d space (possibily a cube)
618 // that the avatar hasn't been surrounding it's draw distance.
619 // It would be better if the distance increased incrementally
620 // until there was no space to update because either the avatar's draw
621 // distance is smaller then the space they've been or the avatar has explored
622 // all the space in the sim.
623
624 //m_scene.SendAllSceneObjectsToClient(this);
625 //m_gotAllObjectsInScene = true;
626 //}
627 //}
628 //MainLog.Instance.Verbose("CAMERA", "AtAxis:" + m_CameraAtAxis.ToString() + " Center:" + m_CameraCenter.ToString() + " LeftAxis:" + m_CameraLeftAxis.ToString() + " UpAxis:" + m_CameraUpAxis.ToString() + " Far:" + m_CameraFar);
629
630
631 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) 653 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
632 { 654 {
633 StandUp(); 655 StandUp();
@@ -793,7 +815,10 @@ namespace OpenSim.Region.Environment.Scenes
793 SetMovementAnimation(Animations.AnimsLLUUID["SIT"], 1); 815 SetMovementAnimation(Animations.AnimsLLUUID["SIT"], 1);
794 SendFullUpdateToAllClients(); 816 SendFullUpdateToAllClients();
795 } 817 }
796 818 /// <summary>
819 /// Event handler for the 'Always run' setting on the client
820 /// Tells the physics plugin to increase speed of movement.
821 /// </summary>
797 public void HandleSetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun) 822 public void HandleSetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun)
798 { 823 {
799 m_setAlwaysRun = SetAlwaysRun; 824 m_setAlwaysRun = SetAlwaysRun;
@@ -853,13 +878,18 @@ namespace OpenSim.Region.Environment.Scenes
853 SendAnimPack(); 878 SendAnimPack();
854 } 879 }
855 } 880 }
856 881 /// <summary>
882 /// This method handles agent movement related animations
883 /// </summary>
857 protected void UpdateMovementAnimations(bool update_movementflag) 884 protected void UpdateMovementAnimations(bool update_movementflag)
858 { 885 {
859 if (update_movementflag) 886 if (update_movementflag)
860 { 887 {
888 // Are we moving?
861 if (m_movementflag != 0) 889 if (m_movementflag != 0)
862 { 890 {
891 // We are moving
892 // Are we flying
863 if (m_physicsActor.Flying) 893 if (m_physicsActor.Flying)
864 { 894 {
865 SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1); 895 SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1);
@@ -867,18 +897,22 @@ namespace OpenSim.Region.Environment.Scenes
867 else if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && 897 else if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) &&
868 PhysicsActor.IsColliding) 898 PhysicsActor.IsColliding)
869 { 899 {
900 // Client is pressing the page down button and moving and is colliding with something
870 SetMovementAnimation(Animations.AnimsLLUUID["CROUCHWALK"], 1); 901 SetMovementAnimation(Animations.AnimsLLUUID["CROUCHWALK"], 1);
871 } 902 }
872 else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6) 903 else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6)
873 { 904 {
905 // Client is moving and falling at a velocity greater then 6 meters per unit
874 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); 906 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1);
875 } 907 }
876 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) 908 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
877 { 909 {
910 // client is moving, and colliding and pressing the page up button but isn't flying
878 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); 911 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1);
879 } 912 }
880 else if (m_setAlwaysRun) 913 else if (m_setAlwaysRun)
881 { 914 {
915 // We are running
882 SetMovementAnimation(Animations.AnimsLLUUID["RUN"], 1); 916 SetMovementAnimation(Animations.AnimsLLUUID["RUN"], 1);
883 } 917 }
884 else 918 else
@@ -886,29 +920,39 @@ namespace OpenSim.Region.Environment.Scenes
886 } 920 }
887 else 921 else
888 { 922 {
923 // Not moving
924
889 if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && 925 if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) &&
890 PhysicsActor.IsColliding) 926 PhysicsActor.IsColliding)
891 { 927 {
928 // Client pressing the page down button
892 SetMovementAnimation(Animations.AnimsLLUUID["CROUCH"], 1); 929 SetMovementAnimation(Animations.AnimsLLUUID["CROUCH"], 1);
893 } 930 }
894 else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6 && !m_physicsActor.Flying) 931 else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6 && !m_physicsActor.Flying)
895 { 932 {
933 // Not colliding, and we're not flying and we're falling at a speed of 6m per unit
896 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); 934 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1);
897 } 935 }
898 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) 936 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
899 { 937 {
938 // This is the standing jump
900 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); 939 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1);
901 } 940 }
902 else if (m_physicsActor.Flying) 941 else if (m_physicsActor.Flying)
903 { 942 {
943 // This should probably be HOVER and not Fly
944 // We're not moving and flying
904 SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1); 945 SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1);
905 } 946 }
906 else 947 else
907 SetMovementAnimation(Animations.AnimsLLUUID["STAND"], 1); 948 SetMovementAnimation(Animations.AnimsLLUUID["STAND"], 1);
949 // We're not moving.. and we're not doing anything.. so play the stand animation
908 } 950 }
909 } 951 }
910 } 952 }
911 953 /// <summary>
954 /// Adds a new movement
955 /// </summary>
912 protected void AddNewMovement(Vector3 vec, Quaternion rotation) 956 protected void AddNewMovement(Vector3 vec, Quaternion rotation)
913 { 957 {
914 if (m_isChildAgent) 958 if (m_isChildAgent)
@@ -935,6 +979,7 @@ namespace OpenSim.Region.Environment.Scenes
935 { 979 {
936 direc.z *= 3; 980 direc.z *= 3;
937 //System.Console.WriteLine("Jump"); 981 //System.Console.WriteLine("Jump");
982 // PreJump and jump happen too quickly. Many times prejump gets ignored.
938 SetMovementAnimation(Animations.AnimsLLUUID["PREJUMP"], 1); 983 SetMovementAnimation(Animations.AnimsLLUUID["PREJUMP"], 1);
939 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); 984 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1);
940 } 985 }
@@ -946,7 +991,9 @@ namespace OpenSim.Region.Environment.Scenes
946 newVelocity.Z = direc.z; 991 newVelocity.Z = direc.z;
947 m_forcesList.Add(newVelocity); 992 m_forcesList.Add(newVelocity);
948 } 993 }
949 994 /// <summary>
995 /// Sets whether or not the agent is typing.
996 /// </summary>
950 public void setTyping(bool typing) 997 public void setTyping(bool typing)
951 { 998 {
952 if (m_isChildAgent) 999 if (m_isChildAgent)
@@ -1010,7 +1057,7 @@ namespace OpenSim.Region.Environment.Scenes
1010 #region Update Client(s) 1057 #region Update Client(s)
1011 1058
1012 /// <summary> 1059 /// <summary>
1013 /// 1060 /// Sends a location update to the client connected to this scenePresence
1014 /// </summary> 1061 /// </summary>
1015 /// <param name="RemoteClient"></param> 1062 /// <param name="RemoteClient"></param>
1016 public void SendTerseUpdateToClient(IClientAPI RemoteClient) 1063 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
@@ -1027,7 +1074,7 @@ namespace OpenSim.Region.Environment.Scenes
1027 } 1074 }
1028 1075
1029 /// <summary> 1076 /// <summary>
1030 /// 1077 /// Send a location/velocity/accelleration update to all agents in scene
1031 /// </summary> 1078 /// </summary>
1032 public void SendTerseUpdateToAllClients() 1079 public void SendTerseUpdateToAllClients()
1033 { 1080 {
@@ -1055,7 +1102,7 @@ namespace OpenSim.Region.Environment.Scenes
1055 } 1102 }
1056 1103
1057 /// <summary> 1104 /// <summary>
1058 /// 1105 /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar)
1059 /// </summary> 1106 /// </summary>
1060 /// <param name="remoteAvatar"></param> 1107 /// <param name="remoteAvatar"></param>
1061 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) 1108 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
@@ -1063,7 +1110,9 @@ namespace OpenSim.Region.Environment.Scenes
1063 remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, 1110 remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid,
1064 LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), m_parentID); 1111 LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), m_parentID);
1065 } 1112 }
1066 1113 /// <summary>
1114 /// Tell *ALL* agents about this agent
1115 /// </summary>
1067 public void SendFullUpdateToAllClients() 1116 public void SendFullUpdateToAllClients()
1068 { 1117 {
1069 List<ScenePresence> avatars = m_scene.GetScenePresences(); 1118 List<ScenePresence> avatars = m_scene.GetScenePresences();
@@ -1167,7 +1216,9 @@ namespace OpenSim.Region.Environment.Scenes
1167 #endregion 1216 #endregion
1168 1217
1169 #region Significant Movement Method 1218 #region Significant Movement Method
1170 1219 /// <summary>
1220 /// This checks for a significant movement and sends a courselocationchange update
1221 /// </summary>
1171 protected void CheckForSignificantMovement() 1222 protected void CheckForSignificantMovement()
1172 { 1223 {
1173 if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.02) 1224 if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.02)
@@ -1186,7 +1237,7 @@ namespace OpenSim.Region.Environment.Scenes
1186 #region Border Crossing Methods 1237 #region Border Crossing Methods
1187 1238
1188 /// <summary> 1239 /// <summary>
1189 /// 1240 /// Checks to see if the avatar is in range of a border and calls CrossToNewRegion
1190 /// </summary> 1241 /// </summary>
1191 protected void CheckForBorderCrossing() 1242 protected void CheckForBorderCrossing()
1192 { 1243 {
@@ -1210,7 +1261,10 @@ namespace OpenSim.Region.Environment.Scenes
1210 } 1261 }
1211 1262
1212 /// <summary> 1263 /// <summary>
1213 /// 1264 /// Moves the agent outside the region bounds
1265 /// Tells neighbor region that we're crossing to it
1266 /// If the neighbor accepts, remove the agent's viewable avatar from this scene
1267 /// set them to a child agent.
1214 /// </summary> 1268 /// </summary>
1215 protected void CrossToNewRegion() 1269 protected void CrossToNewRegion()
1216 { 1270 {
@@ -1262,7 +1316,10 @@ namespace OpenSim.Region.Environment.Scenes
1262 } 1316 }
1263 1317
1264 #endregion 1318 #endregion
1265 1319 /// <summary>
1320 /// This allows the Sim owner the abiility to kick users from their sim currently.
1321 /// It tells the client that the agent has permission to do so.
1322 /// </summary>
1266 public void GrantGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token) 1323 public void GrantGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token)
1267 { 1324 {
1268 GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket(); 1325 GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
@@ -1279,6 +1336,10 @@ namespace OpenSim.Region.Environment.Scenes
1279 respondPacket.AgentData = adb; 1336 respondPacket.AgentData = adb;
1280 ControllingClient.OutPacket(respondPacket, ThrottleOutPacketType.Task); 1337 ControllingClient.OutPacket(respondPacket, ThrottleOutPacketType.Task);
1281 } 1338 }
1339 /// <summary>
1340 /// This updates important decision making data about a child agent
1341 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region
1342 /// </summary>
1282 public void ChildAgentDataUpdate(ChildAgentDataUpdate cAgentData) 1343 public void ChildAgentDataUpdate(ChildAgentDataUpdate cAgentData)
1283 { 1344 {
1284 // 1345 //
@@ -1301,7 +1362,7 @@ namespace OpenSim.Region.Environment.Scenes
1301 } 1362 }
1302 1363
1303 /// <summary> 1364 /// <summary>
1304 /// 1365 /// handles part of the PID controller function for moving an avatar.
1305 /// </summary> 1366 /// </summary>
1306 public override void UpdateMovement() 1367 public override void UpdateMovement()
1307 { 1368 {
@@ -1363,6 +1424,9 @@ namespace OpenSim.Region.Environment.Scenes
1363 throw new Exception("Can't set Text on avatar."); 1424 throw new Exception("Can't set Text on avatar.");
1364 } 1425 }
1365 1426
1427 /// <summary>
1428 /// Adds a physical representation of the avatar to the Physics plugin
1429 /// </summary>
1366 public void AddToPhysicalScene() 1430 public void AddToPhysicalScene()
1367 { 1431 {
1368 PhysicsScene scene = m_scene.PhysicsScene; 1432 PhysicsScene scene = m_scene.PhysicsScene;
@@ -1375,7 +1439,7 @@ namespace OpenSim.Region.Environment.Scenes
1375 m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; 1439 m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
1376 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 1440 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
1377 } 1441 }
1378 1442 // Event called by the physics plugin to tell the avatar about a collision.
1379 private void PhysicsCollisionUpdate(EventArgs e) 1443 private void PhysicsCollisionUpdate(EventArgs e)
1380 { 1444 {
1381 bool isUserMoving = Velocity.X > 0 || Velocity.Y > 0; 1445 bool isUserMoving = Velocity.X > 0 || Velocity.Y > 0;