Browse Source

Refactor, move OjectChangeData into it's own file and rename
ObjectChnageWhat what into ObjectChangeType change. What is
no name for a variable or type!

Melanie 12 years ago
parent
commit
ebcd4910a2

+ 80 - 0
OpenSim/Framework/ObjectChangeData.cs

@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the OpenSimulator Project nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using OpenMetaverse;
+
+namespace OpenSim.Framework
+{
+    public enum ObjectChangeType : uint
+    {
+        // bits definitions
+        Position = 0x01,
+        Rotation = 0x02,
+        Scale   = 0x04,
+        Group = 0x08,
+        UniformScale = 0x10,
+
+        // macros from above
+        // single prim
+        primP = 0x01,
+        primR = 0x02,
+        primPR = 0x03,
+        primS = 0x04,
+        primPS = 0x05,
+        primRS = 0x06,
+        primPSR = 0x07,
+
+        primUS = 0x14,
+        primPUS = 0x15,
+        primRUS = 0x16,
+        primPUSR = 0x17,
+
+        // group
+        groupP = 0x09,
+        groupR = 0x0A,
+        groupPR = 0x0B,
+        groupS = 0x0C,
+        groupPS = 0x0D,
+        groupRS = 0x0E,
+        groupPSR = 0x0F,
+
+        groupUS = 0x1C,
+        groupPUS = 0x1D,
+        groupRUS = 0x1E,
+        groupPUSR = 0x1F,
+
+        PRSmask = 0x07
+    }
+
+    public struct ObjectChangeData
+    {
+        public Quaternion rotation;
+        public Vector3 position;
+        public Vector3 scale;
+        public ObjectChangeType change;
+    }
+}

+ 16 - 16
OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs

@@ -11504,14 +11504,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
                                 case 1: //change position sp
                                     udata.position = new Vector3(block.Data, 0);
 
-                                    udata.what = ObjectChangeWhat.primP;
+                                    udata.change = ObjectChangeType.primP;
                                     updatehandler(localId, udata, this);
                                     break;
 
                                 case 2: // rotation sp
                                     udata.rotation = new Quaternion(block.Data, 0, true);
 
-                                    udata.what = ObjectChangeWhat.primR;
+                                    udata.change = ObjectChangeType.primR;
                                     updatehandler(localId, udata, this);
                                     break;
 
@@ -11519,13 +11519,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
                                     udata.position = new Vector3(block.Data, 0);
                                     udata.rotation = new Quaternion(block.Data, 12, true);
 
-                                    udata.what = ObjectChangeWhat.primPR;
+                                    udata.change = ObjectChangeType.primPR;
                                     updatehandler(localId, udata, this);
                                     break;
 
                                 case 4: // scale sp
                                     udata.scale = new Vector3(block.Data, 0);
-                                    udata.what = ObjectChangeWhat.primS;
+                                    udata.change = ObjectChangeType.primS;
 
                                     updatehandler(localId, udata, this);
                                     break;
@@ -11533,7 +11533,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
                                 case 0x14: // uniform scale sp 
                                     udata.scale = new Vector3(block.Data, 0);
 
-                                    udata.what = ObjectChangeWhat.primUS;
+                                    udata.change = ObjectChangeType.primUS;
                                     updatehandler(localId, udata, this);
                                     break;
 
@@ -11541,7 +11541,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
                                     udata.position = new Vector3(block.Data, 0);
                                     udata.scale = new Vector3(block.Data, 12);
 
-                                    udata.what = ObjectChangeWhat.primPS;
+                                    udata.change = ObjectChangeType.primPS;
                                     updatehandler(localId, udata, this);
                                     break;
 
@@ -11549,7 +11549,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
                                     udata.position = new Vector3(block.Data, 0);
                                     udata.scale = new Vector3(block.Data, 12);
 
-                                    udata.what = ObjectChangeWhat.primPUS;
+                                    udata.change = ObjectChangeType.primPUS;
                                     updatehandler(localId, udata, this);
                                     break;
 
@@ -11557,14 +11557,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
                                 case 9: //( 8 + 1 )group position
                                     udata.position = new Vector3(block.Data, 0);
 
