diff --git a/src/ipc/broad_phase/lbvh.cpp b/src/ipc/broad_phase/lbvh.cpp index f2107839d..97ba8a9c6 100644 --- a/src/ipc/broad_phase/lbvh.cpp +++ b/src/ipc/broad_phase/lbvh.cpp @@ -149,13 +149,14 @@ void LBVH::init_bvh( { IPC_TOOLKIT_PROFILE_BLOCK("compute_morton_codes"); - const Eigen::Array3d mesh_width = mesh_aabb.max - mesh_aabb.min; + const Eigen::Array3d mesh_width_inv = + 1.0 / (mesh_aabb.max - mesh_aabb.min); tbb::parallel_for(size_t(0), boxes.size(), [&](size_t i) { const auto& box = boxes[i]; const Eigen::Array3d center = 0.5 * (box.min + box.max); const Eigen::Array3d mapped_center = - (center - mesh_aabb.min) / mesh_width; + (center - mesh_aabb.min) * mesh_width_inv; if (dim == 2) { morton_codes[i].morton_code = diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 716cb3c87..7cfa3e9ef 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -76,9 +76,15 @@ if(IPC_TOOLKIT_WITH_CUDA) # other libraries and executables. set_target_properties(ipc_toolkit_tests PROPERTIES CUDA_SEPARABLE_COMPILATION ON) - # Use the same CUDA architectures Scalable CCD - # get_target_property(CMAKE_CUDA_ARCHITECTURES scalable_ccd CUDA_ARCHITECTURES) - set_target_properties(ipc_toolkit_tests PROPERTIES CUDA_ARCHITECTURES "native") + # Use the CUDA architectures specified by the user (e.g. via + # -DCMAKE_CUDA_ARCHITECTURES) and only fall back to auto-detecting the local + # GPU ("native") when none were given. "native" requires a physical GPU, so + # the fallback fails in GPU-less environments such as CI/Docker builds. + if(DEFINED CMAKE_CUDA_ARCHITECTURES) + set_target_properties(ipc_toolkit_tests PROPERTIES CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}") + else() + set_target_properties(ipc_toolkit_tests PROPERTIES CUDA_ARCHITECTURES "native") + endif() endif() if (IPC_TOOLKIT_TESTS_CCD_BENCHMARK)