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.
parent
b8a7cbb9e9
commit
0cd99c74a7
|
@ -620,8 +620,7 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
}
|
}
|
||||||
else
|
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, true, false);
|
||||||
meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, false);
|
|
||||||
|
|
||||||
if (meshData != null)
|
if (meshData != null)
|
||||||
{
|
{
|
||||||
|
@ -694,8 +693,8 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Build a new hull in the physical world
|
// 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
|
// 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, false);
|
IMesh meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, true, false);
|
||||||
if (meshData != null)
|
if (meshData != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical);
|
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.
|
// Values for level of detail to be passed to the mesher.
|
||||||
|
|
|
@ -64,10 +64,15 @@ namespace OpenSim.Region.Physics.Manager
|
||||||
{
|
{
|
||||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
|
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)
|
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
|
// Remove the reference to the encoded JPEG2000 data so it can be GCed
|
||||||
primShape.SculptData = OpenMetaverse.Utils.EmptyBytes;
|
primShape.SculptData = OpenMetaverse.Utils.EmptyBytes;
|
||||||
|
|
|
@ -702,11 +702,16 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
|
|
||||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
|
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)
|
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
|
#if SPAM
|
||||||
m_log.DebugFormat("[MESH]: Creating mesh for {0}", primName);
|
m_log.DebugFormat("[MESH]: Creating mesh for {0}", primName);
|
||||||
#endif
|
#endif
|
||||||
|
@ -716,9 +721,12 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
|
|
||||||
// If this mesh has been created already, return it instead of creating another copy
|
// 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
|
// For large regions with 100k+ prims and hundreds of copies of each, this can save a GB or more of memory
|
||||||
key = primShape.GetMeshKey(size, lod);
|
if (shouldCache)
|
||||||
if (m_uniqueMeshes.TryGetValue(key, out mesh))
|
{
|
||||||
return mesh;
|
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.X < 0.01f) size.X = 0.01f;
|
||||||
if (size.Y < 0.01f) size.Y = 0.01f;
|
if (size.Y < 0.01f) size.Y = 0.01f;
|
||||||
|
@ -741,7 +749,10 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
// trim the vertex and triangle lists to free up memory
|
// trim the vertex and triangle lists to free up memory
|
||||||
mesh.TrimExcess();
|
mesh.TrimExcess();
|
||||||
|
|
||||||
m_uniqueMeshes.Add(key, mesh);
|
if (shouldCache)
|
||||||
|
{
|
||||||
|
m_uniqueMeshes.Add(key, mesh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mesh;
|
return mesh;
|
||||||
|
|
Loading…
Reference in New Issue