diff options
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/UndoState.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/UndoState.cs | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/UndoState.cs b/OpenSim/Region/Environment/Scenes/UndoState.cs new file mode 100644 index 0000000..65c8669 --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/UndoState.cs | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using libsecondlife; | ||
31 | |||
32 | namespace OpenSim.Region.Environment.Scenes | ||
33 | { | ||
34 | public class UndoState | ||
35 | { | ||
36 | public LLVector3 Position = LLVector3.Zero; | ||
37 | public LLVector3 Scale = LLVector3.Zero; | ||
38 | public LLQuaternion Rotation = LLQuaternion.Identity; | ||
39 | |||
40 | public UndoState(LLVector3 pos, LLQuaternion rot, LLVector3 scale) | ||
41 | { | ||
42 | Position = pos; | ||
43 | Rotation = rot; | ||
44 | Scale = scale; | ||
45 | } | ||
46 | |||
47 | public UndoState(SceneObjectPart part) | ||
48 | { | ||
49 | if (part != null) | ||
50 | { | ||
51 | if (part.ParentID == 0) | ||
52 | { | ||
53 | Position = part.AbsolutePosition; | ||
54 | Rotation = part.RotationOffset; | ||
55 | |||
56 | } | ||
57 | else | ||
58 | { | ||
59 | Position = part.GroupPosition; | ||
60 | Rotation = part.RotationOffset; | ||
61 | Scale = part.Shape.Scale; | ||
62 | |||
63 | } | ||
64 | } | ||
65 | } | ||
66 | |||
67 | public bool Compare(SceneObjectPart part) | ||
68 | { | ||
69 | if (part != null) | ||
70 | { | ||
71 | if (part.ParentID == 0) | ||
72 | { | ||
73 | if (Position == part.AbsolutePosition && Rotation == part.RotationOffset) | ||
74 | return true; | ||
75 | else | ||
76 | return false; | ||
77 | } | ||
78 | else | ||
79 | { | ||
80 | if (Position == part.GroupPosition && Rotation == part.RotationOffset && Scale == part.Shape.Scale) | ||
81 | return true; | ||
82 | else | ||
83 | return false; | ||
84 | |||
85 | } | ||
86 | } | ||
87 | return false; | ||
88 | } | ||
89 | |||
90 | public void PlaybackState(SceneObjectPart part) | ||
91 | { | ||
92 | if (part != null) | ||
93 | { | ||
94 | part.m_undoing = true; | ||
95 | |||
96 | if (part.ParentID == 0) | ||
97 | { | ||
98 | part.ParentGroup.AbsolutePosition = Position; | ||
99 | part.UpdateRotation(Rotation); | ||
100 | part.ParentGroup.ScheduleGroupForTerseUpdate(); | ||
101 | } | ||
102 | else | ||
103 | { | ||
104 | part.OffsetPosition = Position; | ||
105 | part.UpdateRotation(Rotation); | ||
106 | part.Resize(Scale); | ||
107 | part.ScheduleTerseUpdate(); | ||
108 | } | ||
109 | part.m_undoing = false; | ||
110 | |||
111 | } | ||
112 | } | ||
113 | |||
114 | public UndoState() | ||
115 | { | ||
116 | } | ||
117 | } | ||
118 | } | ||