aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-03-09 02:38:11 +0000
committerJustin Clark-Casey (justincc)2012-03-09 02:38:11 +0000
commit94e58ff6b9368975925cea4697077a8e59162bc0 (patch)
tree1798f25a23316e71182aca5634fcd5eebb4133bf /OpenSim/Region/Framework
parentrefactor: cleanup SP.HandleAgentSit so that everything is done within one if ... (diff)
downloadopensim-SC_OLD-94e58ff6b9368975925cea4697077a8e59162bc0.zip
opensim-SC_OLD-94e58ff6b9368975925cea4697077a8e59162bc0.tar.gz
opensim-SC_OLD-94e58ff6b9368975925cea4697077a8e59162bc0.tar.bz2
opensim-SC_OLD-94e58ff6b9368975925cea4697077a8e59162bc0.tar.xz
Use SP.ParentPart instead of ParentID in places where it's more efficient (saving extra null checks, etc.)
However, it looks like we should retain SP.ParentID since it's much easier to use that in places where another thread could change ParentPart to null. Otherwise one has to clumsily put ParentPart in a reference, etc. to avoid a race.
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs24
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs26
2 files changed, 18 insertions, 32 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 66fb493..dd0ca43 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -215,27 +215,13 @@ namespace OpenSim.Region.Framework.Scenes
215 if (sp.IsChildAgent) 215 if (sp.IsChildAgent)
216 continue; 216 continue;
217 217
218 if (sp.ParentID != 0) 218 SceneObjectPart sitPart = sp.ParentPart;
219 { 219 if (sitPart != null)
220 // sitting avatar 220 coarseLocations.Add(sitPart.AbsolutePosition + sp.OffsetPosition);
221 SceneObjectPart sop = m_parentScene.GetSceneObjectPart(sp.ParentID);
222 if (sop != null)
223 {
224 coarseLocations.Add(sop.AbsolutePosition + sp.OffsetPosition);
225 avatarUUIDs.Add(sp.UUID);
226 }
227 else
228 {
229 // we can't find the parent.. ! arg!
230 coarseLocations.Add(sp.AbsolutePosition);
231 avatarUUIDs.Add(sp.UUID);
232 }
233 }
234 else 221 else
235 {
236 coarseLocations.Add(sp.AbsolutePosition); 222 coarseLocations.Add(sp.AbsolutePosition);
237 avatarUUIDs.Add(sp.UUID); 223
238 } 224 avatarUUIDs.Add(sp.UUID);
239 } 225 }
240 } 226 }
241 227
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index c9dc7fd..aab0bf0 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -432,7 +432,7 @@ namespace OpenSim.Region.Framework.Scenes
432 { 432 {
433 get 433 get
434 { 434 {
435 if (PhysicsActor != null && m_parentID == 0) 435 if (PhysicsActor != null && ParentID == 0)
436 { 436 {
437 m_pos = PhysicsActor.Position; 437 m_pos = PhysicsActor.Position;
438 438
@@ -504,6 +504,7 @@ namespace OpenSim.Region.Framework.Scenes
504 // There is no offset position when not seated 504 // There is no offset position when not seated
505 if (ParentID == 0) 505 if (ParentID == 0)
506 return; 506 return;
507
507 m_pos = value; 508 m_pos = value;
508 } 509 }
509 } 510 }
@@ -562,19 +563,18 @@ namespace OpenSim.Region.Framework.Scenes
562 563
563 public bool IsChildAgent { get; set; } 564 public bool IsChildAgent { get; set; }
564 565
565 public uint ParentID 566 /// <summary>
566 { 567 /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero.
567 get { return m_parentID; } 568 /// </summary>
568 set { m_parentID = value; } 569 public uint ParentID { get; set; }
569 }
570 private uint m_parentID;
571 570
572 public SceneObjectPart ParentPart 571 /// <summary>
573 { 572 /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null.
574 get { return m_parentPart; } 573 /// </summary>
575 set { m_parentPart = value; } 574 /// <remarks>
576 } 575 /// If you use this property then you must take a reference since another thread could set it to null.
577 private SceneObjectPart m_parentPart = null; 576 /// </remarks>
577 public SceneObjectPart ParentPart { get; set; }
578 578
579 public float Health 579 public float Health
580 { 580 {