BulletSim: add expanded call to IMesher/Meshmerizer which enables/disables mesh caching. Since BulletSim caches and tracks the unmanaged memory version of meshes, the Meshmerizer itself does not need to cache built meshes once BulletSim has made the physical proxy mesh.

avinationmerge
Robert Adams 2012-11-29 09:24:53 -08:00
parent b8a7cbb9e9
commit 0cd99c74a7
4 changed files with 26 additions and 10 deletions

View File

@ -620,8 +620,7 @@ public sealed class BSShapeCollection : IDisposable
}
else
{
// Pass false for physicalness as this creates some sort of bounding box which we don't need
meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, false);
meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, true, false);
if (meshData != null)
{
@ -694,8 +693,8 @@ public sealed class BSShapeCollection : IDisposable
else
{
// Build a new hull in the physical world
// Pass false for physicalness as this creates some sort of bounding box which we don't need
IMesh meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, false);
// Pass true for physicalness as this creates some sort of bounding box which we don't need
IMesh meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, true, false);
if (meshData != null)
{

View File

@ -36,6 +36,7 @@ namespace OpenSim.Region.Physics.Manager
{
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod);
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical);
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache);
}
// Values for level of detail to be passed to the mesher.

View File

@ -64,10 +64,15 @@ namespace OpenSim.Region.Physics.Manager
{
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
{
return CreateMesh(primName, primShape, size, lod, false);
return CreateMesh(primName, primShape, size, lod, false, false);
}
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
{
return CreateMesh(primName, primShape, size, lod, false, false);
}
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache)
{
// Remove the reference to the encoded JPEG2000 data so it can be GCed
primShape.SculptData = OpenMetaverse.Utils.EmptyBytes;

View File

@ -702,11 +702,16 @@ namespace OpenSim.Region.Physics.Meshing
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
{
return CreateMesh(primName, primShape, size, lod, false);
return CreateMesh(primName, primShape, size, lod, false, true);
}
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
{
return CreateMesh(primName, primShape, size, lod, isPhysical, true);
}
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache)
{
#if SPAM
m_log.DebugFormat("[MESH]: Creating mesh for {0}", primName);
#endif
@ -716,9 +721,12 @@ namespace OpenSim.Region.Physics.Meshing
// If this mesh has been created already, return it instead of creating another copy
// For large regions with 100k+ prims and hundreds of copies of each, this can save a GB or more of memory
if (shouldCache)
{
key = primShape.GetMeshKey(size, lod);
if (m_uniqueMeshes.TryGetValue(key, out mesh))
return mesh;
}
if (size.X < 0.01f) size.X = 0.01f;
if (size.Y < 0.01f) size.Y = 0.01f;
@ -741,8 +749,11 @@ namespace OpenSim.Region.Physics.Meshing
// trim the vertex and triangle lists to free up memory
mesh.TrimExcess();
if (shouldCache)
{
m_uniqueMeshes.Add(key, mesh);
}
}
return mesh;
}