diff --git a/include/reactphysics3d/collision/CollisionCallback.h b/include/reactphysics3d/collision/CollisionCallback.h index f3f2b41d..492ce308 100644 --- a/include/reactphysics3d/collision/CollisionCallback.h +++ b/include/reactphysics3d/collision/CollisionCallback.h @@ -172,14 +172,14 @@ class CollisionCallback { /** * @return The number of contact points in the contact pair */ - uint getNbContactPoints() const; + size_t getNbContactPoints() const; /// Return a given contact point /** * @param index Index of the contact point to retrieve * @return A contact point object */ - ContactPoint getContactPoint(uint index) const; + ContactPoint getContactPoint(size_t index) const; /// Return a pointer to the first body in contact /** @@ -271,14 +271,14 @@ class CollisionCallback { /** * @return The number of contact pairs */ - uint getNbContactPairs() const; + size_t getNbContactPairs() const; /// Return a given contact pair /** * @param index Index of the contact pair to retrieve * @return A contact pair object */ - ContactPair getContactPair(uint index) const; + ContactPair getContactPair(size_t index) const; // -------------------- Friendship -------------------- // @@ -296,7 +296,7 @@ class CollisionCallback { /** * @return The number of contact pairs */ -inline uint CollisionCallback::CallbackData::getNbContactPairs() const { +inline size_t CollisionCallback::CallbackData::getNbContactPairs() const { return mContactPairsIndices.size() + mLostContactPairsIndices.size(); } @@ -304,7 +304,7 @@ inline uint CollisionCallback::CallbackData::getNbContactPairs() const { /** * @return The number of contact points */ -inline uint CollisionCallback::ContactPair::getNbContactPoints() const { +inline size_t CollisionCallback::ContactPair::getNbContactPoints() const { return mContactPair.nbToTalContactPoints; } diff --git a/include/reactphysics3d/collision/HalfEdgeStructure.h b/include/reactphysics3d/collision/HalfEdgeStructure.h index d0d915df..80eb6889 100644 --- a/include/reactphysics3d/collision/HalfEdgeStructure.h +++ b/include/reactphysics3d/collision/HalfEdgeStructure.h @@ -100,7 +100,7 @@ class HalfEdgeStructure { void init(); /// Add a vertex - uint addVertex(uint vertexPointIndex); + size_t addVertex(uint vertexPointIndex); /// Add a face void addFace(List faceVertices); @@ -129,7 +129,7 @@ class HalfEdgeStructure { /** * @param vertexPointIndex Index of the vertex in the vertex data array */ -inline uint HalfEdgeStructure::addVertex(uint vertexPointIndex) { +inline size_t HalfEdgeStructure::addVertex(uint vertexPointIndex) { Vertex vertex(vertexPointIndex); mVertices.add(vertex); return mVertices.size() - 1; diff --git a/include/reactphysics3d/collision/OverlapCallback.h b/include/reactphysics3d/collision/OverlapCallback.h index 1fb99660..6241b0b5 100644 --- a/include/reactphysics3d/collision/OverlapCallback.h +++ b/include/reactphysics3d/collision/OverlapCallback.h @@ -165,10 +165,10 @@ class OverlapCallback { // -------------------- Methods -------------------- // /// Return the number of overlapping pairs of bodies - uint getNbOverlappingPairs() const; + size_t getNbOverlappingPairs() const; /// Return a given overlapping pair of bodies - OverlapPair getOverlappingPair(uint index) const; + OverlapPair getOverlappingPair(size_t index) const; // -------------------- Friendship -------------------- // @@ -185,7 +185,7 @@ class OverlapCallback { }; // Return the number of overlapping pairs of bodies -inline uint OverlapCallback::CallbackData::getNbOverlappingPairs() const { +inline size_t OverlapCallback::CallbackData::getNbOverlappingPairs() const { return mContactPairsIndices.size() + mLostContactPairsIndices.size(); } @@ -193,7 +193,7 @@ inline uint OverlapCallback::CallbackData::getNbOverlappingPairs() const { /// Note that the returned OverlapPair object is only valid during the call of the CollisionCallback::onOverlap() /// method. Therefore, you need to get contact data from it and make a copy. Do not make a copy of the OverlapPair /// object itself because it won't be valid after the CollisionCallback::onOverlap() call. -inline OverlapCallback::OverlapPair OverlapCallback::CallbackData::getOverlappingPair(uint index) const { +inline OverlapCallback::OverlapPair OverlapCallback::CallbackData::getOverlappingPair(size_t index) const { assert(index < getNbOverlappingPairs()); diff --git a/include/reactphysics3d/collision/TriangleMesh.h b/include/reactphysics3d/collision/TriangleMesh.h index 155f7a44..72189959 100644 --- a/include/reactphysics3d/collision/TriangleMesh.h +++ b/include/reactphysics3d/collision/TriangleMesh.h @@ -63,10 +63,10 @@ class TriangleMesh { void addSubpart(TriangleVertexArray* triangleVertexArray); /// Return a pointer to a given subpart (triangle vertex array) of the mesh - TriangleVertexArray* getSubpart(uint indexSubpart) const; + TriangleVertexArray* getSubpart(size_t indexSubpart) const; /// Return the number of subparts of the mesh - uint getNbSubparts() const; + size_t getNbSubparts() const; // ---------- Friendship ---------- // @@ -87,7 +87,7 @@ inline void TriangleMesh::addSubpart(TriangleVertexArray* triangleVertexArray) { * @param indexSubpart The index of the sub-part of the mesh * @return A pointer to the triangle vertex array of a given sub-part of the mesh */ -inline TriangleVertexArray* TriangleMesh::getSubpart(uint indexSubpart) const { +inline TriangleVertexArray* TriangleMesh::getSubpart(size_t indexSubpart) const { assert(indexSubpart < mTriangleArrays.size()); return mTriangleArrays[indexSubpart]; } @@ -96,7 +96,7 @@ inline TriangleVertexArray* TriangleMesh::getSubpart(uint indexSubpart) const { /** * @return The number of sub-parts of the mesh */ -inline uint TriangleMesh::getNbSubparts() const { +inline size_t TriangleMesh::getNbSubparts() const { return mTriangleArrays.size(); } diff --git a/include/reactphysics3d/collision/narrowphase/CapsuleVsCapsuleAlgorithm.h b/include/reactphysics3d/collision/narrowphase/CapsuleVsCapsuleAlgorithm.h index a34d58bf..9f975203 100644 --- a/include/reactphysics3d/collision/narrowphase/CapsuleVsCapsuleAlgorithm.h +++ b/include/reactphysics3d/collision/narrowphase/CapsuleVsCapsuleAlgorithm.h @@ -66,8 +66,8 @@ class CapsuleVsCapsuleAlgorithm : public NarrowPhaseAlgorithm { CapsuleVsCapsuleAlgorithm& operator=(const CapsuleVsCapsuleAlgorithm& algorithm) = delete; /// Compute the narrow-phase collision detection between two capsules - bool testCollision(CapsuleVsCapsuleNarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, - uint batchNbItems, MemoryAllocator& memoryAllocator); + bool testCollision(CapsuleVsCapsuleNarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, + size_t batchNbItems, MemoryAllocator& memoryAllocator); }; } diff --git a/include/reactphysics3d/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.h b/include/reactphysics3d/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.h index 80987bf3..deb27d96 100644 --- a/include/reactphysics3d/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.h +++ b/include/reactphysics3d/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.h @@ -69,8 +69,8 @@ class CapsuleVsConvexPolyhedronAlgorithm : public NarrowPhaseAlgorithm { CapsuleVsConvexPolyhedronAlgorithm& operator=(const CapsuleVsConvexPolyhedronAlgorithm& algorithm) = delete; /// Compute the narrow-phase collision detection between a capsule and a polyhedron - bool testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, - uint batchNbItems, bool clipWithPreviousAxisIfStillColliding, + bool testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, + size_t batchNbItems, bool clipWithPreviousAxisIfStillColliding, MemoryAllocator& memoryAllocator); }; diff --git a/include/reactphysics3d/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.h b/include/reactphysics3d/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.h index c3cb6e0d..8d619bf8 100644 --- a/include/reactphysics3d/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.h +++ b/include/reactphysics3d/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.h @@ -64,7 +64,7 @@ class ConvexPolyhedronVsConvexPolyhedronAlgorithm : public NarrowPhaseAlgorithm ConvexPolyhedronVsConvexPolyhedronAlgorithm& operator=(const ConvexPolyhedronVsConvexPolyhedronAlgorithm& algorithm) = delete; /// Compute the narrow-phase collision detection between two convex polyhedra - bool testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems, + bool testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, size_t batchNbItems, bool clipWithPreviousAxisIfStillColliding, MemoryAllocator& memoryAllocator); }; diff --git a/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h b/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h index 7b727920..86d1676f 100644 --- a/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h +++ b/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h @@ -97,8 +97,8 @@ class GJKAlgorithm { GJKAlgorithm& operator=(const GJKAlgorithm& algorithm) = delete; /// Compute a contact info if the two bounding volumes collide. - void testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, - uint batchNbItems, List& gjkResults); + void testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, + size_t batchNbItems, List& gjkResults); #ifdef IS_RP3D_PROFILING_ENABLED diff --git a/include/reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h b/include/reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h index 73ce4e33..3a401116 100644 --- a/include/reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h +++ b/include/reactphysics3d/collision/narrowphase/NarrowPhaseInfoBatch.h @@ -56,7 +56,7 @@ struct NarrowPhaseInfoBatch { OverlappingPairs& mOverlappingPairs; /// Cached capacity - uint mCachedCapacity = 0; + size_t mCachedCapacity = 0; public: @@ -103,7 +103,7 @@ struct NarrowPhaseInfoBatch { virtual ~NarrowPhaseInfoBatch(); /// Return the number of objects in the batch - uint getNbObjects() const; + size_t getNbObjects() const; /// Add shapes to be tested during narrow-phase collision detection into the batch virtual void addNarrowPhaseInfo(uint64 pairId, uint64 pairIndex, Entity collider1, Entity collider2, CollisionShape* shape1, @@ -111,11 +111,11 @@ struct NarrowPhaseInfoBatch { const Transform& shape2Transform, bool needToReportContacts, MemoryAllocator& shapeAllocator); /// Add a new contact point - virtual void addContactPoint(uint index, const Vector3& contactNormal, decimal penDepth, + virtual void addContactPoint(size_t index, const Vector3& contactNormal, decimal penDepth, const Vector3& localPt1, const Vector3& localPt2); /// Reset the remaining contact points - void resetContactPoints(uint index); + void resetContactPoints(size_t index); // Initialize the containers using cached capacity virtual void reserveMemory(); @@ -125,7 +125,7 @@ struct NarrowPhaseInfoBatch { }; /// Return the number of objects in the batch -inline uint NarrowPhaseInfoBatch::getNbObjects() const { +inline size_t NarrowPhaseInfoBatch::getNbObjects() const { return overlappingPairIds.size(); } diff --git a/include/reactphysics3d/collision/narrowphase/SAT/SATAlgorithm.h b/include/reactphysics3d/collision/narrowphase/SAT/SATAlgorithm.h index 9f8a4bef..095ef344 100644 --- a/include/reactphysics3d/collision/narrowphase/SAT/SATAlgorithm.h +++ b/include/reactphysics3d/collision/narrowphase/SAT/SATAlgorithm.h @@ -133,7 +133,7 @@ class SATAlgorithm { bool computePolyhedronVsPolyhedronFaceContactPoints(bool isMinPenetrationFaceNormalPolyhedron1, const ConvexPolyhedronShape* polyhedron1, const ConvexPolyhedronShape* polyhedron2, const Transform& polyhedron1ToPolyhedron2, const Transform& polyhedron2ToPolyhedron1, uint minFaceIndex, - NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchIndex) const; + NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchIndex) const; public : @@ -154,24 +154,24 @@ class SATAlgorithm { /// Test collision between a sphere and a convex mesh bool testCollisionSphereVsConvexPolyhedron(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, - uint batchStartIndex, uint batchNbItems) const; + size_t batchStartIndex, size_t batchNbItems) const; /// Test collision between a capsule and a convex mesh - bool testCollisionCapsuleVsConvexPolyhedron(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchIndex) const; + bool testCollisionCapsuleVsConvexPolyhedron(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchIndex) const; /// Compute the two contact points between a polyhedron and a capsule when the separating axis is a face normal of the polyhedron bool computeCapsulePolyhedronFaceContactPoints(uint referenceFaceIndex, decimal capsuleRadius, const ConvexPolyhedronShape* polyhedron, decimal penetrationDepth, const Transform& polyhedronToCapsuleTransform, Vector3& normalWorld, const Vector3& separatingAxisCapsuleSpace, const Vector3& capsuleSegAPolyhedronSpace, const Vector3& capsuleSegBPolyhedronSpace, - NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchIndex, bool isCapsuleShape1) const; + NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchIndex, bool isCapsuleShape1) const; // This method returns true if an edge of a polyhedron and a capsule forms a face of the Minkowski Difference bool isMinkowskiFaceCapsuleVsEdge(const Vector3& capsuleSegment, const Vector3& edgeAdjacentFace1Normal, const Vector3& edgeAdjacentFace2Normal) const; /// Test collision between two convex meshes - bool testCollisionConvexPolyhedronVsConvexPolyhedron(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems) const; + bool testCollisionConvexPolyhedronVsConvexPolyhedron(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, size_t batchNbItems) const; #ifdef IS_RP3D_PROFILING_ENABLED diff --git a/include/reactphysics3d/collision/narrowphase/SphereVsCapsuleAlgorithm.h b/include/reactphysics3d/collision/narrowphase/SphereVsCapsuleAlgorithm.h index 21c85918..720be236 100644 --- a/include/reactphysics3d/collision/narrowphase/SphereVsCapsuleAlgorithm.h +++ b/include/reactphysics3d/collision/narrowphase/SphereVsCapsuleAlgorithm.h @@ -65,8 +65,8 @@ class SphereVsCapsuleAlgorithm : public NarrowPhaseAlgorithm { SphereVsCapsuleAlgorithm& operator=(const SphereVsCapsuleAlgorithm& algorithm) = delete; /// Compute the narrow-phase collision detection between a sphere and a capsule - bool testCollision(SphereVsCapsuleNarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, - uint batchNbItems, MemoryAllocator& memoryAllocator); + bool testCollision(SphereVsCapsuleNarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, + size_t batchNbItems, MemoryAllocator& memoryAllocator); }; } diff --git a/include/reactphysics3d/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.h b/include/reactphysics3d/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.h index 264e9f5a..897ff0b7 100644 --- a/include/reactphysics3d/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.h +++ b/include/reactphysics3d/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.h @@ -70,7 +70,7 @@ class SphereVsConvexPolyhedronAlgorithm : public NarrowPhaseAlgorithm { SphereVsConvexPolyhedronAlgorithm& operator=(const SphereVsConvexPolyhedronAlgorithm& algorithm) = delete; /// Compute the narrow-phase collision detection between a sphere and a convex polyhedron - bool testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems, + bool testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, size_t batchNbItems, bool clipWithPreviousAxisIfStillColliding, MemoryAllocator& memoryAllocator); }; diff --git a/include/reactphysics3d/collision/narrowphase/SphereVsSphereAlgorithm.h b/include/reactphysics3d/collision/narrowphase/SphereVsSphereAlgorithm.h index e6f68e7a..ce55075f 100644 --- a/include/reactphysics3d/collision/narrowphase/SphereVsSphereAlgorithm.h +++ b/include/reactphysics3d/collision/narrowphase/SphereVsSphereAlgorithm.h @@ -65,8 +65,8 @@ class SphereVsSphereAlgorithm : public NarrowPhaseAlgorithm { SphereVsSphereAlgorithm& operator=(const SphereVsSphereAlgorithm& algorithm) = delete; /// Compute a contact info if the two bounding volume collide - bool testCollision(SphereVsSphereNarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, - uint batchNbItems, MemoryAllocator& memoryAllocator); + bool testCollision(SphereVsSphereNarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, + size_t batchNbItems, MemoryAllocator& memoryAllocator); }; } diff --git a/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h b/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h index 3ecfc5e0..966412a7 100644 --- a/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h +++ b/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h @@ -182,10 +182,10 @@ class ConcaveMeshShape : public ConcaveShape { ConcaveMeshShape& operator=(const ConcaveMeshShape& shape) = delete; /// Return the number of sub parts contained in this mesh - uint getNbSubparts() const; + size_t getNbSubparts() const; /// Return the number of triangles in a sub part of the mesh - uint getNbTriangles(uint subPart) const; + uint getNbTriangles(size_t subPart) const; /// Return the indices of the three vertices of a given triangle in the array void getTriangleVerticesIndices(uint subPart, uint triangleIndex, uint* outVerticesIndices) const; diff --git a/include/reactphysics3d/collision/shapes/HeightFieldShape.h b/include/reactphysics3d/collision/shapes/HeightFieldShape.h index adb4c947..dc3a86dd 100644 --- a/include/reactphysics3d/collision/shapes/HeightFieldShape.h +++ b/include/reactphysics3d/collision/shapes/HeightFieldShape.h @@ -193,16 +193,17 @@ inline decimal HeightFieldShape::getHeightAt(int x, int y) const { assert(y >= 0 && y < mNbRows); switch(mHeightDataType) { - case HeightDataType::HEIGHT_FLOAT_TYPE : return ((float*)mHeightFieldData)[y * mNbColumns + x]; - case HeightDataType::HEIGHT_DOUBLE_TYPE : return ((double*)mHeightFieldData)[y * mNbColumns + x]; - case HeightDataType::HEIGHT_INT_TYPE : return ((int*)mHeightFieldData)[y * mNbColumns + x] * mIntegerHeightScale; + case HeightDataType::HEIGHT_FLOAT_TYPE : return static_cast(((float*)mHeightFieldData)[y * mNbColumns + x]); + case HeightDataType::HEIGHT_DOUBLE_TYPE : return static_cast(((double*)mHeightFieldData)[y * mNbColumns + x]); + case HeightDataType::HEIGHT_INT_TYPE : return static_cast(((int*)mHeightFieldData)[y * mNbColumns + x] * mIntegerHeightScale); default: assert(false); return 0; } } // Return the closest inside integer grid value of a given floating grid value inline int HeightFieldShape::computeIntegerGridValue(decimal value) const { - return (value < decimal(0.0)) ? value - decimal(0.5) : value + decimal(0.5); + // might produce wrong results either way + return static_cast((value < decimal(0.0)) ? value - decimal(0.5) : value + decimal(0.5)); } // Compute the shape Id for a given triangle diff --git a/include/reactphysics3d/containers/Deque.h b/include/reactphysics3d/containers/Deque.h index ace6b567..aee57596 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 uint CHUNK_NB_ITEMS = 17; + const uint8 CHUNK_NB_ITEMS = 17; /// First item index in a chunk - const uint 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/List.h b/include/reactphysics3d/containers/List.h index a85fb65a..4e0dc154 100755 --- a/include/reactphysics3d/containers/List.h +++ b/include/reactphysics3d/containers/List.h @@ -332,7 +332,7 @@ class List { } /// Remove an element from the list at a given index (all the following items will be moved) - Iterator removeAt(uint index) { + Iterator removeAt(size_t index) { assert(index >= 0 && index < mSize); @@ -403,13 +403,13 @@ class List { } /// Overloaded index operator - T& operator[](const uint index) { + T& operator[](const size_t index) { assert(index >= 0 && index < mSize); return (static_cast(mBuffer)[index]); } /// Overloaded const index operator - const T& operator[](const uint index) const { + const T& operator[](const size_t index) const { assert(index >= 0 && index < mSize); return (static_cast(mBuffer)[index]); } diff --git a/include/reactphysics3d/containers/Map.h b/include/reactphysics3d/containers/Map.h index a486f529..271effba 100755 --- a/include/reactphysics3d/containers/Map.h +++ b/include/reactphysics3d/containers/Map.h @@ -353,7 +353,7 @@ class Map { // -------------------- Methods -------------------- // /// Constructor - Map(MemoryAllocator& allocator, size_t capacity = 0) + Map(MemoryAllocator& allocator, int capacity = 0) : mNbUsedEntries(0), mNbFreeEntries(0), mCapacity(0), mBuckets(nullptr), mEntries(nullptr), mAllocator(allocator), mFreeIndex(-1) { @@ -468,7 +468,7 @@ class Map { } } - size_t entryIndex; + int entryIndex; // If there are free entries to use if (mNbFreeEntries > 0) { diff --git a/include/reactphysics3d/containers/Set.h b/include/reactphysics3d/containers/Set.h index 17088fe3..ad5a480d 100755 --- a/include/reactphysics3d/containers/Set.h +++ b/include/reactphysics3d/containers/Set.h @@ -348,7 +348,7 @@ class Set { // -------------------- Methods -------------------- // /// Constructor - Set(MemoryAllocator& allocator, size_t capacity = 0) + Set(MemoryAllocator& allocator, int capacity = 0) : mNbUsedEntries(0), mNbFreeEntries(0), mCapacity(0), mBuckets(nullptr), mEntries(nullptr), mAllocator(allocator), mFreeIndex(-1) { @@ -446,7 +446,7 @@ class Set { } } - size_t entryIndex; + int entryIndex; // If there are free entries to use if (mNbFreeEntries > 0) { diff --git a/include/reactphysics3d/containers/Stack.h b/include/reactphysics3d/containers/Stack.h index ed697262..d20fa788 100644 --- a/include/reactphysics3d/containers/Stack.h +++ b/include/reactphysics3d/containers/Stack.h @@ -51,10 +51,10 @@ class Stack { T* mArray; /// Number of elements in the stack - uint mNbElements; + size_t mNbElements; /// Number of allocated elements in the stack - uint mCapacity; + size_t mCapacity; // -------------------- Methods -------------------- // diff --git a/include/reactphysics3d/engine/Islands.h b/include/reactphysics3d/engine/Islands.h index 2ffc26a5..24c486a7 100644 --- a/include/reactphysics3d/engine/Islands.h +++ b/include/reactphysics3d/engine/Islands.h @@ -91,7 +91,7 @@ struct Islands { /// Add an island and return its index uint32 addIsland(uint32 contactManifoldStartIndex) { - uint32 islandIndex = contactManifoldsIndices.size(); + uint32 islandIndex = static_cast(contactManifoldsIndices.size()); contactManifoldsIndices.add(contactManifoldStartIndex); nbContactManifolds.add(0); diff --git a/include/reactphysics3d/engine/PhysicsWorld.h b/include/reactphysics3d/engine/PhysicsWorld.h index 8ebf4ab1..d532f08f 100644 --- a/include/reactphysics3d/engine/PhysicsWorld.h +++ b/include/reactphysics3d/engine/PhysicsWorld.h @@ -435,22 +435,22 @@ class PhysicsWorld { void setEventListener(EventListener* eventListener); /// Return the number of CollisionBody in the physics world - uint getNbCollisionBodies() const; + size_t getNbCollisionBodies() const; /// Return a constant pointer to a given CollisionBody of the world - const CollisionBody* getCollisionBody(uint index) const; + const CollisionBody* getCollisionBody(size_t index) const; /// Return a pointer to a given CollisionBody of the world - CollisionBody* getCollisionBody(uint index) ; + CollisionBody* getCollisionBody(size_t index) ; /// Return the number of RigidBody in the physics world - uint getNbRigidBodies() const; + size_t getNbRigidBodies() const; /// Return a constant pointer to a given RigidBody of the world - const RigidBody* getRigidBody(uint index) const; + const RigidBody* getRigidBody(size_t index) const; /// Return a pointer to a given RigidBody of the world - RigidBody* getRigidBody(uint index) ; + RigidBody* getRigidBody(size_t index) ; /// Return true if the debug rendering is enabled bool getIsDebugRenderingEnabled() const; @@ -706,7 +706,7 @@ inline void PhysicsWorld::setEventListener(EventListener* eventListener) { /** * @return The number of collision bodies in the physics world */ -inline uint PhysicsWorld::getNbCollisionBodies() const { +inline size_t PhysicsWorld::getNbCollisionBodies() const { return mCollisionBodies.size(); } @@ -714,7 +714,7 @@ inline uint PhysicsWorld::getNbCollisionBodies() const { /** * @return The number of rigid bodies in the physics world */ -inline uint PhysicsWorld::getNbRigidBodies() const { +inline size_t PhysicsWorld::getNbRigidBodies() const { return mRigidBodies.size(); } diff --git a/include/reactphysics3d/engine/Timer.h b/include/reactphysics3d/engine/Timer.h index 8db66360..a12d0e51 100644 --- a/include/reactphysics3d/engine/Timer.h +++ b/include/reactphysics3d/engine/Timer.h @@ -188,7 +188,7 @@ inline void Timer::update() { mLastUpdateTime = currentTime; // Update the accumulator value - mAccumulator += mDeltaTime; + mAccumulator += static_cast(mDeltaTime); } } diff --git a/include/reactphysics3d/utils/DebugRenderer.h b/include/reactphysics3d/utils/DebugRenderer.h index cae56c8c..2921ca96 100644 --- a/include/reactphysics3d/utils/DebugRenderer.h +++ b/include/reactphysics3d/utils/DebugRenderer.h @@ -214,7 +214,7 @@ class DebugRenderer : public EventListener { ~DebugRenderer(); /// Return the number of lines - uint32 getNbLines() const; + size_t getNbLines() const; /// Return a reference to the list of lines const List& getLines() const; @@ -223,7 +223,7 @@ class DebugRenderer : public EventListener { const DebugLine* getLinesArray() const; /// Return the number of triangles - uint32 getNbTriangles() const; + size_t getNbTriangles() const; /// Return a reference to the list of triangles const List& getTriangles() const; @@ -263,7 +263,7 @@ class DebugRenderer : public EventListener { /** * @return The number of lines in the array of lines to draw */ -inline uint32 DebugRenderer::getNbLines() const { +inline size_t DebugRenderer::getNbLines() const { return mLines.size(); } @@ -287,7 +287,7 @@ inline const DebugRenderer::DebugLine* DebugRenderer::getLinesArray() const { /** * @return The number of triangles in the array of triangles to draw */ -inline uint32 DebugRenderer::getNbTriangles() const { +inline size_t DebugRenderer::getNbTriangles() const { return mTriangles.size(); } diff --git a/include/reactphysics3d/utils/DefaultLogger.h b/include/reactphysics3d/utils/DefaultLogger.h index bcc2f450..9574e7e7 100644 --- a/include/reactphysics3d/utils/DefaultLogger.h +++ b/include/reactphysics3d/utils/DefaultLogger.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -253,7 +254,7 @@ class DefaultLogger : public Logger { /// Convert a string to lower case std::string toLowerCase(const std::string& text) { std::string textLower = text; - std::transform(textLower.begin(), textLower.end(), textLower.begin(), ::tolower); + std::transform(textLower.begin(), textLower.end(), textLower.begin(), [locale=std::locale()](char c) { return std::tolower(c, locale); }); return textLower; } diff --git a/src/collision/CollisionCallback.cpp b/src/collision/CollisionCallback.cpp index 88779023..6a1fc782 100644 --- a/src/collision/CollisionCallback.cpp +++ b/src/collision/CollisionCallback.cpp @@ -103,7 +103,7 @@ CollisionCallback::CallbackData::CallbackData(List* /// Note that the returned ContactPoint object is only valid during the call of the CollisionCallback::onContact() /// method. Therefore, you need to get contact data from it and make a copy. Do not make a copy of the ContactPoint /// object itself because it won't be valid after the CollisionCallback::onContact() call. -CollisionCallback::ContactPoint CollisionCallback::ContactPair::getContactPoint(uint index) const { +CollisionCallback::ContactPoint CollisionCallback::ContactPair::getContactPoint(size_t index) const { assert(index < getNbContactPoints()); @@ -114,7 +114,7 @@ CollisionCallback::ContactPoint CollisionCallback::ContactPair::getContactPoint( /// Note that the returned ContactPair object is only valid during the call of the CollisionCallback::onContact() /// method. Therefore, you need to get contact data from it and make a copy. Do not make a copy of the ContactPair /// object itself because it won't be valid after the CollisionCallback::onContact() call. -CollisionCallback::ContactPair CollisionCallback::CallbackData::getContactPair(uint index) const { +CollisionCallback::ContactPair CollisionCallback::CallbackData::getContactPair(size_t index) const { assert(index < getNbContactPairs()); diff --git a/src/collision/HalfEdgeStructure.cpp b/src/collision/HalfEdgeStructure.cpp index b1da7ef8..c3f99915 100644 --- a/src/collision/HalfEdgeStructure.cpp +++ b/src/collision/HalfEdgeStructure.cpp @@ -82,7 +82,7 @@ void HalfEdgeStructure::init() { auto itEdge = edges.find(pairV2V1); if (itEdge != edges.end()) { - const uint edgeIndex = mEdges.size(); + const uint edgeIndex = static_cast(mEdges.size()); itEdge->second.twinEdgeIndex = edgeIndex + 1; edge.twinEdgeIndex = edgeIndex; diff --git a/src/collision/PolyhedronMesh.cpp b/src/collision/PolyhedronMesh.cpp index 28ae4754..2d90189e 100644 --- a/src/collision/PolyhedronMesh.cpp +++ b/src/collision/PolyhedronMesh.cpp @@ -152,7 +152,7 @@ void PolyhedronMesh::computeCentroid() { mCentroid += getVertex(v); } - mCentroid /= getNbVertices(); + mCentroid /= static_cast(getNbVertices()); } // Compute and return the area of a face diff --git a/src/collision/broadphase/DynamicAABBTree.cpp b/src/collision/broadphase/DynamicAABBTree.cpp index a5a7ad21..0d9e3923 100644 --- a/src/collision/broadphase/DynamicAABBTree.cpp +++ b/src/collision/broadphase/DynamicAABBTree.cpp @@ -583,7 +583,7 @@ void DynamicAABBTree::reportAllShapesOverlappingWithShapes(const List& no Stack stack(mAllocator, 64); // For each shape to be tested for overlap - for (uint i=startIndex; i < endIndex; i++) { + for (size_t i=startIndex; i < endIndex; i++) { assert(nodesToTest[i] != -1); diff --git a/src/collision/narrowphase/CapsuleVsCapsuleAlgorithm.cpp b/src/collision/narrowphase/CapsuleVsCapsuleAlgorithm.cpp index 4fa4595f..2750a4b7 100755 --- a/src/collision/narrowphase/CapsuleVsCapsuleAlgorithm.cpp +++ b/src/collision/narrowphase/CapsuleVsCapsuleAlgorithm.cpp @@ -34,12 +34,12 @@ 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(CapsuleVsCapsuleNarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems, +bool CapsuleVsCapsuleAlgorithm::testCollision(CapsuleVsCapsuleNarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, size_t batchNbItems, MemoryAllocator& memoryAllocator) { bool isCollisionFound = false; - for (uint batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { + for (size_t batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { assert(narrowPhaseInfoBatch.contactPoints[batchIndex].size() == 0); diff --git a/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp b/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp index 8e082822..b900f57d 100644 --- a/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp +++ b/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp @@ -40,7 +40,7 @@ using namespace reactphysics3d; // This technique is based on the "Robust Contact Creation for Physics Simulations" presentation // by Dirk Gregorius. bool CapsuleVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, - uint batchStartIndex, uint batchNbItems, + size_t batchStartIndex, size_t batchNbItems, bool clipWithPreviousAxisIfStillColliding, MemoryAllocator& memoryAllocator) { @@ -63,7 +63,7 @@ bool CapsuleVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& nar gjkAlgorithm.testCollision(narrowPhaseInfoBatch, batchStartIndex, batchNbItems, gjkResults); assert(gjkResults.size() == batchNbItems); - for (uint batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { + for (size_t batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { // Get the last frame collision info LastFrameCollisionInfo* lastFrameCollisionInfo = narrowPhaseInfoBatch.lastFrameCollisionInfos[batchIndex]; diff --git a/src/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.cpp b/src/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.cpp index a44ba93b..3b1aafec 100644 --- a/src/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.cpp +++ b/src/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.cpp @@ -36,7 +36,7 @@ using namespace reactphysics3d; // This technique is based on the "Robust Contact Creation for Physics Simulations" presentation // by Dirk Gregorius. bool ConvexPolyhedronVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, - uint batchStartIndex, uint batchNbItems, + size_t batchStartIndex, size_t batchNbItems, bool clipWithPreviousAxisIfStillColliding, MemoryAllocator& memoryAllocator) { // Run the SAT algorithm to find the separating axis and compute contact point @@ -51,7 +51,7 @@ bool ConvexPolyhedronVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoB bool isCollisionFound = satAlgorithm.testCollisionConvexPolyhedronVsConvexPolyhedron(narrowPhaseInfoBatch, batchStartIndex, batchNbItems); - for (uint batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { + for (size_t batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { // Get the last frame collision info LastFrameCollisionInfo* lastFrameCollisionInfo = narrowPhaseInfoBatch.lastFrameCollisionInfos[batchIndex]; diff --git a/src/collision/narrowphase/GJK/GJKAlgorithm.cpp b/src/collision/narrowphase/GJK/GJKAlgorithm.cpp index 28c3ff0f..b0c4aa70 100644 --- a/src/collision/narrowphase/GJK/GJKAlgorithm.cpp +++ b/src/collision/narrowphase/GJK/GJKAlgorithm.cpp @@ -47,13 +47,13 @@ using namespace reactphysics3d; /// algorithm on the enlarged object to obtain a simplex polytope that contains the /// origin, they we give that simplex polytope to the EPA algorithm which will compute /// the correct penetration depth and contact points between the enlarged objects. -void GJKAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, - uint batchNbItems, List& gjkResults) { +void GJKAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, + size_t batchNbItems, List& gjkResults) { RP3D_PROFILE("GJKAlgorithm::testCollision()", mProfiler); // For each item in the batch - for (uint batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { + for (size_t batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { Vector3 suppA; // Support point of object A Vector3 suppB; // Support point of object B diff --git a/src/collision/narrowphase/NarrowPhaseInfoBatch.cpp b/src/collision/narrowphase/NarrowPhaseInfoBatch.cpp index ff59d32b..7fe71d67 100644 --- a/src/collision/narrowphase/NarrowPhaseInfoBatch.cpp +++ b/src/collision/narrowphase/NarrowPhaseInfoBatch.cpp @@ -70,7 +70,7 @@ void NarrowPhaseInfoBatch::addNarrowPhaseInfo(uint64 pairId, uint64 pairIndex, E } // Add a new contact point -void NarrowPhaseInfoBatch::addContactPoint(uint index, const Vector3& contactNormal, decimal penDepth, +void NarrowPhaseInfoBatch::addContactPoint(size_t index, const Vector3& contactNormal, decimal penDepth, const Vector3& localPt1, const Vector3& localPt2) { assert(reportContacts[index]); @@ -88,13 +88,13 @@ void NarrowPhaseInfoBatch::addContactPoint(uint index, const Vector3& contactNor } // Reset the remaining contact points -void NarrowPhaseInfoBatch::resetContactPoints(uint index) { +void NarrowPhaseInfoBatch::resetContactPoints(size_t index) { // Get the memory allocator MemoryAllocator& allocator = mOverlappingPairs.getTemporaryAllocator(); // For each remaining contact point info - for (uint i=0; i < contactPoints[index].size(); i++) { + for (size_t i=0; i < contactPoints[index].size(); i++) { ContactPointInfo* contactPoint = contactPoints[index][i]; diff --git a/src/collision/narrowphase/SAT/SATAlgorithm.cpp b/src/collision/narrowphase/SAT/SATAlgorithm.cpp index 4271b900..465f30f2 100644 --- a/src/collision/narrowphase/SAT/SATAlgorithm.cpp +++ b/src/collision/narrowphase/SAT/SATAlgorithm.cpp @@ -56,13 +56,13 @@ SATAlgorithm::SATAlgorithm(bool clipWithPreviousAxisIfStillColliding, MemoryAllo // Test collision between a sphere and a convex mesh bool SATAlgorithm::testCollisionSphereVsConvexPolyhedron(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, - uint batchStartIndex, uint batchNbItems) const { + size_t batchStartIndex, size_t batchNbItems) const { bool isCollisionFound = false; RP3D_PROFILE("SATAlgorithm::testCollisionSphereVsConvexPolyhedron()", mProfiler); - for (uint batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { + for (size_t batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { bool isSphereShape1 = narrowPhaseInfoBatch.collisionShapes1[batchIndex]->getType() == CollisionShapeType::SPHERE; @@ -163,7 +163,7 @@ decimal SATAlgorithm::computePolyhedronFaceVsSpherePenetrationDepth(uint faceInd } // Test collision between a capsule and a convex mesh -bool SATAlgorithm::testCollisionCapsuleVsConvexPolyhedron(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchIndex) const { +bool SATAlgorithm::testCollisionCapsuleVsConvexPolyhedron(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchIndex) const { RP3D_PROFILE("SATAlgorithm::testCollisionCapsuleVsConvexPolyhedron()", mProfiler); @@ -383,7 +383,7 @@ bool SATAlgorithm::computeCapsulePolyhedronFaceContactPoints(uint referenceFaceI decimal penetrationDepth, const Transform& polyhedronToCapsuleTransform, Vector3& normalWorld, const Vector3& separatingAxisCapsuleSpace, const Vector3& capsuleSegAPolyhedronSpace, const Vector3& capsuleSegBPolyhedronSpace, - NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchIndex, bool isCapsuleShape1) const { + NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchIndex, bool isCapsuleShape1) const { RP3D_PROFILE("SATAlgorithm::computeCapsulePolyhedronFaceContactPoints", mProfiler); @@ -430,7 +430,7 @@ bool SATAlgorithm::computeCapsulePolyhedronFaceContactPoints(uint referenceFaceI bool contactFound = false; // For each of the two clipped points - for (uint i = 0; igetType() == CollisionShapeType::CONVEX_POLYHEDRON); assert(narrowPhaseInfoBatch.collisionShapes2[batchIndex]->getType() == CollisionShapeType::CONVEX_POLYHEDRON); @@ -890,7 +890,7 @@ bool SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron(NarrowPhaseIn bool SATAlgorithm::computePolyhedronVsPolyhedronFaceContactPoints(bool isMinPenetrationFaceNormalPolyhedron1, const ConvexPolyhedronShape* polyhedron1, const ConvexPolyhedronShape* polyhedron2, const Transform& polyhedron1ToPolyhedron2, const Transform& polyhedron2ToPolyhedron1, - uint minFaceIndex, NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchIndex) const { + uint minFaceIndex, NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchIndex) const { RP3D_PROFILE("SATAlgorithm::computePolyhedronVsPolyhedronFaceContactPoints", mProfiler); diff --git a/src/collision/narrowphase/SphereVsCapsuleAlgorithm.cpp b/src/collision/narrowphase/SphereVsCapsuleAlgorithm.cpp index a441cbca..871cb6d9 100755 --- a/src/collision/narrowphase/SphereVsCapsuleAlgorithm.cpp +++ b/src/collision/narrowphase/SphereVsCapsuleAlgorithm.cpp @@ -35,12 +35,12 @@ 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(SphereVsCapsuleNarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems, +bool SphereVsCapsuleAlgorithm::testCollision(SphereVsCapsuleNarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, size_t batchNbItems, MemoryAllocator& memoryAllocator) { bool isCollisionFound = false; - for (uint batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { + for (size_t batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { assert(!narrowPhaseInfoBatch.isColliding[batchIndex]); assert(narrowPhaseInfoBatch.contactPoints[batchIndex].size() == 0); diff --git a/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp b/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp index 0c0f609b..60a9c2f5 100644 --- a/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp +++ b/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp @@ -35,7 +35,7 @@ using namespace reactphysics3d; // Compute the narrow-phase collision detection between a sphere and a convex polyhedron // This technique is based on the "Robust Contact Creation for Physics Simulations" presentation // by Dirk Gregorius. -bool SphereVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems, +bool SphereVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, size_t batchNbItems, bool clipWithPreviousAxisIfStillColliding, MemoryAllocator& memoryAllocator) { // First, we run the GJK algorithm @@ -55,7 +55,7 @@ bool SphereVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& narr assert(gjkResults.size() == batchNbItems); // For each item in the batch - for (uint batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { + for (size_t batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { assert(narrowPhaseInfoBatch.collisionShapes1[batchIndex]->getType() == CollisionShapeType::CONVEX_POLYHEDRON || narrowPhaseInfoBatch.collisionShapes2[batchIndex]->getType() == CollisionShapeType::CONVEX_POLYHEDRON); diff --git a/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp b/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp index 943ae89d..b4655eea 100755 --- a/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp +++ b/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp @@ -31,12 +31,12 @@ // We want to use the ReactPhysics3D namespace using namespace reactphysics3d; -bool SphereVsSphereAlgorithm::testCollision(SphereVsSphereNarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems, MemoryAllocator& memoryAllocator) { +bool SphereVsSphereAlgorithm::testCollision(SphereVsSphereNarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, size_t batchNbItems, MemoryAllocator& memoryAllocator) { bool isCollisionFound = false; // For each item in the batch - for (uint batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { + for (size_t batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) { assert(narrowPhaseInfoBatch.contactPoints[batchIndex].size() == 0); assert(!narrowPhaseInfoBatch.isColliding[batchIndex]); diff --git a/src/collision/shapes/ConcaveMeshShape.cpp b/src/collision/shapes/ConcaveMeshShape.cpp index c395b0ec..4f36e3c7 100644 --- a/src/collision/shapes/ConcaveMeshShape.cpp +++ b/src/collision/shapes/ConcaveMeshShape.cpp @@ -114,13 +114,13 @@ void ConcaveMeshShape::getTriangleVerticesIndices(uint subPart, uint triangleInd } // Return the number of sub parts contained in this mesh -uint ConcaveMeshShape::getNbSubparts() const +size_t ConcaveMeshShape::getNbSubparts() const { return mTriangleMesh->getNbSubparts(); } // Return the number of triangles in a sub part of the mesh -uint ConcaveMeshShape::getNbTriangles(uint subPart) const +uint ConcaveMeshShape::getNbTriangles(size_t subPart) const { assert(mTriangleMesh->getSubpart(subPart)); return mTriangleMesh->getSubpart(subPart)->getNbTriangles(); @@ -142,7 +142,7 @@ void ConcaveMeshShape::computeOverlappingTriangles(const AABB& localAABB, List overlappingNodes(allocator); mDynamicAABBTree.reportAllShapesOverlappingWithAABB(aabb, overlappingNodes); - const uint nbOverlappingNodes = overlappingNodes.size(); + const uint nbOverlappingNodes = static_cast(overlappingNodes.size()); // Add space in the list of triangles vertices/normals for the new triangles triangleVertices.addWithoutInit(nbOverlappingNodes * 3); diff --git a/src/collision/shapes/HeightFieldShape.cpp b/src/collision/shapes/HeightFieldShape.cpp index 7c2e99cd..f3e2784b 100644 --- a/src/collision/shapes/HeightFieldShape.cpp +++ b/src/collision/shapes/HeightFieldShape.cpp @@ -45,7 +45,7 @@ HeightFieldShape::HeightFieldShape(int nbGridColumns, int nbGridRows, decimal mi const void* heightFieldData, HeightDataType dataType, MemoryAllocator& allocator, int upAxis, decimal integerHeightScale, const Vector3& scaling) : ConcaveShape(CollisionShapeName::HEIGHTFIELD, allocator, scaling), mNbColumns(nbGridColumns), mNbRows(nbGridRows), - mWidth(nbGridColumns - 1), mLength(nbGridRows - 1), mMinHeight(minHeight), + mWidth(static_cast(nbGridColumns - 1)), mLength(static_cast(nbGridRows - 1)), mMinHeight(minHeight), mMaxHeight(maxHeight), mUpAxis(upAxis), mIntegerHeightScale(integerHeightScale), mHeightDataType(dataType) { diff --git a/src/engine/PhysicsWorld.cpp b/src/engine/PhysicsWorld.cpp index 19e55eab..8469fe69 100644 --- a/src/engine/PhysicsWorld.cpp +++ b/src/engine/PhysicsWorld.cpp @@ -118,8 +118,10 @@ PhysicsWorld::~PhysicsWorld() { "Physics World: Physics world " + mName + " has been destroyed", __FILE__, __LINE__); // Destroy all the collision bodies that have not been removed - for (int i=mCollisionBodies.size() - 1 ; i >= 0; i--) { - destroyCollisionBody(mCollisionBodies[i]); + // Remark: consider using reverse iterator; don't know exactly why reverse iteration is necessary. + //for (int i=mCollisionBodies.size() - 1 ; i >= 0; i--) { + for (size_t i = 1, cachedSize = mCollisionBodies.size(); i <= cachedSize; ++i) { + destroyCollisionBody(mCollisionBodies[cachedSize - i]); } #ifdef IS_RP3D_PROFILING_ENABLED @@ -136,8 +138,10 @@ PhysicsWorld::~PhysicsWorld() { } // Destroy all the rigid bodies that have not been removed - for (int i=mRigidBodies.size() - 1; i >= 0; i--) { - destroyRigidBody(mRigidBodies[i]); + // Remark: consider using reverse iterator; don't know exactly why reverse iteration is necessary. + //for (int i=mRigidBodies.size() - 1; i >= 0; i--) { + for (size_t i = 1, cachedSize = mRigidBodies.size(); i <= cachedSize; ++i) { + destroyRigidBody(mRigidBodies[cachedSize - i]); } assert(mJointsComponents.getNbComponents() == 0); @@ -803,7 +807,7 @@ void PhysicsWorld::createIslands() { // For each contact pair in which the current body is involded List& contactPairs = itBodyContactPairs->second; - for (uint p=0; p < contactPairs.size(); p++) { + for (size_t p=0; p < contactPairs.size(); p++) { ContactPair& pair = (*mCollisionDetection.mCurrentContactPairs)[contactPairs[p]]; @@ -815,10 +819,10 @@ void PhysicsWorld::createIslands() { && !mCollidersComponents.getIsTrigger(pair.collider1Entity) && !mCollidersComponents.getIsTrigger(pair.collider2Entity)) { assert(pair.potentialContactManifoldsIndices.size() > 0); - nbTotalManifolds += pair.potentialContactManifoldsIndices.size(); + nbTotalManifolds += static_cast(pair.potentialContactManifoldsIndices.size()); // Add the contact manifold into the island - mIslands.nbContactManifolds[islandIndex] += pair.potentialContactManifoldsIndices.size(); + mIslands.nbContactManifolds[islandIndex] += static_cast(pair.potentialContactManifoldsIndices.size()); pair.isAlreadyInIsland = true; const Entity otherBodyEntity = pair.body1Entity == bodyToVisitEntity ? pair.body2Entity : pair.body1Entity; @@ -1042,7 +1046,7 @@ void PhysicsWorld::setIsGravityEnabled(bool isGravityEnabled) { * @param index Index of a CollisionBody in the world * @return Constant pointer to a given CollisionBody */ -const CollisionBody* PhysicsWorld::getCollisionBody(uint index) const { +const CollisionBody* PhysicsWorld::getCollisionBody(size_t index) const { if (index >= getNbCollisionBodies()) { @@ -1060,7 +1064,7 @@ const CollisionBody* PhysicsWorld::getCollisionBody(uint index) const { * @param index Index of a CollisionBody in the world * @return Pointer to a given CollisionBody */ -CollisionBody* PhysicsWorld::getCollisionBody(uint index) { +CollisionBody* PhysicsWorld::getCollisionBody(size_t index) { if (index >= getNbCollisionBodies()) { @@ -1078,7 +1082,7 @@ CollisionBody* PhysicsWorld::getCollisionBody(uint index) { * @param index Index of a RigidBody in the world * @return Constant pointer to a given RigidBody */ -const RigidBody* PhysicsWorld::getRigidBody(uint index) const { +const RigidBody* PhysicsWorld::getRigidBody(size_t index) const { if (index >= getNbRigidBodies()) { @@ -1096,7 +1100,7 @@ const RigidBody* PhysicsWorld::getRigidBody(uint index) const { * @param index Index of a RigidBody in the world * @return Pointer to a given RigidBody */ -RigidBody* PhysicsWorld::getRigidBody(uint index) { +RigidBody* PhysicsWorld::getRigidBody(size_t index) { if (index >= getNbRigidBodies()) { diff --git a/src/mathematics/mathematics_functions.cpp b/src/mathematics/mathematics_functions.cpp index 66c3efda..f9e2af77 100755 --- a/src/mathematics/mathematics_functions.cpp +++ b/src/mathematics/mathematics_functions.cpp @@ -301,22 +301,22 @@ List reactphysics3d::clipPolygonWithPlanes(const List& polygon assert(planesPoints.size() == planesNormals.size()); - uint nbMaxElements = polygonVertices.size() + planesPoints.size(); + size_t nbMaxElements = polygonVertices.size() + planesPoints.size(); List inputVertices(allocator, nbMaxElements); List outputVertices(allocator, nbMaxElements); inputVertices.addRange(polygonVertices); // For each clipping plane - for (uint p=0; pmemoryUnits = static_cast(mBaseAllocator.allocate(BLOCK_SIZE)); assert(newBlock->memoryUnits != nullptr); size_t unitSize = mUnitSizes[indexHeap]; - uint nbUnits = BLOCK_SIZE / unitSize; + size_t nbUnits = BLOCK_SIZE / unitSize; assert(nbUnits * unitSize <= BLOCK_SIZE); void* memoryUnitsStart = static_cast(newBlock->memoryUnits); char* memoryUnitsStartChar = static_cast(memoryUnitsStart); diff --git a/src/systems/CollisionDetectionSystem.cpp b/src/systems/CollisionDetectionSystem.cpp index 24f9660c..f0d9f699 100644 --- a/src/systems/CollisionDetectionSystem.cpp +++ b/src/systems/CollisionDetectionSystem.cpp @@ -157,8 +157,8 @@ void CollisionDetectionSystem::addLostContactPair(uint64 overlappingPairIndex) { const bool isTrigger = isCollider1Trigger || isCollider2Trigger; // Create a lost contact pair - ContactPair lostContactPair(mOverlappingPairs.mPairIds[overlappingPairIndex], body1Entity, body2Entity, collider1Entity, collider2Entity, mLostContactPairs.size(), - true, isTrigger, mMemoryManager.getHeapAllocator()); + ContactPair lostContactPair(mOverlappingPairs.mPairIds[overlappingPairIndex], body1Entity, body2Entity, collider1Entity, collider2Entity, + static_cast(mLostContactPairs.size()), true, isTrigger, mMemoryManager.getHeapAllocator()); mLostContactPairs.add(lostContactPair); } @@ -606,7 +606,7 @@ void CollisionDetectionSystem::computeOverlapSnapshotContactPairs(NarrowPhaseInf RP3D_PROFILE("CollisionDetectionSystem::computeSnapshotContactPairs()", mProfiler); // For each narrow phase info object - for(uint i=0; i < narrowPhaseInfoBatch.getNbObjects(); i++) { + for(size_t i=0; i < narrowPhaseInfoBatch.getNbObjects(); i++) { // If there is a collision if (narrowPhaseInfoBatch.isColliding[i]) { @@ -627,7 +627,7 @@ void CollisionDetectionSystem::computeOverlapSnapshotContactPairs(NarrowPhaseInf // Create a new contact pair ContactPair contactPair(narrowPhaseInfoBatch.overlappingPairIds[i], body1Entity, body2Entity, collider1Entity, collider2Entity, - contactPairs.size(), isTrigger, false, mMemoryManager.getHeapAllocator()); + static_cast(contactPairs.size()), isTrigger, false, mMemoryManager.getHeapAllocator()); contactPairs.add(contactPair); setOverlapContactPairId.add(narrowPhaseInfoBatch.overlappingPairIds[i]); @@ -717,13 +717,13 @@ void CollisionDetectionSystem::createContacts() { mCurrentContactPoints->reserve(mCurrentContactManifolds->size()); // For each contact pair - for (uint p=0; p < (*mCurrentContactPairs).size(); p++) { + for (size_t p=0; p < (*mCurrentContactPairs).size(); p++) { ContactPair& contactPair = (*mCurrentContactPairs)[p]; - contactPair.contactManifoldsIndex = mCurrentContactManifolds->size(); - contactPair.nbContactManifolds = contactPair.potentialContactManifoldsIndices.size(); - contactPair.contactPointsIndex = mCurrentContactPoints->size(); + contactPair.contactManifoldsIndex = static_cast(mCurrentContactManifolds->size()); + contactPair.nbContactManifolds = static_cast(contactPair.potentialContactManifoldsIndices.size()); + contactPair.contactPointsIndex = static_cast(mCurrentContactPoints->size()); // For each potential contact manifold of the pair for (uint m=0; m < contactPair.potentialContactManifoldsIndices.size(); m++) { @@ -731,7 +731,7 @@ void CollisionDetectionSystem::createContacts() { ContactManifoldInfo& potentialManifold = mPotentialContactManifolds[contactPair.potentialContactManifoldsIndices[m]]; // Start index and number of contact points for this manifold - const uint contactPointsIndex = mCurrentContactPoints->size(); + const uint contactPointsIndex = static_cast(mCurrentContactPoints->size()); const int8 nbContactPoints = static_cast(potentialManifold.potentialContactPointsIndices.size()); contactPair.nbToTalContactPoints += nbContactPoints; @@ -745,7 +745,7 @@ void CollisionDetectionSystem::createContacts() { assert(potentialManifold.potentialContactPointsIndices.size() > 0); // For each contact point of the manifold - for (uint c=0; c < potentialManifold.potentialContactPointsIndices.size(); c++) { + for (size_t c=0; c < potentialManifold.potentialContactPointsIndices.size(); c++) { ContactPointInfo& potentialContactPoint = mPotentialContactPoints[potentialManifold.potentialContactPointsIndices[c]]; @@ -811,17 +811,17 @@ void CollisionDetectionSystem::createSnapshotContacts(List& contact ContactPair& contactPair = contactPairs[p]; assert(contactPair.potentialContactManifoldsIndices.size() > 0); - contactPair.contactManifoldsIndex = contactManifolds.size(); - contactPair.nbContactManifolds = contactPair.potentialContactManifoldsIndices.size(); - contactPair.contactPointsIndex = contactPoints.size(); + contactPair.contactManifoldsIndex = static_cast(contactManifolds.size()); + contactPair.nbContactManifolds = static_cast(contactPair.potentialContactManifoldsIndices.size()); + contactPair.contactPointsIndex = static_cast(contactPoints.size()); // For each potential contact manifold of the pair - for (uint m=0; m < contactPair.potentialContactManifoldsIndices.size(); m++) { + for (size_t m=0; m < contactPair.potentialContactManifoldsIndices.size(); m++) { ContactManifoldInfo& potentialManifold = potentialContactManifolds[contactPair.potentialContactManifoldsIndices[m]]; // Start index and number of contact points for this manifold - const uint contactPointsIndex = contactPoints.size(); + const uint contactPointsIndex = static_cast(contactPoints.size()); const int8 nbContactPoints = static_cast(potentialManifold.potentialContactPointsIndices.size()); contactPair.nbToTalContactPoints += nbContactPoints; @@ -835,7 +835,7 @@ void CollisionDetectionSystem::createSnapshotContacts(List& contact assert(potentialManifold.potentialContactPointsIndices.size() > 0); // For each contact point of the manifold - for (uint c=0; c < potentialManifold.potentialContactPointsIndices.size(); c++) { + for (size_t c=0; c < potentialManifold.potentialContactPointsIndices.size(); c++) { ContactPointInfo& potentialContactPoint = potentialContactPoints[potentialManifold.potentialContactPointsIndices[c]]; @@ -853,7 +853,7 @@ void CollisionDetectionSystem::createSnapshotContacts(List& contact void CollisionDetectionSystem::initContactsWithPreviousOnes() { // For each contact pair of the current frame - for (uint i=0; i < mCurrentContactPairs->size(); i++) { + for (size_t i=0; i < mCurrentContactPairs->size(); i++) { ContactPair& currentContactPair = (*mCurrentContactPairs)[i]; @@ -869,7 +869,7 @@ void CollisionDetectionSystem::initContactsWithPreviousOnes() { // --------------------- Contact Manifolds --------------------- // const uint contactManifoldsIndex = currentContactPair.contactManifoldsIndex; - const uint nbContactManifolds = currentContactPair.nbContactManifolds; + const uint8 nbContactManifolds = static_cast(currentContactPair.nbContactManifolds); // For each current contact manifold of the current contact pair for (uint m=contactManifoldsIndex; m < contactManifoldsIndex + nbContactManifolds; m++) { @@ -1025,7 +1025,7 @@ void CollisionDetectionSystem::processPotentialContacts(NarrowPhaseInfoBatch& na assert(!mWorld->mCollisionBodyComponents.getIsEntityDisabled(body1Entity) || !mWorld->mCollisionBodyComponents.getIsEntityDisabled(body2Entity)); - const uint newContactPairIndex = contactPairs->size(); + const uint newContactPairIndex = static_cast(contactPairs->size()); ContactPair overlappingPairContact(pairId, body1Entity, body2Entity, collider1Entity, collider2Entity, newContactPairIndex, mOverlappingPairs.getCollidingInPreviousFrame(pairId), isTrigger, mMemoryManager.getHeapAllocator()); diff --git a/src/systems/ContactSolverSystem.cpp b/src/systems/ContactSolverSystem.cpp index f384a78a..544432d8 100644 --- a/src/systems/ContactSolverSystem.cpp +++ b/src/systems/ContactSolverSystem.cpp @@ -70,8 +70,8 @@ void ContactSolverSystem::init(List* contactManifolds, Listsize(); - uint nbContactPoints = mAllContactPoints->size(); + size_t nbContactManifolds = mAllContactManifolds->size(); + size_t nbContactPoints = mAllContactPoints->size(); mNbContactManifolds = 0; mNbContactPoints = 0; diff --git a/src/utils/DebugRenderer.cpp b/src/utils/DebugRenderer.cpp index 4e1533f7..c8ffc5db 100644 --- a/src/utils/DebugRenderer.cpp +++ b/src/utils/DebugRenderer.cpp @@ -171,7 +171,7 @@ void DebugRenderer::drawCapsule(const Transform& transform, decimal radius, deci Vector3 vertices[(NB_SECTORS_SPHERE + 1) * (NB_STACKS_SPHERE + 1) + (NB_SECTORS_SPHERE + 1)]; - const decimal halfHeight = 0.5 * height; + const decimal halfHeight = decimal(0.5) * height; // Use an even number of stacks const uint nbStacks = NB_STACKS_SPHERE % 2 == 0 ? NB_STACKS_SPHERE : NB_STACKS_SPHERE - 1; @@ -399,11 +399,11 @@ void DebugRenderer::computeDebugRenderingPrimitives(const PhysicsWorld& world) { const bool drawColliderBroadphaseAABB = getIsDebugItemDisplayed(DebugItem::COLLIDER_BROADPHASE_AABB); const bool drawCollisionShape = getIsDebugItemDisplayed(DebugItem::COLLISION_SHAPE); - const uint nbCollisionBodies = world.getNbCollisionBodies(); - const uint nbRigidBodies = world.getNbRigidBodies(); + const auto nbCollisionBodies = world.getNbCollisionBodies(); + const auto nbRigidBodies = world.getNbRigidBodies(); // For each body of the world - for (uint b = 0; b < nbCollisionBodies + nbRigidBodies; b++) { + for (size_t b = 0; b < nbCollisionBodies + nbRigidBodies; b++) { // Get a body const CollisionBody* body = b < nbCollisionBodies ? world.getCollisionBody(b) : world.getRigidBody(b - nbCollisionBodies);