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(-) 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