From 36e3123069fb7524d3872d095c0f54c155c55a28 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 26 Sep 2012 23:17:21 +0100 Subject: Make it possible to rescale SOGs when they are not in a scene. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 54 +++++++++++----------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 20 ++++---- 2 files changed, 40 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ac26be7..85a37e9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2703,29 +2703,32 @@ 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.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); - scale.Y = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Y)); - scale.Z = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Z)); - PhysicsActor pa = m_rootPart.PhysActor; - if (pa != null && pa.IsPhysical) + RootPart.StoreUndoState(true); + + if (Scene != null) { - scale.X = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.X)); - scale.Y = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Y)); - scale.Z = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Z)); + scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); + scale.Y = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Y)); + scale.Z = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Z)); + + if (pa != null && pa.IsPhysical) + { + scale.X = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.X)); + scale.Y = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Y)); + scale.Z = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, 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 = m_parts.GetArray(); + + if (Scene != null & (x > 1.0f || y > 1.0f || z > 1.0f)) { - parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) { SceneObjectPart obPart = parts[i]; @@ -2739,7 +2742,7 @@ namespace OpenSim.Region.Framework.Scenes if (pa != null && pa.IsPhysical) { - if (oldSize.X * x > m_scene.m_maxPhys) + if (oldSize.X * x > Scene.m_maxPhys) { f = m_scene.m_maxPhys / oldSize.X; a = f / x; @@ -2747,7 +2750,7 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } - else if (oldSize.X * x < m_scene.m_minPhys) + else if (oldSize.X * x < Scene.m_minPhys) { f = m_scene.m_minPhys / oldSize.X; a = f / x; @@ -2756,7 +2759,7 @@ namespace OpenSim.Region.Framework.Scenes z *= a; } - if (oldSize.Y * y > m_scene.m_maxPhys) + if (oldSize.Y * y > Scene.m_maxPhys) { f = m_scene.m_maxPhys / oldSize.Y; a = f / y; @@ -2764,7 +2767,7 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } - else if (oldSize.Y * y < m_scene.m_minPhys) + else if (oldSize.Y * y < Scene.m_minPhys) { f = m_scene.m_minPhys / oldSize.Y; a = f / y; @@ -2773,7 +2776,7 @@ namespace OpenSim.Region.Framework.Scenes z *= a; } - if (oldSize.Z * z > m_scene.m_maxPhys) + if (oldSize.Z * z > Scene.m_maxPhys) { f = m_scene.m_maxPhys / oldSize.Z; a = f / z; @@ -2781,7 +2784,7 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } - else if (oldSize.Z * z < m_scene.m_minPhys) + else if (oldSize.Z * z < Scene.m_minPhys) { f = m_scene.m_minPhys / oldSize.Z; a = f / z; @@ -2792,7 +2795,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - if (oldSize.X * x > m_scene.m_maxNonphys) + if (oldSize.X * x > Scene.m_maxNonphys) { f = m_scene.m_maxNonphys / oldSize.X; a = f / x; @@ -2800,7 +2803,7 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } - else if (oldSize.X * x < m_scene.m_minNonphys) + else if (oldSize.X * x < Scene.m_minNonphys) { f = m_scene.m_minNonphys / oldSize.X; a = f / x; @@ -2809,7 +2812,7 @@ namespace OpenSim.Region.Framework.Scenes z *= a; } - if (oldSize.Y * y > m_scene.m_maxNonphys) + if (oldSize.Y * y > Scene.m_maxNonphys) { f = m_scene.m_maxNonphys / oldSize.Y; a = f / y; @@ -2817,7 +2820,7 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } - else if (oldSize.Y * y < m_scene.m_minNonphys) + else if (oldSize.Y * y < Scene.m_minNonphys) { f = m_scene.m_minNonphys / oldSize.Y; a = f / y; @@ -2826,7 +2829,7 @@ namespace OpenSim.Region.Framework.Scenes z *= a; } - if (oldSize.Z * z > m_scene.m_maxNonphys) + if (oldSize.Z * z > Scene.m_maxNonphys) { f = m_scene.m_maxNonphys / oldSize.Z; a = f / z; @@ -2834,7 +2837,7 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } - else if (oldSize.Z * z < m_scene.m_minNonphys) + else if (oldSize.Z * z < Scene.m_minNonphys) { f = m_scene.m_minNonphys / oldSize.Z; a = f / z; @@ -2858,7 +2861,6 @@ namespace OpenSim.Region.Framework.Scenes RootPart.Resize(prevScale); // RootPart.IgnoreUndoUpdate = false; - 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 9e78242..018e4fc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2368,16 +2368,20 @@ namespace OpenSim.Region.Framework.Scenes /// public void Resize(Vector3 scale) { - scale.X = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.X)); - scale.Y = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Y)); - scale.Z = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Z)); - PhysicsActor pa = PhysActor; - if (pa != null && pa.IsPhysical) + + if (ParentGroup.Scene != null) { - scale.X = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.X)); - scale.Y = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Y)); - scale.Z = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Z)); + scale.X = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.X)); + scale.Y = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Y)); + scale.Z = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Z)); + + if (pa != null && pa.IsPhysical) + { + scale.X = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.X)); + scale.Y = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Y)); + scale.Z = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Z)); + } } // m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale); -- cgit v1.1