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/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 +++-------
5 files changed, 101 insertions(+), 40 deletions(-)
(limited to 'OpenSim/Region')
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