aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/UndoState.cs
diff options
context:
space:
mode:
authorTom Grimshaw2010-07-03 06:10:55 -0700
committerTom Grimshaw2010-07-03 06:10:55 -0700
commitfe2b044d38f3bd3aa669334d34567fd991a67b3e (patch)
treebb94a343716c2620e043ac070a8cb269564f3a9c /OpenSim/Region/Framework/Scenes/UndoState.cs
parentRe-implement the Undo stack as a List; the old implementation was buggy (diff)
downloadopensim-SC_OLD-fe2b044d38f3bd3aa669334d34567fd991a67b3e.zip
opensim-SC_OLD-fe2b044d38f3bd3aa669334d34567fd991a67b3e.tar.gz
opensim-SC_OLD-fe2b044d38f3bd3aa669334d34567fd991a67b3e.tar.bz2
opensim-SC_OLD-fe2b044d38f3bd3aa669334d34567fd991a67b3e.tar.xz
Fix Undo! Made a lot of changes to Undo state saving; it now considers that groups of objects can be moved and not just individual prims..
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/UndoState.cs55
1 files changed, 45 insertions, 10 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 55e407e..77381ab 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -35,6 +35,10 @@ namespace OpenSim.Region.Framework.Scenes
35 public Vector3 Position = Vector3.Zero; 35 public Vector3 Position = Vector3.Zero;
36 public Vector3 Scale = Vector3.Zero; 36 public Vector3 Scale = Vector3.Zero;
37 public Quaternion Rotation = Quaternion.Identity; 37 public Quaternion Rotation = Quaternion.Identity;
38 public bool GroupChange = false;
39 public Vector3 GroupPosition = Vector3.Zero;
40 public Quaternion GroupRotation = Quaternion.Identity;
41 public Vector3 GroupScale = Vector3.Zero;
38 42
39 public UndoState(SceneObjectPart part) 43 public UndoState(SceneObjectPart part)
40 { 44 {
@@ -42,12 +46,24 @@ namespace OpenSim.Region.Framework.Scenes
42 { 46 {
43 if (part.ParentID == 0) 47 if (part.ParentID == 0)
44 { 48 {
45 Position = part.ParentGroup.AbsolutePosition; 49 GroupScale = part.Shape.Scale;
50
51 //FUBAR WARNING: Do NOT get the group's absoluteposition here
52 //or you'll experience a loop and/or a stack issue
53 GroupPosition = part.ParentGroup.RootPart.AbsolutePosition;
54 GroupRotation = part.ParentGroup.Rotation;
55 Position = part.ParentGroup.RootPart.AbsolutePosition;
46 Rotation = part.RotationOffset; 56 Rotation = part.RotationOffset;
47 Scale = part.Shape.Scale; 57 Scale = part.Shape.Scale;
48 } 58 }
49 else 59 else
50 { 60 {
61 GroupScale = part.Shape.Scale;
62
63 //FUBAR WARNING: Do NOT get the group's absoluteposition here
64 //or you'll experience a loop and/or a stack issue
65 GroupPosition = part.ParentGroup.RootPart.AbsolutePosition;
66 GroupRotation = part.ParentGroup.Rotation;
51 Position = part.OffsetPosition; 67 Position = part.OffsetPosition;
52 Rotation = part.RotationOffset; 68 Rotation = part.RotationOffset;
53 Scale = part.Shape.Scale; 69 Scale = part.Shape.Scale;
@@ -61,14 +77,14 @@ namespace OpenSim.Region.Framework.Scenes
61 { 77 {
62 if (part.ParentID == 0) 78 if (part.ParentID == 0)
63 { 79 {
64 if (Position == part.ParentGroup.AbsolutePosition && Rotation == part.ParentGroup.Rotation) 80 if (Position == part.ParentGroup.RootPart.AbsolutePosition && Rotation == part.ParentGroup.Rotation && GroupPosition == part.ParentGroup.RootPart.AbsolutePosition && part.ParentGroup.Rotation == GroupRotation && part.Shape.Scale == GroupScale)
65 return true; 81 return true;
66 else 82 else
67 return false; 83 return false;
68 } 84 }
69 else 85 else
70 { 86 {
71 if (Position == part.OffsetPosition && Rotation == part.RotationOffset && Scale == part.Shape.Scale) 87 if (Position == part.OffsetPosition && Rotation == part.RotationOffset && Scale == part.Shape.Scale && GroupPosition == part.ParentGroup.RootPart.AbsolutePosition && part.ParentGroup.Rotation == GroupRotation && part.Shape.Scale == GroupScale)
72 return true; 88 return true;
73 else 89 else
74 return false; 90 return false;
@@ -84,10 +100,10 @@ namespace OpenSim.Region.Framework.Scenes
84 { 100 {
85 part.Undoing = true; 101 part.Undoing = true;
86 102
87 if (part.ParentID == 0) 103 if (part.ParentID == 0 && GroupChange == false)
88 { 104 {
89 if (Position != Vector3.Zero) 105 if (Position != Vector3.Zero)
90 part.ParentGroup.AbsolutePosition = Position; 106 part.ParentGroup.AbsolutePosition = Position;
91 part.RotationOffset = Rotation; 107 part.RotationOffset = Rotation;
92 if (Scale != Vector3.Zero) 108 if (Scale != Vector3.Zero)
93 part.Resize(Scale); 109 part.Resize(Scale);
@@ -95,11 +111,30 @@ namespace OpenSim.Region.Framework.Scenes
95 } 111 }
96 else 112 else
97 { 113 {
98 if (Position != Vector3.Zero) 114 if (GroupChange)
99 part.OffsetPosition = Position; 115 {
100 part.UpdateRotation(Rotation); 116 if (Position != Vector3.Zero)
101 if (Scale != Vector3.Zero) 117 {
102 part.Resize(Scale); part.ScheduleTerseUpdate(); 118 //Calculate the scale...
119 Vector3 gs = part.Shape.Scale;
120 float scale = GroupScale.Z / gs.Z;
121
122 //Scale first since it can affect our position
123 part.ParentGroup.GroupResize(gs * scale, part.LocalId);
124 part.ParentGroup.AbsolutePosition = GroupPosition;
125 part.ParentGroup.Rotation = GroupRotation;
126
127 }
128 }
129 else
130 {
131 if (Position != Vector3.Zero) //We can use this for all the updates since all are set
132 {
133 part.OffsetPosition = Position;
134 part.UpdateRotation(Rotation);
135 part.Resize(Scale); part.ScheduleTerseUpdate();
136 }
137 }
103 } 138 }
104 part.Undoing = false; 139 part.Undoing = false;
105 140