resolve loss of data warnings due to inconsistent data types

Signed-off-by: DNKpp <DNKpp2011@gmail.com>
This commit is contained in:
DNKpp 2020-08-25 22:48:14 +02:00
parent 24714e9e5f
commit c6f7fd0607
46 changed files with 153 additions and 147 deletions

View File

@ -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;
}

View File

@ -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<uint> 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;

View File

@ -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());

View File

@ -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();
}

View File

@ -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);
};
}

View File

@ -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);
};

View File

@ -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);
};

View File

@ -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<GJKResult>& gjkResults);
void testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex,
size_t batchNbItems, List<GJKResult>& gjkResults);
#ifdef IS_RP3D_PROFILING_ENABLED

View File

@ -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();
}

View File

@ -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

View File

@ -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);
};
}

View File

@ -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);
};

View File

@ -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);
};
}

View File

@ -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;

View File

@ -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<decimal>(((float*)mHeightFieldData)[y * mNbColumns + x]);
case HeightDataType::HEIGHT_DOUBLE_TYPE : return static_cast<decimal>(((double*)mHeightFieldData)[y * mNbColumns + x]);
case HeightDataType::HEIGHT_INT_TYPE : return static_cast<decimal>(((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<int>((value < decimal(0.0)) ? value - decimal(0.5) : value + decimal(0.5));
}
// Compute the shape Id for a given triangle

View File

@ -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 -------------------- //

View File

@ -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<T*>(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<T*>(mBuffer)[index]);
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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 -------------------- //

View File

@ -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<uint32>(contactManifoldsIndices.size());
contactManifoldsIndices.add(contactManifoldStartIndex);
nbContactManifolds.add(0);

View File

@ -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();
}

View File

@ -188,7 +188,7 @@ inline void Timer::update() {
mLastUpdateTime = currentTime;
// Update the accumulator value
mAccumulator += mDeltaTime;
mAccumulator += static_cast<double>(mDeltaTime);
}
}

View File

@ -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<DebugLine>& 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<DebugTriangle>& 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();
}

View File

@ -32,6 +32,7 @@
#include <reactphysics3d/containers/Map.h>
#include <string>
#include <iostream>
#include <locale>
#include <fstream>
#include <sstream>
#include <iomanip>
@ -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;
}

View File

@ -103,7 +103,7 @@ CollisionCallback::CallbackData::CallbackData(List<reactphysics3d::ContactPair>*
/// 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());

View File

@ -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<uint>(mEdges.size());
itEdge->second.twinEdgeIndex = edgeIndex + 1;
edge.twinEdgeIndex = edgeIndex;

View File

@ -152,7 +152,7 @@ void PolyhedronMesh::computeCentroid() {
mCentroid += getVertex(v);
}
mCentroid /= getNbVertices();
mCentroid /= static_cast<decimal>(getNbVertices());
}
// Compute and return the area of a face

View File

@ -583,7 +583,7 @@ void DynamicAABBTree::reportAllShapesOverlappingWithShapes(const List<int32>& no
Stack<int32> 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);

View File

@ -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);

View File

@ -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];

View File

@ -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];

View File

@ -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<GJKResult>& gjkResults) {
void GJKAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex,
size_t batchNbItems, List<GJKResult>& 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

View File

@ -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];

View File

@ -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; i<clipSegment.size(); i++) {
for (size_t i = 0; i<clipSegment.size(); i++) {
// Compute the penetration depth of the two clipped points (to filter out the points that does not correspond to the penetration depth)
const decimal clipPointPenDepth = (planesPoints[0] - clipSegment[i]).dot(faceNormal);
@ -478,13 +478,13 @@ bool SATAlgorithm::isMinkowskiFaceCapsuleVsEdge(const Vector3& capsuleSegment, c
}
// Test collision between two convex polyhedrons
bool SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems) const {
bool SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, size_t batchStartIndex, size_t batchNbItems) const {
RP3D_PROFILE("SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron()", mProfiler);
bool isCollisionFound = false;
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);
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);

View File

@ -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);

View File

@ -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);

View File

@ -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]);

View File