-                                    udata.what = ObjectChangeWhat.groupP;
+                                    udata.change = ObjectChangeType.groupP;
                                     updatehandler(localId, udata, this);
                                     break;
 
                                 case 0x0A: // (8 + 2) group rotation
                                     udata.rotation = new Quaternion(block.Data, 0, true);
 
-                                    udata.what = ObjectChangeWhat.groupR;
+                                    udata.change = ObjectChangeType.groupR;
                                     updatehandler(localId, udata, this);
                                     break;
 
@@ -11572,7 +11572,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
                                     udata.position = new Vector3(block.Data, 0);
                                     udata.rotation = new Quaternion(block.Data, 12, true);
 
-                                    udata.what = ObjectChangeWhat.groupPR;
+                                    udata.change = ObjectChangeType.groupPR;
                                     updatehandler(localId, udata, this);
                                     break;
 
@@ -11583,8 +11583,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
 
                                     udata.scale = new Vector3(block.Data, 0);
 
-                                    //                                    udata.what = ObjectChangeWhat.groupS;
-                                    udata.what = ObjectChangeWhat.primS; // to conform to current SL
+                                    //                                    udata.change = ObjectChangeType.groupS;
+                                    udata.change = ObjectChangeType.primS; // to conform to current SL
                                     updatehandler(localId, udata, this);
 
                                     break;
@@ -11595,15 +11595,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
                                     udata.position = new Vector3(block.Data, 0);
                                     udata.scale = new Vector3(block.Data, 12);
 
-                                    //                                    udata.what = ObjectChangeWhat.groupPS;
-                                    udata.what = ObjectChangeWhat.primPS; // to conform to current SL
+                                    //                                    udata.change = ObjectChangeType.groupPS;
+                                    udata.change = ObjectChangeType.primPS; // to conform to current SL
                                     updatehandler(localId, udata, this);
                                     break;
 
                                 case 0x1C: // (0x10 + 8 + 4 ) group scale UNIFORM
                                     udata.scale = new Vector3(block.Data, 0);
 
-                                    udata.what = ObjectChangeWhat.groupUS;
+                                    udata.change = ObjectChangeType.groupUS;
                                     updatehandler(localId, udata, this);
                                     break;
 
@@ -11611,7 +11611,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
                                     udata.position = new Vector3(block.Data, 0);
                                     udata.scale = new Vector3(block.Data, 12);
 
-                                    udata.what = ObjectChangeWhat.groupPUS;
+                                    udata.change = ObjectChangeType.groupPUS;
                                     updatehandler(localId, udata, this);
                                     break;
 

+ 1 - 114
OpenSim/Region/Framework/Scenes/SceneGraph.cs

@@ -47,57 +47,6 @@ namespace OpenSim.Region.Framework.Scenes
 
     public delegate void ChangedBackupDelegate(SceneObjectGroup sog);
 
-
-    public enum ObjectChangeWhat : uint
-    {
-        // bits definitions
-        Position = 0x01,
-        Rotation = 0x02,
-        Scale   = 0x04,
-        Group = 0x08,
-        UniformScale = 0x10,
-
-        // macros from above
-        // single prim
-        primP = 0x01,
-        primR = 0x02,
-        primPR = 0x03,
-        primS = 0x04,
-        primPS = 0x05,
-        primRS = 0x06,
-        primPSR = 0x07,
-
-        primUS = 0x14,
-        primPUS = 0x15,
-        primRUS = 0x16,
-        primPUSR = 0x17,
-
-        // group
-        groupP = 0x09,
-        groupR = 0x0A,
-        groupPR = 0x0B,
-        groupS = 0x0C,
-        groupPS = 0x0D,
-        groupRS = 0x0E,
-        groupPSR = 0x0F,
-
-        groupUS = 0x1C,
-        groupPUS = 0x1D,
-        groupRUS = 0x1E,
-        groupPUSR = 0x1F,
-
-        PRSmask = 0x07
-    }
-
-    public struct ObjectChangeData
-    {
-        public Quaternion rotation;
-        public Vector3 position;
-        public Vector3 scale;
-        public ObjectChangeWhat what;
-    }
-        
-   
     /// <summary>
     /// This class used to be called InnerScene and may not yet truly be a SceneGraph.  The non scene graph components
     /// should be migrated out over time.
