diff --git a/include/reactphysics3d/containers/Map.h b/include/reactphysics3d/containers/Map.h index 0fa8c083..31755361 100755 --- a/include/reactphysics3d/containers/Map.h +++ b/include/reactphysics3d/containers/Map.h @@ -276,7 +276,7 @@ class Map { uint32* newBuckets = static_cast(mAllocator.allocate(capacity * sizeof(uint32))); // Allocate memory for the entries - const uint32 nbAllocatedEntries = capacity * DEFAULT_LOAD_FACTOR; + const uint32 nbAllocatedEntries = static_cast(capacity * DEFAULT_LOAD_FACTOR); assert(nbAllocatedEntries > 0); Pair* newEntries = static_cast*>(mAllocator.allocate(nbAllocatedEntries * sizeof(Pair))); uint32* newNextEntries = static_cast(mAllocator.allocate(nbAllocatedEntries * sizeof(uint32))); @@ -352,7 +352,7 @@ class Map { /// Returns true if the item has been inserted and false otherwise. bool add(const Pair& keyValue, bool insertIfAlreadyPresent = false) { - uint32 bucket; + uint32 bucket = INVALID_INDEX; // Compute the hash code of the value const size_t hashCode = Hash()(keyValue.first); @@ -389,7 +389,7 @@ class Map { } } - size_t entryIndex; + uint32 entryIndex; // If there are no more free entries to use if (mFreeIndex == INVALID_INDEX) { @@ -411,6 +411,7 @@ class Map { mNbEntries++; + assert(bucket != INVALID_INDEX); mNextEntries[entryIndex] = mBuckets[bucket]; new (mEntries + entryIndex) Pair(keyValue); mBuckets[bucket] = entryIndex; @@ -543,7 +544,7 @@ class Map { const size_t hashCode = Hash()(key); const size_t divider = mHashSize - 1; - bucket = hashCode & divider; + bucket = static_cast(hashCode & divider); auto keyEqual = KeyEqual(); for (uint32 i = mBuckets[bucket]; i != INVALID_INDEX; i = mNextEntries[i]) { diff --git a/include/reactphysics3d/containers/Set.h b/include/reactphysics3d/containers/Set.h index c423043e..f81814fc 100755 --- a/include/reactphysics3d/containers/Set.h +++ b/include/reactphysics3d/containers/Set.h @@ -275,7 +275,7 @@ class Set { uint32* newBuckets = static_cast(mAllocator.allocate(capacity * sizeof(uint32))); // Allocate memory for the entries - const uint32 nbAllocatedEntries = capacity * DEFAULT_LOAD_FACTOR; + const uint32 nbAllocatedEntries = static_cast(capacity * DEFAULT_LOAD_FACTOR); assert(nbAllocatedEntries > 0); V* newEntries = static_cast(mAllocator.allocate(nbAllocatedEntries * sizeof(V))); uint32* newNextEntries = static_cast(mAllocator.allocate(nbAllocatedEntries * sizeof(uint32))); @@ -375,7 +375,7 @@ class Set { } } - size_t entryIndex; + uint32 entryIndex; // If there are no more free entries to use if (mFreeIndex == INVALID_INDEX) { diff --git a/include/reactphysics3d/engine/OverlappingPairs.h b/include/reactphysics3d/engine/OverlappingPairs.h index 21583ef0..65c9fb86 100644 --- a/include/reactphysics3d/engine/OverlappingPairs.h +++ b/include/reactphysics3d/engine/OverlappingPairs.h @@ -399,10 +399,10 @@ RP3D_FORCE_INLINE void OverlappingPairs::setNeedToTestOverlap(uint64 pairId, boo auto it = mMapConvexPairIdToPairIndex.find(pairId); if (it != mMapConvexPairIdToPairIndex.end()) { - mConvexPairs[it->second].needToTestOverlap = needToTestOverlap; + mConvexPairs[static_cast(it->second)].needToTestOverlap = needToTestOverlap; } else { - mConcavePairs[mMapConcavePairIdToPairIndex[pairId]].needToTestOverlap = needToTestOverlap; + mConcavePairs[static_cast(mMapConcavePairIdToPairIndex[pairId])].needToTestOverlap = needToTestOverlap; } } @@ -411,11 +411,11 @@ RP3D_FORCE_INLINE OverlappingPairs::OverlappingPair* OverlappingPairs::getOverla auto it = mMapConvexPairIdToPairIndex.find(pairId); if (it != mMapConvexPairIdToPairIndex.end()) { - return &(mConvexPairs[it->second]); + return &(mConvexPairs[static_cast(it->second)]); } it = mMapConcavePairIdToPairIndex.find(pairId); if (it != mMapConcavePairIdToPairIndex.end()) { - return &(mConcavePairs[it->second]); + return &(mConcavePairs[static_cast(it->second)]); } return nullptr; diff --git a/src/collision/shapes/HeightFieldShape.cpp b/src/collision/shapes/HeightFieldShape.cpp index 06984abf..b508b52e 100644 --- a/src/collision/shapes/HeightFieldShape.cpp +++ b/src/collision/shapes/HeightFieldShape.cpp @@ -262,8 +262,8 @@ bool HeightFieldShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collide switch(mUpAxis) { case 0 : stepI = rayDirection.y > 0 ? 1 : (rayDirection.y < 0 ? -1 : 0); stepJ = rayDirection.z > 0 ? 1 : (rayDirection.z < 0 ? -1 : 0); - nextI = stepI >= 0 ? i + 1 : i; - nextJ = stepJ >= 0 ? j + 1 : j; + nextI = static_cast(stepI >= 0 ? i + 1 : i); + nextJ = static_cast(stepJ >= 0 ? j + 1 : j); sizeI = aabbSize.y / nbCellsI; sizeJ = aabbSize.z / nbCellsJ; tMaxI = ((nextI * sizeI) - outHitGridPoint.y) / rayDirection.y; @@ -273,8 +273,8 @@ bool HeightFieldShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collide break; case 1 : stepI = rayDirection.x > 0 ? 1 : (rayDirection.x < 0 ? -1 : 0); stepJ = rayDirection.z > 0 ? 1 : (rayDirection.z < 0 ? -1 : 0); - nextI = stepI >= 0 ? i + 1 : i; - nextJ = stepJ >= 0 ? j + 1 : j; + nextI = static_cast(stepI >= 0 ? i + 1 : i); + nextJ = static_cast(stepJ >= 0 ? j + 1 : j); sizeI = aabbSize.x / nbCellsI; sizeJ = aabbSize.z / nbCellsJ; tMaxI = ((nextI * sizeI) - outHitGridPoint.x) / rayDirection.x; @@ -284,8 +284,8 @@ bool HeightFieldShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collide break; case 2 : stepI = rayDirection.x > 0 ? 1 : (rayDirection.x < 0 ? -1 : 0); stepJ = rayDirection.y > 0 ? 1 : (rayDirection.y < 0 ? -1 : 0); - nextI = stepI >= 0 ? i + 1 : i; - nextJ = stepJ >= 0 ? j + 1 : j; + nextI = static_cast(stepI >= 0 ? i + 1 : i); + nextJ = static_cast(stepJ >= 0 ? j + 1 : j); sizeI = aabbSize.x / nbCellsI; sizeJ = aabbSize.y / nbCellsJ; tMaxI = ((nextI * sizeI) - outHitGridPoint.x) / rayDirection.x; diff --git a/src/memory/PoolAllocator.cpp b/src/memory/PoolAllocator.cpp index 4999d00d..fb4fca4d 100644 --- a/src/memory/PoolAllocator.cpp +++ b/src/memory/PoolAllocator.cpp @@ -151,7 +151,7 @@ void* PoolAllocator::allocate(size_t size) { newBlock->memoryUnits = 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/utils/DebugRenderer.cpp b/src/utils/DebugRenderer.cpp index 1de0b27e..6c3b77e9 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 uint32 nbStacks = NB_STACKS_SPHERE % 2 == 0 ? NB_STACKS_SPHERE : NB_STACKS_SPHERE - 1;