Skip to content

Commit bd74d52

Browse files
committed
cmake: make double default and float optional
1 parent e6b95de commit bd74d52

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ option(
7272
"Make Coal retro-compatible with HPP-FCL."
7373
FALSE
7474
)
75-
option(COAL_USE_DOUBLE_PRECISION "Use double precision (64-bit) instead of single precision (32-bit)" TRUE)
75+
option(COAL_USE_FLOAT_PRECISION "Use float precision (32-bit) instead of the default double precision (64-bit)" FALSE)
7676

7777
# Check if the submodule cmake have been initialized
7878
set(JRL_CMAKE_MODULES "${CMAKE_CURRENT_LIST_DIR}/cmake")

include/coal/data_types.h

+17-21
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,12 @@
6060
#endif // COAL_HAS_OCTOMAP
6161

6262
namespace coal {
63-
#ifdef COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL
64-
// We keep the FCL_REAL typedef and the Vec[..]f typedefs for backward
65-
// compatibility.
66-
#ifdef COAL_USE_DOUBLE_PRECISION
67-
typedef double FCL_REAL;
63+
#ifdef COAL_USE_FLOAT_PRECISION
64+
COAL_DEPRECATED typedef float CoalScalar;
65+
typedef float Scalar;
6866
#else
69-
typedef float FCL_REAL;
70-
#endif
71-
typedef Eigen::Matrix<FCL_REAL, 3, 1> Vec3f;
72-
typedef Eigen::Matrix<FCL_REAL, 2, 1> Vec2f;
73-
typedef Eigen::Matrix<FCL_REAL, 6, 1> Vec6f;
74-
typedef Eigen::Matrix<FCL_REAL, Eigen::Dynamic, 1> VecXf;
75-
typedef Eigen::Matrix<FCL_REAL, 3, 3> Matrix3f;
76-
typedef Eigen::Matrix<FCL_REAL, Eigen::Dynamic, 3, Eigen::RowMajor> Matrixx3f;
77-
typedef Eigen::Matrix<FCL_REAL, Eigen::Dynamic, 2, Eigen::RowMajor> Matrixx2f;
78-
typedef Eigen::Matrix<FCL_REAL, Eigen::Dynamic, Eigen::Dynamic> MatrixXf;
79-
#endif
80-
81-
#ifdef COAL_USE_DOUBLE_PRECISION
8267
COAL_DEPRECATED typedef double CoalScalar;
8368
typedef double Scalar;
84-
#else
85-
COAL_DEPRECATED typedef float CoalScalar;
86-
typedef float Scalar;
8769
#endif
8870
typedef Eigen::Matrix<Scalar, 3, 1> Vec3s;
8971
typedef Eigen::Matrix<Scalar, 2, 1> Vec2s;
@@ -97,6 +79,20 @@ typedef Eigen::Matrix<Eigen::DenseIndex, Eigen::Dynamic, 3, Eigen::RowMajor>
9779
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> MatrixXs;
9880
typedef Eigen::Vector2i support_func_guess_t;
9981

82+
#ifdef COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL
83+
// We keep the FCL_REAL typedef and the Vec[..]f typedefs for backward
84+
// compatibility.
85+
typedef Scalar FCL_REAL;
86+
typedef Vec3s Vec3f;
87+
typedef Vec2s Vec2f;
88+
typedef Vec6s Vec6f;
89+
typedef VecXs VecXf;
90+
typedef Matrix3s Matrix3f;
91+
typedef MatrixX3s Matrixx3f;
92+
typedef MatrixX2s Matrixx2f;
93+
typedef MatrixXs MatrixXf;
94+
#endif
95+
10096
/// @brief Initial guess to use for the GJK algorithm
10197
/// DefaultGuess: Vec3s(1, 0, 0)
10298
/// CachedGuess: previous vector found by GJK or guess cached by the user

src/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ if(COAL_ENABLE_LOGGING)
250250
)
251251
endif()
252252

253-
if (COAL_USE_DOUBLE_PRECISION)
254-
target_compile_definitions(${LIBRARY_NAME} PUBLIC COAL_USE_DOUBLE_PRECISION)
253+
if (COAL_USE_FLOAT_PRECISION)
254+
target_compile_definitions(${LIBRARY_NAME} PUBLIC COAL_USE_FLOAT_PRECISION)
255255
endif()
256256

257257
if(WIN32)

0 commit comments

Comments
 (0)