Skip to content

Commit

Permalink
Constify variables in utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed Feb 22, 2022
1 parent 02a6cbb commit 3b01f9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions Utilities/FlexibleVertexFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace FVF
if ((fvfCode & ((D3DFVF_RESERVED0 | D3DFVF_RESERVED2) & ~D3DFVF_POSITION_MASK)) != 0)
return 0;

size_t numCoords = (fvfCode & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
const size_t numCoords = (fvfCode & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
if (numCoords > 8)
return 0;

Expand Down Expand Up @@ -132,7 +132,7 @@ namespace FVF
if (pDecl->Type >= std::size(g_declTypeSizes))
return 0;

size_t slotSize = g_declTypeSizes[pDecl->Type];
const size_t slotSize = g_declTypeSizes[pDecl->Type];
if (currentSize < slotSize + pDecl->Offset)
currentSize = slotSize + pDecl->Offset;
}
Expand Down Expand Up @@ -171,7 +171,7 @@ namespace FVF
if (pDecl->Type >= std::size(g_declTypeSizes))
return 0;

size_t slotSize = g_declTypeSizes[pDecl->Type];
const size_t slotSize = g_declTypeSizes[pDecl->Type];
if (currentSize < slotSize + pDecl->Offset)
currentSize = slotSize + pDecl->Offset;
}
Expand Down Expand Up @@ -215,7 +215,7 @@ namespace FVF
if ((fvfCode & ((D3DFVF_RESERVED0 | D3DFVF_RESERVED2) & ~D3DFVF_POSITION_MASK)) != 0)
return false;

uint32_t nTexCoords = (fvfCode & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
const uint32_t nTexCoords = (fvfCode & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
if (nTexCoords > 8)
return false;

Expand Down Expand Up @@ -336,7 +336,7 @@ namespace FVF
{
for (uint32_t t = 0; t < nTexCoords; ++t)
{
size_t texCoordSize = s_texCoordSizes[(fvfCode >> (16 + t * 2)) & 0x3];
const size_t texCoordSize = s_texCoordSizes[(fvfCode >> (16 + t * 2)) & 0x3];

// D3DDECLTYPE_FLOAT1 = 0, D3DDECLTYPE_FLOAT4 = 3
decl.emplace_back(
Expand Down Expand Up @@ -378,7 +378,7 @@ namespace FVF
if ((fvfCode & ((D3DFVF_RESERVED0 | D3DFVF_RESERVED2) & ~D3DFVF_POSITION_MASK)) != 0)
return false;

uint32_t nTexCoords = (fvfCode & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
const uint32_t nTexCoords = (fvfCode & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
if (nTexCoords > 8)
return false;

Expand Down Expand Up @@ -483,7 +483,7 @@ namespace FVF
{
for (uint32_t t = 0; t < nTexCoords; ++t)
{
size_t index = (fvfCode >> (16 + t * 2)) & 0x3;
const size_t index = (fvfCode >> (16 + t * 2)) & 0x3;
il.emplace_back(
D3D11_INPUT_ELEMENT_DESC{ "TEXCOORD", static_cast<UINT>(t),
s_texCoordFormats[index],
Expand Down
8 changes: 4 additions & 4 deletions Utilities/WaveFrontReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class WaveFrontReader
// list. Store the index in the Indices array. The Vertices and Indices
// lists will eventually become the Vertex Buffer and Index Buffer for
// the mesh.
uint32_t index = AddVertex(vertexIndex, &vertex, vertexCache);
const uint32_t index = AddVertex(vertexIndex, &vertex, vertexCache);
if (index == uint32_t(-1))
return E_OUTOFMEMORY;

Expand All @@ -281,7 +281,7 @@ class WaveFrontReader
bool faceEnd = false;
for (;;)
{
wchar_t p = InFile.peek();
const wchar_t p = InFile.peek();

if ('\n' == p || !InFile)
{
Expand All @@ -305,12 +305,12 @@ class WaveFrontReader
}

// Convert polygons to triangles
uint32_t i0 = faceIndex[0];
const uint32_t i0 = faceIndex[0];
uint32_t i1 = faceIndex[1];

for (size_t j = 2; j < iFace; ++j)
{
uint32_t index = faceIndex[j];
const uint32_t index = faceIndex[j];
indices.emplace_back(static_cast<index_t>(i0));
if (ccw)
{
Expand Down

0 comments on commit 3b01f9c

Please sign in to comment.