From 01468f607b03ba612aa9fb401641e611092915cd Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Sun, 11 May 2014 22:59:28 +0400 Subject: [PATCH 2/6] unbundle bullet Signed-off-by: Igor Gnatenko --- CMakeLists.txt | 12 +++++++----- src/physics/btKartRaycast.cpp | 4 ++-- src/physics/physics.cpp | 32 ++++++++++++++++++++------------ 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d87a98..9672f3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,9 +36,13 @@ set(STK_INSTALL_BINARY_DIR "bin" CACHE set(STK_INSTALL_DATA_DIR "share/supertuxkart" CACHE STRING "Install data folder to this directory, absolute or relative to CMAKE_INSTALL_PREFIX") +include(FindPkgConfig) + # Build the Bullet physics library -add_subdirectory("${PROJECT_SOURCE_DIR}/lib/bullet") -include_directories("${PROJECT_SOURCE_DIR}/lib/bullet/src") +pkg_search_module(BULLET REQUIRED bullet) +include_directories(${BULLET_INCLUDE_DIRS}) +string(REGEX REPLACE "\\." "" BULLET_VERSION_INT ${BULLET_VERSION}) +add_definitions(-DBULLET_VERSION=${BULLET_VERSION_INT}) # Build the ENet UDP network library add_subdirectory("${PROJECT_SOURCE_DIR}/lib/enet") @@ -222,9 +226,7 @@ endif() # Common library dependencies target_link_libraries(supertuxkart - bulletdynamics - bulletcollision - bulletmath + ${BULLET_LIBRARIES} enet stkirrlicht ${CURL_LIBRARIES} diff --git a/src/physics/btKartRaycast.cpp b/src/physics/btKartRaycast.cpp index 13b310f..7c00d42 100644 --- a/src/physics/btKartRaycast.cpp +++ b/src/physics/btKartRaycast.cpp @@ -63,7 +63,7 @@ void* btKartRaycaster::castRay(const btVector3& from, const btVector3& to, if (rayCallback.hasHit()) { - btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject); + const btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject); if (body && body->hasContactResponse()) { result.m_hitPointInWorld = rayCallback.m_hitPointWorld; @@ -88,7 +88,7 @@ void* btKartRaycaster::castRay(const btVector3& from, const btVector3& to, result.m_hitNormalInWorld.getZ()); #endif } - return body; + return (void *) body; } } return 0; diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index fcff1f0..b49446a 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -432,14 +432,24 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies, btStackAlloc* stackAlloc, btDispatcher* dispatcher) { - btScalar returnValue= - btSequentialImpulseConstraintSolver::solveGroup(bodies, numBodies, - manifold, numManifolds, - constraints, - numConstraints, info, - debugDrawer, - stackAlloc, - dispatcher); + #if BULLET_VERSION >= 282 + btScalar returnValue= + btSequentialImpulseConstraintSolver::solveGroup(bodies, numBodies, + manifold, numManifolds, + constraints, + numConstraints, info, + debugDrawer, + dispatcher); + #else + btScalar returnValue= + btSequentialImpulseConstraintSolver::solveGroup(bodies, numBodies, + manifold, numManifolds, + constraints, + numConstraints, info, + debugDrawer, + stackAlloc, + dispatcher); + #endif int currentNumManifolds = m_dispatcher->getNumManifolds(); // We can't explode a rocket in a loop, since a rocket might collide with // more than one object, and/or more than once with each object (if there @@ -450,10 +460,8 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies, btPersistentManifold* contact_manifold = m_dynamics_world->getDispatcher()->getManifoldByIndexInternal(i); - btCollisionObject* objA = - static_cast(contact_manifold->getBody0()); - btCollisionObject* objB = - static_cast(contact_manifold->getBody1()); + const btCollisionObject* objA = contact_manifold->getBody0(); + const btCollisionObject* objB = contact_manifold->getBody1(); unsigned int num_contacts = contact_manifold->getNumContacts(); if(!num_contacts) continue; // no real collision -- 1.9.3