CSkeleton: Make use of size_t where applicable

Prevents truncation warnings.
This commit is contained in:
Lioncash 2020-06-17 04:24:43 -04:00
parent 21d89d0a23
commit 32dafc6bb8
4 changed files with 19 additions and 16 deletions

View File

@ -131,7 +131,7 @@ void CSkeleton::Draw(FRenderOptions /*Options*/, const CBoneTransformData *pkDat
}
// Draw child links
for (uint32 iChild = 0; iChild < pBone->NumChildren(); iChild++)
for (size_t iChild = 0; iChild < pBone->NumChildren(); iChild++)
{
const CBone *pChild = pBone->ChildByIndex(iChild);
const CVector3f ChildPos = pkData ? pChild->TransformedPosition(*pkData) : pChild->Position();

View File

@ -73,8 +73,8 @@ public:
// Accessors
CSkeleton* Skeleton() const { return mpSkeleton; }
CBone* Parent() const { return mpParent; }
uint32 NumChildren() const { return mChildren.size(); }
CBone* ChildByIndex(uint32 Index) const { return mChildren[Index]; }
size_t NumChildren() const { return mChildren.size(); }
CBone* ChildByIndex(size_t Index) const { return mChildren[Index]; }
uint32 ID() const { return mID; }
CVector3f Position() const { return mPosition; }
CVector3f LocalPosition() const { return mLocalPosition; }

View File

@ -6,7 +6,7 @@
void CSkeletonLoader::SetLocalBoneCoords(CBone *pBone)
{
for (uint32 iChild = 0; iChild < pBone->NumChildren(); iChild++)
for (size_t iChild = 0; iChild < pBone->NumChildren(); iChild++)
SetLocalBoneCoords(pBone->ChildByIndex(iChild));
if (pBone->mpParent)

View File

@ -20,8 +20,8 @@ QModelIndex CSkeletonHierarchyModel::index(int Row, int Column, const QModelInde
return QModelIndex();
}
CBone *pBone = (CBone*) rkParent.internalPointer();
if (Row < (int) pBone->NumChildren())
auto *pBone = static_cast<CBone*>(rkParent.internalPointer());
if (Row < static_cast<int>(pBone->NumChildren()))
return createIndex(Row, Column, pBone->ChildByIndex(Row));
else
return QModelIndex();
@ -29,7 +29,7 @@ QModelIndex CSkeletonHierarchyModel::index(int Row, int Column, const QModelInde
QModelIndex CSkeletonHierarchyModel::parent(const QModelIndex& rkChild) const
{
CBone *pBone = (CBone*) rkChild.internalPointer();
auto *pBone = static_cast<CBone*>(rkChild.internalPointer());
if (pBone->Parent())
{
@ -40,10 +40,10 @@ QModelIndex CSkeletonHierarchyModel::parent(const QModelIndex& rkChild) const
{
CBone *pGrandparent = pParent->Parent();
for (uint32 iChild = 0; iChild < pGrandparent->NumChildren(); iChild++)
for (size_t iChild = 0; iChild < pGrandparent->NumChildren(); iChild++)
{
if (pGrandparent->ChildByIndex(iChild) == pParent)
return createIndex(iChild, 0, pParent);
return createIndex(static_cast<int>(iChild), 0, pParent);
}
}
@ -55,9 +55,11 @@ QModelIndex CSkeletonHierarchyModel::parent(const QModelIndex& rkChild) const
int CSkeletonHierarchyModel::rowCount(const QModelIndex& rkParent) const
{
if (!mpSkeleton) return 0;
CBone *pBone = (CBone*) rkParent.internalPointer();
return (pBone ? pBone->NumChildren() : 1);
if (!mpSkeleton)
return 0;
auto *pBone = static_cast<CBone*>(rkParent.internalPointer());
return pBone ? static_cast<int>(pBone->NumChildren()) : 1;
}
int CSkeletonHierarchyModel::columnCount(const QModelIndex& /*rkParent*/) const
@ -84,14 +86,15 @@ CBone* CSkeletonHierarchyModel::BoneForIndex(const QModelIndex& rkIndex) const
QModelIndex CSkeletonHierarchyModel::IndexForBone(CBone *pBone) const
{
CBone *pParent = pBone->Parent();
if (!pParent) return index(0, 0, QModelIndex());
if (!pParent)
return index(0, 0, QModelIndex());
QModelIndex ParentIndex = IndexForBone(pParent);
const QModelIndex ParentIndex = IndexForBone(pParent);
for (uint32 iChild = 0; iChild < pParent->NumChildren(); iChild++)
for (size_t iChild = 0; iChild < pParent->NumChildren(); iChild++)
{
if (pParent->ChildByIndex(iChild) == pBone)
return index(iChild, 0, ParentIndex);
return index(static_cast<int>(iChild), 0, ParentIndex);
}
return QModelIndex();