diff options
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 261 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs | 2 |
3 files changed, 133 insertions, 132 deletions
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 | |||
1234 | { | 1234 | { |
1235 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) | 1235 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) |
1236 | { | 1236 | { |
1237 | group.GroupResize(scale, localID); | 1237 | group.GroupResize(scale); |
1238 | } | 1238 | } |
1239 | } | 1239 | } |
1240 | } | 1240 | } |
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 | |||
2658 | } | 2658 | } |
2659 | } | 2659 | } |
2660 | 2660 | ||
2661 | public void GroupResize(Vector3 scale, uint localID) | 2661 | /// <summary> |
2662 | /// Resize the entire group of prims. | ||
2663 | /// </summary> | ||
2664 | /// <param name="scale"></param> | ||
2665 | public void GroupResize(Vector3 scale) | ||
2662 | { | 2666 | { |
2663 | SceneObjectPart part = GetChildPart(localID); | ||
2664 | if (part != null) | ||
2665 | { | ||
2666 | // m_log.DebugFormat( | 2667 | // m_log.DebugFormat( |
2667 | // "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, localID, part.Scale, scale); | 2668 | // "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, localID, RootPart.Scale, scale); |
2669 | |||
2670 | RootPart.IgnoreUndoUpdate = true; | ||
2668 | 2671 | ||
2669 | part.IgnoreUndoUpdate = true; | 2672 | if (scale.X > m_scene.m_maxNonphys) |
2673 | scale.X = m_scene.m_maxNonphys; | ||
2674 | if (scale.Y > m_scene.m_maxNonphys) | ||
2675 | scale.Y = m_scene.m_maxNonphys; | ||
2676 | if (scale.Z > m_scene.m_maxNonphys) | ||
2677 | scale.Z = m_scene.m_maxNonphys; | ||
2670 | 2678 | ||
2671 | if (scale.X > m_scene.m_maxNonphys) | 2679 | if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical) |
2672 | scale.X = m_scene.m_maxNonphys; | 2680 | { |
2673 | if (scale.Y > m_scene.m_maxNonphys) | 2681 | if (scale.X > m_scene.m_maxPhys) |
2674 | scale.Y = m_scene.m_maxNonphys; | 2682 | scale.X = m_scene.m_maxPhys; |
2675 | if (scale.Z > m_scene.m_maxNonphys) | 2683 | if (scale.Y > m_scene.m_maxPhys) |
2676 | scale.Z = m_scene.m_maxNonphys; | 2684 | scale.Y = m_scene.m_maxPhys; |
2685 | if (scale.Z > m_scene.m_maxPhys) | ||
2686 | scale.Z = m_scene.m_maxPhys; | ||
2687 | } | ||
2677 | 2688 | ||
2678 | if (part.PhysActor != null && part.PhysActor.IsPhysical) | 2689 | float x = (scale.X / RootPart.Scale.X); |
2679 | { | 2690 | float y = (scale.Y / RootPart.Scale.Y); |
2680 | if (scale.X > m_scene.m_maxPhys) | 2691 | float z = (scale.Z / RootPart.Scale.Z); |
2681 | scale.X = m_scene.m_maxPhys; | ||
2682 | if (scale.Y > m_scene.m_maxPhys) | ||
2683 | scale.Y = m_scene.m_maxPhys; | ||
2684 | if (scale.Z > m_scene.m_maxPhys) | ||
2685 | scale.Z = m_scene.m_maxPhys; | ||
2686 | } | ||
2687 | float x = (scale.X / part.Scale.X); | ||
2688 | float y = (scale.Y / part.Scale.Y); | ||
2689 | float z = (scale.Z / part.Scale.Z); | ||
2690 | 2692 | ||
2691 | SceneObjectPart[] parts; | 2693 | SceneObjectPart[] parts; |
2692 | if (x > 1.0f || y > 1.0f || z > 1.0f) | 2694 | if (x > 1.0f || y > 1.0f || z > 1.0f) |
2695 | { | ||
2696 | parts = m_parts.GetArray(); | ||
2697 | for (int i = 0; i < parts.Length; i++) | ||
2693 | { | 2698 | { |
2694 | parts = m_parts.GetArray(); | 2699 | SceneObjectPart obPart = parts[i]; |
2695 | for (int i = 0; i < parts.Length; i++) | 2700 | if (obPart.UUID != m_rootPart.UUID) |
2696 | { | 2701 | { |
2697 | SceneObjectPart obPart = parts[i]; | 2702 | obPart.IgnoreUndoUpdate = true; |
2698 | if (obPart.UUID != m_rootPart.UUID) | 2703 | Vector3 oldSize = new Vector3(obPart.Scale); |
2699 | { | ||
2700 | obPart.IgnoreUndoUpdate = true; | ||
2701 | Vector3 oldSize = new Vector3(obPart.Scale); | ||
2702 | 2704 | ||
2703 | float f = 1.0f; | 2705 | float f = 1.0f; |
2704 | float a = 1.0f; | 2706 | float a = 1.0f; |
2705 | 2707 | ||
2706 | if (part.PhysActor != null && part.PhysActor.IsPhysical) | 2708 | if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical) |
2709 | { | ||
2710 | if (oldSize.X * x > m_scene.m_maxPhys) | ||
2707 | { | 2711 | { |
2708 | if (oldSize.X * x > m_scene.m_maxPhys) | 2712 | f = m_scene.m_maxPhys / oldSize.X; |
2709 | { | 2713 | a = f / x; |
2710 | f = m_scene.m_maxPhys / oldSize.X; | 2714 | x *= a; |
2711 | a = f / x; | 2715 | y *= a; |
2712 | x *= a; | 2716 | z *= a; |
2713 | y *= a; | ||
2714 | z *= a; | ||
2715 | } | ||
2716 | if (oldSize.Y * y > m_scene.m_maxPhys) | ||
2717 | { | ||
2718 | f = m_scene.m_maxPhys / oldSize.Y; | ||
2719 | a = f / y; | ||
2720 | x *= a; | ||
2721 | y *= a; | ||
2722 | z *= a; | ||
2723 | } | ||
2724 | if (oldSize.Z * z > m_scene.m_maxPhys) | ||
2725 | { | ||
2726 | f = m_scene.m_maxPhys / oldSize.Z; | ||
2727 | a = f / z; | ||
2728 | x *= a; | ||
2729 | y *= a; | ||
2730 | z *= a; | ||
2731 | } | ||
2732 | } | 2717 | } |
2733 | else | 2718 | if (oldSize.Y * y > m_scene.m_maxPhys) |
2734 | { | 2719 | { |
2735 | if (oldSize.X * x > m_scene.m_maxNonphys) | 2720 | f = m_scene.m_maxPhys / oldSize.Y; |
2736 | { | 2721 | a = f / y; |
2737 | f = m_scene.m_maxNonphys / oldSize.X; | 2722 | x *= a; |
2738 | a = f / x; | 2723 | y *= a; |
2739 | x *= a; | 2724 | z *= a; |
2740 | y *= a; | 2725 | } |
2741 | z *= a; | 2726 | if (oldSize.Z * z > m_scene.m_maxPhys) |
2742 | } | 2727 | { |
2743 | if (oldSize.Y * y > m_scene.m_maxNonphys) | 2728 | f = m_scene.m_maxPhys / oldSize.Z; |
2744 | { | 2729 | a = f / z; |
2745 | f = m_scene.m_maxNonphys / oldSize.Y; | 2730 | x *= a; |
2746 | a = f / y; | 2731 | y *= a; |
2747 | x *= a; | 2732 | z *= a; |
2748 | y *= a; | 2733 | } |
2749 | z *= a; | 2734 | } |
2750 | } | 2735 | else |
2751 | if (oldSize.Z * z > m_scene.m_maxNonphys) | 2736 | { |
2752 | { | 2737 | if (oldSize.X * x > m_scene.m_maxNonphys) |
2753 | f = m_scene.m_maxNonphys / oldSize.Z; | 2738 | { |
2754 | a = f / z; | 2739 | f = m_scene.m_maxNonphys / oldSize.X; |
2755 | x *= a; | 2740 | a = f / x; |
2756 | y *= a; | 2741 | x *= a; |
2757 | z *= a; | 2742 | y *= a; |
2758 | } | 2743 | z *= a; |
2744 | } | ||
2745 | if (oldSize.Y * y > m_scene.m_maxNonphys) | ||
2746 | { | ||
2747 | f = m_scene.m_maxNonphys / oldSize.Y; | ||
2748 | a = f / y; | ||
2749 | x *= a; | ||
2750 | y *= a; | ||
2751 | z *= a; | ||
2752 | } | ||
2753 | if (oldSize.Z * z > m_scene.m_maxNonphys) | ||
2754 | { | ||
2755 | f = m_scene.m_maxNonphys / oldSize.Z; | ||
2756 | a = f / z; | ||
2757 | x *= a; | ||
2758 | y *= a; | ||
2759 | z *= a; | ||
2759 | } | 2760 | } |
2760 | obPart.IgnoreUndoUpdate = false; | ||
2761 | obPart.StoreUndoState(); | ||
2762 | } | 2761 | } |
2762 | obPart.IgnoreUndoUpdate = false; | ||
2763 | obPart.StoreUndoState(); | ||
2763 | } | 2764 | } |
2764 | } | 2765 | } |
2766 | } | ||
2765 | 2767 | ||
2766 | Vector3 prevScale = part.Scale; | 2768 | Vector3 prevScale = RootPart.Scale; |
2767 | prevScale.X *= x; | 2769 | prevScale.X *= x; |
2768 | prevScale.Y *= y; | 2770 | prevScale.Y *= y; |
2769 | prevScale.Z *= z; | 2771 | prevScale.Z *= z; |
2770 | part.Resize(prevScale); | 2772 | RootPart.Resize(prevScale); |
2771 | 2773 | ||
2772 | parts = m_parts.GetArray(); | 2774 | parts = m_parts.GetArray(); |
2773 | for (int i = 0; i < parts.Length; i++) | 2775 | for (int i = 0; i < parts.Length; i++) |
2776 | { | ||
2777 | SceneObjectPart obPart = parts[i]; | ||
2778 | obPart.IgnoreUndoUpdate = true; | ||
2779 | if (obPart.UUID != m_rootPart.UUID) | ||
2774 | { | 2780 | { |
2775 | SceneObjectPart obPart = parts[i]; | 2781 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); |
2776 | obPart.IgnoreUndoUpdate = true; | 2782 | currentpos.X *= x; |
2777 | if (obPart.UUID != m_rootPart.UUID) | 2783 | currentpos.Y *= y; |
2784 | currentpos.Z *= z; | ||
2785 | Vector3 newSize = new Vector3(obPart.Scale); | ||
2786 | newSize.X *= x; | ||
2787 | newSize.Y *= y; | ||
2788 | newSize.Z *= z; | ||
2789 | obPart.Resize(newSize); | ||
2790 | obPart.UpdateOffSet(currentpos); | ||
2791 | |||
2792 | if (obPart.PhysActor != null) | ||
2778 | { | 2793 | { |
2779 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); | 2794 | obPart.PhysActor.Size = newSize; |
2780 | currentpos.X *= x; | ||
2781 | currentpos.Y *= y; | ||
2782 | currentpos.Z *= z; | ||
2783 | Vector3 newSize = new Vector3(obPart.Scale); | ||
2784 | newSize.X *= x; | ||
2785 | newSize.Y *= y; | ||
2786 | newSize.Z *= z; | ||
2787 | obPart.Resize(newSize); | ||
2788 | obPart.UpdateOffSet(currentpos); | ||
2789 | |||
2790 | if (obPart.PhysActor != null) | ||
2791 | { | ||
2792 | obPart.PhysActor.Size = newSize; | ||
2793 | 2795 | ||
2794 | // If we're a sculpt wait for the trigger when the sculpt texture is retrieved. | 2796 | // If we're a sculpt wait for the trigger when the sculpt texture is retrieved. |
2795 | if (((OpenMetaverse.SculptType)obPart.Shape.SculptType) != SculptType.Mesh) | 2797 | if (((OpenMetaverse.SculptType)obPart.Shape.SculptType) != SculptType.Mesh) |
2796 | m_scene.PhysicsScene.AddPhysicsActorTaint(obPart.PhysActor); | 2798 | m_scene.PhysicsScene.AddPhysicsActorTaint(obPart.PhysActor); |
2797 | } | ||
2798 | } | 2799 | } |
2799 | |||
2800 | obPart.IgnoreUndoUpdate = false; | ||
2801 | obPart.StoreUndoState(); | ||
2802 | } | 2800 | } |
2803 | 2801 | ||
2804 | if (part.PhysActor != null) | 2802 | obPart.IgnoreUndoUpdate = false; |
2805 | { | 2803 | obPart.StoreUndoState(); |
2806 | part.PhysActor.Size = prevScale; | 2804 | } |
2807 | 2805 | ||
2808 | // If we're a sculpt wait for the trigger when the sculpt texture is retrieved. | 2806 | if (RootPart.PhysActor != null) |
2809 | if (((OpenMetaverse.SculptType)part.Shape.SculptType) != SculptType.Mesh) | 2807 | { |
2810 | m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); | 2808 | RootPart.PhysActor.Size = prevScale; |
2811 | } | ||
2812 | 2809 | ||
2813 | part.IgnoreUndoUpdate = false; | 2810 | // If we're a sculpt wait for the trigger when the sculpt texture is retrieved. |
2814 | part.StoreUndoState(); | 2811 | if (((OpenMetaverse.SculptType)RootPart.Shape.SculptType) != SculptType.Mesh) |
2815 | HasGroupChanged = true; | 2812 | m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor); |
2816 | m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); | ||
2817 | ScheduleGroupForTerseUpdate(); | ||
2818 | } | 2813 | } |
2814 | |||
2815 | RootPart.IgnoreUndoUpdate = false; | ||
2816 | RootPart.StoreUndoState(); | ||
2817 | HasGroupChanged = true; | ||
2818 | RootPart.TriggerScriptChangedEvent(Changed.SCALE); | ||
2819 | ScheduleGroupForTerseUpdate(); | ||
2819 | } | 2820 | } |
2820 | 2821 | ||
2821 | #endregion | 2822 | #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 | |||
55 | Scene scene = SceneSetupHelpers.SetupScene(); | 55 | Scene scene = SceneSetupHelpers.SetupScene(); |
56 | SceneObjectGroup g1 = SceneSetupHelpers.AddSceneObject(scene).ParentGroup; | 56 | SceneObjectGroup g1 = SceneSetupHelpers.AddSceneObject(scene).ParentGroup; |
57 | 57 | ||
58 | g1.GroupResize(new Vector3(2, 3, 4), g1.LocalId); | 58 | g1.GroupResize(new Vector3(2, 3, 4)); |
59 | 59 | ||
60 | SceneObjectGroup g1Post = scene.GetSceneObjectGroup(g1.UUID); | 60 | SceneObjectGroup g1Post = scene.GetSceneObjectGroup(g1.UUID); |
61 | 61 | ||