diff --git a/src/Core/Resource/Collision/CCollisionMeshGroup.h b/src/Core/Resource/Collision/CCollisionMeshGroup.h index 52a989d9..de20ffc1 100644 --- a/src/Core/Resource/Collision/CCollisionMeshGroup.h +++ b/src/Core/Resource/Collision/CCollisionMeshGroup.h @@ -17,8 +17,8 @@ public: explicit CCollisionMeshGroup(CResourceEntry *pEntry = nullptr) : CResource(pEntry) {} ~CCollisionMeshGroup() = default; - uint32 NumMeshes() const { return mMeshes.size(); } - CCollisionMesh* MeshByIndex(uint32 Index) const { return mMeshes[Index].get(); } + size_t NumMeshes() const { return mMeshes.size(); } + CCollisionMesh* MeshByIndex(size_t Index) const { return mMeshes[Index].get(); } void AddMesh(std::unique_ptr&& pMesh) { mMeshes.push_back(std::move(pMesh)); } void BuildRenderData() diff --git a/src/Core/Scene/CCollisionNode.cpp b/src/Core/Scene/CCollisionNode.cpp index 4a08854d..f1efa954 100644 --- a/src/Core/Scene/CCollisionNode.cpp +++ b/src/Core/Scene/CCollisionNode.cpp @@ -47,13 +47,13 @@ void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ER CColor BaseTint = TintColor(rkViewInfo); - for (uint32 MeshIdx = 0; MeshIdx < mpCollision->NumMeshes(); MeshIdx++) + for (size_t MeshIdx = 0; MeshIdx < mpCollision->NumMeshes(); MeshIdx++) { CCollisionMesh *pMesh = mpCollision->MeshByIndex(MeshIdx); CCollisionRenderData& RenderData = pMesh->GetRenderData(); const SCollisionIndexData& kIndexData = pMesh->GetIndexData(); - for (int MatIdx = 0; MatIdx < (int) kIndexData.Materials.size(); MatIdx++) + for (int MatIdx = 0; MatIdx < static_cast(kIndexData.Materials.size()); MatIdx++) { const CCollisionMaterial& kMat = kIndexData.Materials[MatIdx]; @@ -83,9 +83,9 @@ void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ER // Render bounding hierarchy if (rkViewInfo.CollisionSettings.DrawBoundingHierarchy) { - int Depth = rkViewInfo.CollisionSettings.BoundingHierarchyRenderDepth; + const int Depth = rkViewInfo.CollisionSettings.BoundingHierarchyRenderDepth; - for (uint MeshIdx = 0; MeshIdx < mpCollision->NumMeshes(); MeshIdx++) + for (size_t MeshIdx = 0; MeshIdx < mpCollision->NumMeshes(); MeshIdx++) { mpCollision->MeshByIndex(MeshIdx)->GetRenderData().RenderBoundingHierarchy(Depth); } @@ -124,17 +124,17 @@ void CCollisionNode::SetCollision(CCollisionMeshGroup *pCollision) { mpCollision = pCollision; - if (mpCollision) + if (!mpCollision) + return; + + mpCollision->BuildRenderData(); + + // Update bounds + mLocalAABox = CAABox::Infinite(); + + for (size_t MeshIdx = 0; MeshIdx < pCollision->NumMeshes(); MeshIdx++) { - mpCollision->BuildRenderData(); - - // Update bounds - mLocalAABox = CAABox::Infinite(); - - for (uint MeshIdx = 0; MeshIdx < pCollision->NumMeshes(); MeshIdx++) - { - CCollisionMesh* pMesh = pCollision->MeshByIndex(MeshIdx); - mLocalAABox.ExpandBounds(pMesh->Bounds()); - } + const CCollisionMesh* pMesh = pCollision->MeshByIndex(MeshIdx); + mLocalAABox.ExpandBounds(pMesh->Bounds()); } } diff --git a/src/Editor/CollisionEditor/CCollisionEditor.cpp b/src/Editor/CollisionEditor/CCollisionEditor.cpp index 9dae467c..1f467d28 100644 --- a/src/Editor/CollisionEditor/CCollisionEditor.cpp +++ b/src/Editor/CollisionEditor/CCollisionEditor.cpp @@ -31,11 +31,11 @@ CCollisionEditor::CCollisionEditor(CCollisionMeshGroup* pCollisionMesh, QWidget* mpUI->ToolBar->addWidget( new QLabel("OBBTree: ", this) ); int MaxDepth = 0; - for (uint MeshIdx = 0; MeshIdx < pCollisionMesh->NumMeshes(); MeshIdx++) + for (size_t MeshIdx = 0; MeshIdx < pCollisionMesh->NumMeshes(); MeshIdx++) { - CCollisionMesh* pMesh = pCollisionMesh->MeshByIndex(MeshIdx); - int MeshDepth = pMesh->GetRenderData().MaxBoundingHierarchyDepth(); - MaxDepth = Math::Max(MeshDepth, MaxDepth); + const CCollisionMesh* pMesh = pCollisionMesh->MeshByIndex(MeshIdx); + const int MeshDepth = pMesh->GetRenderData().MaxBoundingHierarchyDepth(); + MaxDepth = std::max(MeshDepth, MaxDepth); } QSlider* pOBBTreeSlider = new QSlider(this);