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

View File

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

View File

@ -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<manifoldSet.getNbContactManifolds(); j++) {
for (int j=0; j<manifoldSet.getNbContactManifolds(); j++) {
const ContactManifold* manifold = manifoldSet.getContactManifold(j);

View File

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

View File

@ -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; i<mNbContactPoints; i++) {
for (uint i=0; i<mNbContactPoints; i++) {
averageNormal += mContactPoints[i]->getNormal();
}
@ -338,7 +338,7 @@ inline Vector3 ContactManifold::getAverageContactNormal() const {
inline decimal ContactManifold::getLargestContactDepth() const {
decimal largestDepth = 0.0f;
for (int i=0; i<mNbContactPoints; i++) {
for (uint i=0; i<mNbContactPoints; i++) {
decimal depth = mContactPoints[i]->getPenetrationDepth();
if (depth > largestDepth) {
largestDepth = depth;

View File

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

View File

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

View File

@ -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; subPart<mTriangleMesh->getNbSubparts(); subPart++) {
for (uint subPart=0; subPart<mTriangleMesh->getNbSubparts(); 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; triangleIndex<triangleVertexArray->getNbTriangles(); triangleIndex++) {
for (uint triangleIndex=0; triangleIndex<triangleVertexArray->getNbTriangles(); triangleIndex++) {
void* vertexIndexPointer = (indicesStart + triangleIndex * 3 * indexStride);
Vector3 trianglePoints[3];

View File

@ -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; triangleIndex<triangleVertexArray->getNbTriangles(); triangleIndex++) {
for (uint triangleIndex=0; triangleIndex<triangleVertexArray->getNbTriangles(); triangleIndex++) {
void* vertexIndexPointer = (indicesStart + triangleIndex * 3 * indexStride);