limit number of prims on physical objects. Not all cases covered still

avinationmerge
UbitUmarov 2014-09-08 23:58:49 +01:00
parent 93143ba012
commit 8e15d4ad57
5 changed files with 78 additions and 3 deletions

View File

@ -2705,12 +2705,17 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
bool oldUsePhysics = (root.Flags & PrimFlags.Physics) != 0;
m_sceneGraph.LinkObjects(root, children);
ScenePresence sp;
if (TryGetScenePresence(agentId, out sp))
{
root.SendPropertiesToClient(sp.ControllingClient);
if (oldUsePhysics && (root.Flags & PrimFlags.Physics) == 0)
{
sp.ControllingClient.SendAlertMessage("Object physics canceled");
}
}
}

View File

@ -204,6 +204,12 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public int m_linksetCapacity = 0;
/// <summary>
/// Max prims an Physical object will hold
/// </summary>
///
public int m_linksetPhysCapacity = 5;
public bool m_clampPrimSize;
public bool m_trustBinaries;
public bool m_allowScriptCrossings;
@ -901,6 +907,9 @@ namespace OpenSim.Region.Framework.Scenes
m_linksetCapacity = RegionInfo.LinksetCapacity;
}
m_linksetPhysCapacity = startupConfig.GetInt("LinksetPhysPrims", m_linksetPhysCapacity);
SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);

View File

@ -1547,6 +1547,7 @@ namespace OpenSim.Region.Framework.Scenes
// VolumeDetect can't be set via UI and will always be off when a change is made there
// now only change volume dtc if phantom off
bool wantedPhys = UsePhysics;
if (PhysData.PhysShapeType == PhysShapeType.invalid) // check for extraPhysics data
{
bool vdtc;
@ -1563,10 +1564,17 @@ namespace OpenSim.Region.Framework.Scenes
if (part != null)
{
part.UpdateExtraPhysics(PhysData);
if (part.UpdatePhysRequired)
if (part.UpdatePhysRequired && remoteClient != null)
remoteClient.SendPartPhysicsProprieties(part);
}
}
if (wantedPhys != group.UsesPhysics && remoteClient != null)
{
remoteClient.SendAlertMessage("Object physics canceled because exceeds the limit of " +
m_parentScene.m_linksetPhysCapacity + " physical prims with shape type not set to None");
group.RootPart.ScheduleFullUpdate();
}
}
}
}

View File

@ -1712,7 +1712,9 @@ namespace OpenSim.Region.Framework.Scenes
m_rootPart.SetParentLocalId(0);
AttachmentPoint = (byte)0;
// must check if buildind should be true or false here
m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false);
// m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false);
ApplyPhysics();
HasGroupChanged = true;
RootPart.Rezzed = DateTime.Now;
RootPart.RemFlag(PrimFlags.TemporaryOnRez);
@ -2879,6 +2881,33 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
// physical prims count limit
// not very eficient :(
if (UsesPhysics && m_scene.m_linksetPhysCapacity > 0 && (PrimCount + objectGroup.PrimCount) >
m_scene.m_linksetPhysCapacity)
{
int cntr = 0;
foreach (SceneObjectPart part in Parts)
{
if (part.PhysicsShapeType != (byte)PhysicsShapeType.None)
cntr++;
}
foreach (SceneObjectPart part in objectGroup.Parts)
{
if (part.PhysicsShapeType != (byte)PhysicsShapeType.None)
cntr++;
}
if (cntr > m_scene.m_linksetPhysCapacity)
{
// cancel physics
RootPart.Flags &= ~PrimFlags.Physics;
ApplyPhysics();
}
}
// 'linkPart' == the root of the group being linked into this group
SceneObjectPart linkPart = objectGroup.m_rootPart;
@ -3477,8 +3506,12 @@ namespace OpenSim.Region.Framework.Scenes
{
SceneObjectPart[] parts = m_parts.GetArray();
if (Scene != null)
if (Scene != null && UsePhysics)
{
int maxprims = m_scene.m_linksetPhysCapacity;
bool checkShape = (maxprims > 0 &&
parts.Length > maxprims);
for (int i = 0; i < parts.Length; i++)
{
SceneObjectPart part = parts[i];
@ -3489,6 +3522,15 @@ namespace OpenSim.Region.Framework.Scenes
UsePhysics = false; // Reset physics
break;
}
if (checkShape && part.PhysicsShapeType != (byte)PhysicsShapeType.None)
{
if (--maxprims < 0)
{
UsePhysics = false;
break;
}
}
}
}

View File

@ -1400,6 +1400,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
SceneObjectGroup group = m_host.ParentGroup;
bool allow = true;
int maxprims = World.m_linksetPhysCapacity;
bool checkShape = (maxprims > 0 && group.PrimCount > maxprims);
foreach (SceneObjectPart part in group.Parts)
{
if (part.Scale.X > World.m_maxPhys || part.Scale.Y > World.m_maxPhys || part.Scale.Z > World.m_maxPhys)
@ -1407,6 +1410,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
allow = false;
break;
}
if (checkShape && part.PhysicsShapeType != (byte)PhysicsShapeType.None)
{
if (--maxprims < 0)
{
allow = false;
break;
}
}
}
if (!allow)