Fix compilation errors/warnings on Linux

This commit is contained in:
Daniel Chappuis 2016-02-22 23:26:50 +01:00
parent 7089e07bd3
commit d0481e0901
9 changed files with 26 additions and 22 deletions

View File

@ -1,8 +1,8 @@
# Minimum cmake version required # Minimum cmake version required
CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0 FATAL_ERROR) CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
# Project configuration # Project configuration
PROJECT(REACTPHYSICS3D) PROJECT(REACTPHYSICS3D CXX)
# Build type # Build type
IF (NOT CMAKE_BUILD_TYPE) IF (NOT CMAKE_BUILD_TYPE)
@ -24,8 +24,17 @@ OPTION(PROFILING_ENABLED "Select this if you want to compile with enabled profil
OPTION(DOUBLE_PRECISION_ENABLED "Select this if you want to compile using double precision floating OPTION(DOUBLE_PRECISION_ENABLED "Select this if you want to compile using double precision floating
values" OFF) values" OFF)
# Compiler flags # Warning Compiler flags
set(CMAKE_CXX_FLAGS "-Wall") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
# C++11 flags
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
IF(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ELSE()
message("The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
ENDIF()
# Headers # Headers
INCLUDE_DIRECTORIES(src) INCLUDE_DIRECTORIES(src)
@ -172,8 +181,8 @@ SET (REACTPHYSICS3D_SOURCES
ADD_LIBRARY(reactphysics3d STATIC ${REACTPHYSICS3D_SOURCES}) ADD_LIBRARY(reactphysics3d STATIC ${REACTPHYSICS3D_SOURCES})
# Enable C++11 features # Enable C++11 features
set_property(TARGET reactphysics3d PROPERTY CXX_STANDARD 11) #set_property(TARGET reactphysics3d PROPERTY CXX_STANDARD 11)
set_property(TARGET reactphysics3d PROPERTY CXX_STANDARD_REQUIRED ON) #set_property(TARGET reactphysics3d PROPERTY CXX_STANDARD_REQUIRED ON)
# If we need to compile the testbed application # If we need to compile the testbed application
IF(COMPILE_TESTBED) IF(COMPILE_TESTBED)

View File

@ -118,7 +118,6 @@ void CollisionBody::removeCollisionShape(const ProxyShape* proxyShape) {
current->~ProxyShape(); current->~ProxyShape();
mWorld.mMemoryAllocator.release(current, sizeof(ProxyShape)); mWorld.mMemoryAllocator.release(current, sizeof(ProxyShape));
mNbCollisionShapes--; mNbCollisionShapes--;
assert(mNbCollisionShapes >= 0);
return; return;
} }
@ -145,8 +144,6 @@ void CollisionBody::removeCollisionShape(const ProxyShape* proxyShape) {
// Get the next element in the list // Get the next element in the list
current = current->mNext; current = current->mNext;
} }
assert(mNbCollisionShapes >= 0);
} }
// Remove all the collision shapes // Remove all the collision shapes

View File

@ -121,7 +121,7 @@ void CollisionDetection::reportCollisionBetweenShapes(CollisionCallback* callbac
// For each contact manifold set of the overlapping pair // For each contact manifold set of the overlapping pair
const ContactManifoldSet& manifoldSet = pair->getContactManifoldSet(); const ContactManifoldSet& manifoldSet = pair->getContactManifoldSet();
for (uint j=0; j<manifoldSet.getNbContactManifolds(); j++) { for (int j=0; j<manifoldSet.getNbContactManifolds(); j++) {
const ContactManifold* manifold = manifoldSet.getContactManifold(j); const ContactManifold* manifold = manifoldSet.getContactManifold(j);

View File

@ -96,8 +96,6 @@ void ContactManifold::removeContactPoint(uint index) {
} }
mNbContactPoints--; mNbContactPoints--;
assert(mNbContactPoints >= 0);
} }
// Update the contact manifold // Update the contact manifold

View File

