BulletSim: make removing zero width triangles from meshes optional

and, for the moment, default to 'off'.
user_profiles
Robert Adams 2013-02-05 17:19:55 -08:00
parent dce9e323f4
commit 3646361279
4 changed files with 33 additions and 24 deletions

View File

@ -62,6 +62,7 @@ public static class BSParam
public static bool ShouldMeshSculptedPrim { get; private set; } // cause scuplted prims to get meshed
public static bool ShouldForceSimplePrimMeshing { get; private set; } // if a cube or sphere, let Bullet do internal shapes
public static bool ShouldUseHullsForPhysicalObjects { get; private set; } // 'true' if should create hulls for physical objects
public static bool ShouldRemoveZeroWidthTriangles { get; private set; }
public static float TerrainImplementation { get; private set; }
public static float TerrainFriction { get; private set; }
@ -218,6 +219,11 @@ public static class BSParam
(s,cf,p,v) => { ShouldUseHullsForPhysicalObjects = cf.GetBoolean(p, BSParam.BoolNumeric(v)); },
(s) => { return BSParam.NumericBool(ShouldUseHullsForPhysicalObjects); },
(s,p,l,v) => { ShouldUseHullsForPhysicalObjects = BSParam.BoolNumeric(v); } ),
new ParameterDefn("ShouldRemoveZeroWidthTriangles", "If true, remove degenerate triangles from meshes",
ConfigurationParameters.numericFalse,
(s,cf,p,v) => { ShouldRemoveZeroWidthTriangles = cf.GetBoolean(p, BSParam.BoolNumeric(v)); },
(s) => { return BSParam.NumericBool(ShouldRemoveZeroWidthTriangles); },
(s,p,l,v) => { ShouldRemoveZeroWidthTriangles = BSParam.BoolNumeric(v); } ),
new ParameterDefn("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)",
32f,

View File

@ -640,13 +640,15 @@ public sealed class BSShapeCollection : IDisposable
{
int[] indices = meshData.getIndexListAsInt();
// int realIndicesIndex = indices.Length;
int realIndicesIndex = indices.Length;
float[] verticesAsFloats = meshData.getVertexListAsFloat();
if (BSParam.ShouldRemoveZeroWidthTriangles)
{
// Remove degenerate triangles. These are triangles with two of the vertices
// are the same. This is complicated by the problem that vertices are not
// made unique in sculpties so we have to compare the values in the vertex.
int realIndicesIndex = 0;
realIndicesIndex = 0;
for (int tri = 0; tri < indices.Length; tri += 3)
{
int v1 = indices[tri + 0] * 3;
@ -670,6 +672,7 @@ public sealed class BSShapeCollection : IDisposable
realIndicesIndex += 3;
}
}
}
DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,origTri={1},realTri={2},numVerts={3}",
BSScene.DetailLogZero, indices.Length / 3, realIndicesIndex / 3, verticesAsFloats.Length / 3);

Binary file not shown.

Binary file not shown.