Code review feedback
This commit is contained in:
Родитель
73d7ca46be
Коммит
6230a4fdd5
|
@ -138,7 +138,7 @@ namespace
|
|||
pReverseRemapArray[i] = i;
|
||||
}
|
||||
|
||||
memcpy(&vOutVertexRemapBuffer.front(), pReverseRemapArray, (*nNewVerts) * sizeof(uint32_t));
|
||||
memcpy(vOutVertexRemapBuffer.data(), pReverseRemapArray, (*nNewVerts) * sizeof(uint32_t));
|
||||
memcpy(pOutIndexData, pNewIndexData, 3 * nFaces * sizeof(IndexType));
|
||||
|
||||
return S_OK;
|
||||
|
@ -377,12 +377,12 @@ namespace
|
|||
size_t outMeshNumVertices = 0;
|
||||
if (DXGI_FORMAT_R16_UINT == indexFormat)
|
||||
{
|
||||
hr = UVAtlasGetRealVertexRemap<uint16_t>(nFaces, nVerts, reinterpret_cast<const uint16_t*>(indices), reinterpret_cast<uint16_t*>(&vOutIndexBuffer.front()),
|
||||
hr = UVAtlasGetRealVertexRemap<uint16_t>(nFaces, nVerts, reinterpret_cast<const uint16_t*>(indices), reinterpret_cast<uint16_t*>(vOutIndexBuffer.data()),
|
||||
&outMeshNumVertices, vOutVertexRemapArray, forwardRemapArray);
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = UVAtlasGetRealVertexRemap<uint32_t>(nFaces, nVerts, reinterpret_cast<const uint32_t*>(indices), reinterpret_cast<uint32_t*>(&vOutIndexBuffer.front()),
|
||||
hr = UVAtlasGetRealVertexRemap<uint32_t>(nFaces, nVerts, reinterpret_cast<const uint32_t*>(indices), reinterpret_cast<uint32_t*>(vOutIndexBuffer.data()),
|
||||
&outMeshNumVertices, vOutVertexRemapArray, forwardRemapArray);
|
||||
}
|
||||
if (FAILED(hr))
|
||||
|
@ -404,10 +404,10 @@ namespace
|
|||
// copy old vertex data using remap array
|
||||
{
|
||||
auto bBaseIn = reinterpret_cast<const uint8_t*>(positions);
|
||||
auto bBaseOut = &vMeshOutVertexBuffer.front();
|
||||
auto bBaseOut = vMeshOutVertexBuffer.data();
|
||||
|
||||
uint32_t* pdwRemap = &vOutVertexRemapArray.front();
|
||||
auto pOutVerts = &vOutVertexBuffer.front();
|
||||
uint32_t* pdwRemap = vOutVertexRemapArray.data();
|
||||
auto pOutVerts = vOutVertexBuffer.data();
|
||||
|
||||
uint32_t* pForwardRemapArray = forwardRemapArray.get();
|
||||
|
||||
|
@ -528,7 +528,7 @@ namespace
|
|||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
auto pIsoVerts = &vTempVertexBuffer.front();
|
||||
auto pIsoVerts = vTempVertexBuffer.data();
|
||||
|
||||
// first transfer mesh position data into a vertex buffer that matches what
|
||||
// isochartpack is expecting (x,y,z,u,v)
|
||||
|
@ -538,13 +538,13 @@ namespace
|
|||
}
|
||||
|
||||
// copy index buffer for isochartpack
|
||||
memcpy(&vTempIndexBuffer.front(), &vMeshIndexBuffer.front(), vTempIndexBuffer.size());
|
||||
memcpy(vTempIndexBuffer.data(), vMeshIndexBuffer.data(), vTempIndexBuffer.size());
|
||||
|
||||
hr = IsochartRepacker::isochartpack2(&vTempVertexBuffer,
|
||||
nVerts,
|
||||
&vTempIndexBuffer,
|
||||
nFaces,
|
||||
&vPartitionResultAdjacency.front(),
|
||||
vPartitionResultAdjacency.data(),
|
||||
width,
|
||||
height,
|
||||
gutter,
|
||||
|
@ -556,7 +556,7 @@ namespace
|
|||
|
||||
// encode new texture coordinates in mesh
|
||||
{
|
||||
auto pOutVerts = &vTempVertexBuffer.front();
|
||||
auto pOutVerts = vTempVertexBuffer.data();
|
||||
|
||||
for (size_t i = 0; i < nVerts; i++)
|
||||
{
|
||||
|
|
|
@ -703,7 +703,7 @@ void CUVAtlasRepacker::CleanUp()
|
|||
template <class T>
|
||||
HRESULT CUVAtlasRepacker::GenerateAdjacentInfo()
|
||||
{
|
||||
auto ib = reinterpret_cast<const _Triangle<T> *>( &m_pvIndexBuffer->front() );
|
||||
auto ib = reinterpret_cast<const _Triangle<T> *>( m_pvIndexBuffer->data() );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -711,7 +711,7 @@ HRESULT CUVAtlasRepacker::GenerateAdjacentInfo()
|
|||
|
||||
if (m_pPartitionAdj)
|
||||
{
|
||||
memcpy(&m_AdjacentInfo.front(), m_pPartitionAdj, m_iNumFaces * 3 * sizeof(uint32_t));
|
||||
memcpy(m_AdjacentInfo.data(), m_pPartitionAdj, m_iNumFaces * 3 * sizeof(uint32_t));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -786,7 +786,7 @@ HRESULT CUVAtlasRepacker::GenerateNewBuffers()
|
|||
// create an attribute buffer
|
||||
m_vAttributeBuffer.resize(m_iNumFaces);
|
||||
|
||||
auto pAB = &m_vAttributeBuffer.front();
|
||||
auto pAB = m_vAttributeBuffer.data();
|
||||
for (size_t i = 0; i < m_iNumFaces; i++)
|
||||
pAB[i] = uint32_t(-1);
|
||||
|
||||
|
@ -800,8 +800,8 @@ HRESULT CUVAtlasRepacker::GenerateNewBuffers()
|
|||
for (size_t i = 0; i < m_iNumVertices; i++)
|
||||
m_IndexPartition[i] = uint32_t(-1);
|
||||
|
||||
auto pVB = reinterpret_cast<const uint8_t*>( &m_pvVertexBuffer->front() );
|
||||
auto pIB = reinterpret_cast<const uint8_t*>( &m_pvIndexBuffer->front() );
|
||||
auto pVB = reinterpret_cast<const uint8_t*>( m_pvVertexBuffer->data() );
|
||||
auto pIB = reinterpret_cast<const uint8_t*>( m_pvIndexBuffer->data() );
|
||||
|
||||
UVATLASATTRIBUTERANGE ar;
|
||||
|
||||
|
@ -1773,14 +1773,14 @@ void CUVAtlasRepacker::Normalize()
|
|||
void CUVAtlasRepacker::OutPutPackResult()
|
||||
{
|
||||
m_vFacePartitioning.resize(m_iNumFaces);
|
||||
memcpy(&m_vFacePartitioning.front(), &m_vAttributeBuffer.front(), m_iNumFaces * sizeof(uint32_t));
|
||||
memcpy(m_vFacePartitioning.data(), m_vAttributeBuffer.data(), m_iNumFaces * sizeof(uint32_t));
|
||||
|
||||
m_vAttributeID.resize(m_iNumFaces);
|
||||
memcpy(&m_vAttributeID.front(), &m_vAttributeBuffer.front(), m_iNumFaces * sizeof(uint32_t));
|
||||
memcpy(m_vAttributeID.data(), m_vAttributeBuffer.data(), m_iNumFaces * sizeof(uint32_t));
|
||||
|
||||
// copy the new UV coordinates from our vertex buffer to the original
|
||||
// vertex buffer according to the original vertex order
|
||||
auto pVB = reinterpret_cast<uint8_t*>( &m_pvVertexBuffer->front() );
|
||||
auto pVB = reinterpret_cast<uint8_t*>( m_pvVertexBuffer->data() );
|
||||
for (size_t i = 0; i < m_IndexPartition.size(); i++)
|
||||
{
|
||||
// handle the situation when the chart has only one vertex.
|
||||
|
@ -1839,8 +1839,8 @@ float CUVAtlasRepacker::GetChartArea(uint32_t index) const
|
|||
template <class T>
|
||||
float CUVAtlasRepacker::GetTotalArea() const
|
||||
{
|
||||
auto pVB = reinterpret_cast<const uint8_t*>( &m_pvVertexBuffer->front() );
|
||||
auto pIB = reinterpret_cast<const uint8_t*>( &m_pvIndexBuffer->front() );
|
||||
auto pVB = reinterpret_cast<const uint8_t*>( m_pvVertexBuffer->data() );
|
||||
auto pIB = reinterpret_cast<const uint8_t*>( m_pvIndexBuffer->data() );
|
||||
|
||||
float Area = 0;
|
||||
for (size_t i = 0; i < m_iNumFaces; i++)
|
||||
|
|
|
@ -971,7 +971,7 @@ HRESULT CIsochartEngine::InitializePacking(
|
|||
DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT;
|
||||
|
||||
if(FAILED(hr = m_baseInfo.Initialize(
|
||||
&pvVertexBuffer->front(),
|
||||
pvVertexBuffer->data(),
|
||||
VertexCount,
|
||||
dwVertexStride,
|
||||
FaceCount,
|
||||
|
@ -985,7 +985,7 @@ HRESULT CIsochartEngine::InitializePacking(
|
|||
if (FAILED(hr=ApplyInitEngine(
|
||||
m_baseInfo,
|
||||
IndexFormat,
|
||||
&pvFaceIndexBuffer->front(),
|
||||
pvFaceIndexBuffer->data(),
|
||||
false)))
|
||||
{
|
||||
goto LEnd;
|
||||
|
@ -1524,11 +1524,11 @@ HRESULT CIsochartEngine::FillExportVertexBuffer(
|
|||
auto pVertex = reinterpret_cast<const uint8_t*>(m_baseInfo.pVertexArray);
|
||||
assert(m_baseInfo.dwVertexStride >= sizeof(XMFLOAT3));
|
||||
|
||||
auto pVertexOut = &pvVertexBuffer->front();
|
||||
auto pVertexOut = pvVertexBuffer->data();
|
||||
|
||||
uint32_t* pdwBaseMap = nullptr;
|
||||
uint32_t* pdwMap = nullptr;
|
||||
pdwBaseMap = pdwMap = &pvMapBuffer->front();
|
||||
pdwBaseMap = pdwMap = pvMapBuffer->data();
|
||||
|
||||
for (size_t i=0; i<finalChartList.size(); i++)
|
||||
{
|
||||
|
@ -1588,7 +1588,7 @@ HRESULT CIsochartEngine::FillExportFaceIndexBuffer(
|
|||
uint32_t dwFaceId = 0;
|
||||
size_t dwOffset = 0;
|
||||
|
||||
auto pBaseFaces = reinterpret_cast<INDEXTYPE*>(&pvFaceBuffer->front());
|
||||
auto pBaseFaces = reinterpret_cast<INDEXTYPE*>(pvFaceBuffer->data());
|
||||
|
||||
INDEXTYPE* pFaces;
|
||||
for (size_t i=0; i<finalChartList.size(); i++)
|
||||
|
@ -1626,7 +1626,7 @@ HRESULT CIsochartEngine::FillExportFaceAttributeBuffer(
|
|||
{
|
||||
assert(pvAttributeBuffer != 0);
|
||||
|
||||
uint32_t* pAttributeID = &pvAttributeBuffer->front();
|
||||
uint32_t* pAttributeID = pvAttributeBuffer->data();
|
||||
|
||||
uint32_t dwFaceID = 0;
|
||||
|
||||
|
@ -1650,7 +1650,7 @@ HRESULT CIsochartEngine::FillExportFaceAdjacencyBuffer(
|
|||
{
|
||||
assert(pvAdjacencyBuffer != 0);
|
||||
|
||||
uint32_t* pdwAdj = &pvAdjacencyBuffer->front();
|
||||
uint32_t* pdwAdj = pvAdjacencyBuffer->data();
|
||||
|
||||
uint32_t dwFaceID = 0;
|
||||
|
||||
|
|
|
@ -464,7 +464,7 @@ HRESULT CIsochartMesh::AdjustToSameChartID(
|
|||
{
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
memset(&subChartIDCountList.front(), 0, sizeof(uint32_t)*subChartIDCountList.size());
|
||||
memset(subChartIDCountList.data(), 0, sizeof(uint32_t)*subChartIDCountList.size());
|
||||
for (size_t ii= 0; ii<dwCongFaceCount; ii++)
|
||||
{
|
||||
for (size_t jj=0; jj<allDiffSubChartIDList.size(); jj++)
|
||||
|
@ -646,7 +646,7 @@ HRESULT CIsochartMesh::SatifyUserSpecifiedRule(
|
|||
uint32_t dwBegin = 0;
|
||||
for (size_t ii=0; ii<congenerFaceCategoryLen.size(); ii++)
|
||||
{
|
||||
uint32_t *pCongFaceID = &congenerFaceCategories.front() + dwBegin;
|
||||
uint32_t *pCongFaceID = congenerFaceCategories.data() + dwBegin;
|
||||
uint32_t dwCongFaceCount = congenerFaceCategoryLen[ii];
|
||||
|
||||
bool bModifiedCurPass = false;
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Isochart
|
|||
public:
|
||||
void setZero()
|
||||
{
|
||||
memset(&front(), 0, size()*sizeof(value_type));
|
||||
memset(data(), 0, size()*sizeof(value_type));
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -101,7 +101,7 @@ namespace Isochart
|
|||
{
|
||||
return false;
|
||||
}
|
||||
memcpy(&dest.front(), &src.front(), src.size()*sizeof(T));
|
||||
memcpy(dest.data(), src.data(), src.size()*sizeof(T));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2518,7 +2518,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)
|
||||
|
@ -2547,7 +2547,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)
|
||||
|
|
|
@ -243,8 +243,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;
|
||||
|
||||
|
@ -283,7 +283,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;
|
||||
|
||||
|
@ -953,14 +953,14 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||
assert(facePartitioning.size() == nFaces);
|
||||
assert(vertexRemapArray.size() == vb.size());
|
||||
|
||||
hr = inMesh->UpdateFaces( nFaces, reinterpret_cast<const uint32_t*>( &ib.front() ) );
|
||||
hr = inMesh->UpdateFaces( nFaces, reinterpret_cast<const uint32_t*>( ib.data() ) );
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
wprintf(L"\nERROR: Failed applying atlas indices (%08X)\n", hr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
hr = inMesh->VertexRemap( &vertexRemapArray.front(), vertexRemapArray.size() );
|
||||
hr = inMesh->VertexRemap( vertexRemapArray.data(), vertexRemapArray.size() );
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
wprintf(L"\nERROR: Failed applying atlas vertex remap (%08X)\n", hr);
|
||||
|
@ -1119,7 +1119,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") )
|
||||
{
|
||||
|
@ -1135,7 +1135,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") )
|
||||
{
|
||||
|
@ -1178,11 +1178,11 @@ 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"))
|
||||
{
|
||||
hr = inMesh->ExportToCMO(outputPath, inMaterial.size(), inMaterial.empty() ? nullptr : &inMaterial.front());
|
||||
hr = inMesh->ExportToCMO(outputPath, inMaterial.size(), inMaterial.empty() ? nullptr : inMaterial.data());
|
||||
}
|
||||
if (FAILED(hr))
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче