diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 203 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 19 |
2 files changed, 83 insertions, 139 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 329ea11..c97c838 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -3795,156 +3795,101 @@ namespace OpenSim.Region.Framework.Scenes | |||
3795 | // m_log.DebugFormat( | 3795 | // m_log.DebugFormat( |
3796 | // "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale); | 3796 | // "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale); |
3797 | 3797 | ||
3798 | if (Scene == null) | ||
3799 | return; | ||
3800 | |||
3798 | PhysicsActor pa = m_rootPart.PhysActor; | 3801 | PhysicsActor pa = m_rootPart.PhysActor; |
3799 | 3802 | ||
3800 | if (Scene != null) | 3803 | float minsize = Scene.m_minNonphys; |
3804 | float maxsize = Scene.m_maxNonphys; | ||
3805 | |||
3806 | if (pa != null && pa.IsPhysical) | ||
3801 | { | 3807 | { |
3802 | scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); | 3808 | minsize = Scene.m_minPhys; |
3803 | scale.Y = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Y)); | 3809 | maxsize = Scene.m_maxPhys; |
3804 | scale.Z = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Z)); | ||
3805 | |||
3806 | if (pa != null && pa.IsPhysical) | ||
3807 | { | ||
3808 | scale.X = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.X)); | ||
3809 | scale.Y = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Y)); | ||
3810 | scale.Z = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Z)); | ||
3811 | } | ||
3812 | } | 3810 | } |
3813 | 3811 | ||
3812 | scale.X = Util.Clamp(scale.X, minsize, maxsize); | ||
3813 | scale.Y = Util.Clamp(scale.Y, minsize, maxsize); | ||
3814 | scale.Z = Util.Clamp(scale.Z, minsize, maxsize); | ||
3815 | |||
3816 | // requested scaling factors | ||
3814 | float x = (scale.X / RootPart.Scale.X); | 3817 | float x = (scale.X / RootPart.Scale.X); |
3815 | float y = (scale.Y / RootPart.Scale.Y); | 3818 | float y = (scale.Y / RootPart.Scale.Y); |
3816 | float z = (scale.Z / RootPart.Scale.Z); | 3819 | float z = (scale.Z / RootPart.Scale.Z); |
3817 | 3820 | ||
3818 | SceneObjectPart[] parts = m_parts.GetArray(); | 3821 | SceneObjectPart[] parts = m_parts.GetArray(); |
3819 | 3822 | ||
3820 | if (Scene != null & (x > 1.0f || y > 1.0f || z > 1.0f)) | 3823 | // fix scaling factors so parts don't violate dimensions |
3824 | for(int i = 0;i < parts.Length;i++) | ||
3821 | { | 3825 | { |
3822 | for (int i = 0; i < parts.Length; i++) | 3826 | SceneObjectPart obPart = parts[i]; |
3827 | if(obPart.UUID != m_rootPart.UUID) | ||
3823 | { | 3828 | { |
3824 | SceneObjectPart obPart = parts[i]; | 3829 | Vector3 oldSize = new Vector3(obPart.Scale); |
3825 | if (obPart.UUID != m_rootPart.UUID) | ||
3826 | { | ||
3827 | Vector3 oldSize = new Vector3(obPart.Scale); | ||
3828 | 3830 | ||
3829 | float f = 1.0f; | 3831 | float f = 1.0f; |
3830 | float a = 1.0f; | 3832 | float a = 1.0f; |
3831 | 3833 | ||
3832 | if (pa != null && pa.IsPhysical) | 3834 | if(oldSize.X * x > maxsize) |
3833 | { | 3835 | { |
3834 | if (oldSize.X * x > Scene.m_maxPhys) | 3836 | f = maxsize / oldSize.X; |
3835 | { | 3837 | a = f / x; |
3836 | f = m_scene.m_maxPhys / oldSize.X; | 3838 | x *= a; |
3837 | a = f / x; | 3839 | y *= a; |
3838 | x *= a; | 3840 | z *= a; |
3839 | y *= a; | 3841 | } |
3840 | z *= a; | 3842 | else if(oldSize.X * x < minsize) |
3841 | } | 3843 | { |
3842 | else if (oldSize.X * x < Scene.m_minPhys) | 3844 | f = minsize / oldSize.X; |
3843 | { | 3845 | a = f / x; |
3844 | f = m_scene.m_minPhys / oldSize.X; | 3846 | x *= a; |
3845 | a = f / x; | 3847 | y *= a; |
3846 | x *= a; | 3848 | z *= a; |
3847 | y *= a; | 3849 | } |
3848 | z *= a; | ||
3849 | } | ||
3850 | |||
3851 | if (oldSize.Y * y > Scene.m_maxPhys) | ||
3852 | { | ||
3853 | f = m_scene.m_maxPhys / oldSize.Y; | ||
3854 | a = f / y; | ||
3855 | x *= a; | ||
3856 | y *= a; | ||
3857 | z *= a; | ||
3858 | } | ||
3859 | else if (oldSize.Y * y < Scene.m_minPhys) | ||
3860 | { | ||
3861 | f = m_scene.m_minPhys / oldSize.Y; | ||
3862 | a = f / y; | ||
3863 | x *= a; | ||
3864 | y *= a; | ||
3865 | z *= a; | ||
3866 | } | ||
3867 | |||
3868 | if (oldSize.Z * z > Scene.m_maxPhys) | ||
3869 | { | ||
3870 | f = m_scene.m_maxPhys / oldSize.Z; | ||
3871 | a = f / z; | ||
3872 | x *= a; | ||
3873 | y *= a; | ||
3874 | z *= a; | ||
3875 | } | ||
3876 | else if (oldSize.Z * z < Scene.m_minPhys) | ||
3877 | { | ||
3878 | f = m_scene.m_minPhys / oldSize.Z; | ||
3879 | a = f / z; | ||
3880 | x *= a; | ||
3881 | y *= a; | ||
3882 | z *= a; | ||
3883 | } | ||
3884 | } | ||
3885 | else | ||
3886 | { | ||
3887 | if (oldSize.X * x > Scene.m_maxNonphys) | ||
3888 | { | ||
3889 | f = m_scene.m_maxNonphys / oldSize.X; | ||
3890 | a = f / x; | ||
3891 | x *= a; | ||
3892 | y *= a; | ||
3893 | z *= a; | ||
3894 | } | ||
3895 | else if (oldSize.X * x < Scene.m_minNonphys) | ||
3896 | { | ||
3897 | f = m_scene.m_minNonphys / oldSize.X; | ||
3898 | a = f / x; | ||
3899 | x *= a; | ||
3900 | y *= a; | ||
3901 | z *= a; | ||
3902 | } | ||
3903 | 3850 | ||
3904 | if (oldSize.Y * y > Scene.m_maxNonphys) | 3851 | if(oldSize.Y * y > maxsize) |
3905 | { | 3852 | { |
3906 | f = m_scene.m_maxNonphys / oldSize.Y; | 3853 | f = maxsize / oldSize.Y; |
3907 | a = f / y; | 3854 | a = f / y; |
3908 | x *= a; | 3855 | x *= a; |
3909 | y *= a; | 3856 | y *= a; |
3910 | z *= a; | 3857 | z *= a; |
3911 | } | 3858 | } |
3912 | else if (oldSize.Y * y < Scene.m_minNonphys) | 3859 | else if(oldSize.Y * y < minsize) |
3913 | { | 3860 | { |
3914 | f = m_scene.m_minNonphys / oldSize.Y; | 3861 | f = minsize / oldSize.Y; |
3915 | a = f / y; | 3862 | a = f / y; |
3916 | x *= a; | 3863 | x *= a; |
3917 | y *= a; | 3864 | y *= a; |
3918 | z *= a; | 3865 | z *= a; |
3919 | } | 3866 | } |
3920 | 3867 | ||
3921 | if (oldSize.Z * z > Scene.m_maxNonphys) | 3868 | if(oldSize.Z * z > maxsize) |
3922 | { | 3869 | { |
3923 | f = m_scene.m_maxNonphys / oldSize.Z; | 3870 | f = maxsize / oldSize.Z; |
3924 | a = f / z; | 3871 | a = f / z; |
3925 | x *= a; | 3872 | x *= a; |
3926 | y *= a; | 3873 | y *= a; |
3927 | z *= a; | 3874 | z *= a; |
3928 | } | 3875 | } |
3929 | else if (oldSize.Z * z < Scene.m_minNonphys) | 3876 | else if(oldSize.Z * z < minsize) |
3930 | { | 3877 | { |
3931 | f = m_scene.m_minNonphys / oldSize.Z; | 3878 | f = minsize / oldSize.Z; |
3932 | a = f / z; | 3879 | a = f / z; |
3933 | x *= a; | 3880 | x *= a; |
3934 | y *= a; | 3881 | y *= a; |
3935 | z *= a; | 3882 | z *= a; |
3936 | } | ||
3937 | } | ||
3938 | } | 3883 | } |
3939 | } | 3884 | } |
3940 | } | 3885 | } |
3941 | 3886 | ||
3942 | Vector3 prevScale = RootPart.Scale; | 3887 | Vector3 rootScale = RootPart.Scale; |
3943 | prevScale.X *= x; | 3888 | rootScale.X *= x; |
3944 | prevScale.Y *= y; | 3889 | rootScale.Y *= y; |
3945 | prevScale.Z *= z; | 3890 | rootScale.Z *= z; |
3946 | 3891 | ||
3947 | RootPart.Resize(prevScale); | 3892 | RootPart.Scale = rootScale; |
3948 | 3893 | ||
3949 | for (int i = 0; i < parts.Length; i++) | 3894 | for (int i = 0; i < parts.Length; i++) |
3950 | { | 3895 | { |
@@ -3962,7 +3907,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3962 | newSize.Y *= y; | 3907 | newSize.Y *= y; |
3963 | newSize.Z *= z; | 3908 | newSize.Z *= z; |
3964 | 3909 | ||
3965 | obPart.Resize(newSize); | 3910 | obPart.Scale = newSize; |
3966 | obPart.UpdateOffSet(currentpos); | 3911 | obPart.UpdateOffSet(currentpos); |
3967 | } | 3912 | } |
3968 | 3913 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index fed9eaf..65511bc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -3073,18 +3073,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
3073 | 3073 | ||
3074 | if (ParentGroup.Scene != null) | 3074 | if (ParentGroup.Scene != null) |
3075 | { | 3075 | { |
3076 | scale.X = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.X)); | 3076 | float minsize = ParentGroup.Scene.m_minNonphys; |
3077 | scale.Y = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Y)); | 3077 | float maxsize = ParentGroup.Scene.m_maxNonphys; |
3078 | scale.Z = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Z)); | ||
3079 | |||
3080 | if (pa != null && pa.IsPhysical) | 3078 | if (pa != null && pa.IsPhysical) |
3081 | { | 3079 | { |
3082 | scale.X = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.X)); | 3080 | minsize = ParentGroup.Scene.m_minPhys; |
3083 | scale.Y = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Y)); | 3081 | maxsize = ParentGroup.Scene.m_maxPhys; |
3084 | scale.Z = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Z)); | 3082 | } |
3085 | } | 3083 | scale.X = Util.Clamp(scale.X, minsize, maxsize); |
3084 | scale.Y = Util.Clamp(scale.Y, minsize, maxsize); | ||
3085 | scale.Z = Util.Clamp(scale.Z, minsize, maxsize); | ||
3086 | } | 3086 | } |
3087 | |||
3088 | // m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale); | 3087 | // m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale); |
3089 | 3088 | ||
3090 | Scale = scale; | 3089 | Scale = scale; |