Updated for vector data method
Родитель
3690d66c89
Коммит
91df82b26c
4
Clean.md
4
Clean.md
|
@ -53,12 +53,12 @@ This is an initial step in performing full mesh optimization, particularly the a
|
|||
pos[ j ] = mesh->vertices[ j ].position;
|
||||
|
||||
std::unique_ptr<uint32_t[]> adj( new uint32_t[ mesh->indices.size() ] );
|
||||
if ( FAILED( GenerateAdjacencyAndPointReps( &mesh->indices.front(), nFaces,
|
||||
if ( FAILED( GenerateAdjacencyAndPointReps( mesh->indices.data(), nFaces,
|
||||
pos.get(), nVerts, 0.f, nullptr, adj.get() ) ) )
|
||||
// Error
|
||||
|
||||
std::unique_ptr<uint16_t[]> indices( new uint16_t[ nFaces * 3 ] );
|
||||
memcpy( indices.get(), &mesh->indices.front(), sizeof(uint16_t) * nFaces * 3 ) );
|
||||
memcpy( indices.get(), mesh->indices.data(), sizeof(uint16_t) * nFaces * 3 ) );
|
||||
|
||||
std::vector<uint32_t> dupVerts;
|
||||
hr = Clean( indices.get(), nFaces, nVerts, adj.get(), nullptr, dupVerts, true );
|
||||
|
|
|
@ -41,7 +41,7 @@ These functions assume the triangular mesh description is valid. See [[Validate]
|
|||
pos[ j ] = mesh->vertices[ j ].position;
|
||||
|
||||
std::unique_ptr<XMFLOAT3[]> normals( new XMFLOAT3[ nVerts ] );
|
||||
if ( FAILED( ComputeNormals( &mesh->indices.front(), nFaces,
|
||||
if ( FAILED( ComputeNormals( mesh->indices.data(), nFaces,
|
||||
pos.get(), nVerts, CNORM_DEFAULT, normals.get() ) ) )
|
||||
// Error
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ Due to the C++ overload resolution rules, if you want to call ComputeTangentFram
|
|||
|
||||
std::unique_ptr<XMFLOAT3[]> bitangents( new XMFLOAT3[ nVerts ] );
|
||||
|
||||
if ( FAILED( ComputeTangentFrame( &mesh->indices.front(), nFaces,
|
||||
if ( FAILED( ComputeTangentFrame( mesh->indices.data(), nFaces,
|
||||
pos.get(), normals.get(), texcoords.get(), nVerts,
|
||||
static_cast<XMFLOAT3*>(nullptr), bitangents.get() ) ) )
|
||||
// Error
|
||||
|
@ -84,7 +84,7 @@ Due to the C++ overload resolution rules, if you want to call ComputeTangentFram
|
|||
|
||||
std::unique_ptr<XMFLOAT3[]> normals( new XMFLOAT3[ nVerts ] );
|
||||
|
||||
if ( FAILED( ComputeNormals( &mesh->indices.front(), nFaces,
|
||||
if ( FAILED( ComputeNormals( mesh->indices.data(), nFaces,
|
||||
pos.get(), nVerts, CNORM_DEFAULT, normals.get() ) ) )
|
||||
// Error
|
||||
|
||||
|
@ -98,7 +98,7 @@ Due to the C++ overload resolution rules, if you want to call ComputeTangentFram
|
|||
std::unique_ptr<XMFLOAT3[]> tangents( new XMFLOAT3[ nVerts ] );
|
||||
std::unique_ptr<XMFLOAT3[]> bitangents( new XMFLOAT3[ nVerts ] );
|
||||
|
||||
if ( FAILED( ComputeTangentFrame( &mesh->indices.front(), nFaces,
|
||||
if ( FAILED( ComputeTangentFrame( mesh->indices.data(), nFaces,
|
||||
pos.get(), normals.get(), texcoords.get(), nVerts,
|
||||
tangents.get(), bitangents.get() ) ) )
|
||||
// Error
|
||||
|
|
|
@ -42,13 +42,13 @@ This computes a topological adjacency:
|
|||
|
||||
std::unique_ptr<uint32_t[]> adj( new uint32_t[ mesh->indices.size() ] );
|
||||
if ( FAILED ( GenerateAdjacencyAndPointReps(
|
||||
&mesh->indices.front(), nFaces,
|
||||
mesh->indices.data(), nFaces,
|
||||
pos.get(), nVerts, 0.f, nullptr, adj.get() ) ) )
|
||||
// Error
|
||||
|
||||
Changing the last statement to use a non-zero epsilon returns a geometric adjacency:
|
||||
|
||||
if ( FAILED ( GenerateAdjacencyAndPointReps(
|
||||
&mesh->indices.front(), nFaces,
|
||||
mesh->indices.data(), nFaces,
|
||||
pos.get(), nVerts, 1e-5f, nullptr, adj.get() ) ) )
|
||||
// Error
|
|
@ -66,17 +66,17 @@ Degenerate and 'unused' faces are skipped by the optimization, so they do not ap
|
|||
pos[ j ] = mesh->vertices[ j ].position;
|
||||
|
||||
std::unique_ptr<uint32_t[]> adj( new uint32_t[ mesh->indices.size() ] );
|
||||
if ( FAILED( GenerateAdjacencyAndPointReps( &mesh->indices.front(), nFaces,
|
||||
if ( FAILED( GenerateAdjacencyAndPointReps( mesh->indices.data(), nFaces,
|
||||
pos.get(), nVerts, 0.f, nullptr, adj.get() ) ) )
|
||||
// Error
|
||||
|
||||
std::unique_ptr<uint32_t[]> faceRemap( new uint32_t[ nFaces ] );
|
||||
if ( FAILED( OptimizeFaces( &mesh->indices.front(), nFaces, adj.get(),
|
||||
if ( FAILED( OptimizeFaces( mesh->indices.data(), nFaces, adj.get(),
|
||||
faceRemap.get() ) ) )
|
||||
// Error
|
||||
|
||||
std::unique_ptr<uint16_t[]> newIndices( new uint16_t[ nFaces * 3 ] );
|
||||
if ( FAILED( ReorderIB( &mesh->indices.front(), nFaces, faceRemap.get(),
|
||||
if ( FAILED( ReorderIB( mesh->indices.data(), nFaces, faceRemap.get(),
|
||||
newIndices.get() ) ) )
|
||||
// Error
|
||||
|
||||
|
|
|
@ -52,12 +52,12 @@ Degenerate and 'unused' faces are skipped by the optimization, so they do not ap
|
|||
size_t nFaces = mesh->indices.size() / 3;
|
||||
|
||||
std::unique_ptr<uint32_t[]> faceRemap( new uint32_t[ nFaces ] );
|
||||
if ( FAILED( OptimizeFacesLRU( &mesh->indices.front(), nFaces,
|
||||
if ( FAILED( OptimizeFacesLRU( mesh->indices.data(), nFaces,
|
||||
faceRemap.get() ) ) )
|
||||
// Error
|
||||
|
||||
std::unique_ptr<uint16_t[]> newIndices( new uint16_t[ nFaces * 3 ] );
|
||||
if ( FAILED( ReorderIB( &mesh->indices.front(), nFaces, faceRemap.get(),
|
||||
if ( FAILED( ReorderIB( mesh->indices.data(), nFaces, faceRemap.get(),
|
||||
newIndices.get() ) ) )
|
||||
// Error
|
||||
|
||||
|
|
|
@ -33,17 +33,17 @@ Any 'unused' vertices are eliminated and the extra space is left at the end of t
|
|||
pos[ j ] = mesh->vertices[ j ].position;
|
||||
|
||||
std::unique_ptr<uint32_t[]> adj( new uint32_t[ mesh->indices.size() ] );
|
||||
if ( FAILED( GenerateAdjacencyAndPointReps( &mesh->indices.front(), nFaces,
|
||||
if ( FAILED( GenerateAdjacencyAndPointReps( mesh->indices.data(), nFaces,
|
||||
pos.get(), nVerts, 0.f, nullptr, adj.get() ) ) )
|
||||
// Error
|
||||
|
||||
std::unique_ptr<uint32_t[]> faceRemap( new uint32_t[ nFaces ] );
|
||||
if ( FAILED( OptimizeFaces( &mesh->indices.front(), nFaces, adj.get(),
|
||||
if ( FAILED( OptimizeFaces( mesh->indices.data(), nFaces, adj.get(),
|
||||
faceRemap.get() ) ) )
|
||||
// Error
|
||||
|
||||
std::unique_ptr<uint16_t[]> newIndices( new uint16_t[ nFaces * 3 ] );
|
||||
if ( FAILED( ReorderIB( &mesh->indices.front(), nFaces,
|
||||
if ( FAILED( ReorderIB( mesh->indices.data(), nFaces,
|
||||
faceRemap.get(), newIndices.get() ) ) )
|
||||
// Error
|
||||
|
||||
|
@ -57,7 +57,7 @@ Any 'unused' vertices are eliminated and the extra space is left at the end of t
|
|||
std::unique_ptr<WaveFrontReader<uint16_t>::Vertex> vb(
|
||||
new WaveFrontReader<uint16_t>::Vertex[ nVerts ] );
|
||||
|
||||
if ( FAILED( FinalizeVB( &mesh->vertices.front(),
|
||||
if ( FAILED( FinalizeVB( mesh->vertices.data(),
|
||||
sizeof(WaveFrontReader<uint16_t>::Vertex),
|
||||
nVerts, nullptr, 0, vertRemap.get(), vb.get() ) ) )
|
||||
// Error
|
||||
|
|
4
VBO.md
4
VBO.md
|
@ -33,8 +33,8 @@ The ResourceLoading sample used a vertex layout of ``{ XMFLOAT3 position, XMFLOA
|
|||
|
||||
std::vector<Vertex> vertices;
|
||||
vertices.resize( numVertices );
|
||||
vboFile.read( reinterpret_cast<char*>( &vertices.front() ), sizeof(Vertex) * numVertices );
|
||||
vboFile.read( reinterpret_cast<char*>( vertices.data() ), sizeof(Vertex) * numVertices );
|
||||
|
||||
std::vector<uint16_t> indices;
|
||||
indices.resize( numIndices );
|
||||
vboFile.read( reinterpret_cast<char*>( &indices.front() ), sizeof(uint16_t) * numIndices );
|
||||
vboFile.read( reinterpret_cast<char*>( indices.data() ), sizeof(uint16_t) * numIndices );
|
||||
|
|
|
@ -42,7 +42,7 @@ Other possible failure codes include ``E_INVALIDARG`` and ``E_OUTOFMEMORY``.
|
|||
size_t nFaces = mesh->indices.size() / 3;
|
||||
size_t nVerts = mesh->vertices.size();
|
||||
|
||||
hr = Validate( &mesh->indices.front(), nFaces, nVerts, nullptr, VALIDATE_DEFAULT );
|
||||
hr = Validate( mesh->indices.data(), nFaces, nVerts, nullptr, VALIDATE_DEFAULT );
|
||||
if ( FAILED(hr) )
|
||||
// E_FAIL indicates that mesh failed validation
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче