Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ dart_option(DART_FAST_DEBUG "Add -O1 option for DEBUG mode build" OFF)
# See: https://medium.com/@alasher/colored-c-compiler-output-with-ninja-clang-gcc-10bfe7f2b949
dart_option(DART_FORCE_COLORED_OUTPUT
"Always produce ANSI-colored output (GNU/Clang only)." OFF)
dart_option(DART_USE_SYSTEM_ODE "Use system ODE" ON)
dart_option(DART_USE_SYSTEM_BULLET "Use system Bullet" ON)
dart_option(DART_USE_SYSTEM_IMGUI "Use system ImGui" OFF)
dart_option(DART_USE_SYSTEM_GOOGLEBENCHMARK "Use system GoogleBenchmark" OFF)
dart_option(DART_USE_SYSTEM_GOOGLETEST "Use system GoogleTest" OFF)
Expand Down
25 changes: 25 additions & 0 deletions cmake/DARTFindBullet.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@
# 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.
if(NOT DART_USE_SYSTEM_BULLET)
if(TARGET BulletCollision AND TARGET LinearMath)
if(DEFINED DART_BULLET_SOURCE_DIR)
set(_bullet_include_dir "${DART_BULLET_SOURCE_DIR}/src")
elseif(DEFINED BULLET_PHYSICS_SOURCE_DIR)
set(_bullet_include_dir "${BULLET_PHYSICS_SOURCE_DIR}/src")
endif()
if(_bullet_include_dir)
set(BULLET_INCLUDE_DIRS "${_bullet_include_dir}")
endif()
set(BULLET_LIBRARIES BulletCollision LinearMath)
set(BULLET_FOUND TRUE)
set(Bullet_FOUND TRUE)
if(NOT TARGET Bullet)
add_library(Bullet INTERFACE IMPORTED)
if(BULLET_INCLUDE_DIRS)
target_include_directories(Bullet INTERFACE ${BULLET_INCLUDE_DIRS})
endif()
target_link_libraries(Bullet INTERFACE ${BULLET_LIBRARIES})
endif()
unset(_bullet_include_dir)
return()
endif()
endif()

find_package(Bullet COMPONENTS BulletMath BulletCollision MODULE QUIET)

if((BULLET_FOUND OR Bullet_FOUND) AND NOT TARGET Bullet)
Expand Down
57 changes: 56 additions & 1 deletion cmake/DARTFindDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,66 @@ option(DART_SKIP_spdlog "If ON, do not use spdlog even if it is found." OFF)
mark_as_advanced(DART_SKIP_spdlog)
dart_find_package(spdlog)

if(NOT DART_USE_SYSTEM_ODE OR NOT DART_USE_SYSTEM_BULLET)
include(FetchContent)
endif()