@ -314,7 +314,7 @@ inline void ContactManifold::setFrictionTwistImpulse(decimal frictionTwistImpuls
// Return a contact point of the manifold // Return a contact point of the manifold
inline ContactPoint* ContactManifold::getContactPoint(uint index) const { inline ContactPoint* ContactManifold::getContactPoint(uint index) const {
assert(index >= 0 && index < mNbContactPoints); assert(index < mNbContactPoints);
return mContactPoints[index]; return mContactPoints[index];
} }
@ -327,7 +327,7 @@ inline bool ContactManifold::isAlreadyInIsland() const {
inline Vector3 ContactManifold::getAverageContactNormal() const { inline Vector3 ContactManifold::getAverageContactNormal() const {
Vector3 averageNormal; Vector3 averageNormal;
for (int i=0; i<mNbContactPoints; i++) { for (uint i=0; i<mNbContactPoints; i++) {
averageNormal += mContactPoints[i]->getNormal(); averageNormal += mContactPoints[i]->getNormal();
} }
@ -338,7 +338,7 @@ inline Vector3 ContactManifold::getAverageContactNormal() const {
inline decimal ContactManifold::getLargestContactDepth() const { inline decimal ContactManifold::getLargestContactDepth() const {
decimal largestDepth = 0.0f; decimal largestDepth = 0.0f;
for (int i=0; i<mNbContactPoints; i++) { for (uint i=0; i<mNbContactPoints; i++) {
decimal depth = mContactPoints[i]->getPenetrationDepth(); decimal depth = mContactPoints[i]->getPenetrationDepth();
if (depth > largestDepth) { if (depth > largestDepth) {
largestDepth = depth; largestDepth = depth;

View File

@ -112,7 +112,7 @@ class ContactManifoldSet {
int getNbContactManifolds() const; int getNbContactManifolds() const;
/// Return a given contact manifold /// Return a given contact manifold
ContactManifold* getContactManifold(uint index) const; ContactManifold* getContactManifold(int index) const;
/// Return the total number of contact points in the set of manifolds /// Return the total number of contact points in the set of manifolds
int getTotalNbContactPoints() const; int getTotalNbContactPoints() const;
@ -134,7 +134,7 @@ inline int ContactManifoldSet::getNbContactManifolds() const {
} }
// Return a given contact manifold // Return a given contact manifold
inline ContactManifold* ContactManifoldSet::getContactManifold(uint index) const { inline ContactManifold* ContactManifoldSet::getContactManifold(int index) const {
assert(index >= 0 && index < mNbManifolds); assert(index >= 0 && index < mNbManifolds);
return mManifolds[index]; return mManifolds[index];
} }

View File

@ -57,7 +57,7 @@ void Simplex::addPoint(const Vector3& point, const Vector3& suppPointA, const Ve
mLastFoundBit <<= 1; mLastFoundBit <<= 1;
} }
assert(mLastFound >= 0 && mLastFound < 4); assert(mLastFound < 4);
// Add the point into the simplex // Add the point into the simplex
mPoints[mLastFound] = point; mPoints[mLastFound] = point;

View File

@ -49,7 +49,7 @@ void ConcaveMeshShape::initBVHTree() {
// TODO : Try to randomly add the triangles into the tree to obtain a better tree // TODO : Try to randomly add the triangles into the tree to obtain a better tree
// For each sub-part of the mesh // For each sub-part of the mesh
for (int subPart=0; subPart<mTriangleMesh->getNbSubparts(); subPart++) { for (uint subPart=0; subPart<mTriangleMesh->getNbSubparts(); subPart++) {
// Get the triangle vertex array of the current sub-part // Get the triangle vertex array of the current sub-part
TriangleVertexArray* triangleVertexArray = mTriangleMesh->getSubpart(subPart); TriangleVertexArray* triangleVertexArray = mTriangleMesh->getSubpart(subPart);
@ -62,7 +62,7 @@ void ConcaveMeshShape::initBVHTree() {
int indexStride = triangleVertexArray->getIndicesStride(); int indexStride = triangleVertexArray->getIndicesStride();
// For each triangle of the concave mesh // For each triangle of the concave mesh
for (int triangleIndex=0; triangleIndex<triangleVertexArray->getNbTriangles(); triangleIndex++) { for (uint triangleIndex=0; triangleIndex<triangleVertexArray->getNbTriangles(); triangleIndex++) {
void* vertexIndexPointer = (indicesStart + triangleIndex * 3 * indexStride); void* vertexIndexPointer = (indicesStart + triangleIndex * 3 * indexStride);
Vector3 trianglePoints[3]; Vector3 trianglePoints[3];

View File

@ -76,7 +76,7 @@ ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool
int indexStride = triangleVertexArray->getIndicesStride(); int indexStride = triangleVertexArray->getIndicesStride();
// For each vertex of the mesh // For each vertex of the mesh
for (int v = 0; v < triangleVertexArray->getNbVertices(); v++) { for (uint v = 0; v < triangleVertexArray->getNbVertices(); v++) {
// Get the vertices components of the triangle // Get the vertices components of the triangle
if (vertexType == TriangleVertexArray::VERTEX_FLOAT_TYPE) { if (vertexType == TriangleVertexArray::VERTEX_FLOAT_TYPE) {
@ -99,7 +99,7 @@ ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool
if (mIsEdgesInformationUsed) { if (mIsEdgesInformationUsed) {
// For each triangle of the mesh // For each triangle of the mesh
for (int triangleIndex=0; triangleIndex<triangleVertexArray->getNbTriangles(); triangleIndex++) { for (uint triangleIndex=0; triangleIndex<triangleVertexArray->getNbTriangles(); triangleIndex++) {
void* vertexIndexPointer = (indicesStart + triangleIndex * 3 * indexStride); void* vertexIndexPointer = (indicesStart + triangleIndex * 3 * indexStride);