From b3d8b13214cba887a916a916a92a533f1b2ee94a Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Thu, 18 Nov 2021 16:52:11 +0100 Subject: [PATCH] Fix warnings --- CHANGELOG.md | 1 - include/reactphysics3d/collision/ContactManifoldInfo.h | 2 +- include/reactphysics3d/collision/ContactPair.h | 2 +- include/reactphysics3d/collision/HalfEdgeStructure.h | 6 +++--- .../reactphysics3d/collision/broadphase/DynamicAABBTree.h | 2 +- include/reactphysics3d/containers/Deque.h | 4 ++-- include/reactphysics3d/containers/Map.h | 2 +- include/reactphysics3d/containers/Set.h | 2 +- src/body/RigidBody.cpp | 4 ++-- src/collision/CollisionCallback.cpp | 8 ++++---- src/collision/HalfEdgeStructure.cpp | 8 ++++---- src/collision/OverlapCallback.cpp | 8 ++++---- src/collision/PolyhedronMesh.cpp | 2 +- src/collision/broadphase/DynamicAABBTree.cpp | 2 +- src/collision/narrowphase/NarrowPhaseInfoBatch.cpp | 4 ++-- src/systems/BroadPhaseSystem.cpp | 2 +- 16 files changed, 29 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e63fb1e2..dd939c42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,7 +66,6 @@ do not hesitate to take a look at the user manual. - Issue in copy-constructors in Map and Set classes - A lot of code warnings have been fixed - ## Version 0.8.0 (May 31, 2020) Note that this release contains some public API changes. Please read carefully the following changes before upgrading to this new version and diff --git a/include/reactphysics3d/collision/ContactManifoldInfo.h b/include/reactphysics3d/collision/ContactManifoldInfo.h index 0e45eed0..5d5726dd 100644 --- a/include/reactphysics3d/collision/ContactManifoldInfo.h +++ b/include/reactphysics3d/collision/ContactManifoldInfo.h @@ -58,7 +58,7 @@ struct ContactManifoldInfo { // -------------------- Methods -------------------- // /// Constructor - ContactManifoldInfo(uint64 pairId) : nbPotentialContactPoints(0), pairId(pairId) { + ContactManifoldInfo(uint64 pairId) : nbPotentialContactPoints(0), potentialContactPointsIndices{0}, pairId(pairId) { } diff --git a/include/reactphysics3d/collision/ContactPair.h b/include/reactphysics3d/collision/ContactPair.h index 5c3688b4..bebc6d73 100644 --- a/include/reactphysics3d/collision/ContactPair.h +++ b/include/reactphysics3d/collision/ContactPair.h @@ -94,7 +94,7 @@ struct ContactPair { /// Constructor ContactPair(uint64 pairId, Entity body1Entity, Entity body2Entity, Entity collider1Entity, Entity collider2Entity, uint32 contactPairIndex, bool collidingInPreviousFrame, bool isTrigger) - : pairId(pairId), nbPotentialContactManifolds(0), body1Entity(body1Entity), body2Entity(body2Entity), + : pairId(pairId), nbPotentialContactManifolds(0), potentialContactManifoldsIndices{0}, body1Entity(body1Entity), body2Entity(body2Entity), collider1Entity(collider1Entity), collider2Entity(collider2Entity), isAlreadyInIsland(false), contactPairIndex(contactPairIndex), contactManifoldsIndex(0), nbContactManifolds(0), contactPointsIndex(0), nbToTalContactPoints(0), collidingInPreviousFrame(collidingInPreviousFrame), isTrigger(isTrigger) { diff --git a/include/reactphysics3d/collision/HalfEdgeStructure.h b/include/reactphysics3d/collision/HalfEdgeStructure.h index 4e746a71..ef00ef53 100644 --- a/include/reactphysics3d/collision/HalfEdgeStructure.h +++ b/include/reactphysics3d/collision/HalfEdgeStructure.h @@ -57,10 +57,10 @@ class HalfEdgeStructure { Array faceVertices; // Index of the vertices of the face /// Constructor - Face(MemoryAllocator& allocator) : faceVertices(allocator) {} + Face(MemoryAllocator& allocator) : edgeIndex(0), faceVertices(allocator) {} /// Constructor - Face(Array vertices) : faceVertices(vertices) {} + Face(Array vertices) : edgeIndex(0), faceVertices(vertices) {} }; /// Vertex @@ -69,7 +69,7 @@ class HalfEdgeStructure { uint32 edgeIndex; // Index of one edge emanting from this vertex /// Constructor - Vertex(uint32 vertexCoordsIndex) : vertexPointIndex(vertexCoordsIndex) { } + Vertex(uint32 vertexCoordsIndex) : vertexPointIndex(vertexCoordsIndex), edgeIndex(0) { } }; private: diff --git a/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h b/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h index d565ca39..a29dce8b 100644 --- a/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h +++ b/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h @@ -241,7 +241,7 @@ class DynamicAABBTree { void* getNodeDataPointer(int32 nodeID) const; /// Report all shapes overlapping with all the shapes in the map in parameter - void reportAllShapesOverlappingWithShapes(const Array& nodesToTest, size_t startIndex, + void reportAllShapesOverlappingWithShapes(const Array& nodesToTest, uint32 startIndex, size_t endIndex, Array>& outOverlappingNodes) const; /// Report all shapes overlapping with the AABB given in parameter. diff --git a/include/reactphysics3d/containers/Deque.h b/include/reactphysics3d/containers/Deque.h index ae4b83a9..adb5430b 100644 --- a/include/reactphysics3d/containers/Deque.h +++ b/include/reactphysics3d/containers/Deque.h @@ -55,10 +55,10 @@ class Deque { // -------------------- Constants -------------------- // /// Number of items in a chunk - const uint64 CHUNK_NB_ITEMS = 17; + const uint8 CHUNK_NB_ITEMS = 17; /// First item index in a chunk - const uint64 CHUNK_FIRST_ITEM_INDEX = CHUNK_NB_ITEMS / 2; + const uint8 CHUNK_FIRST_ITEM_INDEX = CHUNK_NB_ITEMS / 2; // -------------------- Attributes -------------------- // diff --git a/include/reactphysics3d/containers/Map.h b/include/reactphysics3d/containers/Map.h index 7000cbb6..9c1f04aa 100755 --- a/include/reactphysics3d/containers/Map.h +++ b/include/reactphysics3d/containers/Map.h @@ -276,7 +276,7 @@ class Map { uint64* newBuckets = static_cast(mAllocator.allocate(capacity * sizeof(uint64))); // Allocate memory for the entries - const uint64 nbAllocatedEntries = static_cast(capacity * DEFAULT_LOAD_FACTOR); + const uint64 nbAllocatedEntries = static_cast(static_cast(capacity) * DEFAULT_LOAD_FACTOR); assert(nbAllocatedEntries > 0); Pair* newEntries = static_cast*>(mAllocator.allocate(nbAllocatedEntries * sizeof(Pair))); uint64* newNextEntries = static_cast(mAllocator.allocate(nbAllocatedEntries * sizeof(uint64))); diff --git a/include/reactphysics3d/containers/Set.h b/include/reactphysics3d/containers/Set.h index eb13d6cf..ec2d5717 100755 --- a/include/reactphysics3d/containers/Set.h +++ b/include/reactphysics3d/containers/Set.h @@ -275,7 +275,7 @@ class Set { uint64* newBuckets = static_cast(mAllocator.allocate(capacity * sizeof(uint64))); // Allocate memory for the entries - const uint64 nbAllocatedEntries = static_cast(capacity * DEFAULT_LOAD_FACTOR); + const uint64 nbAllocatedEntries = static_cast(static_cast(capacity) * DEFAULT_LOAD_FACTOR); assert(nbAllocatedEntries > 0); V* newEntries = static_cast(mAllocator.allocate(nbAllocatedEntries * sizeof(V))); uint64* newNextEntries = static_cast(mAllocator.allocate(nbAllocatedEntries * sizeof(uint64))); diff --git a/src/body/RigidBody.cpp b/src/body/RigidBody.cpp index adb88b6a..ecf4acd7 100644 --- a/src/body/RigidBody.cpp +++ b/src/body/RigidBody.cpp @@ -1005,8 +1005,8 @@ void RigidBody::resetOverlappingPairs() { // Get the currently overlapping pairs for this collider Array overlappingPairs = mWorld.mCollidersComponents.getOverlappingPairs(colliderEntities[i]); - const uint32 nbOverlappingPairs = overlappingPairs.size(); - for (uint32 j=0; j < nbOverlappingPairs; j++) { + const uint64 nbOverlappingPairs = overlappingPairs.size(); + for (uint64 j=0; j < nbOverlappingPairs; j++) { mWorld.mCollisionDetection.mOverlappingPairs.removePair(overlappingPairs[j]); } diff --git a/src/collision/CollisionCallback.cpp b/src/collision/CollisionCallback.cpp index 27812dee..92add3f0 100644 --- a/src/collision/CollisionCallback.cpp +++ b/src/collision/CollisionCallback.cpp @@ -83,8 +83,8 @@ CollisionCallback::CallbackData::CallbackData(Array mWorld(world) { // Filter the contact pairs to only keep the contact events (not the overlap/trigger events) - const uint32 nbContactPairs = mContactPairs->size(); - for (uint32 i=0; i < nbContactPairs; i++) { + const uint64 nbContactPairs = mContactPairs->size(); + for (uint64 i=0; i < nbContactPairs; i++) { // If the contact pair contains contacts (and is therefore not an overlap/trigger event) if (!(*mContactPairs)[i].isTrigger) { @@ -92,8 +92,8 @@ CollisionCallback::CallbackData::CallbackData(Array } } // Filter the lost contact pairs to only keep the contact events (not the overlap/trigger events) - const uint32 nbLostContactPairs = mLostContactPairs.size(); - for (uint32 i=0; i < nbLostContactPairs; i++) { + const uint64 nbLostContactPairs = mLostContactPairs.size(); + for (uint64 i=0; i < nbLostContactPairs; i++) { // If the contact pair contains contacts (and is therefore not an overlap/trigger event) if (!mLostContactPairs[i].isTrigger) { diff --git a/src/collision/HalfEdgeStructure.cpp b/src/collision/HalfEdgeStructure.cpp index e71e35e1..9387767e 100644 --- a/src/collision/HalfEdgeStructure.cpp +++ b/src/collision/HalfEdgeStructure.cpp @@ -44,7 +44,7 @@ void HalfEdgeStructure::init() { Array currentFaceEdges(mAllocator, mFaces[0].faceVertices.size()); // For each face - const uint32 nbFaces = mFaces.size(); + const uint32 nbFaces = static_cast(mFaces.size()); for (uint32 f=0; f < nbFaces; f++) { Face& face = mFaces[f]; @@ -52,7 +52,7 @@ void HalfEdgeStructure::init() { VerticesPair firstEdgeKey(0, 0); // For each vertex of the face - const uint32 nbFaceVertices = face.faceVertices.size(); + const uint32 nbFaceVertices = static_cast(face.faceVertices.size()); for (uint32 v=0; v < nbFaceVertices; v++) { uint32 v1Index = face.faceVertices[v]; uint32 v2Index = face.faceVertices[v == (face.faceVertices.size() - 1) ? 0 : v + 1]; @@ -84,7 +84,7 @@ void HalfEdgeStructure::init() { auto itEdge = edges.find(pairV2V1); if (itEdge != edges.end()) { - const uint32 edgeIndex = mEdges.size(); + const uint32 edgeIndex = static_cast(mEdges.size()); itEdge->second.twinEdgeIndex = edgeIndex + 1; edge.twinEdgeIndex = edgeIndex; @@ -109,7 +109,7 @@ void HalfEdgeStructure::init() { } // Set next edges - const uint32 nbEdges = mEdges.size(); + const uint32 nbEdges = static_cast(mEdges.size()); for (uint32 i=0; i < nbEdges; i++) { mEdges[i].nextEdgeIndex = mapEdgeToIndex[nextEdges[mapEdgeIndexToKey[i]]]; } diff --git a/src/collision/OverlapCallback.cpp b/src/collision/OverlapCallback.cpp index 67fbf069..08754033 100644 --- a/src/collision/OverlapCallback.cpp +++ b/src/collision/OverlapCallback.cpp @@ -72,8 +72,8 @@ OverlapCallback::CallbackData::CallbackData(Array& contactPairs, Ar mContactPairsIndices(world.mMemoryManager.getHeapAllocator()), mLostContactPairsIndices(world.mMemoryManager.getHeapAllocator()), mWorld(world) { // Filter the contact pairs to only keep the overlap/trigger events (not the contact events) - const uint32 nbContactPairs = mContactPairs.size(); - for (uint32 i=0; i < nbContactPairs; i++) { + const uint64 nbContactPairs = mContactPairs.size(); + for (uint64 i=0; i < nbContactPairs; i++) { // If the contact pair contains contacts (and is therefore not an overlap/trigger event) if (!onlyReportTriggers || mContactPairs[i].isTrigger) { @@ -81,8 +81,8 @@ OverlapCallback::CallbackData::CallbackData(Array& contactPairs, Ar } } // Filter the lost contact pairs to only keep the overlap/trigger events (not the contact events) - const uint32 nbLostContactPairs = mLostContactPairs.size(); - for (uint32 i=0; i < nbLostContactPairs; i++) { + const uint64 nbLostContactPairs = mLostContactPairs.size(); + for (uint i=0; i < nbLostContactPairs; i++) { // If the contact pair contains contacts (and is therefore not an overlap/trigger event) if (!onlyReportTriggers || mLostContactPairs[i].isTrigger) { diff --git a/src/collision/PolyhedronMesh.cpp b/src/collision/PolyhedronMesh.cpp index 52c3afaf..b7958441 100644 --- a/src/collision/PolyhedronMesh.cpp +++ b/src/collision/PolyhedronMesh.cpp @@ -213,7 +213,7 @@ decimal PolyhedronMesh::getFaceArea(uint32 faceIndex) const { Vector3 v1 = getVertex(face.faceVertices[0]); // For each vertex of the face - const uint32 nbFaceVertices = face.faceVertices.size(); + const uint32 nbFaceVertices = static_cast(face.faceVertices.size()); for (uint32 i=2; i < nbFaceVertices; i++) { const Vector3 v2 = getVertex(face.faceVertices[i-1]); diff --git a/src/collision/broadphase/DynamicAABBTree.cpp b/src/collision/broadphase/DynamicAABBTree.cpp index 0c284d17..75a8f9ab 100644 --- a/src/collision/broadphase/DynamicAABBTree.cpp +++ b/src/collision/broadphase/DynamicAABBTree.cpp @@ -587,7 +587,7 @@ int32 DynamicAABBTree::balanceSubTreeAtNode(int32 nodeID) { } /// Take an array of shapes to be tested for broad-phase overlap and return an array of pair of overlapping shapes -void DynamicAABBTree::reportAllShapesOverlappingWithShapes(const Array& nodesToTest, size_t startIndex, +void DynamicAABBTree::reportAllShapesOverlappingWithShapes(const Array& nodesToTest, uint32 startIndex, size_t endIndex, Array>& outOverlappingNodes) const { RP3D_PROFILE("DynamicAABBTree::reportAllShapesOverlappingWithAABB()", mProfiler); diff --git a/src/collision/narrowphase/NarrowPhaseInfoBatch.cpp b/src/collision/narrowphase/NarrowPhaseInfoBatch.cpp index 9109dd64..201052ee 100644 --- a/src/collision/narrowphase/NarrowPhaseInfoBatch.cpp +++ b/src/collision/narrowphase/NarrowPhaseInfoBatch.cpp @@ -52,7 +52,7 @@ void NarrowPhaseInfoBatch::reserveMemory() { // Clear all the objects in the batch void NarrowPhaseInfoBatch::clear() { - const uint32 nbNarrowPhaseInfos = narrowPhaseInfos.size(); + const uint32 nbNarrowPhaseInfos = static_cast(narrowPhaseInfos.size()); for (uint32 i=0; i < nbNarrowPhaseInfos; i++) { assert(narrowPhaseInfos[i].nbContactPoints == 0); @@ -76,7 +76,7 @@ void NarrowPhaseInfoBatch::clear() { // allocated in the next frame at a possibly different location in memory (remember that the // location of the allocated memory of a single frame allocator might change between two frames) - mCachedCapacity = narrowPhaseInfos.capacity(); + mCachedCapacity = static_cast(narrowPhaseInfos.capacity()); narrowPhaseInfos.clear(true); } diff --git a/src/systems/BroadPhaseSystem.cpp b/src/systems/BroadPhaseSystem.cpp index a2afa0ed..d155676e 100644 --- a/src/systems/BroadPhaseSystem.cpp +++ b/src/systems/BroadPhaseSystem.cpp @@ -217,7 +217,7 @@ void BroadPhaseSystem::computeOverlappingPairs(MemoryManager& memoryManager, Arr Array shapesToTest = mMovedShapes.toArray(memoryManager.getHeapAllocator()); // Ask the dynamic AABB tree to report all collision shapes that overlap with the shapes to test - mDynamicAABBTree.reportAllShapesOverlappingWithShapes(shapesToTest, 0, shapesToTest.size(), overlappingNodes); + mDynamicAABBTree.reportAllShapesOverlappingWithShapes(shapesToTest, 0, static_cast(shapesToTest.size()), overlappingNodes); // Reset the array of collision shapes that have move (or have been created) during the // last simulation step