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.
0.6.0-stable
Charles Krinke 2008-07-10 03:13:29 +00:00
parent c9a7bf7e58
commit 38da8960e9
4 changed files with 193 additions and 2 deletions

View File

@ -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
/// <param name="localID"></param>
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);
}

View File

@ -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;

View File

@ -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;

View File

@ -1543,6 +1543,7 @@
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Region.Environment" />
<Reference name="OpenSim.Region.Physics.Manager" />
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
<Reference name="OpenSim.Region.ScriptEngine.Shared.Api.Runtime"/>
@ -1825,6 +1826,7 @@
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Region.Environment" />
<Reference name="OpenSim.Region.Physics.Manager" />
<Reference name="OpenSim.Framework.Console"/>
<Reference name="Axiom.MathLib.dll" localCopy="false"/>
<Reference name="Nini.dll" />