ubOde: represent small objects as a box. A object is small is all scale dimensions are less or equal to option MinSizeToMeshmerize (in ODEPhysicsSettings) with default of 0.1. This is needed because this objects hit narrow phase with high overlaps alot more, and so have high cpu cost.

0.9.0-post-fixes
UbitUmarov 2017-07-22 01:31:39 +01:00
parent 98c64f1aa9
commit d71d13f72b
2 changed files with 25 additions and 13 deletions

View File

@ -62,6 +62,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public byte shapetype; public byte shapetype;
public bool hasOBB; public bool hasOBB;
public bool hasMeshVolume; public bool hasMeshVolume;
public bool isTooSmall;
public MeshState meshState; public MeshState meshState;
public UUID? assetID; public UUID? assetID;
public meshWorkerCmnds comand; public meshWorkerCmnds comand;
@ -69,16 +70,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public class ODEMeshWorker public class ODEMeshWorker
{ {
private ILog m_log; private ILog m_log;
private ODEScene m_scene; private ODEScene m_scene;
private IMesher m_mesher; private IMesher m_mesher;
public bool meshSculptedPrim = true; public bool meshSculptedPrim = true;
public bool forceSimplePrimMeshing = false;
public float meshSculptLOD = 32; public float meshSculptLOD = 32;
public float MeshSculptphysicalLOD = 32; public float MeshSculptphysicalLOD = 32;
public float MinSizeToMeshmerize = 0.1f;
private OpenSim.Framework.BlockingQueue<ODEPhysRepData> workQueue = new OpenSim.Framework.BlockingQueue<ODEPhysRepData>(); private OpenSim.Framework.BlockingQueue<ODEPhysRepData> workQueue = new OpenSim.Framework.BlockingQueue<ODEPhysRepData>();
private bool m_running; private bool m_running;
@ -93,9 +92,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (pConfig != null) if (pConfig != null)
{ {
forceSimplePrimMeshing = pConfig.GetBoolean("force_simple_prim_meshing", forceSimplePrimMeshing);
meshSculptedPrim = pConfig.GetBoolean("mesh_sculpted_prim", meshSculptedPrim); meshSculptedPrim = pConfig.GetBoolean("mesh_sculpted_prim", meshSculptedPrim);
meshSculptLOD = pConfig.GetFloat("mesh_lod", meshSculptLOD); meshSculptLOD = pConfig.GetFloat("mesh_lod", meshSculptLOD);
MinSizeToMeshmerize = pConfig.GetFloat("mesh_min_size", MinSizeToMeshmerize);
MeshSculptphysicalLOD = pConfig.GetFloat("mesh_physical_lod", MeshSculptphysicalLOD); MeshSculptphysicalLOD = pConfig.GetFloat("mesh_physical_lod", MeshSculptphysicalLOD);
} }
m_running = true; m_running = true;
@ -288,6 +287,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{ {
PrimitiveBaseShape pbs = repData.pbs; PrimitiveBaseShape pbs = repData.pbs;
// check sculpts or meshs // check sculpts or meshs
Vector3 scale = pbs.Scale;
if(scale.X <= MinSizeToMeshmerize &&
scale.Y <= MinSizeToMeshmerize &&
scale.Z <= MinSizeToMeshmerize)
{
repData.isTooSmall = true;
return false;
}
if (pbs.SculptEntry) if (pbs.SculptEntry)
{ {
if (meshSculptedPrim) if (meshSculptedPrim)
@ -299,9 +308,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
return false; return false;
} }
if (forceSimplePrimMeshing)
return true;
// convex shapes have no holes // convex shapes have no holes
ushort profilehollow = pbs.ProfileHollow; ushort profilehollow = pbs.ProfileHollow;
if(repData.shapetype == 2) if(repData.shapetype == 2)
@ -554,10 +560,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
private void CalculateBasicPrimVolume(ODEPhysRepData repData) private void CalculateBasicPrimVolume(ODEPhysRepData repData)
{ {
PrimitiveBaseShape _pbs = repData.pbs;
Vector3 _size = repData.size; Vector3 _size = repData.size;
float volume = _size.X * _size.Y * _size.Z; // default float volume = _size.X * _size.Y * _size.Z; // default
if(repData.isTooSmall)
{
repData.volume = volume;
return;
}
PrimitiveBaseShape _pbs = repData.pbs;
float tmp; float tmp;
float hollowAmount = (float)_pbs.ProfileHollow * 2.0e-5f; float hollowAmount = (float)_pbs.ProfileHollow * 2.0e-5f;

View File

@ -1733,7 +1733,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
return true; return true;
} }
private void CreateGeom() private void CreateGeom(bool OverrideToBox)
{ {
bool hasMesh = false; bool hasMesh = false;
@ -1742,7 +1742,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if ((m_meshState & MeshState.MeshNoColide) != 0) if ((m_meshState & MeshState.MeshNoColide) != 0)
m_NoColide = true; m_NoColide = true;
else if(m_mesh != null) else if(!OverrideToBox && m_mesh != null)
{ {
if (GetMeshGeom()) if (GetMeshGeom())
hasMesh = true; hasMesh = true;
@ -1755,7 +1755,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{ {
IntPtr geo = IntPtr.Zero; IntPtr geo = IntPtr.Zero;
if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1 if (!OverrideToBox && _pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1
&& _size.X == _size.Y && _size.Y == _size.Z) && _size.X == _size.Y && _size.Y == _size.Z)
{ // it's a sphere { // it's a sphere
try try
@ -3180,7 +3180,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
primVolume = repData.volume; primVolume = repData.volume;
CreateGeom(); CreateGeom(repData.isTooSmall);
if (prim_geom != IntPtr.Zero) if (prim_geom != IntPtr.Zero)
{ {
@ -3256,7 +3256,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
primVolume = repData.volume; primVolume = repData.volume;
CreateGeom(); CreateGeom(repData.isTooSmall);
if (prim_geom != IntPtr.Zero) if (prim_geom != IntPtr.Zero)
{ {