@@ -1352,75 +1301,13 @@ namespace OpenSim.Region.Framework.Scenes
                 {
                     if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId))
                     {
-//                        part.StoreUndoState(data.what | ObjectChangeWhat.PRSmask); // for now save all to keep previus behavour ???
-                        part.StoreUndoState(data.what); // lets test only saving what we changed
+                        part.StoreUndoState(data.change); // lets test only saving what we changed
                         grp.doChangeObject(part, (ObjectChangeData)data);
                     }
                 }
             }
         }
 
-/* moved to SOG
-        protected internal void doChangeObject(SceneObjectPart part, ObjectChangeData data)
-        {
-            if (part != null && part.ParentGroup != null)
-            {
-                ObjectChangeWhat what = data.what;
-                bool togroup = ((what & ObjectChangeWhat.Group) != 0);
-//                bool uniform = ((what & ObjectChangeWhat.UniformScale) != 0);  not in use
-
-                SceneObjectGroup group = part.ParentGroup;
-                PhysicsActor pha = group.RootPart.PhysActor;
-              
-                if (togroup)
-                {
-                    // related to group                  
-                    if ((what & ObjectChangeWhat.Position) != 0)
-                        group.AbsolutePosition = data.position;
-                    if ((what & ObjectChangeWhat.Rotation) != 0)
-                        group.RootPart.UpdateRotation(data.rotation);
-                    if ((what & ObjectChangeWhat.Scale) != 0)
-                    {
-                        if (pha != null)
-                            pha.Building = true;
-                        group.GroupResize(data.scale);
-                        if (pha != null)
-                            pha.Building = false;
-                    }
-                }
-                else
-                {
-                    // related to single prim in a link-set ( ie group)
-                    if (pha != null)
-                        pha.Building = true;
-
-                    // must deal with root part specially for position and rotation
-                    // so parts offset positions or rotations are fixed
-
-                    if (part == group.RootPart)
-                    {
-                        if ((what & ObjectChangeWhat.Position) != 0)
-                            group.UpdateRootPosition(data.position);
-                        if ((what & ObjectChangeWhat.Rotation) != 0)
-                            group.UpdateRootRotation(data.rotation);
-                    }
-                    else
-                    {
-                        if ((what & ObjectChangeWhat.Position) != 0)
-                            part.OffsetPosition = data.position;
-                        if ((what & ObjectChangeWhat.Rotation) != 0)
-                            part.UpdateRotation(data.rotation);
-                    }
-
-                    if ((what & ObjectChangeWhat.Scale) != 0)
-                        part.Resize(data.scale);
-
-                    if (pha != null)
-                        pha.Building = false;
-                }
-            }
-        }
-*/
         /// <summary>
         /// Update the scale of an individual prim.
         /// </summary>

+ 12 - 12
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs

