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 // 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 CBone *pChild = pBone->ChildByIndex(iChild);
const CVector3f ChildPos = pkData ? pChild->TransformedPosition(*pkData) : pChild->Position(); const CVector3f ChildPos = pkData ? pChild->TransformedPosition(*pkData) : pChild->Position();

View File

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

View File

@ -6,7 +6,7 @@
void CSkeletonLoader::SetLocalBoneCoords(CBone *pBone) 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)); SetLocalBoneCoords(pBone->ChildByIndex(iChild));
if (pBone->mpParent) if (pBone->mpParent)

View File

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