if(NOT DART_USE_SYSTEM_ODE)
# Match Ubuntu/conda-forge libode settings (libccd enabled, box-cylinder disabled).
set(_dart_build_shared_libs "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)

set(ODE_WITH_LIBCCD ON CACHE BOOL "" FORCE)
set(ODE_WITH_LIBCCD_SYSTEM ON CACHE BOOL "" FORCE)
set(ODE_WITH_LIBCCD_BOX_CYL OFF CACHE BOOL "" FORCE)
set(ODE_WITH_DEMOS OFF CACHE BOOL "" FORCE)
set(ODE_WITH_TESTS OFF CACHE BOOL "" FORCE)
FetchContent_Declare(ode
URL https://bitbucket.org/odedevs/ode/downloads/ode-0.16.6.tar.gz
URL_HASH SHA256=c91a28c6ff2650284784a79c726a380d6afec87ecf7a35c32a6be0c5b74513e8
)
FetchContent_MakeAvailable(ode)
set(DART_ODE_SOURCE_DIR "${ode_SOURCE_DIR}" CACHE INTERNAL "ODE source dir.")
set(DART_ODE_BINARY_DIR "${ode_BINARY_DIR}" CACHE INTERNAL "ODE binary dir.")

set(BUILD_SHARED_LIBS "${_dart_build_shared_libs}" CACHE BOOL "" FORCE)
unset(_dart_build_shared_libs)
endif()

if(NOT DART_USE_SYSTEM_BULLET)
# Match conda-forge Bullet float64 build flags.
set(_dart_build_shared_libs "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)

set(USE_DOUBLE_PRECISION ON CACHE BOOL "" FORCE)
set(BULLET2_MULTITHREADING ON CACHE BOOL "" FORCE)
set(BUILD_BULLET_ROBOTICS_GUI_EXTRA OFF CACHE BOOL "" FORCE)
set(BUILD_BULLET_ROBOTICS_EXTRA OFF CACHE BOOL "" FORCE)
set(BUILD_GIMPACTUTILS_EXTRA OFF CACHE BOOL "" FORCE)
set(BUILD_CPU_DEMOS OFF CACHE BOOL "" FORCE)
set(BUILD_BULLET2_DEMOS OFF CACHE BOOL "" FORCE)
set(BUILD_UNIT_TESTS OFF CACHE BOOL "" FORCE)
set(BUILD_OPENGL3_DEMOS OFF CACHE BOOL "" FORCE)
set(BUILD_PYBULLET OFF CACHE BOOL "" FORCE)
set(BUILD_PYBULLET_NUMPY OFF CACHE BOOL "" FORCE)
set(INSTALL_LIBS ON CACHE BOOL "" FORCE)
set(INSTALL_EXTRA_LIBS ON CACHE BOOL "" FORCE)
FetchContent_Declare(bullet
URL https://github.com/bulletphysics/bullet3/archive/refs/tags/3.25.tar.gz
URL_HASH SHA256=c45afb6399e3f68036ddb641c6bf6f552bf332d5ab6be62f7e6c54eda05ceb77
)
FetchContent_MakeAvailable(bullet)
set(DART_BULLET_SOURCE_DIR "${bullet_SOURCE_DIR}" CACHE INTERNAL "Bullet source dir.")
set(DART_BULLET_BINARY_DIR "${bullet_BINARY_DIR}" CACHE INTERNAL "Bullet binary dir.")

set(BUILD_SHARED_LIBS "${_dart_build_shared_libs}" CACHE BOOL "" FORCE)
unset(_dart_build_shared_libs)
endif()

#--------------------
# Misc. dependencies
#--------------------

# Doxygen
find_package(Doxygen QUIET)
dart_check_optional_package(DOXYGEN "generating API documentation" "doxygen")

11 changes: 11 additions & 0 deletions cmake/DARTFindODE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
#
# This file is provided under the "BSD-style" License

if(NOT DART_USE_SYSTEM_ODE)
if(TARGET ODE)
if(NOT TARGET ODE::ODE)
add_library(ODE::ODE ALIAS ODE)
endif()
set(ODE_FOUND TRUE)
set(ode_FOUND TRUE)
return()
endif()
endif()

find_package(ODE QUIET CONFIG NAMES ODE ode)

if(NOT ODE_FOUND AND NOT ode_FOUND)
Expand Down
3 changes: 2 additions & 1 deletion dart/collision/bullet/BulletTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
#ifndef DART_COLLISION_BULLET_BULLETTYPES_HPP_
#define DART_COLLISION_BULLET_BULLETTYPES_HPP_

#include <dart/collision/bullet/BulletInclude.hpp>

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

namespace dart {
namespace collision {
Expand Down
3 changes: 3 additions & 0 deletions dart/collision/bullet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ set(component_name collision-bullet)
# Add target
dart_add_library(${target_name} ${hdrs} ${srcs} ${detail_hdrs} ${detail_srcs})
target_link_libraries(${target_name} PUBLIC dart Bullet)
if(BT_USE_DOUBLE_PRECISION)
target_compile_definitions(${target_name} PUBLIC BT_USE_DOUBLE_PRECISION)
endif()

# Component
add_component(${PROJECT_NAME} ${component_name})
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/test_Raycast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ void testBasicInterface(const std::shared_ptr<CollisionDetector>& cd)
Eigen::Vector3d(2, 0, 0),
option,
&result);
EXPECT_TRUE(result.hasHit());
EXPECT_EQ(result.mRayHits.size(), 1u);
ASSERT_TRUE(result.hasHit());
ASSERT_EQ(result.mRayHits.size(), 1u);
rayHit = result.mRayHits[0];
EXPECT_TRUE(equals(rayHit.mPoint, Eigen::Vector3d(-1, 0, 0)));
EXPECT_TRUE(equals(rayHit.mNormal, Eigen::Vector3d(-1, 0, 0)));
Expand All @@ -118,8 +118,8 @@ void testBasicInterface(const std::shared_ptr<CollisionDetector>& cd)
Eigen::Vector3d(-2, 0, 0),
option,
&result);
EXPECT_TRUE(result.hasHit());
EXPECT_EQ(result.mRayHits.size(), 1u);
ASSERT_TRUE(result.hasHit());
ASSERT_EQ(result.mRayHits.size(), 1u);
rayHit = result.mRayHits[0];
EXPECT_TRUE(equals(rayHit.mPoint, Eigen::Vector3d(1, 0, 0)));
EXPECT_TRUE(equals(rayHit.mNormal, Eigen::Vector3d(1, 0, 0)));
Expand All @@ -133,8 +133,8 @@ void testBasicInterface(const std::shared_ptr<CollisionDetector>& cd)
Eigen::Vector3d(2, 0, 0),
option,
&result);
EXPECT_TRUE(result.hasHit());
EXPECT_EQ(result.mRayHits.size(), 1u);
ASSERT_TRUE(result.hasHit());
ASSERT_EQ(result.mRayHits.size(), 1u);
rayHit = result.mRayHits[0];
EXPECT_TRUE(equals(rayHit.mPoint, Eigen::Vector3d(0, 0, 0)));
EXPECT_TRUE(equals(rayHit.mNormal, Eigen::Vector3d(-1, 0, 0)));
Expand Down Expand Up @@ -194,8 +194,8 @@ void testOptions(const std::shared_ptr<CollisionDetector>& cd)
Eigen::Vector3d(5, 0, 0),
option,
&result);
EXPECT_TRUE(result.hasHit());
EXPECT_EQ(result.mRayHits.size(), 1u);
ASSERT_TRUE(result.hasHit());
ASSERT_EQ(result.mRayHits.size(), 1u);
rayHit = result.mRayHits[0];
EXPECT_TRUE(equals(rayHit.mPoint, Eigen::Vector3d(-3, 0, 0)));
EXPECT_TRUE(equals(rayHit.mNormal, Eigen::Vector3d(-1, 0, 0)));
Expand All @@ -212,8 +212,8 @@ void testOptions(const std::shared_ptr<CollisionDetector>& cd)
Eigen::Vector3d(5, 0, 0),
option,
&result);
EXPECT_TRUE(result.hasHit());
EXPECT_EQ(result.mRayHits.size(), 2u);
ASSERT_TRUE(result.hasHit());
ASSERT_EQ(result.mRayHits.size(), 2u);
rayHit = result.mRayHits[0];
EXPECT_TRUE(equals(rayHit.mPoint, Eigen::Vector3d(-3, 0, 0)));
EXPECT_TRUE(equals(rayHit.mNormal, Eigen::Vector3d(-1, 0, 0)));
Expand Down
Loading