/// <summary>
/// Adds the vertex and index sets necessary for a builder instance
/// to iterate over the triangles in a mesh
/// </summary>
public void AddVertexAndIndexSets( AnyBuilder builder, int lodIndex )
{
var vertexSetCount = 0;
if ( this._sharedVertexData != null )
{
builder.AddVertexData( this._sharedVertexData );
vertexSetCount++;
}
// Prepare the builder using the submesh information
for ( var i = 0; i < this._subMeshList.Count; i++ )
{
var sm = this._subMeshList[ i ];
if ( sm.useSharedVertices )
{
// Use shared vertex data, index as set 0
if ( lodIndex == 0 )
{
// Use shared vertex data, index as set 0
builder.AddIndexData( sm.indexData, 0, sm.operationType );
}
else
{
builder.AddIndexData( sm.lodFaceList[ lodIndex - 1 ], 0, sm.operationType );
}
}
else
{
// own vertex data, add it and reference it directly
builder.AddVertexData( sm.vertexData );
if ( lodIndex == 0 )
{
// base index data
builder.AddIndexData( sm.indexData, vertexSetCount++, sm.operationType );
}
else
{
// LOD index data
builder.AddIndexData( sm.lodFaceList[ lodIndex - 1 ], vertexSetCount++, sm.operationType );
}
}
}
}