aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/UndoState.cs
diff options
context:
space:
mode:
authorTom Grimshaw2010-07-04 19:28:39 -0700
committerTom Grimshaw2010-07-04 19:28:39 -0700
commit5b68343361cbd000a2f024b37797ec235abb7207 (patch)
treea8977cb2d9392c83081675f24f8043a3cc56ad73 /OpenSim/Region/Framework/Scenes/UndoState.cs
parentCorrect positioning of timeout modifier in the SynchronousRestObjectRequester (diff)
downloadopensim-SC_OLD-5b68343361cbd000a2f024b37797ec235abb7207.zip
opensim-SC_OLD-5b68343361cbd000a2f024b37797ec235abb7207.tar.gz
opensim-SC_OLD-5b68343361cbd000a2f024b37797ec235abb7207.tar.bz2
opensim-SC_OLD-5b68343361cbd000a2f024b37797ec235abb7207.tar.xz
The majority of the Undo fix. There is still an issue with Rotation which i'll address next; however position undo and scale undo should be working just fine now. Also removed some residual debug logging.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/UndoState.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/UndoState.cs80
1 files changed, 76 insertions, 4 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 77381ab..ad05351 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -27,26 +27,43 @@
27 27
28using OpenMetaverse; 28using OpenMetaverse;
29using OpenSim.Region.Framework.Interfaces; 29using OpenSim.Region.Framework.Interfaces;
30using System;
30 31
31namespace OpenSim.Region.Framework.Scenes 32namespace OpenSim.Region.Framework.Scenes
32{ 33{
34 [Flags]
35 public enum UndoType
36 {
37 STATE_PRIM_POSITION = 1,
38 STATE_PRIM_ROTATION = 2,
39 STATE_PRIM_SCALE = 4,
40 STATE_PRIM_ALL = 7,
41 STATE_GROUP_POSITION = 8,
42 STATE_GROUP_ROTATION = 16,
43 STATE_GROUP_SCALE = 32,
44 STATE_GROUP_ALL = 56,
45 STATE_ALL = 63
46 }
47
33 public class UndoState 48 public class UndoState
34 { 49 {
35 public Vector3 Position = Vector3.Zero; 50 public Vector3 Position = Vector3.Zero;
36 public Vector3 Scale = Vector3.Zero; 51 public Vector3 Scale = Vector3.Zero;
37 public Quaternion Rotation = Quaternion.Identity; 52 public Quaternion Rotation = Quaternion.Identity;
38 public bool GroupChange = false;
39 public Vector3 GroupPosition = Vector3.Zero; 53 public Vector3 GroupPosition = Vector3.Zero;
40 public Quaternion GroupRotation = Quaternion.Identity; 54 public Quaternion GroupRotation = Quaternion.Identity;
41 public Vector3 GroupScale = Vector3.Zero; 55 public Vector3 GroupScale = Vector3.Zero;
56 public DateTime LastUpdated = DateTime.Now;
57 public UndoType Type;
42 58
43 public UndoState(SceneObjectPart part) 59 public UndoState(SceneObjectPart part, UndoType type)
44 { 60 {
61 Type = type;
45 if (part != null) 62 if (part != null)
46 { 63 {
47 if (part.ParentID == 0) 64 if (part.ParentID == 0)
48 { 65 {
49 GroupScale = part.Shape.Scale; 66 GroupScale = part.ParentGroup.RootPart.Shape.Scale;
50 67
51 //FUBAR WARNING: Do NOT get the group's absoluteposition here 68 //FUBAR WARNING: Do NOT get the group's absoluteposition here
52 //or you'll experience a loop and/or a stack issue 69 //or you'll experience a loop and/or a stack issue
@@ -55,6 +72,7 @@ namespace OpenSim.Region.Framework.Scenes
55 Position = part.ParentGroup.RootPart.AbsolutePosition; 72 Position = part.ParentGroup.RootPart.AbsolutePosition;
56 Rotation = part.RotationOffset; 73 Rotation = part.RotationOffset;
57 Scale = part.Shape.Scale; 74 Scale = part.Shape.Scale;
75 LastUpdated = DateTime.Now;
58 } 76 }
59 else 77 else
60 { 78 {
@@ -67,10 +85,54 @@ namespace OpenSim.Region.Framework.Scenes
67 Position = part.OffsetPosition; 85 Position = part.OffsetPosition;
68 Rotation = part.RotationOffset; 86 Rotation = part.RotationOffset;
69 Scale = part.Shape.Scale; 87 Scale = part.Shape.Scale;
88 LastUpdated = DateTime.Now;
70 } 89 }
71 } 90 }
72 } 91 }
73 92 public void Merge(UndoState last)
93 {
94 if ((Type & UndoType.STATE_GROUP_POSITION) == 0 || ((last.Type & UndoType.STATE_GROUP_POSITION) >= (Type & UndoType.STATE_GROUP_POSITION)))
95 {
96 GroupPosition = last.GroupPosition;
97 Position = last.Position;
98 }
99 if ((Type & UndoType.STATE_GROUP_SCALE) == 0 || ((last.Type & UndoType.STATE_GROUP_SCALE) >= (Type & UndoType.STATE_GROUP_SCALE)))
100 {
101 Console.WriteLine("Setting groupscale to " + last.GroupScale.ToString());
102 GroupScale = last.GroupScale;
103 Scale = last.Scale;
104 }
105 if ((Type & UndoType.STATE_GROUP_ROTATION) == 0 || ((last.Type & UndoType.STATE_GROUP_ROTATION) >= (Type & UndoType.STATE_GROUP_ROTATION)))
106 {
107 GroupRotation = last.GroupRotation;
108 Rotation = last.Rotation;
109 }
110 if ((Type & UndoType.STATE_PRIM_POSITION) == 0 || ((last.Type & UndoType.STATE_PRIM_POSITION) >= (Type & UndoType.STATE_PRIM_POSITION)))
111 {
112 Position = last.Position;
113 }
114 if ((Type & UndoType.STATE_PRIM_SCALE) == 0 || ((last.Type & UndoType.STATE_PRIM_SCALE) >= (Type & UndoType.STATE_PRIM_SCALE)))
115 {
116 Scale = last.Scale;
117 }
118 if ((Type & UndoType.STATE_PRIM_ROTATION) == 0 || ((last.Type & UndoType.STATE_PRIM_ROTATION) >= (Type & UndoType.STATE_PRIM_ROTATION)))
119 {
120 Rotation = last.Rotation;
121 }
122 Type = Type | last.Type;
123 }
124 public bool Compare(UndoState undo)
125 {
126 if (undo == null || Position == null) return false;
127 if (undo.Position == Position && undo.Rotation == Rotation && undo.Scale == Scale && undo.GroupPosition == GroupPosition && undo.GroupScale == GroupScale && undo.GroupRotation == GroupRotation)
128 {
129 return true;
130 }
131 else
132 {
133 return false;
134 }
135 }
74 public bool Compare(SceneObjectPart part) 136 public bool Compare(SceneObjectPart part)
75 { 137 {
76 if (part != null) 138 if (part != null)
@@ -96,6 +158,14 @@ namespace OpenSim.Region.Framework.Scenes
96 158
97 public void PlaybackState(SceneObjectPart part) 159 public void PlaybackState(SceneObjectPart part)
98 { 160 {
161 bool GroupChange = false;
162 if ((Type & UndoType.STATE_GROUP_POSITION) != 0
163 || (Type & UndoType.STATE_GROUP_ROTATION) != 0
164 || (Type & UndoType.STATE_GROUP_SCALE) != 0)
165 {
166 GroupChange = true;
167 }
168
99 if (part != null) 169 if (part != null)
100 { 170 {
101 part.Undoing = true; 171 part.Undoing = true;
@@ -113,6 +183,7 @@ namespace OpenSim.Region.Framework.Scenes
113 { 183 {
114 if (GroupChange) 184 if (GroupChange)
115 { 185 {
186 part.ParentGroup.RootPart.Undoing = true;
116 if (Position != Vector3.Zero) 187 if (Position != Vector3.Zero)
117 { 188 {
118 //Calculate the scale... 189 //Calculate the scale...
@@ -125,6 +196,7 @@ namespace OpenSim.Region.Framework.Scenes
125 part.ParentGroup.Rotation = GroupRotation; 196 part.ParentGroup.Rotation = GroupRotation;
126 197
127 } 198 }
199 part.ParentGroup.RootPart.Undoing = false;
128 } 200 }
129 else 201 else
130 { 202 {