CVertexBuffer: Eliminate implicit bool conversions

This commit is contained in:
Lioncash 2020-06-22 02:29:57 -04:00
parent 12cd221c48
commit 127712f459
2 changed files with 35 additions and 35 deletions

View File

@ -20,7 +20,7 @@ void CAudioManager::LoadAssets()
for (TResourceIterator<EResourceType::AudioGroup> It(mpProject->ResourceStore()); It; ++It)
{
if (auto* pGroup = static_cast<CAudioGroup*>(It->Load()))
mAudioGroups.push_back(pGroup);
mAudioGroups.emplace_back(pGroup);
}
std::sort(mAudioGroups.begin(), mAudioGroups.end(), [](const CAudioGroup *pLeft, const CAudioGroup *pRight) {

View File

@ -29,34 +29,34 @@ uint16 CVertexBuffer::AddVertex(const CVertex& rkVtx)
if (mPositions.size() == 0xFFFF)
throw std::overflow_error("VBO contains too many vertices");
if (mVtxDesc & EVertexAttribute::Position)
mPositions.push_back(rkVtx.Position);
if (mVtxDesc & EVertexAttribute::Normal)
mNormals.push_back(rkVtx.Normal);
if (mVtxDesc & EVertexAttribute::Color0)
mColors[0].push_back(rkVtx.Color[0]);
if (mVtxDesc & EVertexAttribute::Color1)
mColors[1].push_back(rkVtx.Color[1]);
if ((mVtxDesc & EVertexAttribute::Position) != 0)
mPositions.emplace_back(rkVtx.Position);
if ((mVtxDesc & EVertexAttribute::Normal) != 0)
mNormals.emplace_back(rkVtx.Normal);
if ((mVtxDesc & EVertexAttribute::Color0) != 0)
mColors[0].emplace_back(rkVtx.Color[0]);
if ((mVtxDesc & EVertexAttribute::Color1) != 0)
mColors[1].emplace_back(rkVtx.Color[1]);
for (size_t iTex = 0; iTex < mTexCoords.size(); iTex++)
{
if (mVtxDesc & (EVertexAttribute::Tex0 << iTex))
mTexCoords[iTex].push_back(rkVtx.Tex[iTex]);
if ((mVtxDesc & (EVertexAttribute::Tex0 << iTex)) != 0)
mTexCoords[iTex].emplace_back(rkVtx.Tex[iTex]);
}
for (size_t iMtx = 0; iMtx < mTexCoords.size(); iMtx++)
{
if (mVtxDesc & (EVertexAttribute::PosMtx << iMtx))
mTexCoords[iMtx].push_back(rkVtx.MatrixIndices[iMtx]);
if ((mVtxDesc & (EVertexAttribute::PosMtx << iMtx)) != 0)
mTexCoords[iMtx].emplace_back(rkVtx.MatrixIndices[iMtx]);
}
if (mVtxDesc.HasAnyFlags(EVertexAttribute::BoneIndices | EVertexAttribute::BoneWeights) && mpSkin)
if (mVtxDesc.HasAnyFlags(EVertexAttribute::BoneIndices | EVertexAttribute::BoneWeights) && mpSkin != nullptr)
{
const SVertexWeights& rkWeights = mpSkin->WeightsForVertex(rkVtx.ArrayPosition);
if (mVtxDesc & EVertexAttribute::BoneIndices)
mBoneIndices.push_back(rkWeights.Indices);
if (mVtxDesc & EVertexAttribute::BoneWeights)
mBoneWeights.push_back(rkWeights.Weights);
if ((mVtxDesc & EVertexAttribute::BoneIndices) != 0)
mBoneIndices.emplace_back(rkWeights.Indices);
if ((mVtxDesc & EVertexAttribute::BoneWeights) != 0)
mBoneWeights.emplace_back(rkWeights.Weights);
}
return mPositions.size() - 1;
@ -66,30 +66,30 @@ uint16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, uint16 Start)
{
if (Start < mPositions.size())
{
for (uint16 iVert = Start; iVert < mPositions.size(); iVert++)
for (size_t iVert = Start; iVert < mPositions.size(); iVert++)
{
// I use a bool because "continue" doesn't work properly within the iTex loop
bool Unique = false;
if (mVtxDesc & EVertexAttribute::Position)
if ((mVtxDesc & EVertexAttribute::Position) != 0)
{
if (rkVtx.Position != mPositions[iVert])
Unique = true;
}
if (!Unique && (mVtxDesc & EVertexAttribute::Normal))
if (!Unique && (mVtxDesc & EVertexAttribute::Normal) != 0)
{
if (rkVtx.Normal != mNormals[iVert])
Unique = true;
}
if (!Unique && (mVtxDesc & EVertexAttribute::Color0))
if (!Unique && (mVtxDesc & EVertexAttribute::Color0) != 0)
{
if (rkVtx.Color[0] != mColors[0][iVert])
Unique = true;
}
if (!Unique && (mVtxDesc & EVertexAttribute::Color1))
if (!Unique && (mVtxDesc & EVertexAttribute::Color1) != 0)
{
if (rkVtx.Color[1] != mColors[1][iVert])
Unique = true;
@ -99,7 +99,7 @@ uint16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, uint16 Start)
{
for (size_t iTex = 0; iTex < mTexCoords.size(); iTex++)
{
if (mVtxDesc & (EVertexAttribute::Tex0 << iTex))
if ((mVtxDesc & (EVertexAttribute::Tex0 << iTex)) != 0)
{
if (rkVtx.Tex[iTex] != mTexCoords[iTex][iVert])
{
@ -110,14 +110,14 @@ uint16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, uint16 Start)
}
}
if (!Unique && mpSkin && (mVtxDesc.HasAnyFlags(EVertexAttribute::BoneIndices | EVertexAttribute::BoneWeights)))
if (!Unique && mpSkin != nullptr && (mVtxDesc.HasAnyFlags(EVertexAttribute::BoneIndices | EVertexAttribute::BoneWeights)))
{
const SVertexWeights& rkWeights = mpSkin->WeightsForVertex(rkVtx.ArrayPosition);
for (uint32 iWgt = 0; iWgt < 4; iWgt++)
{
if (((mVtxDesc & EVertexAttribute::BoneIndices) && (rkWeights.Indices[iWgt] != mBoneIndices[iVert][iWgt])) ||
((mVtxDesc & EVertexAttribute::BoneWeights) && (rkWeights.Weights[iWgt] != mBoneWeights[iVert][iWgt])))
if (((mVtxDesc & EVertexAttribute::BoneIndices) != 0 && (rkWeights.Indices[iWgt] != mBoneIndices[iVert][iWgt])) ||
((mVtxDesc & EVertexAttribute::BoneWeights) != 0 && (rkWeights.Weights[iWgt] != mBoneWeights[iVert][iWgt])))
{
Unique = true;
break;
@ -126,7 +126,7 @@ uint16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, uint16 Start)
}
if (!Unique)
return iVert;
return static_cast<uint16>(iVert);
}
}
@ -137,28 +137,28 @@ void CVertexBuffer::Reserve(size_t Size)
{
const size_t ReserveSize = mPositions.size() + Size;
if (mVtxDesc & EVertexAttribute::Position)
if ((mVtxDesc & EVertexAttribute::Position) != 0)
mPositions.reserve(ReserveSize);
if (mVtxDesc & EVertexAttribute::Normal)
if ((mVtxDesc & EVertexAttribute::Normal) != 0)
mNormals.reserve(ReserveSize);
if (mVtxDesc & EVertexAttribute::Color0)
if ((mVtxDesc & EVertexAttribute::Color0) != 0)
mColors[0].reserve(ReserveSize);
if (mVtxDesc & EVertexAttribute::Color1)
if ((mVtxDesc & EVertexAttribute::Color1) != 0)
mColors[1].reserve(ReserveSize);
for (size_t iTex = 0; iTex < mTexCoords.size(); iTex++)
{
if (mVtxDesc & (EVertexAttribute::Tex0 << iTex))
if ((mVtxDesc & (EVertexAttribute::Tex0 << iTex)) != 0)
mTexCoords[iTex].reserve(ReserveSize);
}
if (mVtxDesc & EVertexAttribute::BoneIndices)
if ((mVtxDesc & EVertexAttribute::BoneIndices) != 0)
mBoneIndices.reserve(ReserveSize);
if (mVtxDesc & EVertexAttribute::BoneWeights)
if ((mVtxDesc & EVertexAttribute::BoneWeights) != 0)
mBoneWeights.reserve(ReserveSize);
}