This commit is contained in:
Chuck Walbourn 2021-08-26 17:16:49 -07:00
Родитель c6a2afa72f
Коммит de9bc0d306
6 изменённых файлов: 49 добавлений и 49 удалений

Просмотреть файл

@ -382,9 +382,9 @@ namespace
assert((nVerts + dupVerts.size()) == curNewVert);
#ifndef NDEBUG
for (auto it = dupVerts.begin(); it != dupVerts.end(); ++it)
for (const auto it : dupVerts)
{
assert(*it < nVerts);
assert(it < nVerts);
}
#endif
}

Просмотреть файл

@ -584,22 +584,22 @@ HRESULT DirectX::OptimizeFacesLRUEx(
memset(faceRemap, 0, sizeof(uint32_t) * nFaces);
for (auto it = subsets.cbegin(); it != subsets.cend(); ++it)
for (const auto& it : subsets)
{
if (it->first >= nFaces)
if (it.first >= nFaces)
return E_UNEXPECTED;
if ((uint64_t(it->first) + uint64_t(it->second)) >= UINT32_MAX)
if ((uint64_t(it.first) + uint64_t(it.second)) >= UINT32_MAX)
return HRESULT_E_ARITHMETIC_OVERFLOW;
uint32_t faceMax = uint32_t(it->first + it->second);
uint32_t faceMax = uint32_t(it.first + it.second);
if (faceMax > nFaces)
return E_UNEXPECTED;
HRESULT hr = OptimizeFacesImpl<uint16_t>(
&indices[it->first * 3], static_cast<uint32_t>(it->second * 3),
&faceRemap[it->first], lruCacheSize, uint32_t(it->first));
&indices[it.first * 3], static_cast<uint32_t>(it.second * 3),
&faceRemap[it.first], lruCacheSize, uint32_t(it.first));
if (FAILED(hr))
return hr;
}
@ -637,22 +637,22 @@ HRESULT DirectX::OptimizeFacesLRUEx(
memset(faceRemap, 0, sizeof(uint32_t) * nFaces);
for (auto it = subsets.cbegin(); it != subsets.cend(); ++it)
for (const auto& it : subsets)
{
if (it->first >= nFaces)
if (it.first >= nFaces)
return E_UNEXPECTED;
if ((uint64_t(it->first) + uint64_t(it->second)) >= UINT32_MAX)
if ((uint64_t(it.first) + uint64_t(it.second)) >= UINT32_MAX)
return HRESULT_E_ARITHMETIC_OVERFLOW;
uint32_t faceMax = uint32_t(it->first + it->second);
uint32_t faceMax = uint32_t(it.first + it.second);
if (faceMax > nFaces)
return E_UNEXPECTED;
HRESULT hr = OptimizeFacesImpl<uint32_t>(
&indices[it->first * 3], static_cast<uint32_t>(it->second * 3),
&faceRemap[it->first], lruCacheSize, uint32_t(it->first));
&indices[it.first * 3], static_cast<uint32_t>(it.second * 3),
&faceRemap[it.first], lruCacheSize, uint32_t(it.first));
if (FAILED(hr))
return hr;
}

Просмотреть файл

