Skip to content

Commit

Permalink
Code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed Oct 20, 2015
1 parent 4fa870d commit 9d544ed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Meshconvert/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@ HRESULT Mesh::ExportToSDKMESH(const wchar_t* szFileName, size_t nMaterials, cons
// Write subsets
DWORD bytesToWrite = static_cast<DWORD>( sizeof(SDKMESH_SUBSET) * submeshes.size() );
DWORD bytesWritten;
if ( !WriteFile(hFile.get(), &submeshes.front(), bytesToWrite, &bytesWritten, nullptr) )
if ( !WriteFile(hFile.get(), submeshes.data(), bytesToWrite, &bytesWritten, nullptr) )
return HRESULT_FROM_WIN32(GetLastError());

if (bytesWritten != bytesToWrite)
Expand Down Expand Up @@ -2403,7 +2403,7 @@ HRESULT Mesh::ExportToSDKMESH(const wchar_t* szFileName, size_t nMaterials, cons
// Write subset index list
assert(meshHeader.NumSubsets == subsetArray.size());
bytesToWrite = meshHeader.NumSubsets * sizeof(UINT);
if (!WriteFile(hFile.get(), &subsetArray.front(), bytesToWrite, &bytesWritten, nullptr))
if (!WriteFile(hFile.get(), subsetArray.data(), bytesToWrite, &bytesWritten, nullptr))
return HRESULT_FROM_WIN32(GetLastError());

if (bytesWritten != bytesToWrite)
Expand Down
10 changes: 5 additions & 5 deletions Meshconvert/Meshconvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ HRESULT LoadFromOBJ(const WCHAR* szFilename, std::unique_ptr<Mesh>& inMesh, std:
if (wfReader.indices.empty() || wfReader.vertices.empty())
return E_FAIL;

hr = inMesh->SetIndexData(wfReader.indices.size() / 3, &wfReader.indices.front(),
wfReader.attributes.empty() ? nullptr : &wfReader.attributes.front());
hr = inMesh->SetIndexData(wfReader.indices.size() / 3, wfReader.indices.data(),
wfReader.attributes.empty() ? nullptr : wfReader.attributes.data());
if (FAILED(hr))
return hr;

Expand Down Expand Up @@ -206,7 +206,7 @@ HRESULT LoadFromOBJ(const WCHAR* szFilename, std::unique_ptr<Mesh>& inMesh, std:
if (FAILED(hr))
return hr;

hr = vbr.AddStream(&wfReader.vertices.front(), wfReader.vertices.size(), 0, sizeof(WaveFrontReader<uint32_t>::Vertex));
hr = vbr.AddStream(wfReader.vertices.data(), wfReader.vertices.size(), 0, sizeof(WaveFrontReader<uint32_t>::Vertex));
if (FAILED(hr))
return hr;

Expand Down Expand Up @@ -674,7 +674,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
}
else if ( !_wcsicmp(outputExt, L".sdkmesh") )
{
hr = inMesh->ExportToSDKMESH(outputPath, inMaterial.size(), inMaterial.empty() ? nullptr : &inMaterial.front());
hr = inMesh->ExportToSDKMESH(outputPath, inMaterial.size(), inMaterial.empty() ? nullptr : inMaterial.data());
}
else if ( !_wcsicmp(outputExt, L".cmo") )
{
Expand All @@ -690,7 +690,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1;
}

hr = inMesh->ExportToCMO(outputPath, inMaterial.size(), inMaterial.empty() ? nullptr : &inMaterial.front());
hr = inMesh->ExportToCMO(outputPath, inMaterial.size(), inMaterial.empty() ? nullptr : inMaterial.data());
}
else if ( !_wcsicmp(outputExt, L".x") )
{
Expand Down
10 changes: 5 additions & 5 deletions Utilities/WaveFrontReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class WaveFrontReader
// Cleanup
InFile.close();

BoundingBox::CreateFromPoints( bounds, positions.size(), &positions.front(), sizeof(XMFLOAT3) );
BoundingBox::CreateFromPoints( bounds, positions.size(), positions.data(), sizeof(XMFLOAT3) );

// If an associated material file was found, read that in as well.
if( *strMaterialFilename )
Expand Down Expand Up @@ -466,19 +466,19 @@ class WaveFrontReader
return E_FAIL;

vertices.resize( numVertices );
vboFile.read( reinterpret_cast<char*>( &vertices.front() ), sizeof(Vertex) * numVertices );
vboFile.read( reinterpret_cast<char*>( vertices.data() ), sizeof(Vertex) * numVertices );

#pragma warning( suppress : 4127 )
if ( sizeof( index_t ) == 2 )
{
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 );
}
else
{
std::vector<uint16_t> tmp;
tmp.resize( numIndices );
vboFile.read( reinterpret_cast<char*>( &tmp.front() ), sizeof(uint16_t) * numIndices );
vboFile.read( reinterpret_cast<char*>( tmp.data() ), sizeof(uint16_t) * numIndices );

indices.reserve( numIndices );
for( auto it = tmp.cbegin(); it != tmp.cend(); ++it )
Expand All @@ -487,7 +487,7 @@ class WaveFrontReader
}
}

BoundingBox::CreateFromPoints( bounds, vertices.size(), reinterpret_cast<const XMFLOAT3*>( &vertices.front() ), sizeof(Vertex) );
BoundingBox::CreateFromPoints( bounds, vertices.size(), reinterpret_cast<const XMFLOAT3*>( vertices.data() ), sizeof(Vertex) );

vboFile.close();

Expand Down

0 comments on commit 9d544ed

Please sign in to comment.