diff --git a/CMake/External/CMakeLists.txt b/CMake/External/CMakeLists.txt index e658e3880847551a41eb101aeb1ad11befa85706..9121b16fc89ffac4e2402b0489a522e9ae165f2a 100644 --- a/CMake/External/CMakeLists.txt +++ b/CMake/External/CMakeLists.txt @@ -98,6 +98,7 @@ ExternalProject_Add( ${PROJECT_NAME} -D${PROJECT_NAME}_USE_MODEL_REDUCTION:BOOL=${${PROJECT_NAME}_USE_MODEL_REDUCTION} -D${PROJECT_NAME}_ENABLE_AUDIO:BOOL=${${PROJECT_NAME}_ENABLE_AUDIO} -D${PROJECT_NAME}_USE_VRPN:BOOL=${${PROJECT_NAME}_USE_VRPN} + -D${PROJECT_NAME}_USE_PHYSX:BOOL=${${PROJECT_NAME}_USE_PHYSX} -D${PROJECT_NAME}_COLOR_OUTPUT:BOOL=${${PROJECT_NAME}_COLOR_OUTPUT} -D${PROJECT_NAME}_USE_VTK_OSMESA:BOOL=${${PROJECT_NAME}_USE_VTK_OSMESA} -D${PROJECT_NAME}_COVERAGE:BOOL=${${PROJECT_NAME}_COVERAGE} diff --git a/CMake/iMSTKConfig.cmake.in b/CMake/iMSTKConfig.cmake.in index a67039b1df8f88ccad9558c89d4f0dd42f097932..ae81b2b9fd63fcd213ad72af0a01181e490a04ed 100644 --- a/CMake/iMSTKConfig.cmake.in +++ b/CMake/iMSTKConfig.cmake.in @@ -13,6 +13,7 @@ set(iMSTK_DATA_DIR ${PACKAGE_PREFIX_DIR}/data) set(iMSTK_USE_OpenHaptics @iMSTK_USE_OpenHaptics@) set(iMSTK_USE_VTK_OSMESA @iMSTK_USE_VTK_OSMESA@) set(iMSTK_BUILD_TESTING @iMSTK_BUILD_TESTING@) +set(iMSTK_USE_PHYSX @iMSTK_USE_PHYSX@) # Use the iMSTK modules to find all required packages set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules") @@ -51,7 +52,9 @@ find_package( Libusb REQUIRED) find_package( openvr REQUIRED ) # PhysX -find_package(PhysX REQUIRED) +if (iMSTK_USE_PHYSX) + find_package(PhysX REQUIRED) +endif() #SCCD find_package( SCCD REQUIRED ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 58c7030918f8a11e142e7c88f492b2a8f9b53799..38e8085e9d83be086dc3b623d64e63fd8bdf1337 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,7 @@ if (UNIX) endif() endif() option(${PROJECT_NAME}_USE_VRPN "Build with VRPN support" OFF) +option(${PROJECT_NAME}_USE_PHYSX "Build with Physx support" ON) #----------------------------------------------------------------------------- # CTest/Dashboards @@ -143,7 +144,9 @@ if(${PROJECT_NAME}_SUPERBUILD) imstk_define_dependency(g3log) imstk_define_dependency(LibNiFalcon) imstk_define_dependency(openvr) - imstk_define_dependency(PhysX) + if (${PROJECT_NAME}_USE_PHYSX) + imstk_define_dependency(PhysX) + endif() imstk_define_dependency(SCCD) imstk_define_dependency(tbb) imstk_define_dependency(VegaFEM) @@ -224,10 +227,13 @@ find_package( Libusb REQUIRED) find_package( openvr REQUIRED ) # Select the release version of PhysX to use -set(PHYSX_CONFIGURATION "${PHYSX_CONFIGURATION}" CACHE STRING "Select PhysX Library Type for Release and RelWithDebInfo builds") -set(PHYSX_RELEASE_TYPES "RELEASE;CHECKED;PROFILE" CACHE INTERNAL "List of available PhysX release library types") -set_property(CACHE PHYSX_CONFIGURATION PROPERTY STRINGS ${PHYSX_RELEASE_TYPES}) -find_package(PhysX REQUIRED) +if (${PROJECT_NAME}_USE_PHYSX) + add_compile_definitions(IMSTK_USE_PHYSX) + set(PHYSX_CONFIGURATION "${PHYSX_CONFIGURATION}" CACHE STRING "Select PhysX Library Type for Release and RelWithDebInfo builds") + set(PHYSX_RELEASE_TYPES "RELEASE;CHECKED;PROFILE" CACHE INTERNAL "List of available PhysX release library types") + set_property(CACHE PHYSX_CONFIGURATION PROPERTY STRINGS ${PHYSX_RELEASE_TYPES}) + find_package(PhysX REQUIRED) +endif() # SCCD find_package( SCCD REQUIRED ) diff --git a/Examples/PBD/PBDInjection/imstkPbdInflatableDistanceConstraint.cpp b/Examples/PBD/PBDInjection/imstkPbdInflatableDistanceConstraint.cpp index db72f94c2e24e4999505e3ec808152d00683d011..655a553f246f4dcd975f68480a49e20fe434d4a6 100644 --- a/Examples/PBD/PBDInjection/imstkPbdInflatableDistanceConstraint.cpp +++ b/Examples/PBD/PBDInjection/imstkPbdInflatableDistanceConstraint.cpp @@ -21,6 +21,8 @@ #include "imstkPbdInflatableDistanceConstraint.h" +#include <cfloat> + namespace imstk { void diff --git a/Examples/PBD/PBDInjection/imstkPbdInflatableVolumeConstraint.cpp b/Examples/PBD/PBDInjection/imstkPbdInflatableVolumeConstraint.cpp index bb4a6f4453eec774423cabbe502f4eb143801745..f067ae85778ae7f9bafca2061fbb01f982c92197 100644 --- a/Examples/PBD/PBDInjection/imstkPbdInflatableVolumeConstraint.cpp +++ b/Examples/PBD/PBDInjection/imstkPbdInflatableVolumeConstraint.cpp @@ -21,6 +21,8 @@ #include "imstkPbdInflatableVolumeConstraint.h" +#include <cfloat> + namespace imstk { void diff --git a/Examples/RigidBodyDynamics/CMakeLists.txt b/Examples/RigidBodyDynamics/CMakeLists.txt index 6c3fde166c88fa7370e2c2ef1e9d03fe6924776d..ad573d3b8efc600256ab8c0a0b97d5f2ae88a18d 100644 --- a/Examples/RigidBodyDynamics/CMakeLists.txt +++ b/Examples/RigidBodyDynamics/CMakeLists.txt @@ -18,6 +18,8 @@ project(Example-RigidBodyDynamics) +if(iMSTK_USE_PHYSX) + #----------------------------------------------------------------------------- # Create executable #----------------------------------------------------------------------------- @@ -32,3 +34,5 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) # Link libraries to executable #----------------------------------------------------------------------------- target_link_libraries(${PROJECT_NAME} SimulationManager) + +endif() \ No newline at end of file diff --git a/Examples/RigidBodyVirtualCoupling/CMakeLists.txt b/Examples/RigidBodyVirtualCoupling/CMakeLists.txt index b3869546aa7f95a2f8a4c690bd717a2b52ad2a9d..98df44a4e4fc43d65aabc44f6c45775358898ef8 100644 --- a/Examples/RigidBodyVirtualCoupling/CMakeLists.txt +++ b/Examples/RigidBodyVirtualCoupling/CMakeLists.txt @@ -15,7 +15,7 @@ # limitations under the License. # ########################################################################### -if(iMSTK_USE_OpenHaptics) +if(iMSTK_USE_OpenHaptics AND iMSTK_USE_PHYSX) project(Example-RigidBodyVirtualCoupling) diff --git a/README.md b/README.md index 5296873bbd274cc624819084e9c1fc3c02daeb43..e9d26663b9cda3487589a124bcb63dd67788e201 100644 --- a/README.md +++ b/README.md @@ -87,11 +87,14 @@ Run CMake-GUI and follow the directions described [HERE](https://cmake.org/runni If you would like to build on multiple cores add /MP[N] to CMAKE_CXX_FLAGS in CMake-GUI, where N is optional representing the number of cores (without N supplied, the build will use as many cores as available on the device). * ##### PhysX Support +Please note, we are currently deprecating PhysX support, by default PhysX will be OFF but can be turned on via `iMSTK_USE_PHYSX` in the CMAKE configuration + PhysX supports multiple build configurations, designed for different stages of development and deployment. * The DEBUG build can be useful for error analysis, but contains asserts used for SDK development which some customers may find too intrusive for daily use. Optimizations are turned off for this configuration. * The CHECKED build contains code to detect invalid parameters, API race conditions, and other incorrect uses of the API which might otherwise cause mysterious crashes or failures in simulation. * The PROFILE build omits the checks, but still has PVD and memory instrumentation. * The RELEASE build is built for minimal footprint and maximum speed. It omits most checks and instrumentation. + Simulation works the same way in all of them, and all are compiled with high optimization levels (except debug configuration). diff --git a/Source/DynamicalModels/CMakeLists.txt b/Source/DynamicalModels/CMakeLists.txt index f2adc9314ad58f0e1ee2e972dd63f55782d67168..69025909b1a8b1d853cfba643de7eaca1ace2b0d 100644 --- a/Source/DynamicalModels/CMakeLists.txt +++ b/Source/DynamicalModels/CMakeLists.txt @@ -17,7 +17,7 @@ list(APPEND Dependencies VegaFEM::stvk VegaFEM::graph VegaFEM::volumetricMesh - PhysX) + ) list(APPEND ExclusionFiles "") # If using model reduction link to these libs @@ -31,6 +31,18 @@ else() ObjectModels/imstkReducedStVKBodyModel.cpp) endif() +if (iMSTK_USE_PHYSX) + list(APPEND Dependencies PhysX) +else() + list(APPEND ExclusionFiles + ObjectModels/imstkRigidBodyModel.h + ObjectModels/imstkRigidBodyModel.cpp + ObjectModels/imstkRigidBodyWorld.h + ObjectModels/imstkRigidBodyWorld.cpp + ) +endif() + + imstk_add_library(DynamicalModels SUBDIR_LIST ObjectStates diff --git a/Source/Scene/imstkScene.cpp b/Source/Scene/imstkScene.cpp index 0a80c598aa30bd9a3d54a7190cc781619a703108..74685214dd5941520415ad57efec10c5dbb7c1bd 100644 --- a/Source/Scene/imstkScene.cpp +++ b/Source/Scene/imstkScene.cpp @@ -31,7 +31,7 @@ #include "imstkLight.h" #include "imstkLogger.h" #include "imstkParallelUtils.h" -#include "imstkRigidBodyWorld.h" + #include "imstkSequentialTaskGraphController.h" #include "imstkTaskGraph.h" #include "imstkTaskGraphVizWriter.h" @@ -40,6 +40,10 @@ #include "imstkTrackingDeviceControl.h" #include "imstkVisualModel.h" +#ifdef IMSTK_USE_PHYSX +#include "imstkRigidBodyWorld.h" +#endif + namespace imstk { Scene::Scene(const std::string& name, std::shared_ptr<SceneConfig> config) : @@ -167,6 +171,8 @@ Scene::buildTaskGraph() } } +#ifdef IMSTK_USE_PHYSX + // Edge Case: Rigid bodies all have a singular update point because of how PhysX works // Think about generalizes these islands of interaction to Systems if (rigidBodies.size() > 0) @@ -188,6 +194,7 @@ Scene::buildTaskGraph() m_taskGraph->addEdge(physXUpdate, (*i)->getUpdateGeometryNode()); } } +#endif } void diff --git a/Source/SceneEntities/CMakeLists.txt b/Source/SceneEntities/CMakeLists.txt index 5ad9d85d8f1f556ac2beb811cc16a2a6d45a57dc..4de9570fd0401342ac980b67e248ac93f7fac0b0 100644 --- a/Source/SceneEntities/CMakeLists.txt +++ b/Source/SceneEntities/CMakeLists.txt @@ -8,6 +8,13 @@ if (NOT iMSTK_USE_MODEL_REDUCTION) Objects/imstkReducedFeDeformableObject.cpp) endif() +if (NOT iMSTK_USE_PHYSX) + list(APPEND ExclusionFiles + Objects/imstkRigidObject.h + Objects/imstkRigidObject.cpp + ) +endif() + include(imstkAddLibrary) imstk_add_library(SceneEntities EXCLUDE_FILES