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 ++++++++++++++++++++- 1 file changed, 119 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Environment') 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); } -- cgit v1.1