From ef4122213c440c55d32c097c08e52170f4b4346a Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Mon, 6 Aug 2012 15:35:40 +0100 Subject: enables configurable minimum sizes for physical & non-physical prims --- OpenSim/Framework/RegionInfo.cs | 42 ++++++++++++++- OpenSim/Region/Framework/Scenes/Scene.cs | 31 ++++++++++- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 9 ++-- .../Region/Framework/Scenes/SceneObjectGroup.cs | 60 +++++++++++++++++++--- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 13 +++-- .../Shared/Api/Implementation/LSL_Api.cs | 28 +++------- 6 files changed, 141 insertions(+), 42 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 2080a16..8131089 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -120,7 +120,9 @@ namespace OpenSim.Framework public UUID lastMapUUID = UUID.Zero; public string lastMapRefresh = "0"; + private float m_nonphysPrimMin = 0; private int m_nonphysPrimMax = 0; + private float m_physPrimMin = 0; private int m_physPrimMax = 0; private bool m_clampPrimSize = false; private int m_objectCapacity = 0; @@ -285,11 +287,21 @@ namespace OpenSim.Framework set { m_windlight = value; } } + public float NonphysPrimMin + { + get { return m_nonphysPrimMin; } + } + public int NonphysPrimMax { get { return m_nonphysPrimMax; } } + public float PhysPrimMin + { + get { return m_physPrimMin; } + } + public int PhysPrimMax { get { return m_physPrimMax; } @@ -623,16 +635,28 @@ namespace OpenSim.Framework m_regionType = config.GetString("RegionType", String.Empty); allKeys.Remove("RegionType"); - // Prim stuff - // + #region Prim stuff + + m_nonphysPrimMin = config.GetFloat("NonphysicalPrimMin", 0); + allKeys.Remove("NonphysicalPrimMin"); + m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 0); allKeys.Remove("NonphysicalPrimMax"); + + m_physPrimMin = config.GetFloat("PhysicalPrimMin", 0); + allKeys.Remove("PhysicalPrimMin"); + m_physPrimMax = config.GetInt("PhysicalPrimMax", 0); allKeys.Remove("PhysicalPrimMax"); + m_clampPrimSize = config.GetBoolean("ClampPrimSize", false); allKeys.Remove("ClampPrimSize"); + m_objectCapacity = config.GetInt("MaxPrims", 15000); allKeys.Remove("MaxPrims"); + + #endregion + m_agentCapacity = config.GetInt("MaxAgents", 100); allKeys.Remove("MaxAgents"); @@ -668,10 +692,18 @@ namespace OpenSim.Framework config.Set("ExternalHostName", m_externalHostName); + if (m_nonphysPrimMin != 0) + config.Set("NonphysicalPrimMax", m_nonphysPrimMin); + if (m_nonphysPrimMax != 0) config.Set("NonphysicalPrimMax", m_nonphysPrimMax); + + if (m_physPrimMin != 0) + config.Set("PhysicalPrimMax", m_physPrimMin); + if (m_physPrimMax != 0) config.Set("PhysicalPrimMax", m_physPrimMax); + config.Set("ClampPrimSize", m_clampPrimSize.ToString()); if (m_objectCapacity != 0) @@ -754,9 +786,15 @@ namespace OpenSim.Framework configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true); + configMember.addConfigurationOption("nonphysical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, + "Minimum size for nonphysical prims", m_nonphysPrimMin.ToString(), true); + configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true); + configMember.addConfigurationOption("physical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, + "Minimum size for nonphysical prims", m_physPrimMin.ToString(), true); + configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Maximum size for physical prims", m_physPrimMax.ToString(), true); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0e5ddfd..d2d6aba 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -103,8 +103,26 @@ namespace OpenSim.Region.Framework.Scenes /// public bool CollidablePrims { get; private set; } + /// + /// Minimum value of the size of a non-physical prim in each axis + /// + public float m_minNonphys = 0.01f; + + /// + /// Maximum value of the size of a non-physical prim in each axis + /// public float m_maxNonphys = 256; + + /// + /// Minimum value of the size of a physical prim in each axis + /// + public float m_minPhys = 0.01f; + + /// + /// Maximum value of the size of a physical prim in each axis + /// public float m_maxPhys = 10; + public bool m_clampPrimSize; public bool m_trustBinaries; public bool m_allowScriptCrossings; @@ -721,14 +739,25 @@ namespace OpenSim.Region.Framework.Scenes PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); + m_minNonphys = startupConfig.GetFloat("NonphysicalPrimMin", m_minNonphys); + if (RegionInfo.NonphysPrimMin > 0) + { + m_minNonphys = RegionInfo.NonphysPrimMin; + } + m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); if (RegionInfo.NonphysPrimMax > 0) { m_maxNonphys = RegionInfo.NonphysPrimMax; } - m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); + m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys); + if (RegionInfo.PhysPrimMin > 0) + { + m_minPhys = RegionInfo.PhysPrimMin; + } + m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); if (RegionInfo.PhysPrimMax > 0) { m_maxPhys = RegionInfo.PhysPrimMax; diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 13842ad..b6339fb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -375,12 +375,9 @@ namespace OpenSim.Region.Framework.Scenes { Vector3 scale = part.Shape.Scale; - if (scale.X > m_parentScene.m_maxNonphys) - scale.X = m_parentScene.m_maxNonphys; - if (scale.Y > m_parentScene.m_maxNonphys) - scale.Y = m_parentScene.m_maxNonphys; - if (scale.Z > m_parentScene.m_maxNonphys) - scale.Z = m_parentScene.m_maxNonphys; + scale.X = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.X)); + scale.Y = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.Y)); + scale.Z = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.Z)); part.Shape.Scale = scale; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5f90035..f6c725b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2674,17 +2674,17 @@ namespace OpenSim.Region.Framework.Scenes 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); + 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) { - 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); + 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); @@ -2716,6 +2716,14 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } + else if (oldSize.X * x < m_scene.m_minPhys) + { + f = m_scene.m_minPhys / oldSize.X; + a = f / x; + x *= a; + y *= a; + z *= a; + } if (oldSize.Y * y > m_scene.m_maxPhys) { @@ -2725,6 +2733,14 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } + else if (oldSize.Y * y < m_scene.m_minPhys) + { + f = m_scene.m_minPhys / oldSize.Y; + a = f / y; + x *= a; + y *= a; + z *= a; + } if (oldSize.Z * z > m_scene.m_maxPhys) { @@ -2734,6 +2750,14 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } + else if (oldSize.Z * z < m_scene.m_minPhys) + { + f = m_scene.m_minPhys / oldSize.Z; + a = f / z; + x *= a; + y *= a; + z *= a; + } } else { @@ -2745,6 +2769,14 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } + else if (oldSize.X * x < m_scene.m_minNonphys) + { + f = m_scene.m_minNonphys / oldSize.X; + a = f / x; + x *= a; + y *= a; + z *= a; + } if (oldSize.Y * y > m_scene.m_maxNonphys) { @@ -2754,6 +2786,14 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } + else if (oldSize.Y * y < m_scene.m_minNonphys) + { + f = m_scene.m_minNonphys / oldSize.Y; + a = f / y; + x *= a; + y *= a; + z *= a; + } if (oldSize.Z * z > m_scene.m_maxNonphys) { @@ -2763,6 +2803,14 @@ namespace OpenSim.Region.Framework.Scenes y *= a; z *= a; } + else if (oldSize.Z * z < m_scene.m_minNonphys) + { + f = m_scene.m_minNonphys / oldSize.Z; + a = f / z; + x *= a; + y *= a; + z *= a; + } } // obPart.IgnoreUndoUpdate = false; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4c87639..cd75224 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2368,17 +2368,16 @@ namespace OpenSim.Region.Framework.Scenes /// public void Resize(Vector3 scale) { - 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); + 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) { - 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.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); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 55567d1..a7852ec 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1343,31 +1343,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (part == null || part.ParentGroup.IsDeleted) return; - if (scale.x < 0.01) - scale.x = 0.01; - if (scale.y < 0.01) - scale.y = 0.01; - if (scale.z < 0.01) - scale.z = 0.01; - + // First we need to check whether or not we need to clamp the size of a physics-enabled prim PhysicsActor pa = part.ParentGroup.RootPart.PhysActor; - if (pa != null && pa.IsPhysical) { - if (scale.x > World.m_maxPhys) - scale.x = World.m_maxPhys; - if (scale.y > World.m_maxPhys) - scale.y = World.m_maxPhys; - if (scale.z > World.m_maxPhys) - scale.z = World.m_maxPhys; + scale.x = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.x)); + scale.y = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.y)); + scale.z = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.z)); } - if (scale.x > World.m_maxNonphys) - scale.x = World.m_maxNonphys; - if (scale.y > World.m_maxNonphys) - scale.y = World.m_maxNonphys; - if (scale.z > World.m_maxNonphys) - scale.z = World.m_maxNonphys; + // Next we clamp the scale to the non-physical min/max + scale.x = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.x)); + scale.y = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.y)); + scale.z = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.z)); Vector3 tmp = part.Scale; tmp.X = (float)scale.x; -- cgit v1.1