diff --git a/Meshconvert/Mesh.cpp b/Meshconvert/Mesh.cpp index 30646e43..e360b392 100644 --- a/Meshconvert/Mesh.cpp +++ b/Meshconvert/Mesh.cpp @@ -2374,7 +2374,7 @@ HRESULT Mesh::ExportToSDKMESH(const wchar_t* szFileName, size_t nMaterials, cons // Write subsets DWORD bytesToWrite = static_cast( 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) @@ -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) diff --git a/Meshconvert/Meshconvert.cpp b/Meshconvert/Meshconvert.cpp index 98bb6699..1c942708 100644 --- a/Meshconvert/Meshconvert.cpp +++ b/Meshconvert/Meshconvert.cpp @@ -166,8 +166,8 @@ HRESULT LoadFromOBJ(const WCHAR* szFilename, std::unique_ptr& 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; @@ -206,7 +206,7 @@ HRESULT LoadFromOBJ(const WCHAR* szFilename, std::unique_ptr& inMesh, std: if (FAILED(hr)) return hr; - hr = vbr.AddStream(&wfReader.vertices.front(), wfReader.vertices.size(), 0, sizeof(WaveFrontReader::Vertex)); + hr = vbr.AddStream(wfReader.vertices.data(), wfReader.vertices.size(), 0, sizeof(WaveFrontReader::Vertex)); if (FAILED(hr)) return hr; @@ -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") ) { @@ -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") ) { diff --git a/Utilities/WaveFrontReader.h b/Utilities/WaveFrontReader.h index 3b715015..51e4699f 100644 --- a/Utilities/WaveFrontReader.h +++ b/Utilities/WaveFrontReader.h @@ -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 ) @@ -466,19 +466,19 @@ class WaveFrontReader return E_FAIL; vertices.resize( numVertices ); - vboFile.read( reinterpret_cast( &vertices.front() ), sizeof(Vertex) * numVertices ); + vboFile.read( reinterpret_cast( vertices.data() ), sizeof(Vertex) * numVertices ); #pragma warning( suppress : 4127 ) if ( sizeof( index_t ) == 2 ) { indices.resize( numIndices ); - vboFile.read( reinterpret_cast( &indices.front() ), sizeof(uint16_t) * numIndices ); + vboFile.read( reinterpret_cast( indices.data() ), sizeof(uint16_t) * numIndices ); } else { std::vector tmp; tmp.resize( numIndices ); - vboFile.read( reinterpret_cast( &tmp.front() ), sizeof(uint16_t) * numIndices ); + vboFile.read( reinterpret_cast( tmp.data() ), sizeof(uint16_t) * numIndices ); indices.reserve( numIndices ); for( auto it = tmp.cbegin(); it != tmp.cend(); ++it ) @@ -487,7 +487,7 @@ class WaveFrontReader } } - BoundingBox::CreateFromPoints( bounds, vertices.size(), reinterpret_cast( &vertices.front() ), sizeof(Vertex) ); + BoundingBox::CreateFromPoints( bounds, vertices.size(), reinterpret_cast( vertices.data() ), sizeof(Vertex) ); vboFile.close();