@@ -3521,9 +3521,9 @@ namespace OpenSim.Region.Framework.Scenes
 
             if (part != null && part.ParentGroup != null)
             {
-                ObjectChangeWhat what = data.what;
-                bool togroup = ((what & ObjectChangeWhat.Group) != 0);
-                //                bool uniform = ((what & ObjectChangeWhat.UniformScale) != 0);  not in use
+                ObjectChangeType change = data.change;
+                bool togroup = ((change & ObjectChangeType.Group) != 0);
+                //                bool uniform = ((what & ObjectChangeType.UniformScale) != 0);  not in use
 
                 SceneObjectGroup group = part.ParentGroup;
                 PhysicsActor pha = group.RootPart.PhysActor;
@@ -3533,17 +3533,17 @@ namespace OpenSim.Region.Framework.Scenes
                 if (togroup)
                 {
                     // related to group                  
-                    if ((what & ObjectChangeWhat.Position) != 0)
+                    if ((change & ObjectChangeType.Position) != 0)
                     {
                         group.AbsolutePosition = data.position;
                         updateType = updatetype.groupterse;
                     }
-                    if ((what & ObjectChangeWhat.Rotation) != 0)
+                    if ((change & ObjectChangeType.Rotation) != 0)
                     {
                         group.RootPart.UpdateRotation(data.rotation);
                         updateType = updatetype.none;
                     }
-                    if ((what & ObjectChangeWhat.Scale) != 0)
+                    if ((change & ObjectChangeType.Scale) != 0)
                     {
                         if (pha != null)
                             pha.Building = true;
@@ -3566,26 +3566,26 @@ namespace OpenSim.Region.Framework.Scenes
 
                     if (part == group.RootPart)
                     {
-                        if ((what & ObjectChangeWhat.Position) != 0)
+                        if ((change & ObjectChangeType.Position) != 0)
                             group.UpdateRootPosition(data.position);
-                        if ((what & ObjectChangeWhat.Rotation) != 0)
+                        if ((change & ObjectChangeType.Rotation) != 0)
                             group.UpdateRootRotation(data.rotation);
-                        if ((what & ObjectChangeWhat.Scale) != 0)
+                        if ((change & ObjectChangeType.Scale) != 0)
                             part.Resize(data.scale);
                     }
                     else
                     {
-                        if ((what & ObjectChangeWhat.Position) != 0)
+                        if ((change & ObjectChangeType.Position) != 0)
                         {
                             part.OffsetPosition = data.position;
                             updateType = updatetype.partterse;
                         }
-                        if ((what & ObjectChangeWhat.Rotation) != 0)
+                        if ((change & ObjectChangeType.Rotation) != 0)
                         {
                             part.UpdateRotation(data.rotation);
                             updateType = updatetype.none;
                         }
-                        if ((what & ObjectChangeWhat.Scale) != 0)
+                        if ((change & ObjectChangeType.Scale) != 0)
                         {
                             part.Resize(data.scale);
                             updateType = updatetype.none;

+ 2 - 2
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs

@@ -3644,7 +3644,7 @@ namespace OpenSim.Region.Framework.Scenes
             //ParentGroup.ScheduleGroupForFullUpdate();
         }
 
-        public void StoreUndoState(ObjectChangeWhat what)
+        public void StoreUndoState(ObjectChangeType change)
         {
             if (m_UndoRedo == null)
                 m_UndoRedo = new UndoRedoState(5);
@@ -3653,7 +3653,7 @@ namespace OpenSim.Region.Framework.Scenes
             {
                 if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better  - undo is in progress, or suspended
                 {
-                    m_UndoRedo.StoreUndo(this, what);
+                    m_UndoRedo.StoreUndo(this, change);
                 }
             }
         }

+ 22 - 21
OpenSim/Region/Framework/Scenes/UndoState.cs

@@ -30,6 +30,7 @@ using System.Reflection;
 using System.Collections.Generic;
 using log4net;
 using OpenMetaverse;
+using OpenSim.Framework;
 using OpenSim.Region.Framework.Interfaces;
 
 namespace OpenSim.Region.Framework.Scenes
@@ -44,30 +45,30 @@ namespace OpenSim.Region.Framework.Scenes
         /// Constructor.
         /// </summary>
         /// <param name="part"></param>
-        /// <param name="what">bit field with what is changed</param>
+        /// <param name="change">bit field with what is changed</param>
         /// 
-        public UndoState(SceneObjectPart part, ObjectChangeWhat what)
+        public UndoState(SceneObjectPart part, ObjectChangeType change)
         {
             data = new ObjectChangeData();
-            data.what = what;
+            data.change = change;
             creationtime = DateTime.UtcNow;
 
             if (part.ParentGroup.RootPart == part)
             {
-                if ((what & ObjectChangeWhat.Position) != 0)
+                if ((change & ObjectChangeType.Position) != 0)
                     data.position = part.ParentGroup.AbsolutePosition;
-                if ((what & ObjectChangeWhat.Rotation) != 0)
+                if ((change & ObjectChangeType.Rotation) != 0)
                     data.rotation = part.RotationOffset;
-                if ((what & ObjectChangeWhat.Scale) != 0)
+                if ((change & ObjectChangeType.Scale) != 0)
                     data.scale = part.Shape.Scale;
             }
             else
             {
-                if ((what & ObjectChangeWhat.Position) != 0)
+                if ((change & ObjectChangeType.Position) != 0)
                     data.position = part.OffsetPosition;
-                if ((what & ObjectChangeWhat.Rotation) != 0)
+                if ((change & ObjectChangeType.Rotation) != 0)
                     data.rotation = part.RotationOffset;
-                if ((what & ObjectChangeWhat.Scale) != 0)
+                if ((change & ObjectChangeType.Scale) != 0)
                     data.scale = part.Shape.Scale;
             }
         }
@@ -97,27 +98,27 @@ namespace OpenSim.Region.Framework.Scenes
         /// <param name="part"></param>
         /// <returns>true what fiels and related data are equal, False otherwise.</returns>
         /// 
-        public bool Compare(SceneObjectPart part, ObjectChangeWhat what)    
+        public bool Compare(SceneObjectPart part, ObjectChangeType change)    
         {
-            if (data.what != what) // if diferent targets, then they are diferent
+            if (data.change != change) // if diferent targets, then they are diferent
                 return false;
 
             if (part != null)
             {
                 if (part.ParentID == 0)
                 {
-                    if ((what & ObjectChangeWhat.Position) != 0 && data.position != part.ParentGroup.AbsolutePosition)
+                    if ((change & ObjectChangeType.Position) != 0 && data.position != part.ParentGroup.AbsolutePosition)
                         return false;
                 }
                 else
                 {
-                    if ((what & ObjectChangeWhat.Position) != 0 && data.position != part.OffsetPosition)
+                    if ((change & ObjectChangeType.Position) != 0 && data.position != part.OffsetPosition)
                         return false;
                 }
 
-                if ((what & ObjectChangeWhat.Rotation) != 0 && data.rotation != part.RotationOffset)
+                if ((change & ObjectChangeType.Rotation) != 0 && data.rotation != part.RotationOffset)
                     return false;
-                if ((what & ObjectChangeWhat.Rotation) != 0 && data.scale == part.Shape.Scale)
+                if ((change & ObjectChangeType.Rotation) != 0 && data.scale == part.Shape.Scale)
                     return false;
                 return true;
 
@@ -196,9 +197,9 @@ namespace OpenSim.Region.Framework.Scenes
         /// adds a new state undo to part or its group, with changes indicated by what bits
         /// </summary>
         /// <param name="part"></param>
-        /// <param name="what">bit field with what is changed</param>
+        /// <param name="change">bit field with what is changed</param>
 
-        public void StoreUndo(SceneObjectPart part, ObjectChangeWhat what)
+        public void StoreUndo(SceneObjectPart part, ObjectChangeType change)
         {
             lock (m_undo)
             {
@@ -220,7 +221,7 @@ namespace OpenSim.Region.Framework.Scenes
                         // see if we actually have a change
                         if (last != null)
                         {
-                            if (last.Compare(part, what))
+                            if (last.Compare(part, change))
                                 return;
                         }
                     }
@@ -230,7 +231,7 @@ namespace OpenSim.Region.Framework.Scenes
                 while (m_undo.Count >= size)
                     m_undo.RemoveLast();
 
-                UndoState nUndo = new UndoState(part, what);
+                UndoState nUndo = new UndoState(part, change);
                 m_undo.AddFirst(nUndo);
             }
         }
@@ -273,7 +274,7 @@ namespace OpenSim.Region.Framework.Scenes
                         while (m_redo.Count >= size)
                             m_redo.RemoveLast();
 
-                        nUndo = new UndoState(part, goback.data.what); // new value in part should it be full goback copy?
+                        nUndo = new UndoState(part, goback.data.change); // new value in part should it be full goback copy?
                         m_redo.AddFirst(nUndo);
 
                         goback.PlayState(part);
@@ -320,7 +321,7 @@ namespace OpenSim.Region.Framework.Scenes
                         while (m_undo.Count >= size)
                             m_undo.RemoveLast();
 
-                        nUndo = new UndoState(part, gofwd.data.what);   // new value in part should it be full gofwd copy?
+                        nUndo = new UndoState(part, gofwd.data.change);   // new value in part should it be full gofwd copy?
                         m_undo.AddFirst(nUndo);
 
                         gofwd.PlayState(part);