aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorUbitUmarov2012-03-07 07:31:26 +0000
committerUbitUmarov2012-03-07 07:31:26 +0000
commit3d3b81e67698cc361a9eca28083f5f526ff1de2e (patch)
tree22b71ba2e23bcd2297f0f8be7470b76fdd9d08e6 /OpenSim/Region/Framework/Scenes
parentPrevent scripted region crossings from crashing with prim limits enabled (diff)
downloadopensim-SC_OLD-3d3b81e67698cc361a9eca28083f5f526ff1de2e.zip
opensim-SC_OLD-3d3b81e67698cc361a9eca28083f5f526ff1de2e.tar.gz
opensim-SC_OLD-3d3b81e67698cc361a9eca28083f5f526ff1de2e.tar.bz2
opensim-SC_OLD-3d3b81e67698cc361a9eca28083f5f526ff1de2e.tar.xz
changes on undo/redo (untested/incomplete). Think we may consider moving this mfrom SOP to client side. At least does seem to work a bit better ( again there wwas a issue on sop.copy )
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs72
-rw-r--r--OpenSim/Region/Framework/Scenes/UndoState.cs139
3 files changed, 66 insertions, 153 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 8809cd0..038eaa4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -549,11 +549,12 @@ namespace OpenSim.Region.Framework.Scenes
549 val.Z = Util.Clamp<float>(oldp.Z, 0.5f, 4096.0f); 549 val.Z = Util.Clamp<float>(oldp.Z, 0.5f, 4096.0f);
550 } 550 }
551 } 551 }
552 552/* don't see the need but worse don't see where is restored to false if things stay in
553 foreach (SceneObjectPart part in m_parts.GetArray()) 553 foreach (SceneObjectPart part in m_parts.GetArray())
554 { 554 {
555 part.IgnoreUndoUpdate = true; 555 part.IgnoreUndoUpdate = true;
556 } 556 }
557 */
557 if (RootPart.GetStatusSandbox()) 558 if (RootPart.GetStatusSandbox())
558 { 559 {
559 if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) 560 if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10)
@@ -3519,7 +3520,7 @@ namespace OpenSim.Region.Framework.Scenes
3519 if (part.UUID == m_rootPart.UUID) 3520 if (part.UUID == m_rootPart.UUID)
3520 { 3521 {
3521 UpdateRootRotation(rot); 3522 UpdateRootRotation(rot);
3522 if (!m_rootPart.Undoing) 3523/* if (!m_rootPart.Undoing)
3523 { 3524 {
3524 m_rootPart.Undoing = true; 3525 m_rootPart.Undoing = true;
3525 AbsolutePosition = pos; 3526 AbsolutePosition = pos;
@@ -3527,8 +3528,9 @@ namespace OpenSim.Region.Framework.Scenes
3527 } 3528 }
3528 else 3529 else
3529 { 3530 {
3531 */
3530 AbsolutePosition = pos; 3532 AbsolutePosition = pos;
3531 } 3533// }
3532 } 3534 }
3533 else 3535 else
3534 { 3536 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 9c06786..8dd2c76 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -263,8 +263,8 @@ namespace OpenSim.Region.Framework.Scenes
263 private bool m_occupied; // KF if any av is sitting on this prim 263 private bool m_occupied; // KF if any av is sitting on this prim
264 private string m_text = String.Empty; 264 private string m_text = String.Empty;
265 private string m_touchName = String.Empty; 265 private string m_touchName = String.Empty;
266 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5); 266 private Stack<UndoState> m_undo = new Stack<UndoState>(5);
267 private readonly Stack<UndoState> m_redo = new Stack<UndoState>(5); 267 private Stack<UndoState> m_redo = new Stack<UndoState>(5);
268 268
269 private bool m_passTouches; 269 private bool m_passTouches;
270 270
@@ -1711,6 +1711,11 @@ namespace OpenSim.Region.Framework.Scenes
1711 dupe.Category = Category; 1711 dupe.Category = Category;
1712 dupe.m_rezzed = m_rezzed; 1712 dupe.m_rezzed = m_rezzed;
1713 1713
1714 dupe.m_undo = new Stack<UndoState>(5);
1715 dupe.m_redo = new Stack<UndoState>(5);
1716 dupe.IgnoreUndoUpdate = false;
1717 dupe.Undoing = false;
1718
1714 dupe.m_inventory = new SceneObjectPartInventory(dupe); 1719 dupe.m_inventory = new SceneObjectPartInventory(dupe);
1715 dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); 1720 dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone();
1716 1721
@@ -3661,61 +3666,38 @@ namespace OpenSim.Region.Framework.Scenes
3661 3666
3662 public void StoreUndoState(bool forGroup) 3667 public void StoreUndoState(bool forGroup)
3663 { 3668 {
3664 if (!Undoing) 3669 if (!Undoing && !IgnoreUndoUpdate) // just to read better - undo is in progress, or suspended
3665 { 3670 {
3666 if (!IgnoreUndoUpdate) 3671 if (ParentGroup != null)
3667 { 3672 {
3668 if (ParentGroup != null) 3673 lock (m_undo)
3669 { 3674 {
3670 lock (m_undo) 3675 if (m_undo.Count > 0)
3671 { 3676 {
3672 if (m_undo.Count > 0) 3677 // see if we had a change
3673 {
3674 UndoState last = m_undo.Peek();
3675 if (last != null)
3676 {
3677 // TODO: May need to fix for group comparison
3678 if (last.Compare(this))
3679 {
3680 // m_log.DebugFormat(
3681 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3682 // Name, LocalId, m_undo.Count);
3683 3678
3684 return; 3679 UndoState last = m_undo.Peek();
3685 } 3680 if (last != null)
3681 {
3682 if (last.Compare(this, forGroup))
3683 {
3684 return;
3686 } 3685 }
3687 } 3686 }
3688 3687 }
3689 // m_log.DebugFormat(
3690 // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}",
3691 // Name, LocalId, forGroup, m_undo.Count);
3692
3693 if (ParentGroup.GetSceneMaxUndo() > 0)
3694 {
3695 UndoState nUndo = new UndoState(this, forGroup);
3696 3688
3697 m_undo.Push(nUndo); 3689 if (ParentGroup.GetSceneMaxUndo() > 0)
3690 {
3691 UndoState nUndo = new UndoState(this, forGroup);
3698 3692
3699 if (m_redo.Count > 0) 3693 m_undo.Push(nUndo);
3700 m_redo.Clear();
3701 3694
3702 // m_log.DebugFormat( 3695 if (m_redo.Count > 0)
3703 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3696 m_redo.Clear();
3704 // Name, LocalId, forGroup, m_undo.Count);
3705 }
3706 } 3697 }
3707 } 3698 }
3708 } 3699 }
3709 // else
3710 // {
3711 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3712 // }
3713 } 3700 }
3714 // else
3715 // {
3716 // m_log.DebugFormat(
3717 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3718 // }
3719 } 3701 }
3720 3702
3721 /// <summary> 3703 /// <summary>
@@ -3751,7 +3733,7 @@ namespace OpenSim.Region.Framework.Scenes
3751 nUndo = new UndoState(this, goback.ForGroup); 3733 nUndo = new UndoState(this, goback.ForGroup);
3752 } 3734 }
3753 3735
3754 goback.PlaybackState(this); 3736 goback.PlayState(this);
3755 3737
3756 if (nUndo != null) 3738 if (nUndo != null)
3757 m_redo.Push(nUndo); 3739 m_redo.Push(nUndo);
@@ -3785,7 +3767,7 @@ namespace OpenSim.Region.Framework.Scenes
3785 m_undo.Push(nUndo); 3767 m_undo.Push(nUndo);
3786 } 3768 }
3787 3769
3788 gofwd.PlayfwdState(this); 3770 gofwd.PlayState(this);
3789 } 3771 }
3790 3772
3791// m_log.DebugFormat( 3773// m_log.DebugFormat(
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 5ed3c79..029c828 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -66,43 +66,25 @@ namespace OpenSim.Region.Framework.Scenes
66 /// </summary> 66 /// </summary>
67 /// <param name="part"></param> 67 /// <param name="part"></param>
68 /// <param name="forGroup">True if the undo is for an entire group</param> 68 /// <param name="forGroup">True if the undo is for an entire group</param>
69 /// only for root parts ????
69 public UndoState(SceneObjectPart part, bool forGroup) 70 public UndoState(SceneObjectPart part, bool forGroup)
70 { 71 {
71 if (part.ParentID == 0) 72 if (part.ParentID == 0)
72 { 73 {
73 ForGroup = forGroup; 74 ForGroup = forGroup;
74
75 // if (ForGroup)
76 Position = part.ParentGroup.AbsolutePosition; 75 Position = part.ParentGroup.AbsolutePosition;
77 // else
78 // Position = part.OffsetPosition;
79
80 // m_log.DebugFormat(
81 // "[UNDO STATE]: Storing undo position {0} for root part", Position);
82
83 Rotation = part.RotationOffset; 76 Rotation = part.RotationOffset;
84 77 if (!forGroup)
85 // m_log.DebugFormat( 78 Scale = part.Shape.Scale;
86 // "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); 79 else
87 80 Scale = Vector3.Zero; // until we fix it
88 Scale = part.Shape.Scale;
89
90 // m_log.DebugFormat(
91 // "[UNDO STATE]: Storing undo scale {0} for root part", Scale);
92 } 81 }
93 else 82 else
94 { 83 {
84 ForGroup = false; // previus code implies only root parts can undo grp
95 Position = part.OffsetPosition; 85 Position = part.OffsetPosition;
96 // m_log.DebugFormat(
97 // "[UNDO STATE]: Storing undo position {0} for child part", Position);
98
99 Rotation = part.RotationOffset; 86 Rotation = part.RotationOffset;
100 // m_log.DebugFormat(
101 // "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation);
102
103 Scale = part.Shape.Scale; 87 Scale = part.Shape.Scale;
104 // m_log.DebugFormat(
105 // "[UNDO STATE]: Storing undo scale {0} for child part", Scale);
106 } 88 }
107 } 89 }
108 90
@@ -111,35 +93,42 @@ namespace OpenSim.Region.Framework.Scenes
111 /// </summary> 93 /// </summary>
112 /// <param name="part"></param> 94 /// <param name="part"></param>
113 /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns> 95 /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns>
114 public bool Compare(SceneObjectPart part) 96 public bool Compare(SceneObjectPart part, bool forgrp)
115 { 97 {
98 if (ForGroup != forgrp) // if diferent targets, then they are diferent
99 return false;
100
116 if (part != null) 101 if (part != null)
117 { 102 {
118 if (part.ParentID == 0) 103 if (part.ParentID == 0)
119 return 104 {
120 Position == part.ParentGroup.AbsolutePosition 105 // root part
121 && Rotation == part.RotationOffset 106 // grp position is same as part
122 && Scale == part.Shape.Scale; 107 if (Position != part.ParentGroup.AbsolutePosition)
108 return false;
109 if (Rotation != part.RotationOffset)
110 return false;
111 if (ForGroup)
112 return true; // for now don't do grp scale
113 return (Scale == part.Shape.Scale);
114 }
123 else 115 else
124 return 116 {
125 Position == part.OffsetPosition 117 return (Position == part.OffsetPosition
126 && Rotation == part.RotationOffset 118 && Rotation == part.RotationOffset
127 && Scale == part.Shape.Scale; 119 && Scale == part.Shape.Scale);
120 }
128 } 121 }
129 122
130 return false; 123 return false;
131 } 124 }
132 125
133 public void PlaybackState(SceneObjectPart part) 126 public void PlayState(SceneObjectPart part)
134 { 127 {
135 part.Undoing = true; 128 part.Undoing = true;
136 129
137 if (part.ParentID == 0) 130 if (part.ParentID == 0)
138 { 131 {
139 // m_log.DebugFormat(
140 // "[UNDO STATE]: Undoing position to {0} for root part {1} {2}",
141 // Position, part.Name, part.LocalId);
142
143 if (Position != Vector3.Zero) 132 if (Position != Vector3.Zero)
144 { 133 {
145 if (ForGroup) 134 if (ForGroup)
@@ -148,10 +137,6 @@ namespace OpenSim.Region.Framework.Scenes
148 part.ParentGroup.UpdateRootPosition(Position); 137 part.ParentGroup.UpdateRootPosition(Position);
149 } 138 }
150 139
151 // m_log.DebugFormat(
152 // "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}",
153 // part.RotationOffset, Rotation, part.Name, part.LocalId);
154
155 if (ForGroup) 140 if (ForGroup)
156 part.UpdateRotation(Rotation); 141 part.UpdateRotation(Rotation);
157 else 142 else
@@ -159,86 +144,30 @@ namespace OpenSim.Region.Framework.Scenes
159 144
160 if (Scale != Vector3.Zero) 145 if (Scale != Vector3.Zero)
161 { 146 {
162 // m_log.DebugFormat( 147 // if (ForGroup)
163 // "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", 148 // part.ParentGroup.GroupResize(Scale);
164 // part.Shape.Scale, Scale, part.Name, part.LocalId); 149 // else
165 150 if (!ForGroup) // we don't have grp scale for now
166 if (ForGroup)
167 part.ParentGroup.GroupResize(Scale);
168 else
169 part.Resize(Scale); 151 part.Resize(Scale);
170 } 152 }
171
172 part.ParentGroup.ScheduleGroupForTerseUpdate(); 153 part.ParentGroup.ScheduleGroupForTerseUpdate();
173 } 154 }
174 else 155 else
175 { 156 {
176 // Note: Updating these properties on sop automatically schedules an update if needed 157 if (ForGroup) // trap for group since seems parts can't do it
177 if (Position != Vector3.Zero) 158 return;
178 {
179 // m_log.DebugFormat(
180 // "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}",
181 // part.OffsetPosition, Position, part.Name, part.LocalId);
182
183 part.OffsetPosition = Position;
184 }
185
186 // m_log.DebugFormat(
187 // "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}",
188 // part.RotationOffset, Rotation, part.Name, part.LocalId);
189 159
160 // Note: Updating these properties on sop automatically schedules an update if needed
161 part.OffsetPosition = Position;
190 part.UpdateRotation(Rotation); 162 part.UpdateRotation(Rotation);
191
192 if (Scale != Vector3.Zero) 163 if (Scale != Vector3.Zero)
193 { 164 {
194 // m_log.DebugFormat(
195 // "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}",
196 // part.Shape.Scale, Scale, part.Name, part.LocalId);
197
198 part.Resize(Scale); 165 part.Resize(Scale);
199 } 166 }
200 } 167 }
201 168
202 part.Undoing = false; 169 part.Undoing = false;
203 } 170 }
204
205 public void PlayfwdState(SceneObjectPart part)
206 {
207 part.Undoing = true;
208
209 if (part.ParentID == 0)
210 {
211 if (Position != Vector3.Zero)
212 part.ParentGroup.AbsolutePosition = Position;
213
214 if (Rotation != Quaternion.Identity)
215 part.UpdateRotation(Rotation);
216
217 if (Scale != Vector3.Zero)
218 {
219 if (ForGroup)
220 part.ParentGroup.GroupResize(Scale);
221 else
222 part.Resize(Scale);
223 }
224
225 part.ParentGroup.ScheduleGroupForTerseUpdate();
226 }
227 else
228 {
229 // Note: Updating these properties on sop automatically schedules an update if needed
230 if (Position != Vector3.Zero)
231 part.OffsetPosition = Position;
232
233 if (Rotation != Quaternion.Identity)
234 part.UpdateRotation(Rotation);
235
236 if (Scale != Vector3.Zero)
237 part.Resize(Scale);
238 }
239
240 part.Undoing = false;
241 }
242 } 171 }
243 172
244 public class LandUndoState 173 public class LandUndoState