@ -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<V
List<int> overlappingNodes(allocator);
mDynamicAABBTree.reportAllShapesOverlappingWithAABB(aabb, overlappingNodes);
const uint nbOverlappingNodes = overlappingNodes.size();
const uint nbOverlappingNodes = static_cast<uint>(overlappingNodes.size());
// Add space in the list of triangles vertices/normals for the new triangles
triangleVertices.addWithoutInit(nbOverlappingNodes * 3);

View File

@ -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<decimal>(nbGridColumns - 1)), mLength(static_cast<decimal>(nbGridRows - 1)), mMinHeight(minHeight),
mMaxHeight(maxHeight), mUpAxis(upAxis), mIntegerHeightScale(integerHeightScale),
mHeightDataType(dataType) {

View File

@ -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<uint>& 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<uint>(pair.potentialContactManifoldsIndices.size());
// Add the contact manifold into the island
mIslands.nbContactManifolds[islandIndex] += pair.potentialContactManifoldsIndices.size();
mIslands.nbContactManifolds[islandIndex] += static_cast<uint>(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()) {

View File

@ -301,22 +301,22 @@ List<Vector3> reactphysics3d::clipPolygonWithPlanes(const List<Vector3>& polygon
assert(planesPoints.size() == planesNormals.size());
uint nbMaxElements = polygonVertices.size() + planesPoints.size();
size_t nbMaxElements = polygonVertices.size() + planesPoints.size();
List<Vector3> inputVertices(allocator, nbMaxElements);
List<Vector3> outputVertices(allocator, nbMaxElements);
inputVertices.addRange(polygonVertices);
// For each clipping plane
for (uint p=0; p<planesPoints.size(); p++) {
for (size_t p=0; p<planesPoints.size(); p++) {
outputVertices.clear();
uint nbInputVertices = inputVertices.size();
uint vStart = nbInputVertices - 1;
size_t nbInputVertices = inputVertices.size();
size_t vStart = nbInputVertices - 1;
// For each edge of the polygon
for (uint vEnd = 0; vEnd<nbInputVertices; vEnd++) {
for (size_t vEnd = 0; vEnd<nbInputVertices; vEnd++) {
Vector3& v1 = inputVertices[vStart];
Vector3& v2 = inputVertices[vEnd];

View File

@ -151,7 +151,7 @@ void* PoolAllocator::allocate(size_t size) {
newBlock->memoryUnits = static_cast<MemoryUnit*>(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<void*>(newBlock->memoryUnits);
char* memoryUnitsStartChar = static_cast<char*>(memoryUnitsStart);

View File

@ -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<uint>(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<uint>(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<uint>(mCurrentContactManifolds->size());
contactPair.nbContactManifolds = static_cast<int8>(contactPair.potentialContactManifoldsIndices.size());
contactPair.contactPointsIndex = static_cast<uint>(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<uint>(mCurrentContactPoints->size());
const int8 nbContactPoints = static_cast<int8>(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<ContactPair>& 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<uint>(contactManifolds.size());
contactPair.nbContactManifolds = static_cast<int8>(contactPair.potentialContactManifoldsIndices.size());
contactPair.contactPointsIndex = static_cast<uint>(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<uint>(contactPoints.size());
const int8 nbContactPoints = static_cast<int8>(potentialManifold.potentialContactPointsIndices.size());
contactPair.nbToTalContactPoints += nbContactPoints;
@ -835,7 +835,7 @@ void CollisionDetectionSystem::createSnapshotContacts(List<ContactPair>& 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<ContactPair>& 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<uint>(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<uint>(contactPairs->size());
ContactPair overlappingPairContact(pairId, body1Entity, body2Entity,
collider1Entity, collider2Entity,
newContactPairIndex, mOverlappingPairs.getCollidingInPreviousFrame(pairId), isTrigger, mMemoryManager.getHeapAllocator());

View File

@ -70,8 +70,8 @@ void ContactSolverSystem::init(List<ContactManifold>* contactManifolds, List<Con
mTimeStep = timeStep;
uint nbContactManifolds = mAllContactManifolds->size();
uint nbContactPoints = mAllContactPoints->size();
size_t nbContactManifolds = mAllContactManifolds->size();
size_t nbContactPoints = mAllContactPoints->size();
mNbContactManifolds = 0;
mNbContactPoints = 0;

View File

@ -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);