Skip to content

Commit

Permalink
Support for Bullet built with double precision.
Browse files Browse the repository at this point in the history
Bullet requires a pre-processor variable to be set before including any
headers to determine whether the library was built with single or double
precision. Failing to do so may result in a linking error.

This commit:

1. Forces CMake to use CONFIG mode (BulletConfig.cmake shipped with
   bullet) instead of MODULE mode (FindBullet.cmake shipped with CMake
   by default) in find_package(Bullet).

2. Updates references to BULLET_INCLUDE_DIRS and BULLET_LIBRARIES
   accordingly

3. Test whether Bullet was built using double precision floating point
   numbers by attempting to compile code that produces a linking error
   when the necessary preprocessor definition is missing.

4. Set the necessary preprocessor definition in config.h.

combined with commits that
Reverted to using Bullet MODULE mode.
and
Minor output message update for consistency

Backport of #660 to release-5.1 branch.
Closes #776.
  • Loading branch information
Michael Koval authored and scpeters committed Oct 4, 2016
1 parent 1c1f458 commit c6d5b2d
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 19 deletions.
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,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 @@ -393,7 +395,7 @@ if(BULLET_FOUND)

set(HAVE_BULLET_COLLISION TRUE)
else()
message(STATUS "Looking for Bullet - NOT found, to use BulletCollisionDetector, 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 @@ -449,7 +451,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 Down Expand Up @@ -483,9 +484,6 @@ endif()
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
14 changes: 0 additions & 14 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 @@ -59,4 +59,8 @@
// BULLET_DEFINITIONS or generate a #cmakedefine header.
#cmakedefine BT_USE_DOUBLE_PRECISION

// 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 c6d5b2d

Please sign in to comment.