diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 138 |
1 files changed, 84 insertions, 54 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 7081ced..f85d3d9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -349,7 +349,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
349 | public virtual Quaternion Rotation | 349 | public virtual Quaternion Rotation |
350 | { | 350 | { |
351 | get { return m_rotation; } | 351 | get { return m_rotation; } |
352 | set { m_rotation = value; } | 352 | set { |
353 | lockPartsForRead(true); | ||
354 | try | ||
355 | { | ||
356 | foreach(SceneObjectPart p in m_parts.Values) | ||
357 | { | ||
358 | p.StoreUndoState(UndoType.STATE_GROUP_ROTATION); | ||
359 | } | ||
360 | } | ||
361 | finally | ||
362 | { | ||
363 | lockPartsForRead(false); | ||
364 | } | ||
365 | m_rotation = value; | ||
366 | } | ||
353 | } | 367 | } |
354 | 368 | ||
355 | public Quaternion GroupRotation | 369 | public Quaternion GroupRotation |
@@ -431,7 +445,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
431 | } | 445 | } |
432 | 446 | ||
433 | lockPartsForRead(true); | 447 | lockPartsForRead(true); |
434 | 448 | foreach (SceneObjectPart part in m_parts.Values) | |
449 | { | ||
450 | part.IgnoreUndoUpdate = true; | ||
451 | } | ||
435 | if (RootPart.GetStatusSandbox()) | 452 | if (RootPart.GetStatusSandbox()) |
436 | { | 453 | { |
437 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) | 454 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) |
@@ -443,12 +460,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
443 | return; | 460 | return; |
444 | } | 461 | } |
445 | } | 462 | } |
446 | |||
447 | foreach (SceneObjectPart part in m_parts.Values) | 463 | foreach (SceneObjectPart part in m_parts.Values) |
448 | { | 464 | { |
465 | part.IgnoreUndoUpdate = false; | ||
466 | part.StoreUndoState(UndoType.STATE_GROUP_POSITION); | ||
449 | part.GroupPosition = val; | 467 | part.GroupPosition = val; |
450 | } | 468 | } |
451 | |||
452 | lockPartsForRead(false); | 469 | lockPartsForRead(false); |
453 | 470 | ||
454 | //if (m_rootPart.PhysActor != null) | 471 | //if (m_rootPart.PhysActor != null) |
@@ -724,7 +741,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
724 | { | 741 | { |
725 | foreach (SceneObjectPart part in m_parts.Values) | 742 | foreach (SceneObjectPart part in m_parts.Values) |
726 | { | 743 | { |
727 | |||
728 | Vector3 partscale = part.Scale; | 744 | Vector3 partscale = part.Scale; |
729 | Vector3 partoffset = part.OffsetPosition; | 745 | Vector3 partoffset = part.OffsetPosition; |
730 | 746 | ||
@@ -1471,7 +1487,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1471 | 1487 | ||
1472 | public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient) | 1488 | public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient) |
1473 | { | 1489 | { |
1474 | part.StoreUndoState(); | 1490 | part.StoreUndoState(UndoType.STATE_PRIM_ALL); |
1475 | part.OnGrab(offsetPos, remoteClient); | 1491 | part.OnGrab(offsetPos, remoteClient); |
1476 | } | 1492 | } |
1477 | 1493 | ||
@@ -1700,7 +1716,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1700 | "[SCENE]: Storing {0}, {1} in {2}", | 1716 | "[SCENE]: Storing {0}, {1} in {2}", |
1701 | Name, UUID, m_scene.RegionInfo.RegionName); | 1717 | Name, UUID, m_scene.RegionInfo.RegionName); |
1702 | 1718 | ||
1703 | SceneObjectGroup backup_group = Copy(OwnerID, GroupID, false); | 1719 | SceneObjectGroup backup_group = Copy(false); |
1704 | backup_group.RootPart.Velocity = RootPart.Velocity; | 1720 | backup_group.RootPart.Velocity = RootPart.Velocity; |
1705 | backup_group.RootPart.Acceleration = RootPart.Acceleration; | 1721 | backup_group.RootPart.Acceleration = RootPart.Acceleration; |
1706 | backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity; | 1722 | backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity; |
@@ -1758,7 +1774,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1758 | /// Duplicates this object, including operations such as physics set up and attaching to the backup event. | 1774 | /// Duplicates this object, including operations such as physics set up and attaching to the backup event. |
1759 | /// </summary> | 1775 | /// </summary> |
1760 | /// <returns></returns> | 1776 | /// <returns></returns> |
1761 | public SceneObjectGroup Copy(UUID cAgentID, UUID cGroupID, bool userExposed) | 1777 | public SceneObjectGroup Copy(bool userExposed) |
1762 | { | 1778 | { |
1763 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); | 1779 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); |
1764 | dupe.m_isBackedUp = false; | 1780 | dupe.m_isBackedUp = false; |
@@ -1781,7 +1797,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1781 | dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); | 1797 | dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); |
1782 | 1798 | ||
1783 | if (!userExposed) | 1799 | if (!userExposed) |
1800 | { | ||
1784 | dupe.RootPart.IsAttachment = previousAttachmentStatus; | 1801 | dupe.RootPart.IsAttachment = previousAttachmentStatus; |
1802 | } | ||
1785 | 1803 | ||
1786 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); | 1804 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); |
1787 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; | 1805 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; |
@@ -1806,16 +1824,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1806 | dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); | 1824 | dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); |
1807 | } | 1825 | } |
1808 | 1826 | ||
1809 | // Now we've made a copy that replaces this one, we need to | ||
1810 | // switch the owner to the person who did the copying | ||
1811 | // Second Life copies an object and duplicates the first one in it's place | ||
1812 | // So, we have to make a copy of this one, set it in it's place then set the owner on this one | ||
1813 | if (userExposed) | ||
1814 | { | ||
1815 | SetRootPartOwner(m_rootPart, cAgentID, cGroupID); | ||
1816 | m_rootPart.ScheduleFullUpdate(); | ||
1817 | } | ||
1818 | |||
1819 | List<SceneObjectPart> partList; | 1827 | List<SceneObjectPart> partList; |
1820 | 1828 | ||
1821 | lockPartsForRead(true); | 1829 | lockPartsForRead(true); |
@@ -1837,12 +1845,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1837 | SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); | 1845 | SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); |
1838 | 1846 | ||
1839 | newPart.LinkNum = part.LinkNum; | 1847 | newPart.LinkNum = part.LinkNum; |
1840 | |||
1841 | if (userExposed) | ||
1842 | { | ||
1843 | SetPartOwner(newPart, cAgentID, cGroupID); | ||
1844 | newPart.ScheduleFullUpdate(); | ||
1845 | } | ||
1846 | } | 1848 | } |
1847 | } | 1849 | } |
1848 | 1850 | ||
@@ -3146,7 +3148,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3146 | SceneObjectPart part = GetChildPart(localID); | 3148 | SceneObjectPart part = GetChildPart(localID); |
3147 | if (part != null) | 3149 | if (part != null) |
3148 | { | 3150 | { |
3149 | part.IgnoreUndoUpdate = true; | ||
3150 | if (scale.X > m_scene.m_maxNonphys) | 3151 | if (scale.X > m_scene.m_maxNonphys) |
3151 | scale.X = m_scene.m_maxNonphys; | 3152 | scale.X = m_scene.m_maxNonphys; |
3152 | if (scale.Y > m_scene.m_maxNonphys) | 3153 | if (scale.Y > m_scene.m_maxNonphys) |
@@ -3232,8 +3233,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3232 | y *= a; | 3233 | y *= a; |
3233 | z *= a; | 3234 | z *= a; |
3234 | } | 3235 | } |
3235 | obPart.IgnoreUndoUpdate = false; | 3236 | |
3236 | obPart.StoreUndoState(); | ||
3237 | } | 3237 | } |
3238 | } | 3238 | } |
3239 | } | 3239 | } |
@@ -3243,16 +3243,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3243 | Vector3 prevScale = part.Scale; | 3243 | Vector3 prevScale = part.Scale; |
3244 | prevScale.X *= x; | 3244 | prevScale.X *= x; |
3245 | prevScale.Y *= y; | 3245 | prevScale.Y *= y; |
3246 | prevScale.Z *= z; | 3246 | prevScale.Z *= z;; |
3247 | |||
3248 | part.IgnoreUndoUpdate = false; | ||
3249 | part.StoreUndoState(UndoType.STATE_GROUP_SCALE); | ||
3250 | part.IgnoreUndoUpdate = true; | ||
3247 | part.Resize(prevScale); | 3251 | part.Resize(prevScale); |
3252 | part.IgnoreUndoUpdate = false; | ||
3248 | 3253 | ||
3249 | lockPartsForRead(true); | 3254 | lockPartsForRead(true); |
3250 | { | 3255 | { |
3251 | foreach (SceneObjectPart obPart in m_parts.Values) | 3256 | foreach (SceneObjectPart obPart in m_parts.Values) |
3252 | { | 3257 | { |
3253 | obPart.IgnoreUndoUpdate = true; | ||
3254 | if (obPart.UUID != m_rootPart.UUID) | 3258 | if (obPart.UUID != m_rootPart.UUID) |
3255 | { | 3259 | { |
3260 | obPart.IgnoreUndoUpdate = false; | ||
3261 | obPart.StoreUndoState(UndoType.STATE_GROUP_SCALE); | ||
3262 | obPart.IgnoreUndoUpdate = true; | ||
3263 | |||
3256 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); | 3264 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); |
3257 | currentpos.X *= x; | 3265 | currentpos.X *= x; |
3258 | currentpos.Y *= y; | 3266 | currentpos.Y *= y; |
@@ -3265,7 +3273,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3265 | obPart.UpdateOffSet(currentpos); | 3273 | obPart.UpdateOffSet(currentpos); |
3266 | } | 3274 | } |
3267 | obPart.IgnoreUndoUpdate = false; | 3275 | obPart.IgnoreUndoUpdate = false; |
3268 | obPart.StoreUndoState(); | ||
3269 | } | 3276 | } |
3270 | } | 3277 | } |
3271 | lockPartsForRead(false); | 3278 | lockPartsForRead(false); |
@@ -3277,7 +3284,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3277 | } | 3284 | } |
3278 | 3285 | ||
3279 | part.IgnoreUndoUpdate = false; | 3286 | part.IgnoreUndoUpdate = false; |
3280 | part.StoreUndoState(); | ||
3281 | HasGroupChanged = true; | 3287 | HasGroupChanged = true; |
3282 | ScheduleGroupForTerseUpdate(); | 3288 | ScheduleGroupForTerseUpdate(); |
3283 | } | 3289 | } |
@@ -3293,14 +3299,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3293 | /// <param name="pos"></param> | 3299 | /// <param name="pos"></param> |
3294 | public void UpdateGroupPosition(Vector3 pos) | 3300 | public void UpdateGroupPosition(Vector3 pos) |
3295 | { | 3301 | { |
3296 | foreach (SceneObjectPart part in Children.Values) | ||
3297 | { | ||
3298 | part.StoreUndoState(); | ||
3299 | } | ||
3300 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) | 3302 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) |
3301 | { | 3303 | { |
3302 | if (IsAttachment) | 3304 | if (IsAttachment) |
3303 | { | 3305 | { |
3306 | m_rootPart.StoreUndoState(UndoType.STATE_GROUP_POSITION); | ||
3304 | m_rootPart.AttachedPos = pos; | 3307 | m_rootPart.AttachedPos = pos; |
3305 | } | 3308 | } |
3306 | if (RootPart.GetStatusSandbox()) | 3309 | if (RootPart.GetStatusSandbox()) |
@@ -3333,7 +3336,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3333 | SceneObjectPart part = GetChildPart(localID); | 3336 | SceneObjectPart part = GetChildPart(localID); |
3334 | foreach (SceneObjectPart parts in Children.Values) | 3337 | foreach (SceneObjectPart parts in Children.Values) |
3335 | { | 3338 | { |
3336 | parts.StoreUndoState(); | 3339 | parts.StoreUndoState(UndoType.STATE_PRIM_POSITION); |
3337 | } | 3340 | } |
3338 | if (part != null) | 3341 | if (part != null) |
3339 | { | 3342 | { |
@@ -3358,7 +3361,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3358 | { | 3361 | { |
3359 | foreach (SceneObjectPart part in Children.Values) | 3362 | foreach (SceneObjectPart part in Children.Values) |
3360 | { | 3363 | { |
3361 | part.StoreUndoState(); | 3364 | part.StoreUndoState(UndoType.STATE_PRIM_POSITION); |
3362 | } | 3365 | } |
3363 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); | 3366 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); |
3364 | Vector3 oldPos = | 3367 | Vector3 oldPos = |
@@ -3383,10 +3386,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3383 | } | 3386 | } |
3384 | lockPartsForRead(false); | 3387 | lockPartsForRead(false); |
3385 | 3388 | ||
3386 | AbsolutePosition = newPos; | 3389 | //We have to set undoing here because otherwise an undo state will be saved |
3390 | if (!m_rootPart.Undoing) | ||
3391 | { | ||
3392 | m_rootPart.Undoing = true; | ||
3393 | AbsolutePosition = newPos; | ||
3394 | m_rootPart.Undoing = false; | ||
3395 | } | ||
3396 | else | ||
3397 | { | ||
3398 | AbsolutePosition = newPos; | ||
3399 | } | ||
3387 | 3400 | ||
3388 | HasGroupChanged = true; | 3401 | HasGroupChanged = true; |
3389 | ScheduleGroupForTerseUpdate(); | 3402 | if (m_rootPart.Undoing) |
3403 | { | ||
3404 | ScheduleGroupForFullUpdate(); | ||
3405 | } | ||
3406 | else | ||
3407 | { | ||
3408 | ScheduleGroupForTerseUpdate(); | ||
3409 | } | ||
3390 | } | 3410 | } |
3391 | 3411 | ||
3392 | public void OffsetForNewRegion(Vector3 offset) | 3412 | public void OffsetForNewRegion(Vector3 offset) |
@@ -3406,7 +3426,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3406 | { | 3426 | { |
3407 | foreach (SceneObjectPart parts in Children.Values) | 3427 | foreach (SceneObjectPart parts in Children.Values) |
3408 | { | 3428 | { |
3409 | parts.StoreUndoState(); | 3429 | parts.StoreUndoState(UndoType.STATE_GROUP_ROTATION); |
3410 | } | 3430 | } |
3411 | m_rootPart.UpdateRotation(rot); | 3431 | m_rootPart.UpdateRotation(rot); |
3412 | 3432 | ||
@@ -3430,7 +3450,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3430 | { | 3450 | { |
3431 | foreach (SceneObjectPart parts in Children.Values) | 3451 | foreach (SceneObjectPart parts in Children.Values) |
3432 | { | 3452 | { |
3433 | parts.StoreUndoState(); | 3453 | parts.StoreUndoState(UndoType.STATE_GROUP_ROTATION); |
3434 | } | 3454 | } |
3435 | m_rootPart.UpdateRotation(rot); | 3455 | m_rootPart.UpdateRotation(rot); |
3436 | 3456 | ||
@@ -3457,7 +3477,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3457 | SceneObjectPart part = GetChildPart(localID); | 3477 | SceneObjectPart part = GetChildPart(localID); |
3458 | foreach (SceneObjectPart parts in Children.Values) | 3478 | foreach (SceneObjectPart parts in Children.Values) |
3459 | { | 3479 | { |
3460 | parts.StoreUndoState(); | 3480 | parts.StoreUndoState(UndoType.STATE_PRIM_ROTATION); |
3461 | } | 3481 | } |
3462 | if (part != null) | 3482 | if (part != null) |
3463 | { | 3483 | { |
@@ -3485,15 +3505,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3485 | if (part.UUID == m_rootPart.UUID) | 3505 | if (part.UUID == m_rootPart.UUID) |
3486 | { | 3506 | { |
3487 | UpdateRootRotation(rot); | 3507 | UpdateRootRotation(rot); |
3488 | AbsolutePosition = pos; | 3508 | if (!m_rootPart.Undoing) |
3509 | { | ||
3510 | m_rootPart.Undoing = true; | ||
3511 | AbsolutePosition = pos; | ||
3512 | m_rootPart.Undoing = false; | ||
3513 | } | ||
3514 | else | ||
3515 | { | ||
3516 | AbsolutePosition = pos; | ||
3517 | } | ||
3489 | } | 3518 | } |
3490 | else | 3519 | else |
3491 | { | 3520 | { |
3521 | part.StoreUndoState(UndoType.STATE_PRIM_ROTATION); | ||
3492 | part.IgnoreUndoUpdate = true; | 3522 | part.IgnoreUndoUpdate = true; |
3493 | part.UpdateRotation(rot); | 3523 | part.UpdateRotation(rot); |
3494 | part.OffsetPosition = pos; | 3524 | part.OffsetPosition = pos; |
3495 | part.IgnoreUndoUpdate = false; | 3525 | part.IgnoreUndoUpdate = false; |
3496 | part.StoreUndoState(); | ||
3497 | } | 3526 | } |
3498 | } | 3527 | } |
3499 | } | 3528 | } |
@@ -3507,7 +3536,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3507 | Quaternion axRot = rot; | 3536 | Quaternion axRot = rot; |
3508 | Quaternion oldParentRot = m_rootPart.RotationOffset; | 3537 | Quaternion oldParentRot = m_rootPart.RotationOffset; |
3509 | 3538 | ||
3510 | m_rootPart.StoreUndoState(); | 3539 | m_rootPart.StoreUndoState(UndoType.STATE_PRIM_ROTATION); |
3540 | bool cancelUndo = false; | ||
3541 | if (!m_rootPart.Undoing) | ||
3542 | { | ||
3543 | m_rootPart.Undoing = true; | ||
3544 | cancelUndo = true; | ||
3545 | } | ||
3511 | m_rootPart.UpdateRotation(rot); | 3546 | m_rootPart.UpdateRotation(rot); |
3512 | if (m_rootPart.PhysActor != null) | 3547 | if (m_rootPart.PhysActor != null) |
3513 | { | 3548 | { |
@@ -3531,18 +3566,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3531 | newRot *= Quaternion.Inverse(axRot); | 3566 | newRot *= Quaternion.Inverse(axRot); |
3532 | prim.RotationOffset = newRot; | 3567 | prim.RotationOffset = newRot; |
3533 | prim.ScheduleTerseUpdate(); | 3568 | prim.ScheduleTerseUpdate(); |
3569 | prim.IgnoreUndoUpdate = false; | ||
3534 | } | 3570 | } |
3535 | } | 3571 | } |
3536 | 3572 | if (cancelUndo == true) | |
3537 | foreach (SceneObjectPart childpart in Children.Values) | ||
3538 | { | 3573 | { |
3539 | if (childpart != m_rootPart) | 3574 | m_rootPart.Undoing = false; |
3540 | { | ||
3541 | childpart.IgnoreUndoUpdate = false; | ||
3542 | childpart.StoreUndoState(); | ||
3543 | } | ||
3544 | } | 3575 | } |
3545 | |||
3546 | lockPartsForRead(false); | 3576 | lockPartsForRead(false); |
3547 | 3577 | ||
3548 | m_rootPart.ScheduleTerseUpdate(); | 3578 | m_rootPart.ScheduleTerseUpdate(); |
@@ -3911,7 +3941,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3911 | 3941 | ||
3912 | public virtual ISceneObject CloneForNewScene() | 3942 | public virtual ISceneObject CloneForNewScene() |
3913 | { | 3943 | { |
3914 | SceneObjectGroup sog = Copy(this.OwnerID, this.GroupID, false); | 3944 | SceneObjectGroup sog = Copy(false); |
3915 | sog.m_isDeleted = false; | 3945 | sog.m_isDeleted = false; |
3916 | return sog; | 3946 | return sog; |
3917 | } | 3947 | } |