diff options
Shift and Drag copying should now work correctly. [This was one of those stupid little one line bugs that was so much fun to track down that I decided to spend a few hours on it)
Linking groups should now work better than it did, but still a bit of work to do on getting the rotations of all the parts after linking right.
Added part of dalien's #301 patch (xml loading/saving related parts with some small changes)
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 33f41e9..cd38b23 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -251,11 +251,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
251 | public new SceneObjectGroup Copy() | 251 | public new SceneObjectGroup Copy() |
252 | { | 252 | { |
253 | SceneObjectGroup dupe = (SceneObjectGroup)this.MemberwiseClone(); | 253 | SceneObjectGroup dupe = (SceneObjectGroup)this.MemberwiseClone(); |
254 | dupe.m_parts = new Dictionary<LLUUID, SceneObjectPart>(); | ||
254 | dupe.m_parts.Clear(); | 255 | dupe.m_parts.Clear(); |
255 | dupe.AbsolutePosition = new LLVector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); | 256 | dupe.AbsolutePosition = new LLVector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); |
256 | dupe.m_scene = m_scene; | 257 | dupe.m_scene = m_scene; |
257 | dupe.m_regionHandle = this.m_regionHandle; | 258 | dupe.m_regionHandle = this.m_regionHandle; |
258 | |||
259 | dupe.CopyRootPart(this.m_rootPart); | 259 | dupe.CopyRootPart(this.m_rootPart); |
260 | 260 | ||
261 | List<SceneObjectPart> partList = new List<SceneObjectPart>(this.m_parts.Values); | 261 | List<SceneObjectPart> partList = new List<SceneObjectPart>(this.m_parts.Values); |
@@ -291,6 +291,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
291 | public void CopyPart(SceneObjectPart part) | 291 | public void CopyPart(SceneObjectPart part) |
292 | { | 292 | { |
293 | SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate()); | 293 | SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate()); |
294 | newPart.SetParent(this); | ||
294 | this.m_parts.Add(newPart.UUID, newPart); | 295 | this.m_parts.Add(newPart.UUID, newPart); |
295 | this.SetPartAsNonRoot(newPart); | 296 | this.SetPartAsNonRoot(newPart); |
296 | } | 297 | } |
@@ -431,6 +432,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
431 | public void LinkToGroup(SceneObjectGroup objectGroup) | 432 | public void LinkToGroup(SceneObjectGroup objectGroup) |
432 | { | 433 | { |
433 | SceneObjectPart linkPart = objectGroup.m_rootPart; | 434 | SceneObjectPart linkPart = objectGroup.m_rootPart; |
435 | Axiom.Math.Vector3 oldGroupPosition = new Vector3(linkPart.GroupPosition.X, linkPart.GroupPosition.Y, linkPart.GroupPosition.Z); | ||
436 | Axiom.Math.Quaternion oldRootRotation = new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y, linkPart.RotationOffset.Z); | ||
437 | |||
434 | linkPart.OffsetPosition = linkPart.GroupPosition - this.AbsolutePosition; | 438 | linkPart.OffsetPosition = linkPart.GroupPosition - this.AbsolutePosition; |
435 | linkPart.GroupPosition = this.AbsolutePosition; | 439 | linkPart.GroupPosition = this.AbsolutePosition; |
436 | 440 | ||
@@ -450,20 +454,39 @@ namespace OpenSim.Region.Environment.Scenes | |||
450 | { | 454 | { |
451 | if (part.UUID != objectGroup.m_rootPart.UUID) | 455 | if (part.UUID != objectGroup.m_rootPart.UUID) |
452 | { | 456 | { |
453 | this.LinkNonRootPart(part); | 457 | this.LinkNonRootPart(part, oldGroupPosition, oldRootRotation); |
454 | } | 458 | } |
455 | } | 459 | } |
456 | 460 | ||
457 | m_scene.EventManager.OnBackup -= objectGroup.ProcessBackup; | 461 | m_scene.EventManager.OnBackup -= objectGroup.ProcessBackup; |
458 | m_scene.DeleteEntity(objectGroup.UUID); | 462 | m_scene.DeleteEntity(objectGroup.UUID); |
463 | objectGroup.DeleteParts(); | ||
459 | this.ScheduleGroupForFullUpdate(); | 464 | this.ScheduleGroupForFullUpdate(); |
460 | } | 465 | } |
461 | 466 | ||
462 | private void LinkNonRootPart(SceneObjectPart part) | 467 | private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation) |
463 | { | 468 | { |
464 | part.SetParent(this); | 469 | part.SetParent(this); |
465 | part.ParentID = this.m_rootPart.LocalID; | 470 | part.ParentID = this.m_rootPart.LocalID; |
466 | this.m_parts.Add(part.UUID, part); | 471 | this.m_parts.Add(part.UUID, part); |
472 | |||
473 | Vector3 axiomOldPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z); | ||
474 | axiomOldPos = oldGroupRotation * axiomOldPos; | ||
475 | axiomOldPos += oldGroupPosition; | ||
476 | LLVector3 oldAbsolutePosition = new LLVector3(axiomOldPos.x, axiomOldPos.y, axiomOldPos.z); | ||
477 | part.OffsetPosition = oldAbsolutePosition - this.AbsolutePosition; | ||
478 | |||
479 | Quaternion axiomRootRotation = new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z); | ||
480 | |||
481 | Vector3 axiomPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z); | ||
482 | axiomPos = axiomRootRotation.Inverse() * axiomPos; | ||
483 | part.OffsetPosition = new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z); | ||
484 | |||
485 | Quaternion axiomPartRotation = new Quaternion(part.RotationOffset.W, part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z); | ||
486 | |||
487 | axiomPartRotation = oldGroupRotation * axiomPartRotation; | ||
488 | axiomPartRotation = axiomRootRotation.Inverse() * axiomPartRotation; | ||
489 | part.RotationOffset = new LLQuaternion(axiomPartRotation.x, axiomPartRotation.y, axiomPartRotation.z, axiomPartRotation.w); | ||
467 | } | 490 | } |
468 | 491 | ||
469 | /// <summary> | 492 | /// <summary> |
@@ -669,7 +692,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
669 | public void UpdateGroupPosition(LLVector3 pos) | 692 | public void UpdateGroupPosition(LLVector3 pos) |
670 | { | 693 | { |
671 | this.AbsolutePosition = pos; | 694 | this.AbsolutePosition = pos; |
672 | 695 | this.ScheduleGroupForTerseUpdate(); | |
673 | } | 696 | } |
674 | 697 | ||
675 | /// <summary> | 698 | /// <summary> |
@@ -720,6 +743,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
720 | pos.X = newPos.X; | 743 | pos.X = newPos.X; |
721 | pos.Y = newPos.Y; | 744 | pos.Y = newPos.Y; |
722 | pos.Z = newPos.Z; | 745 | pos.Z = newPos.Z; |
746 | this.ScheduleGroupForTerseUpdate(); | ||
723 | } | 747 | } |
724 | #endregion | 748 | #endregion |
725 | 749 | ||
@@ -859,7 +883,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
859 | /// <param name="part"></param> | 883 | /// <param name="part"></param> |
860 | internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part) | 884 | internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part) |
861 | { | 885 | { |
862 | if (m_rootPart == part) | 886 | if (m_rootPart.UUID == part.UUID) |
863 | { | 887 | { |
864 | part.SendFullUpdateToClient(remoteClient, AbsolutePosition); | 888 | part.SendFullUpdateToClient(remoteClient, AbsolutePosition); |
865 | } | 889 | } |
@@ -876,7 +900,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
876 | /// <param name="part"></param> | 900 | /// <param name="part"></param> |
877 | internal void SendPartTerseUpdate(IClientAPI remoteClient, SceneObjectPart part) | 901 | internal void SendPartTerseUpdate(IClientAPI remoteClient, SceneObjectPart part) |
878 | { | 902 | { |
879 | if (m_rootPart == part) | 903 | if (m_rootPart.UUID == part.UUID) |
880 | { | 904 | { |
881 | part.SendTerseUpdateToClient(remoteClient, AbsolutePosition); | 905 | part.SendTerseUpdateToClient(remoteClient, AbsolutePosition); |
882 | } | 906 | } |
@@ -932,6 +956,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
932 | } | 956 | } |
933 | } | 957 | } |
934 | 958 | ||
959 | public void RegenerateFullIDs() | ||
960 | { | ||
961 | foreach (SceneObjectPart part in this.m_parts.Values) | ||
962 | { | ||
963 | part.UUID = LLUUID.Random(); | ||
964 | } | ||
965 | } | ||
966 | |||
935 | public LLUUID GetPartsFullID(uint localID) | 967 | public LLUUID GetPartsFullID(uint localID) |
936 | { | 968 | { |
937 | SceneObjectPart part = this.GetChildPrim(localID); | 969 | SceneObjectPart part = this.GetChildPrim(localID); |
@@ -984,6 +1016,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
984 | } | 1016 | } |
985 | } | 1017 | } |
986 | 1018 | ||
1019 | public void DeleteParts() | ||
1020 | { | ||
1021 | this.m_rootPart = null; | ||
1022 | this.m_parts.Clear(); | ||
1023 | } | ||
1024 | |||
987 | public override void SetText(string text, Vector3 color, double alpha) | 1025 | public override void SetText(string text, Vector3 color, double alpha) |
988 | { | 1026 | { |
989 | Text = text; | 1027 | Text = text; |