diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/UndoState.cs | 80 |
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 | ||
28 | using OpenMetaverse; | 28 | using OpenMetaverse; |
29 | using OpenSim.Region.Framework.Interfaces; | 29 | using OpenSim.Region.Framework.Interfaces; |
30 | using System; | ||
30 | 31 | ||
31 | namespace OpenSim.Region.Framework.Scenes | 32 | namespace 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 | { |