From 38da8960e98c12a16bf8a25e9fe7e03ee251933c Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Thu, 10 Jul 2008 03:13:29 +0000 Subject: Mantis#1707. Thank you, Melanie for a patch that: This patch limits the maximum size of prims that can be created using libsl bots or modified clients to 65536mper side. It also limits LSL functions to that size. If a prim is already physical, the enforced constraint is 10m. A prim that is larger than 10m cannot be turned physical, either via script or UI. Linksets are handled correctly, so scaling of physical linksets is constrained by the size of it's largest component prim. Also, turning linksets physical is based on the size of it's largest ptim. --- .../Region/Environment/Scenes/SceneObjectGroup.cs | 121 ++++++++++++++++++++- .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 36 ++++++ .../Shared/Api/Implementation/LSL_Api.cs | 36 ++++++ 3 files changed, 191 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index ebefdce..eafb882 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -2012,6 +2012,15 @@ namespace OpenSim.Region.Environment.Scenes // If we have children lock (m_parts) { + foreach (SceneObjectPart parts in m_parts.Values) + { + if(part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0) + { + data[47] = 0; // Reset physics + break; + } + } + if (m_parts.Count > 1) { foreach (SceneObjectPart parts in m_parts.Values) @@ -2100,12 +2109,28 @@ namespace OpenSim.Region.Environment.Scenes /// public void Resize(LLVector3 scale, uint localID) { + if(scale.X > 65536.0f) + scale.X = 65536.0f; + if(scale.Y > 65536.0f) + scale.Y = 65536.0f; + if(scale.Z > 65536.0f) + scale.Z = 65536.0f; + SceneObjectPart part = GetChildPart(localID); if (part != null) { part.Resize(scale); if (part.PhysActor != null) { + if(part.PhysActor.IsPhysical) + { + if(scale.X > 10.0f) + scale.X = 10.0f; + if(scale.Y > 10.0f) + scale.Y = 10.0f; + if(scale.Z > 10.0f) + scale.Z = 10.0f; + } part.PhysActor.Size = new PhysicsVector(scale.X, scale.Y, scale.Z); m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); @@ -2132,10 +2157,102 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectPart part = GetChildPart(localID); if (part != null) { + if(scale.X > 65536.0f) + scale.X = 65536.0f; + if(scale.Y > 65536.0f) + scale.Y = 65536.0f; + if(scale.Z > 65536.0f) + scale.Z = 65536.0f; + if(part.PhysActor != null && part.PhysActor.IsPhysical) + { + if(scale.X > 10.0f) + scale.X = 10.0f; + if(scale.Y > 10.0f) + scale.Y = 10.0f; + if(scale.Z > 10.0f) + scale.Z = 10.0f; + } float x = (scale.X / part.Scale.X); float y = (scale.Y / part.Scale.Y); float z = (scale.Z / part.Scale.Z); - part.Resize(scale); + + lock (m_parts) + { + if(x > 1.0f || y > 1.0f || z > 1.0f) + { + foreach (SceneObjectPart obPart in m_parts.Values) + { + if (obPart.UUID != m_rootPart.UUID) + { + LLVector3 oldSize = new LLVector3(obPart.Scale); + + float f = 1.0f; + float a = 1.0f; + + if(part.PhysActor != null && part.PhysActor.IsPhysical) + { + if(oldSize.X*x > 10.0f) + { + f = 10.0f / oldSize.X; + a = f / x; + x *= a; + y *= a; + z *= a; + } + if(oldSize.Y*y > 10.0f) + { + f = 10.0f / oldSize.Y; + a = f / y; + x *= a; + y *= a; + z *= a; + } + if(oldSize.Z*z > 10.0f) + { + f = 10.0f / oldSize.Z; + a = f / z; + x *= a; + y *= a; + z *= a; + } + } + else + { + if(oldSize.X*x > 65536.0f) + { + f = 65536.0f / oldSize.X; + a = f / x; + x *= a; + y *= a; + z *= a; + } + if(oldSize.Y*y > 65536.0f) + { + f = 65536.0f / oldSize.Y; + a = f / y; + x *= a; + y *= a; + z *= a; + } + if(oldSize.Z*z > 65536.0f) + { + f = 65536.0f / oldSize.Z; + a = f / z; + x *= a; + y *= a; + z *= a; + } + } + } + } + } + } + + LLVector3 prevScale = part.Scale; + prevScale.X *= x; + prevScale.Y *= y; + prevScale.Z *= z; + part.Resize(prevScale); lock (m_parts) { @@ -2160,7 +2277,7 @@ namespace OpenSim.Region.Environment.Scenes if (part.PhysActor != null) { part.PhysActor.Size = - new PhysicsVector(scale.X, scale.Y, scale.Z); + new PhysicsVector(prevScale.X, prevScale.Y, prevScale.Z); m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); } diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 2b986be..2538246 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -831,7 +831,24 @@ namespace OpenSim.Region.ScriptEngine.Common if ((status & BuiltIn_Commands_BaseClass.STATUS_PHYSICS) == BuiltIn_Commands_BaseClass.STATUS_PHYSICS) { if (value == 1) + { + SceneObjectGroup group = m_host.ParentGroup; + if(group == null) + return; + bool allow = true; + foreach(SceneObjectPart part in group.Children.Values) + { + if(part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0) + { + allow = false; + break; + } + } + + if(!allow) + return; m_host.ScriptSetPhysicsStatus(true); + } else m_host.ScriptSetPhysicsStatus(false); @@ -948,6 +965,25 @@ namespace OpenSim.Region.ScriptEngine.Common private void SetScale(SceneObjectPart part, LSL_Types.Vector3 scale) { // TODO: this needs to trigger a persistance save as well + + if(part == null || part.ParentGroup == null || part.ParentGroup.RootPart == null) + return; + + if(part.ParentGroup.RootPart.PhysActor != null && part.ParentGroup.RootPart.PhysActor.IsPhysical) + { + if(scale.x > 10.0) + scale.x = 10.0; + if(scale.y > 10.0) + scale.y = 10.0; + if(scale.z > 10.0) + scale.z = 10.0; + } + if(scale.x > 65536.0) + scale.x = 65536.0; + if(scale.y > 65536.0) + scale.y = 65536.0; + if(scale.z > 65536.0) + scale.z = 65536.0; LLVector3 tmp = part.Scale; tmp.X = (float)scale.x; tmp.Y = (float)scale.y; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 57f9141..4bf3e93 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -671,7 +671,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((status & ScriptBaseClass.STATUS_PHYSICS) == ScriptBaseClass.STATUS_PHYSICS) { if (value == 1) + { + SceneObjectGroup group = m_host.ParentGroup; + if(group == null) + return; + bool allow = true; + foreach(SceneObjectPart part in group.Children.Values) + { + if(part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0) + { + allow = false; + break; + } + } + + if(!allow) + return; m_host.ScriptSetPhysicsStatus(true); + } else m_host.ScriptSetPhysicsStatus(false); } @@ -802,6 +819,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private void SetScale(SceneObjectPart part, LSL_Types.Vector3 scale) { // TODO: this needs to trigger a persistance save as well + + if(part == null || part.ParentGroup == null || part.ParentGroup.RootPart == null) + return; + + if(part.ParentGroup.RootPart.PhysActor != null && part.ParentGroup.RootPart.PhysActor.IsPhysical) + { + if(scale.x > 10.0) + scale.x = 10.0; + if(scale.y > 10.0) + scale.y = 10.0; + if(scale.z > 10.0) + scale.z = 10.0; + } + if(scale.x > 65536.0) + scale.x = 65536.0; + if(scale.y > 65536.0) + scale.y = 65536.0; + if(scale.z > 65536.0) + scale.z = 65536.0; LLVector3 tmp = part.Scale; tmp.X = (float)scale.x; tmp.Y = (float)scale.y; -- cgit v1.1