diff --git a/src/Core/OpenGL/CVertexBuffer.cpp b/src/Core/OpenGL/CVertexBuffer.cpp index 1bc4e14f..1586adbb 100644 --- a/src/Core/OpenGL/CVertexBuffer.cpp +++ b/src/Core/OpenGL/CVertexBuffer.cpp @@ -270,7 +270,7 @@ void CVertexBuffer::SetSkin(CSkin *pSkin) mpSkin = pSkin; } -uint32 CVertexBuffer::Size() const +size_t CVertexBuffer::Size() const { return mPositions.size(); } diff --git a/src/Core/OpenGL/CVertexBuffer.h b/src/Core/OpenGL/CVertexBuffer.h index cef82df8..d5a2460f 100644 --- a/src/Core/OpenGL/CVertexBuffer.h +++ b/src/Core/OpenGL/CVertexBuffer.h @@ -37,7 +37,7 @@ public: FVertexDescription VertexDesc() const; void SetVertexDesc(FVertexDescription Desc); void SetSkin(CSkin *pSkin); - uint32 Size() const; + size_t Size() const; GLuint CreateVAO(); }; diff --git a/src/Core/Resource/Collision/CCollisionRenderData.cpp b/src/Core/Resource/Collision/CCollisionRenderData.cpp index 78498e3e..51878861 100644 --- a/src/Core/Resource/Collision/CCollisionRenderData.cpp +++ b/src/Core/Resource/Collision/CCollisionRenderData.cpp @@ -1,6 +1,8 @@ #include "CCollisionRenderData.h" #include #include +#include +#include /** Build from collision data */ void CCollisionRenderData::BuildRenderData(const SCollisionIndexData& kIndexData) @@ -21,10 +23,10 @@ void CCollisionRenderData::BuildRenderData(const SCollisionIndexData& kIndexData // Build list of triangle indices sorted by material index // Apparently some collision meshes have more triangle indices than actual triangles - uint NumTris = Math::Min(kIndexData.TriangleIndices.size() / 3, kIndexData.TriangleMaterialIndices.size()); - std::vector SortedTris(NumTris, 0); + const uint NumTris = std::min(kIndexData.TriangleIndices.size() / 3, kIndexData.TriangleMaterialIndices.size()); + std::vector SortedTris(NumTris); - for (uint16 i=0; i(mVertexBuffer.Size()); + const uint16 Index1 = Index0 + 1; + const uint16 Index2 = Index1 + 1; CVertex Vtx; Vtx.Normal = TriNormal; @@ -168,7 +167,7 @@ void CCollisionRenderData::BuildBoundingHierarchyRenderData(const SOBBTreeNode* pkNode->Transform * CTransform4f::ScaleMatrix(pkNode->Radii); // Transform a 1x1x1 unit cube using the transform... - static const CVector3f skUnitCubeVertices[] = { + static constexpr std::array skUnitCubeVertices{ CVector3f(-1, -1, -1), CVector3f(-1, -1, 1), CVector3f(-1, 1, -1), @@ -179,14 +178,14 @@ void CCollisionRenderData::BuildBoundingHierarchyRenderData(const SOBBTreeNode* CVector3f( 1, 1, 1) }; - for (uint i=0; i<8; i++) + for (const auto& vert : skUnitCubeVertices) { - CVector3f Transformed = CombinedTransform * skUnitCubeVertices[i]; - mBoundingVertexBuffer.AddVertex( CVertex(Transformed) ); + const CVector3f Transformed = CombinedTransform * vert; + mBoundingVertexBuffer.AddVertex(CVertex(Transformed)); } // Add corresponding indices - static const uint16 skUnitCubeWireIndices[24] = { + static constexpr std::array skUnitCubeWireIndices{ 0, 1, 1, 3, 3, 2, @@ -200,10 +199,11 @@ void CCollisionRenderData::BuildBoundingHierarchyRenderData(const SOBBTreeNode* 2, 6, 3, 7 }; - uint FirstIndex = mBoundingVertexBuffer.Size() - 8; - for (uint i=0; i<24; i++) + + const size_t FirstIndex = mBoundingVertexBuffer.Size() - 8; + for (const uint16 index : skUnitCubeWireIndices) { - mBoundingIndexBuffer.AddIndex(skUnitCubeWireIndices[i] + FirstIndex); + mBoundingIndexBuffer.AddIndex(static_cast(index + FirstIndex)); } } }