enforce prim size restrictions on physical state change; Place restrictions on ini values

0.9.1.0-post-fixes
UbitUmarov 2019-02-05 01:45:04 +00:00
parent b8121ad8a2
commit 175817fe55
2 changed files with 32 additions and 2 deletions

View File

@ -951,18 +951,25 @@ namespace OpenSim.Region.Framework.Scenes
{ {
m_minNonphys = RegionInfo.NonphysPrimMin; m_minNonphys = RegionInfo.NonphysPrimMin;
} }
// don't allow nonsense values
if(m_minNonphys < 0.001f)
m_minNonphys = 0.001f;
m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
if (RegionInfo.NonphysPrimMax > 0) if (RegionInfo.NonphysPrimMax > 0)
{ {
m_maxNonphys = RegionInfo.NonphysPrimMax; m_maxNonphys = RegionInfo.NonphysPrimMax;
} }
if (m_maxNonphys > 2048)
m_maxNonphys = 2048;
m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys); m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys);
if (RegionInfo.PhysPrimMin > 0) if (RegionInfo.PhysPrimMin > 0)
{ {
m_minPhys = RegionInfo.PhysPrimMin; m_minPhys = RegionInfo.PhysPrimMin;
} }
if(m_minPhys < 0.01f)
m_minPhys = 0.01f;
m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
@ -970,6 +977,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
m_maxPhys = RegionInfo.PhysPrimMax; m_maxPhys = RegionInfo.PhysPrimMax;
} }
if (m_maxPhys > 2048)
m_maxPhys = 2048;
m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity);
if (RegionInfo.LinksetCapacity > 0) if (RegionInfo.LinksetCapacity > 0)

View File

@ -2319,6 +2319,17 @@ namespace OpenSim.Region.Framework.Scenes
if (pa != null) if (pa != null)
{ {
if (UsePhysics != pa.IsPhysical)
{
float minsize = UsePhysics ? ParentGroup.Scene.m_minPhys : ParentGroup.Scene.m_minNonphys;
float maxsize = UsePhysics ? ParentGroup.Scene.m_maxPhys : ParentGroup.Scene.m_maxNonphys;
Vector3 scale = Scale;
scale.X = Util.Clamp(scale.X, minsize, maxsize);
scale.Y = Util.Clamp(scale.Y, minsize, maxsize);
scale.Z = Util.Clamp(scale.Z, minsize, maxsize);
Scale = scale;
}
if (UsePhysics != pa.IsPhysical || isNew) if (UsePhysics != pa.IsPhysical || isNew)
{ {
if (pa.IsPhysical) // implies UsePhysics==false for this block if (pa.IsPhysical) // implies UsePhysics==false for this block
@ -4776,8 +4787,18 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="applyDynamics">applies velocities, force and torque</param> /// <param name="applyDynamics">applies velocities, force and torque</param>
private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics) private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics)
{ {
PhysicsActor pa; if (ParentGroup.Scene != null)
{
float minsize = isPhysical ? ParentGroup.Scene.m_minPhys : ParentGroup.Scene.m_minNonphys;
float maxsize = isPhysical ? ParentGroup.Scene.m_maxPhys : ParentGroup.Scene.m_maxNonphys;
Vector3 scale = Scale;
scale.X = Util.Clamp(scale.X, minsize, maxsize);
scale.Y = Util.Clamp(scale.Y, minsize, maxsize);
scale.Z = Util.Clamp(scale.Z, minsize, maxsize);
Scale = scale;
}
PhysicsActor pa;
Vector3 velocity = Velocity; Vector3 velocity = Velocity;
Vector3 rotationalVelocity = AngularVelocity; ; Vector3 rotationalVelocity = AngularVelocity; ;