From df0e5cc9fe9b0851ae5442bdeeb49ab7778d5fe1 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 12 Jul 2011 02:33:09 +0100
Subject: When a mesh object is added to a scene, delay adding the physics
actor until the sculpt data has been added to the shape (possibly via an
async asset service request)
This prevents spurious 'no asset data' for meshes added on startup.
---
OpenSim/Region/Framework/Scenes/Scene.cs | 5 +++--
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +-
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 7 ++++++-
3 files changed, 10 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 8195a0d..0104a96 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1751,8 +1751,9 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart rootPart = group.GetChildPart(group.UUID);
rootPart.Flags &= ~PrimFlags.Scripted;
rootPart.TrimPermissions();
- group.CheckSculptAndLoad();
- //rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
+
+ // Don't do this here - it will get done later on when sculpt data is loaded.
+// group.CheckSculptAndLoad();
}
m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)");
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index fa23fcd..905acd6 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -584,7 +584,7 @@ namespace OpenSim.Region.Framework.Scenes
part.ParentID = m_rootPart.LocalId;
//m_log.DebugFormat("[SCENE]: Given local id {0} to part {1}, linknum {2}, parent {3} {4}", part.LocalId, part.UUID, part.LinkNum, part.ParentID, part.ParentUUID);
}
-
+
ApplyPhysics(m_scene.m_physicalPrim);
// Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 2026c53..e9571aa 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1896,7 +1896,12 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
+ // If this part is a sculpt then delay the physics update until we've asynchronously loaded the
+ // mesh data.
+ if (((OpenMetaverse.SculptType)Shape.SculptType) == SculptType.Mesh)
+ CheckSculptAndLoad();
+ else
+ m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
}
}
}
--
cgit v1.1
From b55076990c3ba27bc9a0ca716031928fae887deb Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Thu, 14 Jul 2011 12:38:35 -0700
Subject: fix duplication of physical objects for physics engines that care
about the initial value of localID
---
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 905acd6..343a8fd 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1463,16 +1463,16 @@ namespace OpenSim.Region.Framework.Scenes
// Need to duplicate the physics actor as well
if (part.PhysActor != null && userExposed)
{
- PrimitiveBaseShape pbs = part.Shape;
+ PrimitiveBaseShape pbs = newPart.Shape;
newPart.PhysActor
= m_scene.PhysicsScene.AddPrimShape(
- part.LocalId,
- string.Format("{0}/{1}", part.Name, part.UUID),
+ newPart.LocalId,
+ string.Format("{0}/{1}", newPart.Name, newPart.UUID),
pbs,
- part.AbsolutePosition,
- part.Scale,
- part.RotationOffset,
+ newPart.AbsolutePosition,
+ newPart.Scale,
+ newPart.RotationOffset,
part.PhysActor.IsPhysical);
newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true);
--
cgit v1.1
From e9dbe54ab1217e4310b0e7e014516363237e2a21 Mon Sep 17 00:00:00 2001
From: root
Date: Fri, 15 Jul 2011 20:07:59 +0100
Subject: Fix some local id issues in physics glue
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 4 +--
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 32 ++++++++++++++--------
2 files changed, 22 insertions(+), 14 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 343a8fd..0fbd746 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1467,13 +1467,13 @@ namespace OpenSim.Region.Framework.Scenes
newPart.PhysActor
= m_scene.PhysicsScene.AddPrimShape(
- newPart.LocalId,
string.Format("{0}/{1}", newPart.Name, newPart.UUID),
pbs,
newPart.AbsolutePosition,
newPart.Scale,
newPart.RotationOffset,
- part.PhysActor.IsPhysical);
+ part.PhysActor.IsPhysical,
+ newPart.LocalId);
newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true);
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index e9571aa..7604510 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1588,17 +1588,23 @@ namespace OpenSim.Region.Framework.Scenes
// or flexible
if (!isPhantom && !IsAttachment && !(Shape.PathCurve == (byte) Extrusion.Flexible))
{
-// m_log.DebugFormat("[SCENE OBJECT PART]: Creating PhysActor for {0} {1} {2}", Name, LocalId, UUID);
-
- PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
- LocalId,
- string.Format("{0}/{1}", Name, UUID),
- Shape,
- AbsolutePosition,
- Scale,
- RotationOffset,
- RigidBody);
-
+ try
+ {
+ PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
+ string.Format("{0}/{1}", Name, UUID),
+ Shape,
+ AbsolutePosition,
+ Scale,
+ RotationOffset,
+ RigidBody,
+ m_localId);
+ PhysActor.SetMaterial(Material);
+ }
+ catch
+ {
+ m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid);
+ PhysActor = null;
+ }
// Basic Physics returns null.. joy joy joy.
if (PhysActor != null)
{
@@ -4446,7 +4452,9 @@ namespace OpenSim.Region.Framework.Scenes
AbsolutePosition,
Scale,
RotationOffset,
- UsePhysics);
+ UsePhysics,
+ m_localId);
+ PhysActor.SetMaterial(Material);
pa = PhysActor;
if (pa != null)
--
cgit v1.1
From 18652eb87ef0613b66664059581f991448d76af4 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 01:36:27 +0100
Subject: Fix physics proxy regeneration when a mesh with more than one submesh
is resized
Addresses http://opensimulator.org/mantis/view.php?id=5584
---
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 12 ++++++++++++
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 9 ++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 0fbd746..fd5f1b0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2662,13 +2662,18 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart part = GetChildPart(localID);
if (part != null)
{
+// m_log.DebugFormat(
+// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, localID, part.Scale, scale);
+
part.IgnoreUndoUpdate = true;
+
if (scale.X > m_scene.m_maxNonphys)
scale.X = m_scene.m_maxNonphys;
if (scale.Y > m_scene.m_maxNonphys)
scale.Y = m_scene.m_maxNonphys;
if (scale.Z > m_scene.m_maxNonphys)
scale.Z = m_scene.m_maxNonphys;
+
if (part.PhysActor != null && part.PhysActor.IsPhysical)
{
if (scale.X > m_scene.m_maxPhys)
@@ -2780,7 +2785,14 @@ namespace OpenSim.Region.Framework.Scenes
newSize.Z *= z;
obPart.Resize(newSize);
obPart.UpdateOffSet(currentpos);
+
+ if (obPart.PhysActor != null)
+ {
+ obPart.PhysActor.Size = newSize;
+ m_scene.PhysicsScene.AddPhysicsActorTaint(obPart.PhysActor);
+ }
}
+
obPart.IgnoreUndoUpdate = false;
obPart.StoreUndoState();
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 7604510..96dc82b8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2839,6 +2839,8 @@ namespace OpenSim.Region.Framework.Scenes
///
public void Resize(Vector3 scale)
{
+// m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale);
+
StoreUndoState();
m_shape.Scale = scale;
@@ -2976,6 +2978,11 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ ///
+ /// Sets sculpt and mesh data, and tells the physics engine to process the change.
+ ///
+ /// Texture id of the mesh. XXX: Redundant since this is also in AssetBase
+ /// The mesh itself.
public void SculptTextureCallback(UUID textureID, AssetBase texture)
{
if (m_shape.SculptEntry)
@@ -4613,7 +4620,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public void CheckSculptAndLoad()
{
-// m_log.Debug("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId);
+// m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId);
if (ParentGroup.IsDeleted)
return;
--
cgit v1.1
From da7340b9fb6a6f4468310958671f429f133e8424 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 01:42:56 +0100
Subject: If resized shape is a mesh/sculpt, leave it to the mesh asset
callback to trigger the physics actor taint.
In the last commit, the fix was made by updating all the child prim physics actors with the new size rather than just the root part.
---
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index fd5f1b0..9c307a3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2789,7 +2789,10 @@ namespace OpenSim.Region.Framework.Scenes
if (obPart.PhysActor != null)
{
obPart.PhysActor.Size = newSize;
- m_scene.PhysicsScene.AddPhysicsActorTaint(obPart.PhysActor);
+
+ // If we're a sculpt wait for the trigger when the sculpt texture is retrieved.
+ if (((OpenMetaverse.SculptType)obPart.Shape.SculptType) != SculptType.Mesh)
+ m_scene.PhysicsScene.AddPhysicsActorTaint(obPart.PhysActor);
}
}
@@ -2800,7 +2803,10 @@ namespace OpenSim.Region.Framework.Scenes
if (part.PhysActor != null)
{
part.PhysActor.Size = prevScale;
- m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
+
+ // If we're a sculpt wait for the trigger when the sculpt texture is retrieved.
+ if (((OpenMetaverse.SculptType)part.Shape.SculptType) != SculptType.Mesh)
+ m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
}
part.IgnoreUndoUpdate = false;
--
cgit v1.1
From 50bd48542c379f0ce0cec85eb412ded16c819434 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 02:44:00 +0100
Subject: Add very basic test for resizing a scene object with one prim
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 3 +-
.../Scenes/Tests/SceneObjectResizeTests.cs | 67 ++++++++++++++++++++++
2 files changed, 69 insertions(+), 1 deletion(-)
create mode 100644 OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 9c307a3..34e44e5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -617,9 +617,10 @@ namespace OpenSim.Region.Framework.Scenes
finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X;
finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
- return finalScale;
+ return finalScale;
}
+
public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters)
{
// We got a request from the inner_scene to raytrace along the Ray hRay
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
new file mode 100644
index 0000000..3865329
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -0,0 +1,67 @@
+/*
+ * 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 System;
+using System.Reflection;
+using NUnit.Framework;
+using OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Framework.Communications;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Tests.Common;
+using OpenSim.Tests.Common.Mock;
+
+namespace OpenSim.Region.Framework.Scenes.Tests
+{
+ ///
+ /// Basic scene object resize tests
+ ///
+ [TestFixture]
+ public class SceneObjectResizeTests
+ {
+ ///
+ /// Test resizing an object
+ ///
+ [Test]
+ public void TestResizeSceneObject()
+ {
+ TestHelper.InMethod();
+ //log4net.Config.XmlConfigurator.Configure();
+
+ Scene scene = SceneSetupHelpers.SetupScene();
+ SceneObjectGroup g1 = SceneSetupHelpers.AddSceneObject(scene).ParentGroup;
+
+ g1.GroupResize(new Vector3(2, 3, 4), g1.LocalId);
+
+ SceneObjectGroup g1Post = scene.GetSceneObjectGroup(g1.UUID);
+
+ Assert.That(g1Post.RootPart.Scale.X, Is.EqualTo(2));
+ Assert.That(g1Post.RootPart.Scale.Y, Is.EqualTo(3));
+ Assert.That(g1Post.RootPart.Scale.Z, Is.EqualTo(4));
+ }
+ }
+}
\ No newline at end of file
--
cgit v1.1
From 27fae36a21ff39e9bd413a3f4a4bb544f40bb4e1 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 02:53:36 +0100
Subject: remove the need to supply SceneObjectGroup.GroupResize() with a
localId.
This is utterly pointless scene we already know which sog we're dealing with.
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +-
.../Region/Framework/Scenes/SceneObjectGroup.cs | 261 +++++++++++----------
.../Scenes/Tests/SceneObjectResizeTests.cs | 2 +-
3 files changed, 133 insertions(+), 132 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 7ec7ea3..0e5ffc0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1234,7 +1234,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId))
{
- group.GroupResize(scale, localID);
+ group.GroupResize(scale);
}
}
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 34e44e5..f7ef0b4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2658,164 +2658,165 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- public void GroupResize(Vector3 scale, uint localID)
+ ///
+ /// Resize the entire group of prims.
+ ///
+ ///
+ public void GroupResize(Vector3 scale)
{
- SceneObjectPart part = GetChildPart(localID);
- if (part != null)
- {
// m_log.DebugFormat(
-// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, localID, part.Scale, scale);
+// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, localID, RootPart.Scale, scale);
+
+ RootPart.IgnoreUndoUpdate = true;
- part.IgnoreUndoUpdate = true;
+ if (scale.X > m_scene.m_maxNonphys)
+ scale.X = m_scene.m_maxNonphys;
+ if (scale.Y > m_scene.m_maxNonphys)
+ scale.Y = m_scene.m_maxNonphys;
+ if (scale.Z > m_scene.m_maxNonphys)
+ scale.Z = m_scene.m_maxNonphys;
- if (scale.X > m_scene.m_maxNonphys)
- scale.X = m_scene.m_maxNonphys;
- if (scale.Y > m_scene.m_maxNonphys)
- scale.Y = m_scene.m_maxNonphys;
- if (scale.Z > m_scene.m_maxNonphys)
- scale.Z = m_scene.m_maxNonphys;
+ if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical)
+ {
+ if (scale.X > m_scene.m_maxPhys)
+ scale.X = m_scene.m_maxPhys;
+ if (scale.Y > m_scene.m_maxPhys)
+ scale.Y = m_scene.m_maxPhys;
+ if (scale.Z > m_scene.m_maxPhys)
+ scale.Z = m_scene.m_maxPhys;
+ }
- if (part.PhysActor != null && part.PhysActor.IsPhysical)
- {
- if (scale.X > m_scene.m_maxPhys)
- scale.X = m_scene.m_maxPhys;
- if (scale.Y > m_scene.m_maxPhys)
- scale.Y = m_scene.m_maxPhys;
- if (scale.Z > m_scene.m_maxPhys)
- scale.Z = m_scene.m_maxPhys;
- }
- float x = (scale.X / part.Scale.X);
- float y = (scale.Y / part.Scale.Y);
- float z = (scale.Z / part.Scale.Z);
+ float x = (scale.X / RootPart.Scale.X);
+ float y = (scale.Y / RootPart.Scale.Y);
+ float z = (scale.Z / RootPart.Scale.Z);
- SceneObjectPart[] parts;
- if (x > 1.0f || y > 1.0f || z > 1.0f)
+ SceneObjectPart[] parts;
+ if (x > 1.0f || y > 1.0f || z > 1.0f)
+ {
+ parts = m_parts.GetArray();
+ for (int i = 0; i < parts.Length; i++)
{
- parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
+ SceneObjectPart obPart = parts[i];
+ if (obPart.UUID != m_rootPart.UUID)
{
- SceneObjectPart obPart = parts[i];
- if (obPart.UUID != m_rootPart.UUID)
- {
- obPart.IgnoreUndoUpdate = true;
- Vector3 oldSize = new Vector3(obPart.Scale);
+ obPart.IgnoreUndoUpdate = true;
+ Vector3 oldSize = new Vector3(obPart.Scale);
- float f = 1.0f;
- float a = 1.0f;
+ float f = 1.0f;
+ float a = 1.0f;
- if (part.PhysActor != null && part.PhysActor.IsPhysical)
+ if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical)
+ {
+ if (oldSize.X * x > m_scene.m_maxPhys)
{
- if (oldSize.X * x > m_scene.m_maxPhys)
- {
- f = m_scene.m_maxPhys / oldSize.X;
- a = f / x;
- x *= a;
- y *= a;
- z *= a;
- }
- if (oldSize.Y * y > m_scene.m_maxPhys)
- {
- f = m_scene.m_maxPhys / oldSize.Y;
- a = f / y;
- x *= a;
- y *= a;
- z *= a;
- }
- if (oldSize.Z * z > m_scene.m_maxPhys)
- {
- f = m_scene.m_maxPhys / oldSize.Z;
- a = f / z;
- x *= a;
- y *= a;
- z *= a;
- }
+ f = m_scene.m_maxPhys / oldSize.X;
+ a = f / x;
+ x *= a;
+ y *= a;
+ z *= a;
}
- else
+ if (oldSize.Y * y > m_scene.m_maxPhys)
{
- if (oldSize.X * x > m_scene.m_maxNonphys)
- {
- f = m_scene.m_maxNonphys / oldSize.X;
- a = f / x;
- x *= a;
- y *= a;
- z *= a;
- }
- if (oldSize.Y * y > m_scene.m_maxNonphys)
- {
- f = m_scene.m_maxNonphys / oldSize.Y;
- a = f / y;
- x *= a;
- y *= a;
- z *= a;
- }
- if (oldSize.Z * z > m_scene.m_maxNonphys)
- {
- f = m_scene.m_maxNonphys / oldSize.Z;
- a = f / z;
- x *= a;
- y *= a;
- z *= a;
- }
+ f = m_scene.m_maxPhys / oldSize.Y;
+ a = f / y;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
+ if (oldSize.Z * z > m_scene.m_maxPhys)
+ {
+ f = m_scene.m_maxPhys / oldSize.Z;
+ a = f / z;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
+ }
+ else
+ {
+ if (oldSize.X * x > m_scene.m_maxNonphys)
+ {
+ f = m_scene.m_maxNonphys / oldSize.X;
+ a = f / x;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
+ if (oldSize.Y * y > m_scene.m_maxNonphys)
+ {
+ f = m_scene.m_maxNonphys / oldSize.Y;
+ a = f / y;
+ x *= a;
+ y *= a;
+ z *= a;
+ }
+ if (oldSize.Z * z > m_scene.m_maxNonphys)
+ {
+ f = m_scene.m_maxNonphys / oldSize.Z;
+ a = f / z;
+ x *= a;
+ y *= a;
+ z *= a;
}
- obPart.IgnoreUndoUpdate = false;
- obPart.StoreUndoState();
}
+ obPart.IgnoreUndoUpdate = false;
+ obPart.StoreUndoState();
}
}
+ }
- Vector3 prevScale = part.Scale;
- prevScale.X *= x;
- prevScale.Y *= y;
- prevScale.Z *= z;
- part.Resize(prevScale);
+ Vector3 prevScale = RootPart.Scale;
+ prevScale.X *= x;
+ prevScale.Y *= y;
+ prevScale.Z *= z;
+ RootPart.Resize(prevScale);
- parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
+ parts = m_parts.GetArray();
+ for (int i = 0; i < parts.Length; i++)
+ {
+ SceneObjectPart obPart = parts[i];
+ obPart.IgnoreUndoUpdate = true;
+ if (obPart.UUID != m_rootPart.UUID)
{
- SceneObjectPart obPart = parts[i];
- obPart.IgnoreUndoUpdate = true;
- if (obPart.UUID != m_rootPart.UUID)
+ Vector3 currentpos = new Vector3(obPart.OffsetPosition);
+ currentpos.X *= x;
+ currentpos.Y *= y;
+ currentpos.Z *= z;
+ Vector3 newSize = new Vector3(obPart.Scale);
+ newSize.X *= x;
+ newSize.Y *= y;
+ newSize.Z *= z;
+ obPart.Resize(newSize);
+ obPart.UpdateOffSet(currentpos);
+
+ if (obPart.PhysActor != null)
{
- Vector3 currentpos = new Vector3(obPart.OffsetPosition);
- currentpos.X *= x;
- currentpos.Y *= y;
- currentpos.Z *= z;
- Vector3 newSize = new Vector3(obPart.Scale);
- newSize.X *= x;
- newSize.Y *= y;
- newSize.Z *= z;
- obPart.Resize(newSize);
- obPart.UpdateOffSet(currentpos);
-
- if (obPart.PhysActor != null)
- {
- obPart.PhysActor.Size = newSize;
+ obPart.PhysActor.Size = newSize;
- // If we're a sculpt wait for the trigger when the sculpt texture is retrieved.
- if (((OpenMetaverse.SculptType)obPart.Shape.SculptType) != SculptType.Mesh)
- m_scene.PhysicsScene.AddPhysicsActorTaint(obPart.PhysActor);
- }
+ // If we're a sculpt wait for the trigger when the sculpt texture is retrieved.
+ if (((OpenMetaverse.SculptType)obPart.Shape.SculptType) != SculptType.Mesh)
+ m_scene.PhysicsScene.AddPhysicsActorTaint(obPart.PhysActor);
}
-
- obPart.IgnoreUndoUpdate = false;
- obPart.StoreUndoState();
}
- if (part.PhysActor != null)
- {
- part.PhysActor.Size = prevScale;
+ obPart.IgnoreUndoUpdate = false;
+ obPart.StoreUndoState();
+ }
- // If we're a sculpt wait for the trigger when the sculpt texture is retrieved.
- if (((OpenMetaverse.SculptType)part.Shape.SculptType) != SculptType.Mesh)
- m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
- }
+ if (RootPart.PhysActor != null)
+ {
+ RootPart.PhysActor.Size = prevScale;
- part.IgnoreUndoUpdate = false;
- part.StoreUndoState();
- HasGroupChanged = true;
- m_rootPart.TriggerScriptChangedEvent(Changed.SCALE);
- ScheduleGroupForTerseUpdate();
+ // If we're a sculpt wait for the trigger when the sculpt texture is retrieved.
+ if (((OpenMetaverse.SculptType)RootPart.Shape.SculptType) != SculptType.Mesh)
+ m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor);
}
+
+ RootPart.IgnoreUndoUpdate = false;
+ RootPart.StoreUndoState();
+ HasGroupChanged = true;
+ RootPart.TriggerScriptChangedEvent(Changed.SCALE);
+ ScheduleGroupForTerseUpdate();
}
#endregion
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
index 3865329..627f294 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Scene scene = SceneSetupHelpers.SetupScene();
SceneObjectGroup g1 = SceneSetupHelpers.AddSceneObject(scene).ParentGroup;
- g1.GroupResize(new Vector3(2, 3, 4), g1.LocalId);
+ g1.GroupResize(new Vector3(2, 3, 4));
SceneObjectGroup g1Post = scene.GetSceneObjectGroup(g1.UUID);
--
cgit v1.1
From 3fc12e72245c81075fb7a584c40aa49a10a3b458 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 03:02:28 +0100
Subject: Eliminate the pointless textured id argument to SculptTextureCallback
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 96dc82b8..a55e07a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1731,7 +1731,7 @@ namespace OpenSim.Region.Framework.Scenes
{
SceneObjectPart sop = (SceneObjectPart)sender;
if (sop != null)
- sop.SculptTextureCallback(asset.FullID, asset);
+ sop.SculptTextureCallback(asset);
}
}
@@ -2979,11 +2979,10 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// Sets sculpt and mesh data, and tells the physics engine to process the change.
+ /// Set sculpt and mesh data, and tell the physics engine to process the change.
///
- /// Texture id of the mesh. XXX: Redundant since this is also in AssetBase
/// The mesh itself.
- public void SculptTextureCallback(UUID textureID, AssetBase texture)
+ public void SculptTextureCallback(AssetBase texture)
{
if (m_shape.SculptEntry)
{
@@ -3009,16 +3008,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
-// ///
-// ///
-// ///
-// ///
-// public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
-// {
-// m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags);
-// }
-
-
///
/// Send a full update to the client for the given part
///
@@ -4631,9 +4620,11 @@ namespace OpenSim.Region.Framework.Scenes
if (Shape.SculptEntry && Shape.SculptTexture != UUID.Zero)
{
// check if a previously decoded sculpt map has been cached
+ // We don't read the file here - the meshmerizer will do that later.
+ // TODO: Could we simplify the meshmerizer code by reading and setting the data here?
if (File.Exists(System.IO.Path.Combine("j2kDecodeCache", "smap_" + Shape.SculptTexture.ToString())))
{
- SculptTextureCallback(Shape.SculptTexture, null);
+ SculptTextureCallback(null);
}
else
{
--
cgit v1.1
From c82f19e41cbfcf4eb8bb3691d1653eeceaa6a8ad Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 03:06:30 +0100
Subject: fix build break from last commit
---
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index f7ef0b4..0b474b5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -3345,7 +3345,7 @@ namespace OpenSim.Region.Framework.Scenes
if (sop != null)
{
if (asset != null)
- sop.SculptTextureCallback(asset.FullID, asset);
+ sop.SculptTextureCallback(asset);
}
}
--
cgit v1.1
From 982e71b6b88ccbb884044d4b1c350b27c4877060 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 03:08:28 +0100
Subject: eliminate unused and redundant SceneObjectGroup.AssetReceived()
---
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 17 -----------------
1 file changed, 17 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 0b474b5..8ffe84b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -3333,23 +3333,6 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// Handle an asset received asynchronously from the asset service.
- ///
- ///
- ///
- ///
- protected void AssetReceived(string id, Object sender, AssetBase asset)
- {
- SceneObjectPart sop = (SceneObjectPart)sender;
-
- if (sop != null)
- {
- if (asset != null)
- sop.SculptTextureCallback(asset);
- }
- }
-
- ///
/// Set the user group to which this scene object belongs.
///
///
--
cgit v1.1
From 6f9b8557192ea5fe65e4dc7416809a4d1affa954 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 03:16:24 +0100
Subject: refactor: remove pointless sender != null tests, etc, in
AssetReceived, since the method called always belongs to the object that
generated the request
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index a55e07a..697dd0e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1711,7 +1711,8 @@ namespace OpenSim.Region.Framework.Scenes
{
if (dupe.m_shape.SculptEntry && dupe.m_shape.SculptTexture != UUID.Zero)
{
- m_parentGroup.Scene.AssetService.Get(dupe.m_shape.SculptTexture.ToString(), dupe, AssetReceived);
+ ParentGroup.Scene.AssetService.Get(
+ dupe.m_shape.SculptTexture.ToString(), dupe, dupe.AssetReceived);
}
bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0);
@@ -1725,14 +1726,16 @@ namespace OpenSim.Region.Framework.Scenes
return dupe;
}
+ ///
+ /// Called back by asynchronous asset fetch.
+ ///
+ /// ID of asset received
+ /// Register
+ ///
protected void AssetReceived(string id, Object sender, AssetBase asset)
{
if (asset != null)
- {
- SceneObjectPart sop = (SceneObjectPart)sender;
- if (sop != null)
- sop.SculptTextureCallback(asset);
- }
+ SculptTextureCallback(asset);
}
public static SceneObjectPart Create()
--
cgit v1.1
From 0f9882db5b6708864924218f713863ff7b9ded47 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 03:24:36 +0100
Subject: minor: add a log warning if a sculpt/mesh async asset request returns
no data
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 697dd0e..5035317 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1736,6 +1736,10 @@ namespace OpenSim.Region.Framework.Scenes
{
if (asset != null)
SculptTextureCallback(asset);
+ else
+ m_log.WarnFormat(
+ "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data",
+ Name, LocalId, id);
}
public static SceneObjectPart Create()
--
cgit v1.1
From df2a59d31b1ae21f99c1b18976b8d799b935a762 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 03:30:14 +0100
Subject: refactor: make SceneObjectGroup.GroupScale() a property rather than a
mehod
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 61 ++++++++++++----------
1 file changed, 32 insertions(+), 29 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 8ffe84b..7aa7831 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -236,6 +236,38 @@ namespace OpenSim.Region.Framework.Scenes
get { return m_rootPart.RotationOffset; }
}
+ public Vector3 GroupScale
+ {
+ get
+ {
+ Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
+ Vector3 maxScale = Vector3.Zero;
+ Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
+
+ SceneObjectPart[] parts = m_parts.GetArray();
+ for (int i = 0; i < parts.Length; i++)
+ {
+ SceneObjectPart part = parts[i];
+ Vector3 partscale = part.Scale;
+ Vector3 partoffset = part.OffsetPosition;
+
+ minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X;
+ minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y;
+ minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z;
+
+ maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X;
+ maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y;
+ maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z;
+ }
+
+ finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X;
+ finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
+ finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
+
+ return finalScale;
+ }
+ }
+
public UUID GroupID
{
get { return m_rootPart.GroupID; }
@@ -592,35 +624,6 @@ namespace OpenSim.Region.Framework.Scenes
//ScheduleGroupForFullUpdate();
}
- public Vector3 GroupScale()
- {
- Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
- Vector3 maxScale = Vector3.Zero;
- Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
-
- SceneObjectPart[] parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
- {
- SceneObjectPart part = parts[i];
- Vector3 partscale = part.Scale;
- Vector3 partoffset = part.OffsetPosition;
-
- minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X;
- minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y;
- minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z;
-
- maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X;
- maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y;
- maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z;
- }
-
- finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X;
- finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
- finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
-
- return finalScale;
- }
-
public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters)
{
// We got a request from the inner_scene to raytrace along the Ray hRay
--
cgit v1.1
From 4b5a6b655becd5162054bc53365fdcd9c7ed1772 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 03:52:30 +0100
Subject: add test for resizing one part in a group
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +-
.../Scenes/Tests/SceneObjectResizeTests.cs | 35 ++++++++++++++++++++++
2 files changed, 36 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 0e5ffc0..df6908a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1210,7 +1210,7 @@ namespace OpenSim.Region.Framework.Scenes
#region Client Event handlers
///
- ///
+ /// Update the scale of an individual prim.
///
///
///
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
index 627f294..95ecfc6 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -63,5 +63,40 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(g1Post.RootPart.Scale.Y, Is.EqualTo(3));
Assert.That(g1Post.RootPart.Scale.Z, Is.EqualTo(4));
}
+
+ ///
+ /// Test resizing an individual part in a scene object.
+ ///
+ [Test]
+ public void TestResizeSceneObjectPart()
+ {
+ TestHelper.InMethod();
+ //log4net.Config.XmlConfigurator.Configure();
+
+ Scene scene = SceneSetupHelpers.SetupScene();
+
+ SceneObjectGroup g1 = SceneSetupHelpers.CreateSceneObject(2, UUID.Zero);
+ g1.RootPart.Scale = new Vector3(2, 3, 4);
+ g1.Parts[1].Scale = new Vector3(5, 6, 7);
+
+ scene.AddSceneObject(g1);
+
+ SceneObjectGroup g1Post = scene.GetSceneObjectGroup(g1.UUID);
+
+ g1Post.Resize(new Vector3(8, 9, 10), g1Post.Parts[1].LocalId);
+
+ SceneObjectGroup g1PostPost = scene.GetSceneObjectGroup(g1.UUID);
+
+ SceneObjectPart g1RootPart = g1PostPost.RootPart;
+ SceneObjectPart g1ChildPart = g1PostPost.Parts[1];
+
+ Assert.That(g1RootPart.Scale.X, Is.EqualTo(2));
+ Assert.That(g1RootPart.Scale.Y, Is.EqualTo(3));
+ Assert.That(g1RootPart.Scale.Z, Is.EqualTo(4));
+
+ Assert.That(g1ChildPart.Scale.X, Is.EqualTo(8));
+ Assert.That(g1ChildPart.Scale.Y, Is.EqualTo(9));
+ Assert.That(g1ChildPart.Scale.Z, Is.EqualTo(10));
+ }
}
}
\ No newline at end of file
--
cgit v1.1
From 2b68ac4ba31205a55f53f1b69629dd9ebbd66ef6 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 04:22:57 +0100
Subject: refactor: Push all part resize code down into
SceneObjectPart.Resize()
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 9 ++--
.../Region/Framework/Scenes/SceneObjectGroup.cs | 50 ----------------------
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 27 +++++++++++-
.../Scenes/Tests/SceneObjectResizeTests.cs | 2 +-
4 files changed, 32 insertions(+), 56 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index df6908a..00d25c2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1217,12 +1217,13 @@ namespace OpenSim.Region.Framework.Scenes
///
protected internal void UpdatePrimScale(uint localID, Vector3 scale, IClientAPI remoteClient)
{
- SceneObjectGroup group = GetGroupByPrim(localID);
- if (group != null)
+ SceneObjectPart part = GetSceneObjectPart(localID);
+
+ if (part != null)
{
- if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId))
+ if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId))
{
- group.Resize(scale, localID);
+ part.Resize(scale);
}
}
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 7aa7831..477b3e3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2612,56 +2612,6 @@ namespace OpenSim.Region.Framework.Scenes
#region Resize
///
- /// Resize the given part
- ///
- ///
- ///
- public void Resize(Vector3 scale, uint localID)
- {
- if (scale.X > m_scene.m_maxNonphys)
- scale.X = m_scene.m_maxNonphys;
- if (scale.Y > m_scene.m_maxNonphys)
- scale.Y = m_scene.m_maxNonphys;
- if (scale.Z > m_scene.m_maxNonphys)
- scale.Z = m_scene.m_maxNonphys;
-
- SceneObjectPart part = GetChildPart(localID);
- if (part != null)
- {
- part.Resize(scale);
- if (part.PhysActor != null)
- {
- if (part.PhysActor.IsPhysical)
- {
- if (scale.X > m_scene.m_maxPhys)
- scale.X = m_scene.m_maxPhys;
- if (scale.Y > m_scene.m_maxPhys)
- scale.Y = m_scene.m_maxPhys;
- if (scale.Z > m_scene.m_maxPhys)
- scale.Z = m_scene.m_maxPhys;
- }
- part.PhysActor.Size = scale;
- m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
- }
- //if (part.UUID != m_rootPart.UUID)
-
- HasGroupChanged = true;
- part.TriggerScriptChangedEvent(Changed.SCALE);
- ScheduleGroupForFullUpdate();
-
- //if (part.UUID == m_rootPart.UUID)
- //{
- //if (m_rootPart.PhysActor != null)
- //{
- //m_rootPart.PhysActor.Size =
- //new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z);
- //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
- //}
- //}
- }
- }
-
- ///
/// Resize the entire group of prims.
///
///
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 5035317..ffde68e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2846,6 +2846,13 @@ namespace OpenSim.Region.Framework.Scenes
///
public void Resize(Vector3 scale)
{
+ if (scale.X > ParentGroup.Scene.m_maxNonphys)
+ scale.X = ParentGroup.Scene.m_maxNonphys;
+ if (scale.Y > ParentGroup.Scene.m_maxNonphys)
+ scale.Y = ParentGroup.Scene.m_maxNonphys;
+ if (scale.Z > ParentGroup.Scene.m_maxNonphys)
+ scale.Z = ParentGroup.Scene.m_maxNonphys;
+
// m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale);
StoreUndoState();
@@ -2855,9 +2862,27 @@ namespace OpenSim.Region.Framework.Scenes
// need to reinsert the sculpt data into the shape, since the physics engine deletes it when done to
// save memory
if (PhysActor != null)
- CheckSculptAndLoad();
+ {
+ if (PhysActor.IsPhysical)
+ {
+ if (scale.X > ParentGroup.Scene.m_maxPhys)
+ scale.X = ParentGroup.Scene.m_maxPhys;
+ if (scale.Y > ParentGroup.Scene.m_maxPhys)
+ scale.Y = ParentGroup.Scene.m_maxPhys;
+ if (scale.Z > ParentGroup.Scene.m_maxPhys)
+ scale.Z = ParentGroup.Scene.m_maxPhys;
+ }
+
+ PhysActor.Size = scale;
+
+ if (((OpenMetaverse.SculptType)Shape.SculptType) == SculptType.Mesh)
+ CheckSculptAndLoad();
+ else
+ ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
+ }
ParentGroup.HasGroupChanged = true;
+ TriggerScriptChangedEvent(Changed.SCALE);
ScheduleFullUpdate();
}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
index 95ecfc6..7ec36b8 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
SceneObjectGroup g1Post = scene.GetSceneObjectGroup(g1.UUID);
- g1Post.Resize(new Vector3(8, 9, 10), g1Post.Parts[1].LocalId);
+ g1Post.Parts[1].Resize(new Vector3(8, 9, 10));
SceneObjectGroup g1PostPost = scene.GetSceneObjectGroup(g1.UUID);
--
cgit v1.1
From 122745fe1c17ff0862f5a0cb2f97e8abf8d67cb6 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 04:28:49 +0100
Subject: refactor: replace scale limiting code with more elegant Math.Min
calls
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index ffde68e..f5b8daf 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2846,12 +2846,9 @@ namespace OpenSim.Region.Framework.Scenes
///
public void Resize(Vector3 scale)
{
- if (scale.X > ParentGroup.Scene.m_maxNonphys)
- scale.X = ParentGroup.Scene.m_maxNonphys;
- if (scale.Y > ParentGroup.Scene.m_maxNonphys)
- scale.Y = ParentGroup.Scene.m_maxNonphys;
- if (scale.Z > ParentGroup.Scene.m_maxNonphys)
- scale.Z = ParentGroup.Scene.m_maxNonphys;
+ scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxNonphys);
+ scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxNonphys);
+ scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxNonphys);
// m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale);
@@ -2865,12 +2862,9 @@ namespace OpenSim.Region.Framework.Scenes
{
if (PhysActor.IsPhysical)
{
- if (scale.X > ParentGroup.Scene.m_maxPhys)
- scale.X = ParentGroup.Scene.m_maxPhys;
- if (scale.Y > ParentGroup.Scene.m_maxPhys)
- scale.Y = ParentGroup.Scene.m_maxPhys;
- if (scale.Z > ParentGroup.Scene.m_maxPhys)
- scale.Z = ParentGroup.Scene.m_maxPhys;
+ scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxPhys);
+ scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxPhys);
+ scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxPhys);
}
PhysActor.Size = scale;
--
cgit v1.1
From 9a80adf33ae0d255d923d33f5b6abac540efcd52 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 04:49:21 +0100
Subject: remove now unncessary parts of SceneObjectGroup.Resize()
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 26 +++++-----------------
1 file changed, 5 insertions(+), 21 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 477b3e3..7662874 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2611,6 +2611,7 @@ namespace OpenSim.Region.Framework.Scenes
#region Resize
+
///
/// Resize the entire group of prims.
///
@@ -2712,6 +2713,7 @@ namespace OpenSim.Region.Framework.Scenes
z *= a;
}
}
+
obPart.IgnoreUndoUpdate = false;
obPart.StoreUndoState();
}
@@ -2729,47 +2731,29 @@ namespace OpenSim.Region.Framework.Scenes
{
SceneObjectPart obPart = parts[i];
obPart.IgnoreUndoUpdate = true;
+
if (obPart.UUID != m_rootPart.UUID)
{
Vector3 currentpos = new Vector3(obPart.OffsetPosition);
currentpos.X *= x;
currentpos.Y *= y;
currentpos.Z *= z;
+
Vector3 newSize = new Vector3(obPart.Scale);
newSize.X *= x;
newSize.Y *= y;
newSize.Z *= z;
+
obPart.Resize(newSize);
obPart.UpdateOffSet(currentpos);
-
- if (obPart.PhysActor != null)
- {
- obPart.PhysActor.Size = newSize;
-
- // If we're a sculpt wait for the trigger when the sculpt texture is retrieved.
- if (((OpenMetaverse.SculptType)obPart.Shape.SculptType) != SculptType.Mesh)
- m_scene.PhysicsScene.AddPhysicsActorTaint(obPart.PhysActor);
- }
}
obPart.IgnoreUndoUpdate = false;
obPart.StoreUndoState();
}
- if (RootPart.PhysActor != null)
- {
- RootPart.PhysActor.Size = prevScale;
-
- // If we're a sculpt wait for the trigger when the sculpt texture is retrieved.
- if (((OpenMetaverse.SculptType)RootPart.Shape.SculptType) != SculptType.Mesh)
- m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor);
- }
-
RootPart.IgnoreUndoUpdate = false;
RootPart.StoreUndoState();
- HasGroupChanged = true;
- RootPart.TriggerScriptChangedEvent(Changed.SCALE);
- ScheduleGroupForTerseUpdate();
}
#endregion
--
cgit v1.1
From f5ddf37112d4881243e3350d5df898c6b2bb02ae Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Jul 2011 05:23:21 +0100
Subject: Replace ifs in SOG.GroupResize() with Math.Min()
Also fiddle a bit with undo. This is not currently working properly, though to be fair it also didn't appear to work in 0.7.1.1 either (at least for resize).
Will get some more attention soon.
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 1 +
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 20 +++++++-------------
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 18 +++++++++++++++++-
3 files changed, 25 insertions(+), 14 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 00d25c2..bdb7f95 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -569,6 +569,7 @@ namespace OpenSim.Region.Framework.Scenes
if (primId != UUID.Zero)
{
SceneObjectPart part = m_parentScene.GetSceneObjectPart(primId);
+
if (part != null)
part.Redo();
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 7662874..ce5db5f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2623,21 +2623,15 @@ namespace OpenSim.Region.Framework.Scenes
RootPart.IgnoreUndoUpdate = true;
- if (scale.X > m_scene.m_maxNonphys)
- scale.X = m_scene.m_maxNonphys;
- if (scale.Y > m_scene.m_maxNonphys)
- scale.Y = m_scene.m_maxNonphys;
- if (scale.Z > m_scene.m_maxNonphys)
- scale.Z = m_scene.m_maxNonphys;
+ scale.X = Math.Min(scale.X, Scene.m_maxNonphys);
+ scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys);
+ scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys);
if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical)
{
- if (scale.X > m_scene.m_maxPhys)
- scale.X = m_scene.m_maxPhys;
- if (scale.Y > m_scene.m_maxPhys)
- scale.Y = m_scene.m_maxPhys;
- if (scale.Z > m_scene.m_maxPhys)
- scale.Z = m_scene.m_maxPhys;
+ scale.X = Math.Min(scale.X, Scene.m_maxPhys);
+ scale.Y = Math.Min(scale.Y, Scene.m_maxPhys);
+ scale.Z = Math.Min(scale.Z, Scene.m_maxPhys);
}
float x = (scale.X / RootPart.Scale.X);
@@ -2715,7 +2709,6 @@ namespace OpenSim.Region.Framework.Scenes
}
obPart.IgnoreUndoUpdate = false;
- obPart.StoreUndoState();
}
}
}
@@ -2753,6 +2746,7 @@ namespace OpenSim.Region.Framework.Scenes
}
RootPart.IgnoreUndoUpdate = false;
+
RootPart.StoreUndoState();
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index f5b8daf..6b9607c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3687,6 +3687,8 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_parentGroup != null)
{
+// m_log.DebugFormat("[SCENE OBJECT PART]: Storing undo state for {0} {1}", Name, LocalId);
+
lock (m_undo)
{
if (m_undo.Count > 0)
@@ -3705,11 +3707,18 @@ namespace OpenSim.Region.Framework.Scenes
m_undo.Push(nUndo);
}
-
}
}
}
+// else
+// {
+// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
+// }
}
+// else
+// {
+// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
+// }
}
public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot)
@@ -4179,11 +4188,14 @@ namespace OpenSim.Region.Framework.Scenes
if (m_undo.Count > 0)
{
UndoState nUndo = null;
+
if (m_parentGroup.GetSceneMaxUndo() > 0)
{
nUndo = new UndoState(this);
}
+
UndoState goback = m_undo.Pop();
+
if (goback != null)
{
goback.PlaybackState(this);
@@ -4196,6 +4208,8 @@ namespace OpenSim.Region.Framework.Scenes
public void Redo()
{
+// m_log.DebugFormat("[SCENE OBJECT PART]: Handling redo request for {0} {1}", Name, LocalId);
+
lock (m_redo)
{
if (m_parentGroup.GetSceneMaxUndo() > 0)
@@ -4204,7 +4218,9 @@ namespace OpenSim.Region.Framework.Scenes
m_undo.Push(nUndo);
}
+
UndoState gofwd = m_redo.Pop();
+
if (gofwd != null)
gofwd.PlayfwdState(this);
}
--
cgit v1.1
From e9a739f45fdc464b19ad520c3efcb202d8bd5458 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 18 Jul 2011 01:33:57 +0100
Subject: refactor: group all the undo/redo code in SOP into one place for
easier code reading
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 121 +++++++++++----------
1 file changed, 62 insertions(+), 59 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 6b9607c..253326e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -414,7 +414,6 @@ namespace OpenSim.Region.Framework.Scenes
CreateSelected = true;
TrimPermissions();
- //m_undo = new UndoStack(ParentGroup.GetSceneMaxUndo());
m_inventory = new SceneObjectPartInventory(this);
}
@@ -1621,19 +1620,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- public void ClearUndoState()
- {
- lock (m_undo)
- {
- m_undo.Clear();
- }
- lock (m_redo)
- {
- m_redo.Clear();
- }
- StoreUndoState();
- }
-
public byte ConvertScriptUintToByte(uint indata)
{
byte outdata = (byte)TextureAnimFlags.NONE;
@@ -3721,6 +3707,68 @@ namespace OpenSim.Region.Framework.Scenes
// }
}
+ public void Undo()
+ {
+// m_log.DebugFormat("[SCENE OBJECT PART]: Handling undo request for {0} {1}", Name, LocalId);
+
+ lock (m_undo)
+ {
+ if (m_undo.Count > 0)
+ {
+ UndoState nUndo = null;
+
+ if (m_parentGroup.GetSceneMaxUndo() > 0)
+ {
+ nUndo = new UndoState(this);
+ }
+
+ UndoState goback = m_undo.Pop();
+
+ if (goback != null)
+ {
+ goback.PlaybackState(this);
+ if (nUndo != null)
+ m_redo.Push(nUndo);
+ }
+ }
+ }
+ }
+
+ public void Redo()
+ {
+// m_log.DebugFormat("[SCENE OBJECT PART]: Handling redo request for {0} {1}", Name, LocalId);
+
+ lock (m_redo)
+ {
+ if (m_parentGroup.GetSceneMaxUndo() > 0)
+ {
+ UndoState nUndo = new UndoState(this);
+
+ m_undo.Push(nUndo);
+ }
+
+ UndoState gofwd = m_redo.Pop();
+
+ if (gofwd != null)
+ gofwd.PlayfwdState(this);
+ }
+ }
+
+ public void ClearUndoState()
+ {
+ lock (m_undo)
+ {
+ m_undo.Clear();
+ }
+
+ lock (m_redo)
+ {
+ m_redo.Clear();
+ }
+
+ StoreUndoState();
+ }
+
public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot)
{
// In this case we're using a sphere with a radius of the largest dimension of the prim
@@ -4181,51 +4229,6 @@ namespace OpenSim.Region.Framework.Scenes
_nextOwnerMask &= (uint)PermissionMask.All;
}
- public void Undo()
- {
- lock (m_undo)
- {
- if (m_undo.Count > 0)
- {
- UndoState nUndo = null;
-
- if (m_parentGroup.GetSceneMaxUndo() > 0)
- {
- nUndo = new UndoState(this);
- }
-
- UndoState goback = m_undo.Pop();
-
- if (goback != null)
- {
- goback.PlaybackState(this);
- if (nUndo != null)
- m_redo.Push(nUndo);
- }
- }
- }
- }
-
- public void Redo()
- {
-// m_log.DebugFormat("[SCENE OBJECT PART]: Handling redo request for {0} {1}", Name, LocalId);
-
- lock (m_redo)
- {
- if (m_parentGroup.GetSceneMaxUndo() > 0)
- {
- UndoState nUndo = new UndoState(this);
-
- m_undo.Push(nUndo);
- }
-
- UndoState gofwd = m_redo.Pop();
-
- if (gofwd != null)
- gofwd.PlayfwdState(this);
- }
- }
-
public void UpdateExtraParam(ushort type, bool inUse, byte[] data)
{
m_shape.ReadInUpdateExtraParam(type, inUse, data);
--
cgit v1.1
From 3f8e571b7887758514645c46b2b26d7c3fc82e45 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 18 Jul 2011 02:01:12 +0100
Subject: Use a standard generic system stack for the undo/redo stacks instead
of our own homebrew.
system stack also uses an array, so no performance penalty.
Also exposes undo count and adds a test assertion for correct undo count after resize
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 16 ++++++++++++++--
.../Framework/Scenes/Tests/SceneObjectResizeTests.cs | 2 ++
2 files changed, 16 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 253326e..a1200ee 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -287,8 +287,8 @@ namespace OpenSim.Region.Framework.Scenes
private string m_sitAnimation = "SIT";
private string m_text = String.Empty;
private string m_touchName = String.Empty;
- private readonly UndoStack m_undo = new UndoStack(5);
- private readonly UndoStack m_redo = new UndoStack(5);
+ private readonly Stack m_undo = new Stack(5);
+ private readonly Stack m_redo = new Stack(5);
private UUID _creatorID;
private bool m_passTouches;
@@ -3707,6 +3707,18 @@ namespace OpenSim.Region.Framework.Scenes
// }
}
+ ///
+ /// Return number of undos on the stack. Here temporarily pending a refactor.
+ ///
+ public int UndoCount
+ {
+ get
+ {
+ lock (m_undo)
+ return m_undo.Count;
+ }
+ }
+
public void Undo()
{
// m_log.DebugFormat("[SCENE OBJECT PART]: Handling undo request for {0} {1}", Name, LocalId);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
index 7ec36b8..6dbac3c 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -62,6 +62,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(g1Post.RootPart.Scale.X, Is.EqualTo(2));
Assert.That(g1Post.RootPart.Scale.Y, Is.EqualTo(3));
Assert.That(g1Post.RootPart.Scale.Z, Is.EqualTo(4));
+
+ Assert.That(g1Post.RootPart.UndoCount, Is.EqualTo(1));
}
///
--
cgit v1.1
From 6fc74b36d1d0f7dcd6f013893c3189a3f989431c Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 18 Jul 2011 04:54:21 +0100
Subject: Make various tweaks to undo code in an effort to get things working
better.
Undo rotation and position appear to be working.
Resizing a single prim appears to be working, though the undo has to be done twice.
Resizing a group of prims still does not work properly - possibly because in the UndoState we don't store a knowledge of when we're resizing a whole group rather than individual prims.
This needs to be addressed.
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 1 +
.../Region/Framework/Scenes/SceneObjectGroup.cs | 58 +++++++++++---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 92 +++++++++++++--------
.../Scenes/Tests/SceneObjectResizeTests.cs | 2 +-
OpenSim/Region/Framework/Scenes/UndoState.cs | 93 ++++++++++++++++++++--
5 files changed, 193 insertions(+), 53 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index bdb7f95..0a0bde8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -564,6 +564,7 @@ namespace OpenSim.Region.Framework.Scenes
part.Undo();
}
}
+
protected internal void HandleRedo(IClientAPI remoteClient, UUID primId)
{
if (primId != UUID.Zero)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index ce5db5f..7254992 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1145,6 +1145,10 @@ namespace OpenSim.Region.Framework.Scenes
public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient)
{
+// m_log.DebugFormat(
+// "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}",
+// remoteClient.Name, part.Name, part.LocalId, offsetPos);
+
part.StoreUndoState();
part.OnGrab(offsetPos, remoteClient);
}
@@ -2611,17 +2615,14 @@ namespace OpenSim.Region.Framework.Scenes
#region Resize
-
///
/// Resize the entire group of prims.
///
///
public void GroupResize(Vector3 scale)
{
-// m_log.DebugFormat(
-// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, localID, RootPart.Scale, scale);
-
- RootPart.IgnoreUndoUpdate = true;
+// m_log.DebugFormat(
+// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale);
scale.X = Math.Min(scale.X, Scene.m_maxNonphys);
scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys);
@@ -2647,7 +2648,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart obPart = parts[i];
if (obPart.UUID != m_rootPart.UUID)
{
- obPart.IgnoreUndoUpdate = true;
+// obPart.IgnoreUndoUpdate = true;
Vector3 oldSize = new Vector3(obPart.Scale);
float f = 1.0f;
@@ -2663,6 +2664,7 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
+
if (oldSize.Y * y > m_scene.m_maxPhys)
{
f = m_scene.m_maxPhys / oldSize.Y;
@@ -2671,6 +2673,7 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
+
if (oldSize.Z * z > m_scene.m_maxPhys)
{
f = m_scene.m_maxPhys / oldSize.Z;
@@ -2690,6 +2693,7 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
+
if (oldSize.Y * y > m_scene.m_maxNonphys)
{
f = m_scene.m_maxNonphys / oldSize.Y;
@@ -2698,6 +2702,7 @@ namespace OpenSim.Region.Framework.Scenes
y *= a;
z *= a;
}
+
if (oldSize.Z * z > m_scene.m_maxNonphys)
{
f = m_scene.m_maxNonphys / oldSize.Z;
@@ -2708,7 +2713,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- obPart.IgnoreUndoUpdate = false;
+// obPart.IgnoreUndoUpdate = false;
}
}
}
@@ -2723,7 +2728,7 @@ namespace OpenSim.Region.Framework.Scenes
for (int i = 0; i < parts.Length; i++)
{
SceneObjectPart obPart = parts[i];
- obPart.IgnoreUndoUpdate = true;
+// obPart.IgnoreUndoUpdate = true;
if (obPart.UUID != m_rootPart.UUID)
{
@@ -2738,16 +2743,18 @@ namespace OpenSim.Region.Framework.Scenes
newSize.Z *= z;
obPart.Resize(newSize);
+
+ obPart.IgnoreUndoUpdate = true;
obPart.UpdateOffSet(currentpos);
+ obPart.IgnoreUndoUpdate = false;
}
- obPart.IgnoreUndoUpdate = false;
- obPart.StoreUndoState();
+// obPart.IgnoreUndoUpdate = false;
+// obPart.StoreUndoState();
}
- RootPart.IgnoreUndoUpdate = false;
-
- RootPart.StoreUndoState();
+// m_log.DebugFormat(
+// "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale);
}
#endregion
@@ -2760,6 +2767,8 @@ namespace OpenSim.Region.Framework.Scenes
///
public void UpdateGroupPosition(Vector3 pos)
{
+// m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos);
+
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
parts[i].StoreUndoState();
@@ -2805,6 +2814,9 @@ namespace OpenSim.Region.Framework.Scenes
if (part != null)
{
+// m_log.DebugFormat(
+// "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos);
+
if (part.UUID == m_rootPart.UUID)
{
UpdateRootPosition(pos);
@@ -2824,6 +2836,9 @@ namespace OpenSim.Region.Framework.Scenes
///
private void UpdateRootPosition(Vector3 pos)
{
+// m_log.DebugFormat(
+// "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos);
+
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
parts[i].StoreUndoState();
@@ -2868,6 +2883,9 @@ namespace OpenSim.Region.Framework.Scenes
///
public void UpdateGroupRotationR(Quaternion rot)
{
+// m_log.DebugFormat(
+// "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot);
+
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
parts[i].StoreUndoState();
@@ -2892,6 +2910,9 @@ namespace OpenSim.Region.Framework.Scenes
///
public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot)
{
+// m_log.DebugFormat(
+// "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot);
+
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
parts[i].StoreUndoState();
@@ -2926,6 +2947,9 @@ namespace OpenSim.Region.Framework.Scenes
if (part != null)
{
+// m_log.DebugFormat(
+// "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot);
+
if (part.UUID == m_rootPart.UUID)
{
UpdateRootRotation(rot);
@@ -2947,6 +2971,10 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart part = GetChildPart(localID);
if (part != null)
{
+// m_log.DebugFormat(
+// "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}",
+// part.Name, part.LocalId, rot);
+
if (part.UUID == m_rootPart.UUID)
{
UpdateRootRotation(rot);
@@ -2969,6 +2997,10 @@ namespace OpenSim.Region.Framework.Scenes
///
private void UpdateRootRotation(Quaternion rot)
{
+// m_log.DebugFormat(
+// "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}",
+// Name, LocalId, rot);
+
Quaternion axRot = rot;
Quaternion oldParentRot = m_rootPart.RotationOffset;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index a1200ee..aab83b8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1014,15 +1014,19 @@ namespace OpenSim.Region.Framework.Scenes
get { return m_shape; }
set { m_shape = value; }
}
-
+
+ ///
+ /// Change the scale of this part.
+ ///
public Vector3 Scale
{
get { return m_shape.Scale; }
set
{
- StoreUndoState();
if (m_shape != null)
{
+ StoreUndoState();
+
m_shape.Scale = value;
PhysicsActor actor = PhysActor;
@@ -1033,11 +1037,16 @@ namespace OpenSim.Region.Framework.Scenes
if (m_parentGroup.Scene.PhysicsScene != null)
{
actor.Size = m_shape.Scale;
- m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
+
+ if (((OpenMetaverse.SculptType)Shape.SculptType) == SculptType.Mesh)
+ CheckSculptAndLoad();
+ else
+ ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
}
}
}
}
+
TriggerScriptChangedEvent(Changed.SCALE);
}
}
@@ -2827,8 +2836,12 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// Resize this part.
+ /// Set the scale of this part.
///
+ ///
+ /// Unlike the scale property, this checks the new size against scene limits and schedules a full property
+ /// update to viewers.
+ ///
///
public void Resize(Vector3 scale)
{
@@ -2836,33 +2849,18 @@ namespace OpenSim.Region.Framework.Scenes
scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxNonphys);
scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxNonphys);
-// m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale);
-
- StoreUndoState();
- m_shape.Scale = scale;
-
- // If we're a mesh/sculpt, then we need to tell the physics engine about our new size. To do this, we
- // need to reinsert the sculpt data into the shape, since the physics engine deletes it when done to
- // save memory
- if (PhysActor != null)
+ if (PhysActor != null && PhysActor.IsPhysical)
{
- if (PhysActor.IsPhysical)
- {
- scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxPhys);
- scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxPhys);
- scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxPhys);
- }
+ scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxPhys);
+ scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxPhys);
+ scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxPhys);
+ }
- PhysActor.Size = scale;
+// m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale);
- if (((OpenMetaverse.SculptType)Shape.SculptType) == SculptType.Mesh)
- CheckSculptAndLoad();
- else
- ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
- }
+ Scale = scale;
ParentGroup.HasGroupChanged = true;
- TriggerScriptChangedEvent(Changed.SCALE);
ScheduleFullUpdate();
}
@@ -3673,8 +3671,6 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_parentGroup != null)
{
-// m_log.DebugFormat("[SCENE OBJECT PART]: Storing undo state for {0} {1}", Name, LocalId);
-
lock (m_undo)
{
if (m_undo.Count > 0)
@@ -3683,15 +3679,29 @@ namespace OpenSim.Region.Framework.Scenes
if (last != null)
{
if (last.Compare(this))
+ {
+// m_log.DebugFormat(
+// "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
+// Name, LocalId, m_undo.Count);
+
return;
+ }
}
}
+// m_log.DebugFormat(
+// "[SCENE OBJECT PART]: Storing undo state for {0} {1}, initial stack size {2}",
+// Name, LocalId, m_undo.Count);
+
if (m_parentGroup.GetSceneMaxUndo() > 0)
{
UndoState nUndo = new UndoState(this);
m_undo.Push(nUndo);
+
+// m_log.DebugFormat(
+// "[SCENE OBJECT PART]: Stored undo state for {0} {1}, stack size now {2}",
+// Name, LocalId, m_undo.Count);
}
}
}
@@ -3703,7 +3713,8 @@ namespace OpenSim.Region.Framework.Scenes
}
// else
// {
-// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
+// m_log.DebugFormat(
+// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
// }
}
@@ -3721,10 +3732,12 @@ namespace OpenSim.Region.Framework.Scenes
public void Undo()
{
-// m_log.DebugFormat("[SCENE OBJECT PART]: Handling undo request for {0} {1}", Name, LocalId);
-
lock (m_undo)
{
+// m_log.DebugFormat(
+// "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}",
+// Name, LocalId, m_undo.Count);
+
if (m_undo.Count > 0)
{
UndoState nUndo = null;
@@ -3739,19 +3752,26 @@ namespace OpenSim.Region.Framework.Scenes
if (goback != null)
{
goback.PlaybackState(this);
+
if (nUndo != null)
m_redo.Push(nUndo);
}
}
+
+// m_log.DebugFormat(
+// "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}",
+// Name, LocalId, m_undo.Count);
}
}
public void Redo()
{
-// m_log.DebugFormat("[SCENE OBJECT PART]: Handling redo request for {0} {1}", Name, LocalId);
-
lock (m_redo)
{
+// m_log.DebugFormat(
+// "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}",
+// Name, LocalId, m_redo.Count);
+
if (m_parentGroup.GetSceneMaxUndo() > 0)
{
UndoState nUndo = new UndoState(this);
@@ -3763,11 +3783,17 @@ namespace OpenSim.Region.Framework.Scenes
if (gofwd != null)
gofwd.PlayfwdState(this);
+
+// m_log.DebugFormat(
+// "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}",
+// Name, LocalId, m_redo.Count);
}
}
public void ClearUndoState()
{
+// m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId);
+
lock (m_undo)
{
m_undo.Clear();
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
index 6dbac3c..c4047ee 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
public void TestResizeSceneObject()
{
TestHelper.InMethod();
- //log4net.Config.XmlConfigurator.Configure();
+// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene();
SceneObjectGroup g1 = SceneSetupHelpers.AddSceneObject(scene).ParentGroup;
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 55e407e..38bbeb0 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -25,6 +25,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
+using System.Reflection;
+using log4net;
using OpenMetaverse;
using OpenSim.Region.Framework.Interfaces;
@@ -32,49 +35,80 @@ namespace OpenSim.Region.Framework.Scenes
{
public class UndoState
{
+// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
public Vector3 Position = Vector3.Zero;
public Vector3 Scale = Vector3.Zero;
public Quaternion Rotation = Quaternion.Identity;
+ ///
+ /// Constructor.
+ ///
+ ///
public UndoState(SceneObjectPart part)
{
if (part != null)
{
if (part.ParentID == 0)
{
+// m_log.DebugFormat(
+// "[UNDO STATE]: Storing undo position {0} for root part", part.ParentGroup.AbsolutePosition);
Position = part.ParentGroup.AbsolutePosition;
+
+// m_log.DebugFormat(
+// "[UNDO STATE]: Storing undo rotation {0} for root part", part.RotationOffset);
Rotation = part.RotationOffset;
+
+// m_log.DebugFormat(
+// "[UNDO STATE]: Storing undo scale {0} for root part", part.Shape.Scale);
Scale = part.Shape.Scale;
}
else
{
+// m_log.DebugFormat(
+// "[UNDO STATE]: Storing undo position {0} for child part", part.OffsetPosition);
Position = part.OffsetPosition;
+
+// m_log.DebugFormat(
+// "[UNDO STATE]: Storing undo rotation {0} for child part", part.RotationOffset);
Rotation = part.RotationOffset;
+
+// m_log.DebugFormat(
+// "[UNDO STATE]: Storing undo scale {0} for child part", part.Shape.Scale);
Scale = part.Shape.Scale;
}
}
}
+ ///
+ /// Compare the relevant state in the given part to this state.
+ ///
+ ///
+ /// true if both the part's position, rotation and scale match those in this undo state. False otherwise.
public bool Compare(SceneObjectPart part)
{
if (part != null)
{
if (part.ParentID == 0)
{
- if (Position == part.ParentGroup.AbsolutePosition && Rotation == part.ParentGroup.Rotation)
+ if (Position == part.ParentGroup.AbsolutePosition
+ && Rotation == part.RotationOffset
+ && Scale == part.Shape.Scale)
return true;
else
return false;
}
else
{
- if (Position == part.OffsetPosition && Rotation == part.RotationOffset && Scale == part.Shape.Scale)
+ if (Position == part.OffsetPosition
+ && Rotation == part.RotationOffset
+ && Scale == part.Shape.Scale)
return true;
else
return false;
-
}
}
+
return false;
}
@@ -87,24 +121,64 @@ namespace OpenSim.Region.Framework.Scenes
if (part.ParentID == 0)
{
if (Position != Vector3.Zero)
+ {
+// m_log.DebugFormat(
+// "[UNDO STATE]: Undoing position {0} to {1} for root part {2} {3}",
+// part.ParentGroup.AbsolutePosition, Position, part.Name, part.LocalId);
+
part.ParentGroup.AbsolutePosition = Position;
+ }
+
+// m_log.DebugFormat(
+// "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}",
+// part.RotationOffset, Rotation, part.Name, part.LocalId);
+
part.RotationOffset = Rotation;
+
if (Scale != Vector3.Zero)
+ {
+// m_log.DebugFormat(
+// "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}",
+// part.Shape.Scale, Scale, part.Name, part.LocalId);
+
part.Resize(Scale);
+ }
+
part.ParentGroup.ScheduleGroupForTerseUpdate();
}
else
{
if (Position != Vector3.Zero)
+ {
+// m_log.DebugFormat(
+// "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}",
+// part.OffsetPosition, Position, part.Name, part.LocalId);
+
part.OffsetPosition = Position;
+ }
+
+// m_log.DebugFormat(
+// "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}",
+// part.RotationOffset, Rotation, part.Name, part.LocalId);
+
part.UpdateRotation(Rotation);
+
if (Scale != Vector3.Zero)
- part.Resize(Scale); part.ScheduleTerseUpdate();
+ {
+// m_log.DebugFormat(
+// "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}",
+// part.Shape.Scale, Scale, part.Name, part.LocalId);
+
+ part.Resize(Scale);
+ }
+
+ part.ScheduleTerseUpdate();
}
- part.Undoing = false;
+ part.Undoing = false;
}
}
+
public void PlayfwdState(SceneObjectPart part)
{
if (part != null)
@@ -115,27 +189,34 @@ namespace OpenSim.Region.Framework.Scenes
{
if (Position != Vector3.Zero)
part.ParentGroup.AbsolutePosition = Position;
+
if (Rotation != Quaternion.Identity)
part.UpdateRotation(Rotation);
+
if (Scale != Vector3.Zero)
part.Resize(Scale);
+
part.ParentGroup.ScheduleGroupForTerseUpdate();
}
else
{
if (Position != Vector3.Zero)
part.OffsetPosition = Position;
+
if (Rotation != Quaternion.Identity)
part.UpdateRotation(Rotation);
+
if (Scale != Vector3.Zero)
part.Resize(Scale);
+
part.ScheduleTerseUpdate();
}
- part.Undoing = false;
+ part.Undoing = false;
}
}
}
+
public class LandUndoState
{
public ITerrainModule m_terrainModule;
--
cgit v1.1
From 86f45f6fe716541647e628bc6a29df63330813f8 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 01:24:43 +0100
Subject: remove undo state storage in a few places where it's pointless
no functional effect - existing bugs still remain
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 --
.../Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 4 +---
2 files changed, 1 insertion(+), 5 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index aab83b8..44d7ce3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3803,8 +3803,6 @@ namespace OpenSim.Region.Framework.Scenes
{
m_redo.Clear();
}
-
- StoreUndoState();
}
public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot)
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index c18c93a..8fb9fad 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -102,7 +102,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
sceneObject.AddPart(part);
part.LinkNum = linkNum;
part.TrimPermissions();
- part.StoreUndoState();
reader.Close();
sr.Close();
}
@@ -236,15 +235,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
if (originalLinkNum != 0)
part.LinkNum = originalLinkNum;
- part.StoreUndoState();
reader.Close();
sr.Close();
}
// Script state may, or may not, exist. Not having any, is NOT
// ever a problem.
-
sceneObject.LoadScriptState(doc);
+
return sceneObject;
}
catch (Exception e)
--
cgit v1.1
From 430a4aeba8e98b8285ea3ebdf264baf429a55e22 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 03:01:54 +0100
Subject: Fix undo for resizing linksets
This involves implementing a boolean in UndoState to signal whether the undo needs to be done for an entire group/linkset or just a single prim
Resizing individual components of linksets is still dodgy.
Resizing still has to be down twice, since for some reason the client is sending two multiobjectupdate packets on every resize except the very first. This applies to single prims and linksets. Need to look into this.
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 23 +++++++-----
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 42 +++++++++++++---------
OpenSim/Region/Framework/Scenes/UndoState.cs | 24 ++++++++++---
3 files changed, 60 insertions(+), 29 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 7254992..3bbf76c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2624,6 +2624,8 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat(
// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale);
+ RootPart.StoreUndoState(true);
+
scale.X = Math.Min(scale.X, Scene.m_maxNonphys);
scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys);
scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys);
@@ -2722,16 +2724,20 @@ namespace OpenSim.Region.Framework.Scenes
prevScale.X *= x;
prevScale.Y *= y;
prevScale.Z *= z;
+
+// RootPart.IgnoreUndoUpdate = true;
RootPart.Resize(prevScale);
+// RootPart.IgnoreUndoUpdate = false;
parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
{
SceneObjectPart obPart = parts[i];
-// obPart.IgnoreUndoUpdate = true;
if (obPart.UUID != m_rootPart.UUID)
{
+ obPart.IgnoreUndoUpdate = true;
+
Vector3 currentpos = new Vector3(obPart.OffsetPosition);
currentpos.X *= x;
currentpos.Y *= y;
@@ -2741,12 +2747,11 @@ namespace OpenSim.Region.Framework.Scenes
newSize.X *= x;
newSize.Y *= y;
newSize.Z *= z;
-
- obPart.Resize(newSize);
- obPart.IgnoreUndoUpdate = true;
+ obPart.Resize(newSize);
obPart.UpdateOffSet(currentpos);
- obPart.IgnoreUndoUpdate = false;
+
+ obPart.IgnoreUndoUpdate = false;
}
// obPart.IgnoreUndoUpdate = false;
@@ -2769,9 +2774,11 @@ namespace OpenSim.Region.Framework.Scenes
{
// m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos);
- SceneObjectPart[] parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
- parts[i].StoreUndoState();
+ RootPart.StoreUndoState(true);
+
+// SceneObjectPart[] parts = m_parts.GetArray();
+// for (int i = 0; i < parts.Length; i++)
+// parts[i].StoreUndoState();
if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
{
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 44d7ce3..5414cf2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3665,6 +3665,11 @@ namespace OpenSim.Region.Framework.Scenes
public void StoreUndoState()
{
+ StoreUndoState(false);
+ }
+
+ public void StoreUndoState(bool forGroup)
+ {
if (!Undoing)
{
if (!IgnoreUndoUpdate)
@@ -3678,6 +3683,7 @@ namespace OpenSim.Region.Framework.Scenes
UndoState last = m_undo.Peek();
if (last != null)
{
+ // TODO: May need to fix for group comparison
if (last.Compare(this))
{
// m_log.DebugFormat(
@@ -3690,12 +3696,12 @@ namespace OpenSim.Region.Framework.Scenes
}
// m_log.DebugFormat(
-// "[SCENE OBJECT PART]: Storing undo state for {0} {1}, initial stack size {2}",
-// Name, LocalId, m_undo.Count);
+// "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}",
+// Name, LocalId, forGroup, m_undo.Count);
if (m_parentGroup.GetSceneMaxUndo() > 0)
{
- UndoState nUndo = new UndoState(this);
+ UndoState nUndo = new UndoState(this, forGroup);
m_undo.Push(nUndo);
@@ -3740,17 +3746,17 @@ namespace OpenSim.Region.Framework.Scenes
if (m_undo.Count > 0)
{
- UndoState nUndo = null;
-
- if (m_parentGroup.GetSceneMaxUndo() > 0)
- {
- nUndo = new UndoState(this);
- }
-
UndoState goback = m_undo.Pop();
if (goback != null)
{
+ UndoState nUndo = null;
+
+ if (m_parentGroup.GetSceneMaxUndo() > 0)
+ {
+ nUndo = new UndoState(this, goback.ForGroup);
+ }
+
goback.PlaybackState(this);
if (nUndo != null)
@@ -3772,17 +3778,19 @@ namespace OpenSim.Region.Framework.Scenes
// "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}",
// Name, LocalId, m_redo.Count);
- if (m_parentGroup.GetSceneMaxUndo() > 0)
- {
- UndoState nUndo = new UndoState(this);
-
- m_undo.Push(nUndo);
- }
-
UndoState gofwd = m_redo.Pop();
if (gofwd != null)
+ {
+ if (m_parentGroup.GetSceneMaxUndo() > 0)
+ {
+ UndoState nUndo = new UndoState(this, gofwd.ForGroup);
+
+ m_undo.Push(nUndo);
+ }
+
gofwd.PlayfwdState(this);
+ }
// m_log.DebugFormat(
// "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}",
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 38bbeb0..1fa8ee2 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -42,10 +42,16 @@ namespace OpenSim.Region.Framework.Scenes
public Quaternion Rotation = Quaternion.Identity;
///
+ /// Is this undo state for an entire group?
+ ///
+ public bool ForGroup;
+
+ ///
/// Constructor.
///
///
- public UndoState(SceneObjectPart part)
+ /// True if the undo is for an entire group
+ public UndoState(SceneObjectPart part, bool forGroup)
{
if (part != null)
{
@@ -62,6 +68,8 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo scale {0} for root part", part.Shape.Scale);
Scale = part.Shape.Scale;
+
+ ForGroup = forGroup;
}
else
{
@@ -141,7 +149,10 @@ namespace OpenSim.Region.Framework.Scenes
// "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}",
// part.Shape.Scale, Scale, part.Name, part.LocalId);
- part.Resize(Scale);
+ if (ForGroup)
+ part.ParentGroup.GroupResize(Scale);
+ else
+ part.Resize(Scale);
}
part.ParentGroup.ScheduleGroupForTerseUpdate();
@@ -194,7 +205,12 @@ namespace OpenSim.Region.Framework.Scenes
part.UpdateRotation(Rotation);
if (Scale != Vector3.Zero)
- part.Resize(Scale);
+ {
+ if (ForGroup)
+ part.ParentGroup.GroupResize(Scale);
+ else
+ part.Resize(Scale);
+ }
part.ParentGroup.ScheduleGroupForTerseUpdate();
}
@@ -241,4 +257,4 @@ namespace OpenSim.Region.Framework.Scenes
m_terrainModule.UndoTerrain(m_terrainChannel);
}
}
-}
+}
\ No newline at end of file
--
cgit v1.1
From c94dc95844c5a43483a30807353aaebf658b015e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 03:27:16 +0100
Subject: fix undo when resizing of non-root individual prims in a linkset
undo resize, rotation and position still needs fixing when only editing root prim of a linkset
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +-
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 0a0bde8..8e174f5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1291,7 +1291,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))
{
- group.UpdateSingleRotation(rot,pos, localID);
+ group.UpdateSingleRotation(rot, pos, localID);
}
}
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 3bbf76c..3adeef1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2815,15 +2815,17 @@ namespace OpenSim.Region.Framework.Scenes
{
SceneObjectPart part = GetChildPart(localID);
- SceneObjectPart[] parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
- parts[i].StoreUndoState();
+// SceneObjectPart[] parts = m_parts.GetArray();
+// for (int i = 0; i < parts.Length; i++)
+// parts[i].StoreUndoState();
if (part != null)
{
// m_log.DebugFormat(
// "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos);
+ part.StoreUndoState(false);
+
if (part.UUID == m_rootPart.UUID)
{
UpdateRootPosition(pos);
--
cgit v1.1
From 7c468cda360b9a9382986c3a029b799fd49bf898 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 03:38:22 +0100
Subject: Stop undo of just the root prim position in the linkset from shifting
the whole linkset.
However, what happens now is that undo just doesn't do anything when the root prim is selected on its own. This requires more code than just fiddling with undo states.
---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 1 -
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 12 ++++++------
OpenSim/Region/Framework/Scenes/UndoState.cs | 11 +++++++++--
3 files changed, 15 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 8e174f5..26857c2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1296,7 +1296,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
-
///
///
///
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 5414cf2..af836f6 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3705,9 +3705,9 @@ namespace OpenSim.Region.Framework.Scenes
m_undo.Push(nUndo);
-// m_log.DebugFormat(
-// "[SCENE OBJECT PART]: Stored undo state for {0} {1}, stack size now {2}",
-// Name, LocalId, m_undo.Count);
+ m_log.DebugFormat(
+ "[SCENE OBJECT PART]: Stored undo state for {0} {1}, stack size now {2}",
+ Name, LocalId, m_undo.Count);
}
}
}
@@ -3740,9 +3740,9 @@ namespace OpenSim.Region.Framework.Scenes
{
lock (m_undo)
{
-// m_log.DebugFormat(
-// "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}",
-// Name, LocalId, m_undo.Count);
+ m_log.DebugFormat(
+ "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}",
+ Name, LocalId, m_undo.Count);
if (m_undo.Count > 0)
{
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 1fa8ee2..faa1f9e 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -59,7 +59,11 @@ namespace OpenSim.Region.Framework.Scenes
{
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo position {0} for root part", part.ParentGroup.AbsolutePosition);
- Position = part.ParentGroup.AbsolutePosition;
+
+ if (ForGroup)
+ Position = part.ParentGroup.AbsolutePosition;
+ else
+ Position = part.OffsetPosition;
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo rotation {0} for root part", part.RotationOffset);
@@ -134,7 +138,10 @@ namespace OpenSim.Region.Framework.Scenes
// "[UNDO STATE]: Undoing position {0} to {1} for root part {2} {3}",
// part.ParentGroup.AbsolutePosition, Position, part.Name, part.LocalId);
- part.ParentGroup.AbsolutePosition = Position;
+ if (ForGroup)
+ part.ParentGroup.AbsolutePosition = Position;
+ else
+ part.OffsetPosition = Position;
}
// m_log.DebugFormat(
--
cgit v1.1
From 4b9ef4f39c420b99568b853b627ad83d253ac2c9 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 03:44:49 +0100
Subject: Rename UpdatePrimRotation() to UpdatePrimGroupRotation() since this
is what it actually does and is more consistent with other method names.
---
OpenSim/Region/Framework/Scenes/Scene.cs | 12 ++++++++----
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 6 +++---
2 files changed, 11 insertions(+), 7 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 0104a96..2c71c70 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2718,10 +2718,12 @@ namespace OpenSim.Region.Framework.Scenes
{
client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimPosition;
client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
- client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimRotation;
- client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimRotation;
+
+ client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
+ client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
client.OnUpdatePrimSingleRotationPosition += m_sceneGraph.UpdatePrimSingleRotationPosition;
+
client.OnUpdatePrimScale += m_sceneGraph.UpdatePrimScale;
client.OnUpdatePrimGroupScale += m_sceneGraph.UpdatePrimGroupScale;
client.OnUpdateExtraParams += m_sceneGraph.UpdateExtraParam;
@@ -2845,10 +2847,12 @@ namespace OpenSim.Region.Framework.Scenes
{
client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimPosition;
client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
- client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimRotation;
- client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimRotation;
+
+ client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
+ client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
client.OnUpdatePrimSingleRotationPosition -= m_sceneGraph.UpdatePrimSingleRotationPosition;
+
client.OnUpdatePrimScale -= m_sceneGraph.UpdatePrimScale;
client.OnUpdatePrimGroupScale -= m_sceneGraph.UpdatePrimGroupScale;
client.OnUpdateExtraParams -= m_sceneGraph.UpdateExtraParam;
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 26857c2..d5e0bbb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1297,12 +1297,12 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- ///
+ /// Update the rotation of a whole group.
///
///
///
///
- protected internal void UpdatePrimRotation(uint localID, Quaternion rot, IClientAPI remoteClient)
+ protected internal void UpdatePrimGroupRotation(uint localID, Quaternion rot, IClientAPI remoteClient)
{
SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null)
@@ -1321,7 +1321,7 @@ namespace OpenSim.Region.Framework.Scenes
///
///
///
- protected internal void UpdatePrimRotation(uint localID, Vector3 pos, Quaternion rot, IClientAPI remoteClient)
+ protected internal void UpdatePrimGroupRotation(uint localID, Vector3 pos, Quaternion rot, IClientAPI remoteClient)
{
SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null)
--
cgit v1.1
From 97f1edfd95176415d0e0b3169467655522334804 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 04:15:27 +0100
Subject: Fix undo of prim group rotation.
This isn't that great since I think I broke it a few commits earlier.
Undo of rotation of individual prims in a linkset is still broken
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 19 ++++++++----
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 +--
OpenSim/Region/Framework/Scenes/UndoState.cs | 35 ++++++++++++----------
3 files changed, 34 insertions(+), 24 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 3adeef1..aa1f7bc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2895,9 +2895,11 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat(
// "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot);
- SceneObjectPart[] parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
- parts[i].StoreUndoState();
+// SceneObjectPart[] parts = m_parts.GetArray();
+// for (int i = 0; i < parts.Length; i++)
+// parts[i].StoreUndoState();
+
+ m_rootPart.StoreUndoState(true);
m_rootPart.UpdateRotation(rot);
@@ -2922,9 +2924,12 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat(
// "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot);
- SceneObjectPart[] parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
- parts[i].StoreUndoState();
+// SceneObjectPart[] parts = m_parts.GetArray();
+// for (int i = 0; i < parts.Length; i++)
+// parts[i].StoreUndoState();
+
+ RootPart.StoreUndoState(true);
+ RootPart.IgnoreUndoUpdate = true;
m_rootPart.UpdateRotation(rot);
@@ -2939,6 +2944,8 @@ namespace OpenSim.Region.Framework.Scenes
HasGroupChanged = true;
ScheduleGroupForTerseUpdate();
+
+ RootPart.IgnoreUndoUpdate = false;
}
///
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index af836f6..c3aca15 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3706,8 +3706,8 @@ namespace OpenSim.Region.Framework.Scenes
m_undo.Push(nUndo);
m_log.DebugFormat(
- "[SCENE OBJECT PART]: Stored undo state for {0} {1}, stack size now {2}",
- Name, LocalId, m_undo.Count);
+ "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
+ Name, LocalId, forGroup, m_undo.Count);
}
}
}
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index faa1f9e..6f6504c 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -35,7 +35,7 @@ namespace OpenSim.Region.Framework.Scenes
{
public class UndoState
{
-// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public Vector3 Position = Vector3.Zero;
public Vector3 Scale = Vector3.Zero;
@@ -57,23 +57,25 @@ namespace OpenSim.Region.Framework.Scenes
{
if (part.ParentID == 0)
{
-// m_log.DebugFormat(
-// "[UNDO STATE]: Storing undo position {0} for root part", part.ParentGroup.AbsolutePosition);
+ ForGroup = forGroup;
if (ForGroup)
Position = part.ParentGroup.AbsolutePosition;
else
Position = part.OffsetPosition;
-// m_log.DebugFormat(
-// "[UNDO STATE]: Storing undo rotation {0} for root part", part.RotationOffset);
+ m_log.DebugFormat(
+ "[UNDO STATE]: Storing undo position {0} for root part", Position);
+
Rotation = part.RotationOffset;
-// m_log.DebugFormat(
-// "[UNDO STATE]: Storing undo scale {0} for root part", part.Shape.Scale);
+ m_log.DebugFormat(
+ "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation);
+
Scale = part.Shape.Scale;
- ForGroup = forGroup;
+ m_log.DebugFormat(
+ "[UNDO STATE]: Storing undo scale {0} for root part", Scale);
}
else
{
@@ -132,23 +134,24 @@ namespace OpenSim.Region.Framework.Scenes
if (part.ParentID == 0)
{
+ m_log.DebugFormat(
+ "[UNDO STATE]: Undoing position to {0} for root part {1} {2}",
+ Position, part.Name, part.LocalId);
+
if (Position != Vector3.Zero)
{
-// m_log.DebugFormat(
-// "[UNDO STATE]: Undoing position {0} to {1} for root part {2} {3}",
-// part.ParentGroup.AbsolutePosition, Position, part.Name, part.LocalId);
-
if (ForGroup)
part.ParentGroup.AbsolutePosition = Position;
else
part.OffsetPosition = Position;
}
-// m_log.DebugFormat(
-// "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}",
-// part.RotationOffset, Rotation, part.Name, part.LocalId);
+ m_log.DebugFormat(
+ "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}",
+ part.RotationOffset, Rotation, part.Name, part.LocalId);
- part.RotationOffset = Rotation;
+ part.UpdateRotation(Rotation);
+ //part.RotationOffset = Rotation;
if (Scale != Vector3.Zero)
{
--
cgit v1.1
From b2722e984ab99deb01d55cd4c4e9f1a7cb563709 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 04:40:02 +0100
Subject: Fix undo of rotation of single prims in a linkset
---
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 +++++---
OpenSim/Region/Framework/Scenes/UndoState.cs | 12 ++++++------
2 files changed, 11 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index aa1f7bc..9076d73 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2991,6 +2991,9 @@ namespace OpenSim.Region.Framework.Scenes
// "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}",
// part.Name, part.LocalId, rot);
+ part.StoreUndoState();
+ part.IgnoreUndoUpdate = true;
+
if (part.UUID == m_rootPart.UUID)
{
UpdateRootRotation(rot);
@@ -2998,12 +3001,11 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
- part.IgnoreUndoUpdate = true;
part.UpdateRotation(rot);
part.OffsetPosition = pos;
- part.IgnoreUndoUpdate = false;
- part.StoreUndoState();
}
+
+ part.IgnoreUndoUpdate = false;
}
}
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 6f6504c..68d4cb4 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -79,17 +79,17 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
-// m_log.DebugFormat(
-// "[UNDO STATE]: Storing undo position {0} for child part", part.OffsetPosition);
Position = part.OffsetPosition;
+ m_log.DebugFormat(
+ "[UNDO STATE]: Storing undo position {0} for child part", Position);
-// m_log.DebugFormat(
-// "[UNDO STATE]: Storing undo rotation {0} for child part", part.RotationOffset);
Rotation = part.RotationOffset;
+ m_log.DebugFormat(
+ "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation);
-// m_log.DebugFormat(
-// "[UNDO STATE]: Storing undo scale {0} for child part", part.Shape.Scale);
Scale = part.Shape.Scale;
+ m_log.DebugFormat(
+ "[UNDO STATE]: Storing undo scale {0} for child part", Scale);
}
}
}
--
cgit v1.1
From 1fdb16f1cdf6e2722a763cdc0e9b7af9fed27a29 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 05:05:50 +0100
Subject: Fix undo for rotation of the root prim in a linkset on its own.
The only obviously broken things right now are the undo of the position of just a root prim (stays in place) and the fact that resizes need two undoes.
---
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 17 +++++++++++------
OpenSim/Region/Framework/Scenes/UndoState.cs | 6 ++++--
2 files changed, 15 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 9076d73..d653e66 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -3013,11 +3013,11 @@ namespace OpenSim.Region.Framework.Scenes
///
///
///
- private void UpdateRootRotation(Quaternion rot)
+ public void UpdateRootRotation(Quaternion rot)
{
-// m_log.DebugFormat(
-// "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}",
-// Name, LocalId, rot);
+ m_log.DebugFormat(
+ "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}",
+ Name, LocalId, rot);
Quaternion axRot = rot;
Quaternion oldParentRot = m_rootPart.RotationOffset;
@@ -3046,6 +3046,7 @@ namespace OpenSim.Region.Framework.Scenes
newRot *= Quaternion.Inverse(axRot);
prim.RotationOffset = newRot;
prim.ScheduleTerseUpdate();
+ prim.IgnoreUndoUpdate = false;
}
}
@@ -3054,12 +3055,16 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart childpart = parts[i];
if (childpart != m_rootPart)
{
- childpart.IgnoreUndoUpdate = false;
- childpart.StoreUndoState();
+// childpart.IgnoreUndoUpdate = false;
+// childpart.StoreUndoState();
}
}
m_rootPart.ScheduleTerseUpdate();
+
+ m_log.DebugFormat(
+ "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}",
+ Name, LocalId, rot);
}
#endregion
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 68d4cb4..dc509d9 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -150,8 +150,10 @@ namespace OpenSim.Region.Framework.Scenes
"[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}",
part.RotationOffset, Rotation, part.Name, part.LocalId);
- part.UpdateRotation(Rotation);
- //part.RotationOffset = Rotation;
+ if (ForGroup)
+ part.UpdateRotation(Rotation);
+ else
+ part.ParentGroup.UpdateRootRotation(Rotation);
if (Scale != Vector3.Zero)
{
--
cgit v1.1
From 62325829ecab7d956416ff0450faa3f90f267e6c Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 05:14:58 +0100
Subject: comment out all kinds of debugging guff
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 30 +++++++++---------
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 12 ++++----
OpenSim/Region/Framework/Scenes/UndoState.cs | 36 +++++++++++-----------
3 files changed, 39 insertions(+), 39 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index d653e66..0eaed91 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -3015,9 +3015,9 @@ namespace OpenSim.Region.Framework.Scenes
///
public void UpdateRootRotation(Quaternion rot)
{
- m_log.DebugFormat(
- "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}",
- Name, LocalId, rot);
+// m_log.DebugFormat(
+// "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}",
+// Name, LocalId, rot);
Quaternion axRot = rot;
Quaternion oldParentRot = m_rootPart.RotationOffset;
@@ -3050,21 +3050,21 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- for (int i = 0; i < parts.Length; i++)
- {
- SceneObjectPart childpart = parts[i];
- if (childpart != m_rootPart)
- {
-// childpart.IgnoreUndoUpdate = false;
-// childpart.StoreUndoState();
- }
- }
+// for (int i = 0; i < parts.Length; i++)
+// {
+// SceneObjectPart childpart = parts[i];
+// if (childpart != m_rootPart)
+// {
+//// childpart.IgnoreUndoUpdate = false;
+//// childpart.StoreUndoState();
+// }
+// }
m_rootPart.ScheduleTerseUpdate();
- m_log.DebugFormat(
- "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}",
- Name, LocalId, rot);
+// m_log.DebugFormat(
+// "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}",
+// Name, LocalId, rot);
}
#endregion
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index c3aca15..0357cf9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3705,9 +3705,9 @@ namespace OpenSim.Region.Framework.Scenes
m_undo.Push(nUndo);
- m_log.DebugFormat(
- "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
- Name, LocalId, forGroup, m_undo.Count);
+// m_log.DebugFormat(
+// "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
+// Name, LocalId, forGroup, m_undo.Count);
}
}
}
@@ -3740,9 +3740,9 @@ namespace OpenSim.Region.Framework.Scenes
{
lock (m_undo)
{
- m_log.DebugFormat(
- "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}",
- Name, LocalId, m_undo.Count);
+// m_log.DebugFormat(
+// "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}",
+// Name, LocalId, m_undo.Count);
if (m_undo.Count > 0)
{
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index dc509d9..b013d68 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -64,32 +64,32 @@ namespace OpenSim.Region.Framework.Scenes
else
Position = part.OffsetPosition;
- m_log.DebugFormat(
- "[UNDO STATE]: Storing undo position {0} for root part", Position);
+// m_log.DebugFormat(
+// "[UNDO STATE]: Storing undo position {0} for root part", Position);
Rotation = part.RotationOffset;
- m_log.DebugFormat(
- "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation);
+// m_log.DebugFormat(
+// "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation);
Scale = part.Shape.Scale;
- m_log.DebugFormat(
- "[UNDO STATE]: Storing undo scale {0} for root part", Scale);
+// m_log.DebugFormat(
+// "[UNDO STATE]: Storing undo scale {0} for root part", Scale);
}
else
{
Position = part.OffsetPosition;
- m_log.DebugFormat(
- "[UNDO STATE]: Storing undo position {0} for child part", Position);
+// m_log.DebugFormat(
+// "[UNDO STATE]: Storing undo position {0} for child part", Position);
Rotation = part.RotationOffset;
- m_log.DebugFormat(
- "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation);
+// m_log.DebugFormat(
+// "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation);
Scale = part.Shape.Scale;
- m_log.DebugFormat(
- "[UNDO STATE]: Storing undo scale {0} for child part", Scale);
+// m_log.DebugFormat(
+// "[UNDO STATE]: Storing undo scale {0} for child part", Scale);
}
}
}
@@ -134,9 +134,9 @@ namespace OpenSim.Region.Framework.Scenes
if (part.ParentID == 0)
{
- m_log.DebugFormat(
- "[UNDO STATE]: Undoing position to {0} for root part {1} {2}",
- Position, part.Name, part.LocalId);
+// m_log.DebugFormat(
+// "[UNDO STATE]: Undoing position to {0} for root part {1} {2}",
+// Position, part.Name, part.LocalId);
if (Position != Vector3.Zero)
{
@@ -146,9 +146,9 @@ namespace OpenSim.Region.Framework.Scenes
part.OffsetPosition = Position;
}
- m_log.DebugFormat(
- "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}",
- part.RotationOffset, Rotation, part.Name, part.LocalId);
+// m_log.DebugFormat(
+// "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}",
+// part.RotationOffset, Rotation, part.Name, part.LocalId);
if (ForGroup)
part.UpdateRotation(Rotation);
--
cgit v1.1
From 0ef29da9b2844e567928fe6fe5e13da3ee1a37ad Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 05:20:04 +0100
Subject: refactor: rename UpdatePrimPosition() to UpdatePrimGroupPosition()
for consistency
---
OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++--
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 4 ++--
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 2c71c70..6e66632 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2716,7 +2716,7 @@ namespace OpenSim.Region.Framework.Scenes
public virtual void SubscribeToClientPrimEvents(IClientAPI client)
{
- client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimPosition;
+ client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
@@ -2845,7 +2845,7 @@ namespace OpenSim.Region.Framework.Scenes
public virtual void UnSubscribeToClientPrimEvents(IClientAPI client)
{
- client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimPosition;
+ client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index d5e0bbb..65dc2c9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1352,12 +1352,12 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// Update the position of the given part
+ /// Update the position of the given group.
///
///
///
///
- public void UpdatePrimPosition(uint localID, Vector3 pos, IClientAPI remoteClient)
+ public void UpdatePrimGroupPosition(uint localID, Vector3 pos, IClientAPI remoteClient)
{
SceneObjectGroup group = GetGroupByPrim(localID);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 0eaed91..26b35a3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2840,10 +2840,10 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- ///
+ /// Update just the root prim position in a linkset
///
///
- private void UpdateRootPosition(Vector3 pos)
+ public void UpdateRootPosition(Vector3 pos)
{
// m_log.DebugFormat(
// "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos);
--
cgit v1.1
From bc3679b67dc074a9ef1e0e6ffb07bca844eb93c9 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 05:46:17 +0100
Subject: Fix undo when changing just the root prim's position in a linkset.
I think (ha ha) this largely fixes undo, except for the fact that rotation a set of prims with 'edit linked parts' selected doesn't quite work properly (though this works fine if the checkbox isn't selected).
Also, the double undo bug for resize is still present.
Redo might be incredibly buggy, haven't even looked at that yet.
---
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 10 ++++++----
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +-
OpenSim/Region/Framework/Scenes/UndoState.cs | 8 ++++----
3 files changed, 11 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 26b35a3..b6fb5a4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2825,6 +2825,7 @@ namespace OpenSim.Region.Framework.Scenes
// "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos);
part.StoreUndoState(false);
+ part.IgnoreUndoUpdate = true;
if (part.UUID == m_rootPart.UUID)
{
@@ -2836,6 +2837,7 @@ namespace OpenSim.Region.Framework.Scenes
}
HasGroupChanged = true;
+ part.IgnoreUndoUpdate = false;
}
}
@@ -2848,9 +2850,9 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat(
// "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos);
- SceneObjectPart[] parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
- parts[i].StoreUndoState();
+// SceneObjectPart[] parts = m_parts.GetArray();
+// for (int i = 0; i < parts.Length; i++)
+// parts[i].StoreUndoState();
Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z);
Vector3 oldPos =
@@ -2863,7 +2865,7 @@ namespace OpenSim.Region.Framework.Scenes
axDiff *= Quaternion.Inverse(partRotation);
diff = axDiff;
- parts = m_parts.GetArray();
+ SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
{
SceneObjectPart obPart = parts[i];
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 0357cf9..9d7f87a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -788,7 +788,7 @@ namespace OpenSim.Region.Framework.Scenes
get { return m_offsetPosition; }
set
{
- StoreUndoState();
+// StoreUndoState();
m_offsetPosition = value;
if (ParentGroup != null && !ParentGroup.IsDeleted)
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index b013d68..6bf89c5 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -59,10 +59,10 @@ namespace OpenSim.Region.Framework.Scenes
{
ForGroup = forGroup;
- if (ForGroup)
+// if (ForGroup)
Position = part.ParentGroup.AbsolutePosition;
- else
- Position = part.OffsetPosition;
+// else
+// Position = part.OffsetPosition;
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo position {0} for root part", Position);
@@ -143,7 +143,7 @@ namespace OpenSim.Region.Framework.Scenes
if (ForGroup)
part.ParentGroup.AbsolutePosition = Position;
else
- part.OffsetPosition = Position;
+ part.ParentGroup.UpdateRootPosition(Position);
}
// m_log.DebugFormat(
--
cgit v1.1
From 9dd5a2449575d671075c673e5e39ef3e1a108a76 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 05:51:19 +0100
Subject: rip out pointless null checks in UndoState where part can never be
null
---
OpenSim/Region/Framework/Scenes/UndoState.cs | 153 +++++++++++++--------------
1 file changed, 72 insertions(+), 81 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 6bf89c5..f7bed5a 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -53,44 +53,41 @@ namespace OpenSim.Region.Framework.Scenes
/// True if the undo is for an entire group
public UndoState(SceneObjectPart part, bool forGroup)
{
- if (part != null)
+ if (part.ParentID == 0)
{
- if (part.ParentID == 0)
- {
- ForGroup = forGroup;
+ ForGroup = forGroup;
// if (ForGroup)
- Position = part.ParentGroup.AbsolutePosition;
+ Position = part.ParentGroup.AbsolutePosition;
// else
// Position = part.OffsetPosition;
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo position {0} for root part", Position);
- Rotation = part.RotationOffset;
+ Rotation = part.RotationOffset;
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation);
- Scale = part.Shape.Scale;
+ Scale = part.Shape.Scale;
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo scale {0} for root part", Scale);
- }
- else
- {
- Position = part.OffsetPosition;
+ }
+ else
+ {
+ Position = part.OffsetPosition;
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo position {0} for child part", Position);
- Rotation = part.RotationOffset;
+ Rotation = part.RotationOffset;
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation);
- Scale = part.Shape.Scale;
+ Scale = part.Shape.Scale;
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo scale {0} for child part", Scale);
- }
}
}
@@ -128,120 +125,114 @@ namespace OpenSim.Region.Framework.Scenes
public void PlaybackState(SceneObjectPart part)
{
- if (part != null)
- {
- part.Undoing = true;
+ part.Undoing = true;
- if (part.ParentID == 0)
- {
+ if (part.ParentID == 0)
+ {
// m_log.DebugFormat(
// "[UNDO STATE]: Undoing position to {0} for root part {1} {2}",
// Position, part.Name, part.LocalId);
- if (Position != Vector3.Zero)
- {
- if (ForGroup)
- part.ParentGroup.AbsolutePosition = Position;
- else
- part.ParentGroup.UpdateRootPosition(Position);
- }
+ if (Position != Vector3.Zero)
+ {
+ if (ForGroup)
+ part.ParentGroup.AbsolutePosition = Position;
+ else
+ part.ParentGroup.UpdateRootPosition(Position);
+ }
// m_log.DebugFormat(
// "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}",
// part.RotationOffset, Rotation, part.Name, part.LocalId);
- if (ForGroup)
- part.UpdateRotation(Rotation);
- else
- part.ParentGroup.UpdateRootRotation(Rotation);
+ if (ForGroup)
+ part.UpdateRotation(Rotation);
+ else
+ part.ParentGroup.UpdateRootRotation(Rotation);
- if (Scale != Vector3.Zero)
- {
+ if (Scale != Vector3.Zero)
+ {
// m_log.DebugFormat(
// "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}",
// part.Shape.Scale, Scale, part.Name, part.LocalId);
- if (ForGroup)
- part.ParentGroup.GroupResize(Scale);
- else
- part.Resize(Scale);
- }
-
- part.ParentGroup.ScheduleGroupForTerseUpdate();
+ if (ForGroup)
+ part.ParentGroup.GroupResize(Scale);
+ else
+ part.Resize(Scale);
}
- else
+
+ part.ParentGroup.ScheduleGroupForTerseUpdate();
+ }
+ else
+ {
+ if (Position != Vector3.Zero)
{
- if (Position != Vector3.Zero)
- {
// m_log.DebugFormat(
// "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}",
// part.OffsetPosition, Position, part.Name, part.LocalId);
- part.OffsetPosition = Position;
- }
+ part.OffsetPosition = Position;
+ }
// m_log.DebugFormat(
// "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}",
// part.RotationOffset, Rotation, part.Name, part.LocalId);
- part.UpdateRotation(Rotation);
+ part.UpdateRotation(Rotation);
- if (Scale != Vector3.Zero)
- {
+ if (Scale != Vector3.Zero)
+ {
// m_log.DebugFormat(
// "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}",
// part.Shape.Scale, Scale, part.Name, part.LocalId);
- part.Resize(Scale);
- }
-
- part.ScheduleTerseUpdate();
+ part.Resize(Scale);
}
- part.Undoing = false;
+ part.ScheduleTerseUpdate();
}
+
+ part.Undoing = false;
}
public void PlayfwdState(SceneObjectPart part)
{
- if (part != null)
- {
- part.Undoing = true;
-
- if (part.ParentID == 0)
- {
- if (Position != Vector3.Zero)
- part.ParentGroup.AbsolutePosition = Position;
+ part.Undoing = true;
- if (Rotation != Quaternion.Identity)
- part.UpdateRotation(Rotation);
+ if (part.ParentID == 0)
+ {
+ if (Position != Vector3.Zero)
+ part.ParentGroup.AbsolutePosition = Position;
- if (Scale != Vector3.Zero)
- {
- if (ForGroup)
- part.ParentGroup.GroupResize(Scale);
- else
- part.Resize(Scale);
- }
+ if (Rotation != Quaternion.Identity)
+ part.UpdateRotation(Rotation);
- part.ParentGroup.ScheduleGroupForTerseUpdate();
- }
- else
+ if (Scale != Vector3.Zero)
{
- if (Position != Vector3.Zero)
- part.OffsetPosition = Position;
+ if (ForGroup)
+ part.ParentGroup.GroupResize(Scale);
+ else
+ part.Resize(Scale);
+ }
- if (Rotation != Quaternion.Identity)
- part.UpdateRotation(Rotation);
+ part.ParentGroup.ScheduleGroupForTerseUpdate();
+ }
+ else
+ {
+ if (Position != Vector3.Zero)
+ part.OffsetPosition = Position;
- if (Scale != Vector3.Zero)
- part.Resize(Scale);
+ if (Rotation != Quaternion.Identity)
+ part.UpdateRotation(Rotation);
- part.ScheduleTerseUpdate();
- }
+ if (Scale != Vector3.Zero)
+ part.Resize(Scale);
- part.Undoing = false;
+ part.ScheduleTerseUpdate();
}
+
+ part.Undoing = false;
}
}
--
cgit v1.1
From 25c532f2ec0c747eb9c9b6f8fff477a4fb375894 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 05:58:52 +0100
Subject: refator: simplify UndoState.Compare() code
---
OpenSim/Region/Framework/Scenes/UndoState.cs | 29 +++++++++-------------------
1 file changed, 9 insertions(+), 20 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index f7bed5a..393f42d 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -101,23 +101,15 @@ namespace OpenSim.Region.Framework.Scenes
if (part != null)
{
if (part.ParentID == 0)
- {
- if (Position == part.ParentGroup.AbsolutePosition
- && Rotation == part.RotationOffset
- && Scale == part.Shape.Scale)
- return true;
- else
- return false;
- }
+ return
+ Position == part.ParentGroup.AbsolutePosition
+ && Rotation == part.RotationOffset
+ && Scale == part.Shape.Scale;
else
- {
- if (Position == part.OffsetPosition
- && Rotation == part.RotationOffset
- && Scale == part.Shape.Scale)
- return true;
- else
- return false;
- }
+ return
+ Position == part.OffsetPosition
+ && Rotation == part.RotationOffset
+ && Scale == part.Shape.Scale;
}
return false;
@@ -249,10 +241,7 @@ namespace OpenSim.Region.Framework.Scenes
public bool Compare(ITerrainChannel terrainChannel)
{
- if (m_terrainChannel != terrainChannel)
- return false;
- else
- return false;
+ return m_terrainChannel == terrainChannel;
}
public void PlaybackState()
--
cgit v1.1
From ec1ecd363317fd83fd30f45d9c033873f4c35bc2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 06:05:23 +0100
Subject: stop redo throwing an exception if there is nothing to redo
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 23 ++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 9d7f87a..ccf8a25 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3778,23 +3778,26 @@ namespace OpenSim.Region.Framework.Scenes
// "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}",
// Name, LocalId, m_redo.Count);
- UndoState gofwd = m_redo.Pop();
-
- if (gofwd != null)
+ if (m_redo.Count > 0)
{
- if (m_parentGroup.GetSceneMaxUndo() > 0)
+ UndoState gofwd = m_redo.Pop();
+
+ if (gofwd != null)
{
- UndoState nUndo = new UndoState(this, gofwd.ForGroup);
-
- m_undo.Push(nUndo);
+ if (m_parentGroup.GetSceneMaxUndo() > 0)
+ {
+ UndoState nUndo = new UndoState(this, gofwd.ForGroup);
+
+ m_undo.Push(nUndo);
+ }
+
+ gofwd.PlayfwdState(this);
}
- gofwd.PlayfwdState(this);
- }
-
// m_log.DebugFormat(
// "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}",
// Name, LocalId, m_redo.Count);
+ }
}
}
--
cgit v1.1
From c50533659a9c7627cd6b24820078192b18c662f0 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 06:11:16 +0100
Subject: If we store an undo, wipe anything already present on the redo stack
This stops problems when we undo a few steps and start off down another path.
Surprisingly, apart from this now fixed problem, redo appears to be working too.
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 +++
1 file changed, 3 insertions(+)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index ccf8a25..e8097fa 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3705,6 +3705,9 @@ namespace OpenSim.Region.Framework.Scenes
m_undo.Push(nUndo);
+ if (m_redo.Count > 0)
+ m_redo.Clear();
+
// m_log.DebugFormat(
// "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
// Name, LocalId, forGroup, m_undo.Count);
--
cgit v1.1
From ee829a71c2e42d4434d8cec2cfc1d048d50904f0 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 19 Jul 2011 06:13:05 +0100
Subject: On all undo/redo operations, consistently lock the undo object for
everything, in order to avoid any deadlock issues.
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index e8097fa..f74f263 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3775,7 +3775,7 @@ namespace OpenSim.Region.Framework.Scenes
public void Redo()
{
- lock (m_redo)
+ lock (m_undo)
{
// m_log.DebugFormat(
// "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}",
@@ -3811,10 +3811,6 @@ namespace OpenSim.Region.Framework.Scenes
lock (m_undo)
{
m_undo.Clear();
- }
-
- lock (m_redo)
- {
m_redo.Clear();
}
}
--
cgit v1.1
From 51c47677a15bd41eeab2f36ac71384984712362b Mon Sep 17 00:00:00 2001
From: Careminster Team
Date: Tue, 19 Jul 2011 10:15:34 -0700
Subject: Tidy up a superfluous AddPrimShape override in PhysicsScene
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1 -
1 file changed, 1 deletion(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index f74f263..4629757 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -4533,7 +4533,6 @@ namespace OpenSim.Region.Framework.Scenes
{
// It's not phantom anymore. So make sure the physics engine get's knowledge of it
PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
- LocalId,
string.Format("{0}/{1}", Name, UUID),
Shape,
AbsolutePosition,
--
cgit v1.1