6 FinalizeIB
Chuck Walbourn редактировал(а) эту страницу 2022-01-20 17:34:24 -08:00
DirectXMesh

Finishes mesh optimization by updating an index buffer based on a vertex remap.

HRESULT FinalizeIB(
   const uint16_t* ibin, size_t nFaces,
   const uint32_t* vertexRemap, size_t nVerts,
   uint16_t* ibout );

HRESULT FinalizeIB(
   uint16_t* ib, size_t nFaces,
   const uint32_t* vertexRemap, size_t nVerts );
HRESULT FinalizeIB(
   const uint3_t* ibin, size_t nFaces,
   const uint32_t* vertexRemap, size_t nVerts,
   uint32_t* ibout );

HRESULT FinalizeIB(
   uint32_t* ib, size_t nFaces,
   const uint32_t* vertexRemap, size_t nVerts );

Parameters

A vertexRemap is an array with nVerts elements that describes how to reorder the vertices of the original mesh (i.e. oldLoc = vertexRemap[newLoc]). See OptimizeVertices.

Remarks

This should be done after all required face reordering. See ReorderIB and ReorderIBAndAdjacency.

This is the pseudo-code for how to apply a vertex remap to an index buffer:

for each j in nVerts
    vertexRemapInverse[ vertexRemap[ j ] ] = j

for each i in (nFaces *3 )
   newIndices[ i ] = vertexRemapInverse[ indices[ i ] ]