Skip to content

Commit

Permalink
Merge pull request #660 from personalrobotics/bugfix/BulletDoublePrec…
Browse files Browse the repository at this point in the history
…ision

Support for Bullet built with double precision
  • Loading branch information
jslee02 committed Apr 11, 2016
2 parents 7c04754 + dcc9b4e commit 1854915
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 25 deletions.
44 changes: 35 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ if(ASSIMP_FOUND)

# Check for missing symbols in ASSIMP (see #451)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_DEFINITIONS "")
set(CMAKE_REQUIRED_FLAGS "")
set(CMAKE_REQUIRED_INCLUDES ${ASSIMP_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${ASSIMP_LIBRARIES})

Expand Down Expand Up @@ -340,15 +342,43 @@ else()
set(HAVE_SHARK FALSE)
endif()

# BulletCollision
find_package(Bullet COMPONENTS BulletMath BulletCollision QUIET)
# Bullet. Force MODULE mode to use the FindBullet.cmake file distributed with
# CMake. Otherwise, we may end up using the BulletConfig.cmake file distributed
# with Bullet, which uses relative paths and may break transitive dependencies.
find_package(Bullet COMPONENTS BulletMath BulletCollision MODULE QUIET)

if(BULLET_FOUND)
message(STATUS "Looking for BulletCollision - ${BULLET_VERSION} found")
# Test whether Bullet was built with double precision. If so, we need to
# define the BT_USE_DOUBLE_PRECISION pre-processor directive before including
# any Bullet headers. This is a workaround for the fact that Bullet does not
# add the definition to BULLET_DEFINITIONS or generate a #cmakedefine header.
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_FLAGS "")
set(CMAKE_REQUIRED_DEFINITIONS "-DBT_USE_DOUBLE_PRECISION")
set(CMAKE_REQUIRED_INCLUDES "${BULLET_INCLUDE_DIRS}")
set(CMAKE_REQUIRED_LIBRARIES "${BULLET_LIBRARIES}")
check_cxx_source_compiles(
"
#include <btBulletCollisionCommon.h>
int main()
{
btVector3 v(0., 0., 1.);
btStaticPlaneShape planeShape(v, 0.);
return 0;
}
"
BT_USE_DOUBLE_PRECISION
)

if(BT_USE_DOUBLE_PRECISION)
message(STATUS "Looking for Bullet - found (double precision)")
else()
message(STATUS "Looking for Bullet - found (single precision)")
endif()

set(HAVE_BULLET_COLLISION TRUE)
add_definitions(-DHAVE_BULLET_COLLISION)
else()
message(STATUS "Looking for BulletCollision - NOT found, please install libbullet-dev")
message(STATUS "Looking for Bullet - NOT found, please install libbullet-dev")
set(HAVE_BULLET_COLLISION FALSE)
endif()

Expand Down Expand Up @@ -403,7 +433,6 @@ include_directories(SYSTEM ${OPENGL_INCLUDE_DIR})
include_directories(SYSTEM ${GLUT_INCLUDE_DIR})
if(HAVE_BULLET_COLLISION)
include_directories(SYSTEM ${BULLET_INCLUDE_DIRS})
add_definitions(${BULLET_CFLAGS})
endif()

if(NOT BUILD_CORE_ONLY)
Expand All @@ -430,9 +459,6 @@ include_directories("${CMAKE_BINARY_DIR}")
link_directories("${CMAKE_BINARY_DIR}/lib")
link_directories("${CMAKE_INSTALL_PREFIX}/lib")
link_directories(${Boost_LIBRARY_DIRS})
if(HAVE_BULLET_COLLISION)
link_directories("${BULLET_LIBRARY_DIRS}")
endif()

#===============================================================================
# Check for non-case-sensitive filesystems
Expand Down
16 changes: 0 additions & 16 deletions cmake/config.h.in

This file was deleted.

3 changes: 3 additions & 0 deletions dart/collision/bullet/BulletCollisionDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

// Must be included before any Bullet headers.
#include "dart/config.h"

#include "dart/collision/bullet/BulletCollisionDetector.h"

#include <vector>
Expand Down
3 changes: 3 additions & 0 deletions dart/collision/bullet/BulletCollisionDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#ifndef DART_COLLISION_BULLET_BULLETCOLLISIONDETECTOR_H_
#define DART_COLLISION_BULLET_BULLETCOLLISIONDETECTOR_H_

// Must be included before any Bullet headers.
#include "dart/config.h"

#include <vector>
#include <map>

Expand Down
3 changes: 3 additions & 0 deletions dart/collision/bullet/BulletCollisionNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

// Must be included before any Bullet headers.
#include "dart/config.h"

#include "dart/collision/bullet/BulletCollisionNode.h"

#include <iostream>
Expand Down
3 changes: 3 additions & 0 deletions dart/collision/bullet/BulletCollisionNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#ifndef DART_COLLISION_BULLET_BULLETCOLLISIONNODE_H_
#define DART_COLLISION_BULLET_BULLETCOLLISIONNODE_H_

// Must be included before any Bullet headers.
#include "dart/config.h"

#include <vector>

#include <assimp/scene.h>
Expand Down
3 changes: 3 additions & 0 deletions dart/collision/bullet/BulletTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

// Must be included before any Bullet headers.
#include "dart/config.h"

#include "dart/collision/bullet/BulletTypes.h"

namespace dart {
Expand Down
3 changes: 3 additions & 0 deletions dart/collision/bullet/BulletTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#ifndef DART_COLLISION_BULLET_BULLETTYPES_H_
#define DART_COLLISION_BULLET_BULLETTYPES_H_

// Must be included before any Bullet headers.
#include "dart/config.h"

#include <Eigen/Dense>
#include <btBulletCollisionCommon.h>

Expand Down
4 changes: 4 additions & 0 deletions dart/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@
#cmakedefine01 ASSIMP_AISCENE_CTOR_DTOR_DEFINED
#cmakedefine01 ASSIMP_AIMATERIAL_CTOR_DTOR_DEFINED

// Workaround for the fact that Bullet does not add the definition to
// BULLET_DEFINITIONS or generate a #cmakedefine header.
#cmakedefine BT_USE_DOUBLE_PRECISION

#endif // #ifndef DART_CONFIG_H_

0 comments on commit 1854915

Please sign in to comment.