From d0481e0901c08a1807dde31843418bdaabba09e8 Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Mon, 22 Feb 2016 23:26:50 +0100 Subject: [PATCH] Fix compilation errors/warnings on Linux --- CMakeLists.txt | 21 +++++++++++++++------ src/body/CollisionBody.cpp | 3 --- src/collision/CollisionDetection.cpp | 2 +- src/collision/ContactManifold.cpp | 2 -- src/collision/ContactManifold.h | 6 +++--- src/collision/ContactManifoldSet.h | 4 ++-- src/collision/narrowphase/GJK/Simplex.cpp | 2 +- src/collision/shapes/ConcaveMeshShape.cpp | 4 ++-- src/collision/shapes/ConvexMeshShape.cpp | 4 ++-- 9 files changed, 26 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d3b6445..5ae579c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ # Minimum cmake version required -CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0 FATAL_ERROR) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3) # Project configuration -PROJECT(REACTPHYSICS3D) +PROJECT(REACTPHYSICS3D CXX) # 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 values" OFF) -# Compiler flags -set(CMAKE_CXX_FLAGS "-Wall") +# Warning Compiler flags +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 INCLUDE_DIRECTORIES(src) @@ -172,8 +181,8 @@ SET (REACTPHYSICS3D_SOURCES ADD_LIBRARY(reactphysics3d STATIC ${REACTPHYSICS3D_SOURCES}) # Enable C++11 features -set_property(TARGET reactphysics3d PROPERTY CXX_STANDARD 11) -set_property(TARGET reactphysics3d PROPERTY CXX_STANDARD_REQUIRED ON) +#set_property(TARGET reactphysics3d PROPERTY CXX_STANDARD 11) +#set_property(TARGET reactphysics3d PROPERTY CXX_STANDARD_REQUIRED ON) # If we need to compile the testbed application IF(COMPILE_TESTBED) diff --git a/src/body/CollisionBody.cpp b/src/body/CollisionBody.cpp index 0536f823..ac4d8f92 100644 --- a/src/body/CollisionBody.cpp +++ b/src/body/CollisionBody.cpp @@ -118,7 +118,6 @@ void CollisionBody::removeCollisionShape(const ProxyShape* proxyShape) { current->~ProxyShape(); mWorld.mMemoryAllocator.release(current, sizeof(ProxyShape)); mNbCollisionShapes--; - assert(mNbCollisionShapes >= 0); return; } @@ -145,8 +144,6 @@ void CollisionBody::removeCollisionShape(const ProxyShape* proxyShape) { // Get the next element in the list current = current->mNext; } - - assert(mNbCollisionShapes >= 0); } // Remove all the collision shapes diff --git a/src/collision/CollisionDetection.cpp b/src/collision/CollisionDetection.cpp index 5044224c..9ec45523 100644 --- a/src/collision/CollisionDetection.cpp +++ b/src/collision/CollisionDetection.cpp @@ -121,7 +121,7 @@ void CollisionDetection::reportCollisionBetweenShapes(CollisionCallback* callbac // For each contact manifold set of the overlapping pair const ContactManifoldSet& manifoldSet = pair->getContactManifoldSet(); - for (uint j=0; j= 0); } // Update the contact manifold diff --git a/src/collision/ContactManifold.h b/src/collision/ContactManifold.h index 0c16f0b0..0df125ba 100644 --- a/src/collision/ContactManifold.h +++ b/src/collision/ContactManifold.h @@ -314,7 +314,7 @@ inline void ContactManifold::setFrictionTwistImpulse(decimal frictionTwistImpuls // Return a contact point of the manifold inline ContactPoint* ContactManifold::getContactPoint(uint index) const { - assert(index >= 0 && index < mNbContactPoints); + assert(index < mNbContactPoints); return mContactPoints[index]; } @@ -327,7 +327,7 @@ inline bool ContactManifold::isAlreadyInIsland() const { inline Vector3 ContactManifold::getAverageContactNormal() const { Vector3 averageNormal; - for (int i=0; igetNormal(); } @@ -338,7 +338,7 @@ inline Vector3 ContactManifold::getAverageContactNormal() const { inline decimal ContactManifold::getLargestContactDepth() const { decimal largestDepth = 0.0f; - for (int i=0; igetPenetrationDepth(); if (depth > largestDepth) { largestDepth = depth; diff --git a/src/collision/ContactManifoldSet.h b/src/collision/ContactManifoldSet.h index 6fd822ce..e071ce0a 100644 --- a/src/collision/ContactManifoldSet.h +++ b/src/collision/ContactManifoldSet.h @@ -112,7 +112,7 @@ class ContactManifoldSet { int getNbContactManifolds() const; /// 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 int getTotalNbContactPoints() const; @@ -134,7 +134,7 @@ inline int ContactManifoldSet::getNbContactManifolds() const { } // Return a given contact manifold -inline ContactManifold* ContactManifoldSet::getContactManifold(uint index) const { +inline ContactManifold* ContactManifoldSet::getContactManifold(int index) const { assert(index >= 0 && index < mNbManifolds); return mManifolds[index]; } diff --git a/src/collision/narrowphase/GJK/Simplex.cpp b/src/collision/narrowphase/GJK/Simplex.cpp index 2c469429..0f0a824d 100644 --- a/src/collision/narrowphase/GJK/Simplex.cpp +++ b/src/collision/narrowphase/GJK/Simplex.cpp @@ -57,7 +57,7 @@ void Simplex::addPoint(const Vector3& point, const Vector3& suppPointA, const Ve mLastFoundBit <<= 1; } - assert(mLastFound >= 0 && mLastFound < 4); + assert(mLastFound < 4); // Add the point into the simplex mPoints[mLastFound] = point; diff --git a/src/collision/shapes/ConcaveMeshShape.cpp b/src/collision/shapes/ConcaveMeshShape.cpp index 5f8e44f6..d618de4a 100644 --- a/src/collision/shapes/ConcaveMeshShape.cpp +++ b/src/collision/shapes/ConcaveMeshShape.cpp @@ -49,7 +49,7 @@ void ConcaveMeshShape::initBVHTree() { // TODO : Try to randomly add the triangles into the tree to obtain a better tree // For each sub-part of the mesh - for (int subPart=0; subPartgetNbSubparts(); subPart++) { + for (uint subPart=0; subPartgetNbSubparts(); subPart++) { // Get the triangle vertex array of the current sub-part TriangleVertexArray* triangleVertexArray = mTriangleMesh->getSubpart(subPart); @@ -62,7 +62,7 @@ void ConcaveMeshShape::initBVHTree() { int indexStride = triangleVertexArray->getIndicesStride(); // For each triangle of the concave mesh - for (int triangleIndex=0; triangleIndexgetNbTriangles(); triangleIndex++) { + for (uint triangleIndex=0; triangleIndexgetNbTriangles(); triangleIndex++) { void* vertexIndexPointer = (indicesStart + triangleIndex * 3 * indexStride); Vector3 trianglePoints[3]; diff --git a/src/collision/shapes/ConvexMeshShape.cpp b/src/collision/shapes/ConvexMeshShape.cpp index 2d66f953..8dcda4bf 100644 --- a/src/collision/shapes/ConvexMeshShape.cpp +++ b/src/collision/shapes/ConvexMeshShape.cpp @@ -76,7 +76,7 @@ ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool int indexStride = triangleVertexArray->getIndicesStride(); // 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 if (vertexType == TriangleVertexArray::VERTEX_FLOAT_TYPE) { @@ -99,7 +99,7 @@ ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool if (mIsEdgesInformationUsed) { // For each triangle of the mesh - for (int triangleIndex=0; triangleIndexgetNbTriangles(); triangleIndex++) { + for (uint triangleIndex=0; triangleIndexgetNbTriangles(); triangleIndex++) { void* vertexIndexPointer = (indicesStart + triangleIndex * 3 * indexStride);