### Install Unity VHACD Package via Git URL Source: https://github.com/unity-technologies/vhacd/blob/main/README.md Instructions to add the VHACD package to a Unity project using its Git URL through the Package Manager. This method allows users to specify a particular package version or retrieve the latest version from the main branch. ```Unity Package Manager https://github.com/Unity-Technologies/VHACD.git?path=/com.unity.robotics.vhacd ``` -------------------------------- ### VHACD Library CMake Build Script Source: https://github.com/unity-technologies/vhacd/blob/main/src/VHACD_Lib/CMakeLists.txt This CMake script configures the build process for the VHACD library. It sets C++ standards, finds and links OpenCL and OpenMP, defines compiler flags, adds the library, specifies include directories, and handles installation of targets and configuration files. ```CMake project(VHACD_LIB CXX C) include(${CMAKE_COMMON_INC}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") if (NOT NO_OPENCL) #include(FindOpenCL OPTIONAL) find_package(OpenCL) endif() if (NOT NO_OPENMP) #include(FindOpenMP OPTIONAL) find_package(OpenMP) endif() if(OPENMP_FOUND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") endif() set(LIB_TYPE "STATIC" CACHE STRING "STATIC, SHARED or MODULE?") message("[VHACD] \t LIB_TYPE " ${LIB_TYPE}) add_library(vhacd ${LIB_TYPE} ${PROJECT_CPP_FILES} ${PROJECT_C_FILES} ${PROJECT_INC_FILES} ${PROJECT_INL_FILES} ${PROJECT_CL_FILES}) if (OpenCL_FOUND) target_include_directories(vhacd PRIVATE "${OpenCL_INCLUDE_DIR}") target_link_libraries(vhacd PRIVATE "${OpenCL_LIBRARY}") target_compile_definitions(vhacd PRIVATE -DOPENCL_FOUND=1 ) target_compile_definitions(vhacd PRIVATE -DOPENCL_CL_FILES="${PROJECT_CL_FILES}" ) endif() target_include_directories(vhacd PUBLIC $ $ # /include/mylib ) message("[VHACD] \t -> CMAKE_INSTALL_PREFIX " ${CMAKE_INSTALL_PREFIX}) install(TARGETS vhacd EXPORT vhacd-targets DESTINATION lib) install(FILES ${PROJECT_INC_FILES} DESTINATION include) install(FILES ${PROJECT_INL_FILES} DESTINATION include) set(VHACD_LIB_VERSION 3.2.0) include(CMakePackageConfigHelpers) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-config-version.cmake" VERSION ${VHACD_LIB_VERSION} COMPATIBILITY AnyNewerVersion ) export(EXPORT vhacd-targets NAMESPACE :: FILE "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-targets.cmake" ) configure_file(cmake/vhacd-config.cmake "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-config.cmake" COPYONLY ) set(ConfigPackageLocation lib/cmake/vhacd) install(EXPORT vhacd-targets FILE vhacd-targets.cmake DESTINATION ${ConfigPackageLocation} NAMESPACE :: ) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/vhacd/vhacd-config-version.cmake" DESTINATION ${ConfigPackageLocation} COMPONENT Devel ) ``` -------------------------------- ### Configure VHACD Project Build with CMake Source: https://github.com/unity-technologies/vhacd/blob/main/src/test/CMakeLists.txt This CMake script defines the build process for the VHACD project. It conditionally enables OpenCL and OpenMP support, sets C/C++ compiler and linker flags based on found dependencies, creates the `testVHACD` executable from source files, and links it against the `vhacd` library and OpenCL if available. It also includes platform-specific compiler flags and library linking for non-Windows/Apple systems. ```CMake project(VHACD_TEST) include(${CMAKE_COMMON_INC}) if (NOT NO_OPENCL) find_package(OpenCL QUIET) endif() if (NOT NO_OPENMP) find_package(OpenMP QUIET) endif() if(OPENMP_FOUND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") endif() add_executable(testVHACD ${PROJECT_CPP_FILES} ${PROJECT_C_FILES} ${PROJECT_INC_FILES} ${PROJECT_INL_FILES}) target_include_directories(testVHACD PRIVATE ${CMAKE_SOURCE_DIR}/VHACD_Lib/public ${CMAKE_CURRENT_SOURCE_DIR}/inc) target_link_libraries(testVHACD vhacd) if (OpenCL_FOUND) include_directories("${OpenCL_INCLUDE_DIRS}") add_definitions( -DOPENCL_FOUND=1 ) target_link_libraries(testVHACD ${OpenCL_LIBRARIES}) endif() if (NOT WIN32 AND NOT APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall") target_link_libraries(testVHACD rt) endif() ``` -------------------------------- ### Configure VHACD Library Build with CMake Source: https://github.com/unity-technologies/vhacd/blob/main/src/dll/CMakeLists.txt This CMake script defines the build process for the `libvhacd` shared library. It includes logic for detecting and integrating OpenCL and OpenMP, applying specific compiler and linker flags based on the detected environment (e.g., enabling OpenMP, setting debug flags for non-Windows/Apple systems), and specifying include paths and linked libraries for the project. ```CMake project(VHACD_DLL) include(${CMAKE_COMMON_INC}) if (NOT NO_OPENCL) find_package(OpenCL QUIET) endif() if (NOT NO_OPENMP) find_package(OpenMP QUIET) endif() if(OPENMP_FOUND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") endif() add_library(libvhacd SHARED ${PROJECT_CPP_FILES} ${PROJECT_C_FILES} ${PROJECT_INC_FILES} ${PROJECT_INL_FILES}) target_include_directories(libvhacd PRIVATE ${CMAKE_SOURCE_DIR}/VHACD_Lib/public) target_link_libraries(libvhacd vhacd) if (OpenCL_FOUND) include_directories("${OpenCL_INCLUDE_DIRS}") add_definitions( -DOPENCL_FOUND=1 ) target_link_libraries(libvhacd ${OpenCL_LIBRARIES}) endif() if (NOT WIN32 AND NOT APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall") target_link_libraries(libvhacd rt) endif() ``` -------------------------------- ### VHACD Configuration Parameters Source: https://github.com/unity-technologies/vhacd/blob/main/README.md Defines the configurable parameters for the VHACD library, including their purpose, default values, and valid ranges. These parameters control various aspects of the approximate convex decomposition process, such as voxelization, clipping stages, concavity thresholds, and output convex hull properties. ```APIDOC Parameters: - Name: resolution Description: maximum number of voxels generated during the voxelization stage Default: 100,000 Range: 10,000-64,000,000 - Name: depth Description: maximum number of clipping stages. During each split stage, all the model parts (with a concavity higher than the user defined threshold) are clipped according the "best" clipping plane Default: 20 Range: 1-32 - Name: concavity Description: maximum concavity Default: 0.0025 Range: 0.0-1.0 - Name: planeDownsampling Description: controls the granularity of the search for the "best" clipping plane Default: 4 Range: 1-16 - Name: convexhullDownsampling Description: controls the precision of the convex-hull generation process during the clipping plane selection stage Default: 4 Range: 1-16 - Name: alpha Description: controls the bias toward clipping along symmetry planes Default: 0.05 Range: 0.0-1.0 - Name: beta Description: controls the bias toward clipping along revolution axes Default: 0.05 Range: 0.0-1.0 - Name: gamma Description: maximum allowed concavity during the merge stage Default: 0.00125 Range: 0.0-1.0 - Name: pca Description: enable/disable normalizing the mesh before applying the convex decomposition Default: 0 Range: 0-1 - Name: mode Description: 0: voxel-based approximate convex decomposition, 1: tetrahedron-based approximate convex decomposition Default: 0 Range: 0-1 - Name: maxNumVerticesPerCH Description: controls the maximum number of triangles per convex-hull Default: 64 Range: 4-1024 - Name: minVolumePerCH Description: controls the adaptive sampling of the generated convex-hulls Default: 0.0001 Range: 0.0-0.01 ``` -------------------------------- ### Configure VHACD Project with CMake Source: https://github.com/unity-technologies/vhacd/blob/main/src/CMakeLists.txt This CMake script defines the VHACD project, sets the minimum required CMake version, and introduces build options for disabling OpenCL and OpenMP. It also ensures position-independent code generation and modifies MSVC runtime library flags. ```CMake cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) project(VHACD) option(NO_OPENCL "NO_OPENCL" OFF) option(NO_OPENMP "NO_OPENMP" OFF) message("NO_OPENCL " ${NO_OPENCL}) message("NO_OPENMP " ${NO_OPENMP}) set(CMAKE_POSITION_INDEPENDENT_CODE ON) #set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") set(CompilerFlags CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO ) foreach(CompilerFlag ${CompilerFlags}) string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") set(${CompilerFlag} "${${CompilerFlag}}" CACHE STRING "msvc compiler flags" FORCE) message("MSVC flags: ${CompilerFlag}:${${CompilerFlag}}") endforeach() #set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/output" CACHE PATH "project install prefix" FORCE) set(CMAKE_COMMON_INC "${CMAKE_SOURCE_DIR}/../scripts/cmake_common.cmake") add_subdirectory ("${CMAKE_SOURCE_DIR}/VHACD_Lib") add_subdirectory ("${CMAKE_SOURCE_DIR}/test") add_subdirectory ("${CMAKE_SOURCE_DIR}/dll") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.