aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
diff options
context:
space:
mode:
authorRobert Adams2013-12-17 06:18:13 -0800
committerRobert Adams2013-12-17 06:18:13 -0800
commit6937eec2588fab5e73c3ddc74c4ddc1bb35e7527 (patch)
tree4372b6dfa7f2e277312c0547a099f6ffeea6e91f /OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
parentvarregion: rename 'LegacyRegionLocX' back to 'RegionLocX' and same for Y and Z. (diff)
parentFix issue with editing notes for other avatars (diff)
downloadopensim-SC-6937eec2588fab5e73c3ddc74c4ddc1bb35e7527.zip
opensim-SC-6937eec2588fab5e73c3ddc74c4ddc1bb35e7527.tar.gz
opensim-SC-6937eec2588fab5e73c3ddc74c4ddc1bb35e7527.tar.bz2
opensim-SC-6937eec2588fab5e73c3ddc74c4ddc1bb35e7527.tar.xz
Merge branch 'master' into varregion
Add new region crossing code to varregion Conflicts: OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs OpenSim/Region/Framework/Scenes/ScenePresence.cs
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs194
1 files changed, 192 insertions, 2 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index eed8908..d4cbf7d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -118,6 +118,7 @@ namespace OpenSim.Region.Framework.Scenes
118 private bool m_hasGroupChanged = false; 118 private bool m_hasGroupChanged = false;
119 private long timeFirstChanged; 119 private long timeFirstChanged;
120 private long timeLastChanged; 120 private long timeLastChanged;
121 private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>();
121 122
122 /// <summary> 123 /// <summary>
123 /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage 124 /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage
@@ -428,6 +429,12 @@ namespace OpenSim.Region.Framework.Scenes
428 return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); 429 return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0));
429 } 430 }
430 431
432 private struct avtocrossInfo
433 {
434 public ScenePresence av;
435 public uint ParentID;
436 }
437
431 /// <summary> 438 /// <summary>
432 /// The absolute position of this scene object in the scene 439 /// The absolute position of this scene object in the scene
433 /// </summary> 440 /// </summary>
@@ -455,13 +462,122 @@ namespace OpenSim.Region.Framework.Scenes
455 || Scene.TestBorderCross(val, Cardinals.S)) 462 || Scene.TestBorderCross(val, Cardinals.S))
456 && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) 463 && !IsAttachmentCheckFull() && (!Scene.LoadingPrims))
457 { 464 {
465 IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
466 string version = String.Empty;
467 Vector3 newpos = Vector3.Zero;
468 OpenSim.Services.Interfaces.GridRegion destination = null;
469
458 if (m_rootPart.KeyframeMotion != null) 470 if (m_rootPart.KeyframeMotion != null)
459 m_rootPart.KeyframeMotion.StartCrossingCheck(); 471 m_rootPart.KeyframeMotion.StartCrossingCheck();
460 472
461 m_scene.CrossPrimGroupIntoNewRegion(val, this, true); 473 bool canCross = true;
474 foreach (ScenePresence av in m_linkedAvatars)
475 {
476 // We need to cross these agents. First, let's find
477 // out if any of them can't cross for some reason.
478 // We have to deny the crossing entirely if any
479 // of them are banned. Alternatively, we could
480 // unsit banned agents....
481
482
483 // We set the avatar position as being the object
484 // position to get the region to send to
485 if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out version, out newpos)) == null)
486 {
487 canCross = false;
488 break;
489 }
490
491 m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName);
492 }
493
494 if (canCross)
495 {
496 // We unparent the SP quietly so that it won't
497 // be made to stand up
498
499 List<avtocrossInfo> avsToCross = new List<avtocrossInfo>();
500
501 foreach (ScenePresence av in m_linkedAvatars)
502 {
503 avtocrossInfo avinfo = new avtocrossInfo();
504 SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID);
505 if (parentPart != null)
506 av.ParentUUID = parentPart.UUID;
507
508 avinfo.av = av;
509 avinfo.ParentID = av.ParentID;
510 avsToCross.Add(avinfo);
511
512 av.PrevSitOffset = av.OffsetPosition;
513 av.ParentID = 0;
514 }
515
516 // m_linkedAvatars.Clear();
517 m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
518
519 // Normalize
520 if (val.X >= Constants.RegionSize)
521 val.X -= Constants.RegionSize;
522 if (val.Y >= Constants.RegionSize)
523 val.Y -= Constants.RegionSize;
524 if (val.X < 0)
525 val.X += Constants.RegionSize;
526 if (val.Y < 0)
527 val.Y += Constants.RegionSize;
528
529 // If it's deleted, crossing was successful
530 if (IsDeleted)
531 {
532 // foreach (ScenePresence av in m_linkedAvatars)
533 foreach (avtocrossInfo avinfo in avsToCross)
534 {
535 ScenePresence av = avinfo.av;
536 if (!av.IsInTransit) // just in case...
537 {
538 m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val);
539
540 av.IsInTransit = true;
541
542 CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync;
543 d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d);
544 }
545 else
546 m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val);
547 }
548 avsToCross.Clear();
549 return;
550 }
551 else // cross failed, put avas back ??
552 {
553 foreach (avtocrossInfo avinfo in avsToCross)
554 {
555 ScenePresence av = avinfo.av;
556 av.ParentUUID = UUID.Zero;
557 av.ParentID = avinfo.ParentID;
558// m_linkedAvatars.Add(av);
559 }
560 }
561 avsToCross.Clear();
562
563 }
564 else
565 {
566 if (m_rootPart.KeyframeMotion != null)
567 m_rootPart.KeyframeMotion.CrossingFailure();
568
569 if (RootPart.PhysActor != null)
570 {
571 RootPart.PhysActor.CrossingFailure();
572 }
573 }
574 Vector3 oldp = AbsolutePosition;
575 val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f);
576 val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f);
577 val.Z = Util.Clamp<float>(oldp.Z, 0.5f, 4096.0f);
462 } 578 }
463 } 579 }
464 580
465 if (RootPart.GetStatusSandbox()) 581 if (RootPart.GetStatusSandbox())
466 { 582 {
467 if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) 583 if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10)
@@ -495,6 +611,39 @@ namespace OpenSim.Region.Framework.Scenes
495 } 611 }
496 } 612 }
497 613
614 public override Vector3 Velocity
615 {
616 get { return RootPart.Velocity; }
617 set { RootPart.Velocity = value; }
618 }
619
620 private void CrossAgentToNewRegionCompleted(IAsyncResult iar)
621 {
622 CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState;
623 ScenePresence agent = icon.EndInvoke(iar);
624
625 //// If the cross was successful, this agent is a child agent
626 if (agent.IsChildAgent)
627 {
628 if (agent.ParentUUID != UUID.Zero)
629 {
630 agent.ParentPart = null;
631// agent.ParentPosition = Vector3.Zero;
632// agent.ParentUUID = UUID.Zero;
633 }
634 }
635
636 agent.ParentUUID = UUID.Zero;
637// agent.Reset();
638// else // Not successful
639// agent.RestoreInCurrentScene();
640
641 // In any case
642 agent.IsInTransit = false;
643
644 m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
645 }
646
498 public override uint LocalId 647 public override uint LocalId
499 { 648 {
500 get { return m_rootPart.LocalId; } 649 get { return m_rootPart.LocalId; }
@@ -1096,6 +1245,7 @@ namespace OpenSim.Region.Framework.Scenes
1096 } 1245 }
1097 } 1246 }
1098 1247
1248
1099 /// <summary> 1249 /// <summary>
1100 /// 1250 ///
1101 /// </summary> 1251 /// </summary>
@@ -1105,6 +1255,46 @@ namespace OpenSim.Region.Framework.Scenes
1105 part.ParentID = m_rootPart.LocalId; 1255 part.ParentID = m_rootPart.LocalId;
1106 part.ClearUndoState(); 1256 part.ClearUndoState();
1107 } 1257 }
1258 /// <summary>
1259 /// Add the avatar to this linkset (avatar is sat).
1260 /// </summary>
1261 /// <param name="agentID"></param>
1262 public void AddAvatar(UUID agentID)
1263 {
1264 ScenePresence presence;
1265 if (m_scene.TryGetScenePresence(agentID, out presence))
1266 {
1267 if (!m_linkedAvatars.Contains(presence))
1268 {
1269 m_linkedAvatars.Add(presence);
1270 }
1271 }
1272 }
1273
1274 /// <summary>
1275 /// Delete the avatar from this linkset (avatar is unsat).
1276 /// </summary>
1277 /// <param name="agentID"></param>
1278 public void DeleteAvatar(UUID agentID)
1279 {
1280 ScenePresence presence;
1281 if (m_scene.TryGetScenePresence(agentID, out presence))
1282 {
1283 if (m_linkedAvatars.Contains(presence))
1284 {
1285 m_linkedAvatars.Remove(presence);
1286 }
1287 }
1288 }
1289
1290 /// <summary>
1291 /// Returns the list of linked presences (avatars sat on this group)
1292 /// </summary>
1293 /// <param name="agentID"></param>
1294 public List<ScenePresence> GetLinkedAvatars()
1295 {
1296 return m_linkedAvatars;
1297 }
1108 1298
1109 public ushort GetTimeDilation() 1299 public ushort GetTimeDilation()
1110 { 1300 {