@ -53,18 +53,18 @@ namespace
mMaxSubset = 0;
mTotalFaces = nFaces;
for (auto it = subsets.cbegin(); it != subsets.cend(); ++it)
for (const auto& it : subsets)
{
if ((uint64_t(it->first) + uint64_t(it->second)) >= UINT32_MAX)
if ((uint64_t(it.first) + uint64_t(it.second)) >= UINT32_MAX)
return HRESULT_E_ARITHMETIC_OVERFLOW;
if (it->second > mMaxSubset)
if (it.second > mMaxSubset)
{
mMaxSubset = it->second;
mMaxSubset = it.second;
}
uint32_t faceOffset = uint32_t(it->first);
uint32_t faceMax = uint32_t(it->first + it->second);
uint32_t faceOffset = uint32_t(it.first);
uint32_t faceMax = uint32_t(it.first + it.second);
for (uint32_t face = faceOffset; face < faceMax; ++face)
{
@ -529,9 +529,9 @@ namespace
memset(faceRemapInverse.get(), 0xff, sizeof(uint32_t) * nFaces);
for (auto it = subsets.cbegin(); it != subsets.cend(); ++it)
for (const auto& it : subsets)
{
hr = status.setSubset(indices, nFaces, it->first, it->second);
hr = status.setSubset(indices, nFaces, it.first, it.second);
if (FAILED(hr))
return hr;
@ -550,7 +550,7 @@ namespace
for (;;)
{
assert(face != UNUSED32);
faceRemapInverse[face] = uint32_t(curface + it->first);
faceRemapInverse[face] = uint32_t(curface + it.first);
curface += 1;
// if at end of strip, break out
@ -615,9 +615,9 @@ namespace
assert(vertexCache >= restart);
uint32_t desired = vertexCache - restart;
for (auto it = subsets.cbegin(); it != subsets.cend(); ++it)
for (const auto& it : subsets)
{
hr = status.setSubset(indices, nFaces, it->first, it->second);
hr = status.setSubset(indices, nFaces, it.first, it.second);
if (FAILED(hr))
return hr;
@ -691,7 +691,7 @@ namespace
assert(curCorner.first != UNUSED32);
status.mark(curCorner.first);
faceRemapInverse[curCorner.first] = uint32_t(curface + it->first);
faceRemapInverse[curCorner.first] = uint32_t(curface + it.first);
curface += 1;
assert(indices[curCorner.first * 3] != index_t(-1));

Просмотреть файл

@ -1612,22 +1612,22 @@ HRESULT Mesh::ExportToCMO(const wchar_t* szFileName, size_t nMaterials, const Ma
return hr;
size_t startIndex = 0;
for (auto it = subsets.cbegin(); it != subsets.end(); ++it)
for (const auto& it : subsets)
{
SubMesh smesh;
smesh.MaterialIndex = mAttributes[it->first];
smesh.MaterialIndex = mAttributes[it.first];
if (smesh.MaterialIndex >= nMaterials)
smesh.MaterialIndex = 0;
smesh.IndexBufferIndex = 0;
smesh.VertexBufferIndex = 0;
smesh.StartIndex = static_cast<UINT>(startIndex);
smesh.PrimCount = static_cast<UINT>(it->second);
smesh.PrimCount = static_cast<UINT>(it.second);
hr = write_file(hFile.get(), smesh);
if (FAILED(hr))
return hr;
if ((startIndex + (it->second * 3)) > mnFaces * 3)
if ((startIndex + (it.second * 3)) > mnFaces * 3)
return E_FAIL;
startIndex += static_cast<size_t>(uint64_t(smesh.PrimCount) * 3);
@ -2227,18 +2227,18 @@ HRESULT Mesh::ExportToSDKMESH(const wchar_t* szFileName,
auto subsets = ComputeSubsets(mAttributes.get(), mnFaces);
UINT64 startIndex = 0;
for (auto it = subsets.cbegin(); it != subsets.cend(); ++it)
for (const auto& it : subsets)
{
subsetArray.push_back(static_cast<UINT>(submeshes.size()));
SDKMESH_SUBSET s = {};
s.MaterialID = mAttributes[it->first];
s.MaterialID = mAttributes[it.first];
if (s.MaterialID >= nMaterials)
s.MaterialID = 0;
s.PrimitiveType = PT_TRIANGLE_LIST;
s.IndexStart = startIndex;
s.IndexCount = uint64_t(it->second) * 3;
s.IndexCount = uint64_t(it.second) * 3;
s.VertexCount = mnVerts;
submeshes.push_back(s);

Просмотреть файл

@ -125,26 +125,26 @@ HRESULT LoadFromOBJ(
inMaterial.clear();
inMaterial.reserve(wfReader.materials.size());
for (auto it = wfReader.materials.cbegin(); it != wfReader.materials.cend(); ++it)
for (const auto& it : wfReader.materials)
{
Mesh::Material mtl = {};
mtl.name = it->strName;
mtl.specularPower = (it->bSpecular) ? float(it->nShininess) : 1.f;
mtl.alpha = it->fAlpha;
mtl.ambientColor = it->vAmbient;
mtl.diffuseColor = it->vDiffuse;
mtl.specularColor = (it->bSpecular) ? it->vSpecular : XMFLOAT3(0.f, 0.f, 0.f);
mtl.emissiveColor = (it->bEmissive) ? it->vEmissive : XMFLOAT3(0.f, 0.f, 0.f);
mtl.name = it.strName;
mtl.specularPower = (it.bSpecular) ? float(it.nShininess) : 1.f;
mtl.alpha = it.fAlpha;
mtl.ambientColor = it.vAmbient;
mtl.diffuseColor = it.vDiffuse;
mtl.specularColor = (it.bSpecular) ? it.vSpecular : XMFLOAT3(0.f, 0.f, 0.f);
mtl.emissiveColor = (it.bEmissive) ? it.vEmissive : XMFLOAT3(0.f, 0.f, 0.f);
mtl.texture = ProcessTextureFileName(it->strTexture, dds);
mtl.normalTexture = ProcessTextureFileName(it->strNormalTexture, dds);
mtl.specularTexture = ProcessTextureFileName(it->strSpecularTexture, dds);
if (it->bEmissive)
mtl.texture = ProcessTextureFileName(it.strTexture, dds);
mtl.normalTexture = ProcessTextureFileName(it.strNormalTexture, dds);
mtl.specularTexture = ProcessTextureFileName(it.strSpecularTexture, dds);
if (it.bEmissive)
{
mtl.emissiveTexture = ProcessTextureFileName(it->strEmissiveTexture, dds);
mtl.emissiveTexture = ProcessTextureFileName(it.strEmissiveTexture, dds);
}
mtl.rmaTexture = ProcessTextureFileName(it->strRMATexture, dds);
mtl.rmaTexture = ProcessTextureFileName(it.strRMATexture, dds);
inMaterial.push_back(mtl);
}

Просмотреть файл

@ -619,9 +619,9 @@ public:
vboFile.read(reinterpret_cast<char*>(tmp.data()), sizeof(uint16_t) * numIndices);
indices.reserve(numIndices);
for (auto it = tmp.cbegin(); it != tmp.cend(); ++it)
for (const auto it : tmp)
{
indices.emplace_back(*it);
indices.emplace_back(it);
}
}