From 3050c83b0d49a40f5de8c39cc14c14d5ee80647d Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Tue, 17 Aug 2021 07:14:39 +0200 Subject: [PATCH] Fix warnings --- include/reactphysics3d/collision/shapes/BoxShape.h | 2 +- .../reactphysics3d/collision/shapes/ConcaveShape.h | 2 +- include/reactphysics3d/collision/shapes/SphereShape.h | 4 ++-- .../reactphysics3d/collision/shapes/TriangleShape.h | 4 ++-- include/reactphysics3d/containers/Map.h | 4 ++-- include/reactphysics3d/engine/Entity.h | 3 --- include/reactphysics3d/engine/EventListener.h | 4 ++-- include/reactphysics3d/memory/DefaultAllocator.h | 2 +- .../narrowphase/CapsuleVsCapsuleAlgorithm.cpp | 2 +- src/collision/narrowphase/SAT/SATAlgorithm.cpp | 4 ++-- .../narrowphase/SphereVsCapsuleAlgorithm.cpp | 2 +- src/collision/narrowphase/SphereVsSphereAlgorithm.cpp | 2 +- src/collision/shapes/BoxShape.cpp | 2 +- src/collision/shapes/CapsuleShape.cpp | 4 ++-- src/collision/shapes/ConvexMeshShape.cpp | 4 ++-- src/collision/shapes/HeightFieldShape.cpp | 9 ++++++--- src/collision/shapes/SphereShape.cpp | 2 +- src/collision/shapes/TriangleShape.cpp | 2 +- src/engine/Entity.cpp | 11 ----------- 19 files changed, 29 insertions(+), 40 deletions(-) diff --git a/include/reactphysics3d/collision/shapes/BoxShape.h b/include/reactphysics3d/collision/shapes/BoxShape.h index a94df5b5..4670ac54 100644 --- a/include/reactphysics3d/collision/shapes/BoxShape.h +++ b/include/reactphysics3d/collision/shapes/BoxShape.h @@ -186,7 +186,7 @@ RP3D_FORCE_INLINE Vector3 BoxShape::getLocalSupportPointWithoutMargin(const Vect } // Return true if a point is inside the collision shape -RP3D_FORCE_INLINE bool BoxShape::testPointInside(const Vector3& localPoint, Collider* collider) const { +RP3D_FORCE_INLINE bool BoxShape::testPointInside(const Vector3& localPoint, Collider* /*collider*/) const { return (localPoint.x < mHalfExtents[0] && localPoint.x > -mHalfExtents[0] && localPoint.y < mHalfExtents[1] && localPoint.y > -mHalfExtents[1] && localPoint.z < mHalfExtents[2] && localPoint.z > -mHalfExtents[2]); diff --git a/include/reactphysics3d/collision/shapes/ConcaveShape.h b/include/reactphysics3d/collision/shapes/ConcaveShape.h index b49f2e27..7da85c4a 100644 --- a/include/reactphysics3d/collision/shapes/ConcaveShape.h +++ b/include/reactphysics3d/collision/shapes/ConcaveShape.h @@ -130,7 +130,7 @@ RP3D_FORCE_INLINE bool ConcaveShape::isPolyhedron() const { } // Return true if a point is inside the collision shape -RP3D_FORCE_INLINE bool ConcaveShape::testPointInside(const Vector3& localPoint, Collider* collider) const { +RP3D_FORCE_INLINE bool ConcaveShape::testPointInside(const Vector3& /*localPoint*/, Collider* /*collider*/) const { return false; } diff --git a/include/reactphysics3d/collision/shapes/SphereShape.h b/include/reactphysics3d/collision/shapes/SphereShape.h index 6db4d4cd..6203e8b8 100644 --- a/include/reactphysics3d/collision/shapes/SphereShape.h +++ b/include/reactphysics3d/collision/shapes/SphereShape.h @@ -145,7 +145,7 @@ RP3D_FORCE_INLINE size_t SphereShape::getSizeInBytes() const { } // Return a local support point in a given direction without the object margin -RP3D_FORCE_INLINE Vector3 SphereShape::getLocalSupportPointWithoutMargin(const Vector3& direction) const { +RP3D_FORCE_INLINE Vector3 SphereShape::getLocalSupportPointWithoutMargin(const Vector3& /*direction*/) const { // Return the center of the sphere (the radius is taken into account in the object margin) return Vector3(0.0, 0.0, 0.0); @@ -185,7 +185,7 @@ RP3D_FORCE_INLINE decimal SphereShape::getVolume() const { } // Return true if a point is inside the collision shape -RP3D_FORCE_INLINE bool SphereShape::testPointInside(const Vector3& localPoint, Collider* collider) const { +RP3D_FORCE_INLINE bool SphereShape::testPointInside(const Vector3& localPoint, Collider* /*collider*/) const { return (localPoint.lengthSquare() < mMargin * mMargin); } diff --git a/include/reactphysics3d/collision/shapes/TriangleShape.h b/include/reactphysics3d/collision/shapes/TriangleShape.h index e2e783d5..38ce9e11 100644 --- a/include/reactphysics3d/collision/shapes/TriangleShape.h +++ b/include/reactphysics3d/collision/shapes/TriangleShape.h @@ -224,12 +224,12 @@ RP3D_FORCE_INLINE void TriangleShape::getLocalBounds(Vector3& min, Vector3& max) * coordinates * @param mass Mass to use to compute the inertia tensor of the collision shape */ -RP3D_FORCE_INLINE Vector3 TriangleShape::getLocalInertiaTensor(decimal mass) const { +RP3D_FORCE_INLINE Vector3 TriangleShape::getLocalInertiaTensor(decimal /*mass*/) const { return Vector3(0, 0, 0); } // Return true if a point is inside the collision shape -RP3D_FORCE_INLINE bool TriangleShape::testPointInside(const Vector3& localPoint, Collider* collider) const { +RP3D_FORCE_INLINE bool TriangleShape::testPointInside(const Vector3& /*localPoint*/, Collider* /*collider*/) const { return false; } diff --git a/include/reactphysics3d/containers/Map.h b/include/reactphysics3d/containers/Map.h index a914659e..42bc3474 100755 --- a/include/reactphysics3d/containers/Map.h +++ b/include/reactphysics3d/containers/Map.h @@ -83,8 +83,8 @@ class Map { // -------------------- Methods -------------------- // - /// Return the index of the entry with a given key or -1 if there is no entry with this key - int findEntry(const K& key) const { + /// Return the index of the entry with a given key or INVALID_INDEX if there is no entry with this key + uint32 findEntry(const K& key) const { if (mHashSize > 0) { diff --git a/include/reactphysics3d/engine/Entity.h b/include/reactphysics3d/engine/Entity.h index c8eb20ee..8875d09d 100644 --- a/include/reactphysics3d/engine/Entity.h +++ b/include/reactphysics3d/engine/Entity.h @@ -91,9 +91,6 @@ struct Entity { /// Return the generation number of the entity uint32 getGeneration() const; - /// Assignment operator - Entity& operator=(const Entity& entity); - /// Equality operator bool operator==(const Entity& entity) const; diff --git a/include/reactphysics3d/engine/EventListener.h b/include/reactphysics3d/engine/EventListener.h index 00586772..ec15b8ce 100644 --- a/include/reactphysics3d/engine/EventListener.h +++ b/include/reactphysics3d/engine/EventListener.h @@ -55,13 +55,13 @@ class EventListener : public CollisionCallback { /** * @param callbackData Contains information about all the contacts */ - virtual void onContact(const CollisionCallback::CallbackData& callbackData) override {} + virtual void onContact(const CollisionCallback::CallbackData& /*callbackData*/) override {} /// Called when some trigger events occur /** * @param callbackData Contains information about all the triggers that are colliding */ - virtual void onTrigger(const OverlapCallback::CallbackData& callbackData) {} + virtual void onTrigger(const OverlapCallback::CallbackData& /*callbackData*/) {} }; } diff --git a/include/reactphysics3d/memory/DefaultAllocator.h b/include/reactphysics3d/memory/DefaultAllocator.h index fbfb28ec..1194ba56 100644 --- a/include/reactphysics3d/memory/DefaultAllocator.h +++ b/include/reactphysics3d/memory/DefaultAllocator.h @@ -56,7 +56,7 @@ class DefaultAllocator : public MemoryAllocator { } /// Release previously allocated memory. - virtual void release(void* pointer, size_t size) override { + virtual void release(void* pointer, size_t /*size*/) override { std::free(pointer); } }; diff --git a/src/collision/narrowphase/CapsuleVsCapsuleAlgorithm.cpp b/src/collision/narrowphase/CapsuleVsCapsuleAlgorithm.cpp index aa201ac8..48f62069 100755 --- a/src/collision/narrowphase/CapsuleVsCapsuleAlgorithm.cpp +++ b/src/collision/narrowphase/CapsuleVsCapsuleAlgorithm.cpp @@ -34,7 +34,7 @@ using namespace reactphysics3d; // Compute the narrow-phase collision detection between two capsules // This technique is based on the "Robust Contact Creation for Physics Simulations" presentation // by Dirk Gregorius. -bool CapsuleVsCapsuleAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems, MemoryAllocator& memoryAllocator) { +bool CapsuleVsCapsuleAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems, MemoryAllocator& /*memoryAllocator*/) { bool isCollisionFound = false; diff --git a/src/collision/narrowphase/SAT/SATAlgorithm.cpp b/src/collision/narrowphase/SAT/SATAlgorithm.cpp index 835ff13a..8e472983 100644 --- a/src/collision/narrowphase/SAT/SATAlgorithm.cpp +++ b/src/collision/narrowphase/SAT/SATAlgorithm.cpp @@ -961,8 +961,8 @@ bool SATAlgorithm::computePolyhedronVsPolyhedronFaceContactPoints(bool isMinPene // The clipping plane is perpendicular to the edge direction and the reference face normal const Vector3 planeNormal = axisReferenceSpace.cross(edgeDirection); - assert(areVertices1Input && verticesTemp1.size() > 0 || !areVertices1Input); - assert(!areVertices1Input && verticesTemp2.size() > 0 || areVertices1Input); + assert((areVertices1Input && verticesTemp1.size() > 0) || !areVertices1Input); + assert((!areVertices1Input && verticesTemp2.size() > 0) || areVertices1Input); // Clip the incident face with one adjacent plane (corresponding to one edge) of the reference face clipPolygonWithPlane(areVertices1Input ? verticesTemp1 : verticesTemp2, edgeV1, planeNormal, areVertices1Input ? verticesTemp2 : verticesTemp1); diff --git a/src/collision/narrowphase/SphereVsCapsuleAlgorithm.cpp b/src/collision/narrowphase/SphereVsCapsuleAlgorithm.cpp index d839f7cb..eb75057b 100755 --- a/src/collision/narrowphase/SphereVsCapsuleAlgorithm.cpp +++ b/src/collision/narrowphase/SphereVsCapsuleAlgorithm.cpp @@ -35,7 +35,7 @@ using namespace reactphysics3d; // Compute the narrow-phase collision detection between a sphere and a capsule // This technique is based on the "Robust Contact Creation for Physics Simulations" presentation // by Dirk Gregorius. -bool SphereVsCapsuleAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems, MemoryAllocator& memoryAllocator) { +bool SphereVsCapsuleAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems, MemoryAllocator& /*memoryAllocator*/) { bool isCollisionFound = false; diff --git a/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp b/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp index 1d488ad5..4e9d4b22 100755 --- a/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp +++ b/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp @@ -31,7 +31,7 @@ // We want to use the ReactPhysics3D namespace using namespace reactphysics3d; -bool SphereVsSphereAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems, MemoryAllocator& memoryAllocator) { +bool SphereVsSphereAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems, MemoryAllocator& /*memoryAllocator*/) { bool isCollisionFound = false; diff --git a/src/collision/shapes/BoxShape.cpp b/src/collision/shapes/BoxShape.cpp index 51335e0a..8db89812 100644 --- a/src/collision/shapes/BoxShape.cpp +++ b/src/collision/shapes/BoxShape.cpp @@ -59,7 +59,7 @@ Vector3 BoxShape::getLocalInertiaTensor(decimal mass) const { } // Raycast method with feedback information -bool BoxShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collider* collider, MemoryAllocator& allocator) const { +bool BoxShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collider* collider, MemoryAllocator& /*allocator*/) const { Vector3 rayDirection = ray.point2 - ray.point1; decimal tMin = DECIMAL_SMALLEST; diff --git a/src/collision/shapes/CapsuleShape.cpp b/src/collision/shapes/CapsuleShape.cpp index e7e59c62..2a8885ec 100644 --- a/src/collision/shapes/CapsuleShape.cpp +++ b/src/collision/shapes/CapsuleShape.cpp @@ -67,7 +67,7 @@ Vector3 CapsuleShape::getLocalInertiaTensor(decimal mass) const { } // Return true if a point is inside the collision shape -bool CapsuleShape::testPointInside(const Vector3& localPoint, Collider* collider) const { +bool CapsuleShape::testPointInside(const Vector3& localPoint, Collider* /*collider*/) const { const decimal diffYCenterSphere1 = localPoint.y - mHalfHeight; const decimal diffYCenterSphere2 = localPoint.y + mHalfHeight; @@ -83,7 +83,7 @@ bool CapsuleShape::testPointInside(const Vector3& localPoint, Collider* collider } // Raycast method with feedback information -bool CapsuleShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collider* collider, MemoryAllocator& allocator) const { +bool CapsuleShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collider* collider, MemoryAllocator& /*allocator*/) const { const Vector3 n = ray.point2 - ray.point1; diff --git a/src/collision/shapes/ConvexMeshShape.cpp b/src/collision/shapes/ConvexMeshShape.cpp index a8912ee2..95884208 100644 --- a/src/collision/shapes/ConvexMeshShape.cpp +++ b/src/collision/shapes/ConvexMeshShape.cpp @@ -106,7 +106,7 @@ void ConvexMeshShape::recalculateBounds() { // Raycast method with feedback information /// This method implements the technique in the book "Real-time Collision Detection" by /// Christer Ericson. -bool ConvexMeshShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collider* collider, MemoryAllocator& allocator) const { +bool ConvexMeshShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collider* collider, MemoryAllocator& /*allocator*/) const { // Ray direction Vector3 direction = ray.point2 - ray.point1; @@ -184,7 +184,7 @@ bool ConvexMeshShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collider } // Return true if a point is inside the collision shape -bool ConvexMeshShape::testPointInside(const Vector3& localPoint, Collider* collider) const { +bool ConvexMeshShape::testPointInside(const Vector3& localPoint, Collider* /*collider*/) const { const HalfEdgeStructure& halfEdgeStructure = mPolyhedronMesh->getHalfEdgeStructure(); diff --git a/src/collision/shapes/HeightFieldShape.cpp b/src/collision/shapes/HeightFieldShape.cpp index 6480585c..13dd4f5e 100644 --- a/src/collision/shapes/HeightFieldShape.cpp +++ b/src/collision/shapes/HeightFieldShape.cpp @@ -95,7 +95,7 @@ void HeightFieldShape::getLocalBounds(Vector3& min, Vector3& max) const { // and then for each rectangle in the sub-grid we generate two triangles that we use to test collision. void HeightFieldShape::computeOverlappingTriangles(const AABB& localAABB, Array& triangleVertices, Array& triangleVerticesNormals, Array& shapeIds, - MemoryAllocator& allocator) const { + MemoryAllocator& /*allocator*/) const { RP3D_PROFILE("HeightFieldShape::computeOverlappingTriangles()", mProfiler); @@ -373,8 +373,11 @@ bool HeightFieldShape::computeEnteringRayGridCoordinates(const Ray& ray, int& i, decimal stepI, stepJ; const Vector3 aabbSize = mAABB.getExtent(); - const uint32 nbCellsI = mNbColumns - 1; - const uint32 nbCellsJ = mNbRows - 1; + assert(mNbColumns > 0); + assert(mNbRows > 0); + + const int nbCellsI = mNbColumns - 1; + const int nbCellsJ = mNbRows - 1; if (mAABB.raycast(ray, outHitGridPoint)) { diff --git a/src/collision/shapes/SphereShape.cpp b/src/collision/shapes/SphereShape.cpp index 3c789cbf..6017741d 100644 --- a/src/collision/shapes/SphereShape.cpp +++ b/src/collision/shapes/SphereShape.cpp @@ -60,7 +60,7 @@ void SphereShape::computeAABB(AABB& aabb, const Transform& transform) const { } // Raycast method with feedback information -bool SphereShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collider* collider, MemoryAllocator& allocator) const { +bool SphereShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collider* collider, MemoryAllocator& /*allocator*/) const { const Vector3 m = ray.point1; decimal c = m.dot(m) - mMargin * mMargin; diff --git a/src/collision/shapes/TriangleShape.cpp b/src/collision/shapes/TriangleShape.cpp index c072ad84..1a80b31c 100644 --- a/src/collision/shapes/TriangleShape.cpp +++ b/src/collision/shapes/TriangleShape.cpp @@ -136,7 +136,7 @@ void TriangleShape::computeAABB(AABB& aabb, const Transform& transform) const { // Raycast method with feedback information /// This method use the line vs triangle raycasting technique described in /// Real-time Collision Detection by Christer Ericson. -bool TriangleShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collider* collider, MemoryAllocator& allocator) const { +bool TriangleShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collider* collider, MemoryAllocator& /*allocator*/) const { RP3D_PROFILE("TriangleShape::raycast()", mProfiler); diff --git a/src/engine/Entity.cpp b/src/engine/Entity.cpp index 919c5fc2..f39334a1 100644 --- a/src/engine/Entity.cpp +++ b/src/engine/Entity.cpp @@ -43,14 +43,3 @@ Entity::Entity(uint32 index, uint32 generation) assert(getIndex() == index); assert(getGeneration() == generation); } - -// Assignment operator -Entity& Entity::operator=(const Entity& entity) { - - if (&entity != this) { - - id = entity.id; - } - - return *this; -}