diff --git a/externals/cmakemodules/GetCompilerAndPlatform.cmake b/externals/cmakemodules/GetCompilerAndPlatform.cmake index efaee8805..30073dd54 100644 --- a/externals/cmakemodules/GetCompilerAndPlatform.cmake +++ b/externals/cmakemodules/GetCompilerAndPlatform.cmake @@ -116,6 +116,8 @@ FUNCTION (GetPlatformBinName PLATFORM_BIN_NAME LIBPATH_SUFFIX) ENDIF() ELSEIF(TARGET_BUILD_PLATFORM STREQUAL "android") SET(RETVAL "android.${ANDROID_ABI}.fp-soft") + ELSEIF(TARGET_BUILD_PLATFORM STREQUAL "emscripten") + SET(RETVAL "emscripten") ELSEIF(TARGET_BUILD_PLATFORM STREQUAL "linux") IF (${CMAKE_LIBRARY_ARCHITECTURE} STREQUAL "x86_64-unknown-linux-gnu" OR ${CMAKE_LIBRARY_ARCHITECTURE} STREQUAL "x86_64-linux-gnu") SET(RETVAL "linux.clang") diff --git a/physx/buildtools/cmake_generate_projects.py b/physx/buildtools/cmake_generate_projects.py index 2504de35f..ecf88732c 100644 --- a/physx/buildtools/cmake_generate_projects.py +++ b/physx/buildtools/cmake_generate_projects.py @@ -20,7 +20,7 @@ def cmakeExt(): def filterPreset(presetName): - winPresetFilter = ['win','uwp','ps4','switch','xboxone','android','crosscompile'] + winPresetFilter = ['win','uwp','ps4','switch','xboxone','android','crosscompile', 'emscripten'] if sys.platform == 'win32': if any(presetName.find(elem) != -1 for elem in winPresetFilter): return True @@ -120,6 +120,8 @@ def isMultiConfigPlatform(self): return False elif self.targetPlatform == 'android': return False + if self.targetPlatform == 'emscripten': + return False return True def getCMakeSwitches(self): @@ -292,6 +294,11 @@ def getPlatformCMakeParams(self): os.environ['PM_CMakeModules_PATH'] + '/ios/ios.toolchain.cmake\"' outString = outString + ' -DPX_OUTPUT_ARCH=arm' return outString + elif self.targetPlatform == 'emscripten': + outString = outString + ' -DTARGET_BUILD_PLATFORM=emscripten' + outString = outString + ' -DCMAKE_TOOLCHAIN_FILE=\"' + \ + os.path.join(os.environ['EMSCRIPTEN'] + '/cmake/Modules/Platform/Emscripten.cmake\"') + return outString return '' @@ -325,6 +332,8 @@ def presetProvided(pName): if os.environ.get('PM_cmake_PATH') is not None: cmakeExec = os.environ['PM_cmake_PATH'] + '/bin/cmake' + cmakeExt() + elif pName == "emscripten": + cmakeExec = 'emcmake cmake' + cmakeExt() else: cmakeExec = 'cmake' + cmakeExt() print('Cmake: ' + cmakeExec) @@ -346,7 +355,7 @@ def presetProvided(pName): cleanupCompilerDir(outputDir) # run the cmake script - #print('Cmake params:' + cmakeParams) + # print('Cmake params:' + cmakeParams) os.chdir(os.path.join(os.environ['PHYSX_ROOT_DIR'], outputDir)) os.system(cmakeExec + ' \"' + os.environ['PHYSX_ROOT_DIR'] + '/compiler/' + cmakeMasterDir + '\"' + cmakeParams) @@ -359,7 +368,7 @@ def presetProvided(pName): cleanupCompilerDir(outputDir) # run the cmake script - #print('Cmake params:' + cmakeParams) + # print('Cmake params:' + cmakeParams) os.chdir(os.path.join(os.environ['PHYSX_ROOT_DIR'], outputDir)) # print(cmakeExec + ' \"' + os.environ['PHYSX_ROOT_DIR'] + '/compiler/' + cmakeMasterDir + '\"' + cmakeParams + ' -DCMAKE_BUILD_TYPE=' + config) os.system(cmakeExec + ' \"' + os.environ['PHYSX_ROOT_DIR'] + '/compiler/' + diff --git a/physx/buildtools/presets/public/emscripten.xml b/physx/buildtools/presets/public/emscripten.xml new file mode 100644 index 000000000..4f405c6ab --- /dev/null +++ b/physx/buildtools/presets/public/emscripten.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/physx/documentation/platformreadme/emscripten/readme_emscripten.html b/physx/documentation/platformreadme/emscripten/readme_emscripten.html new file mode 100644 index 000000000..5723c6081 --- /dev/null +++ b/physx/documentation/platformreadme/emscripten/readme_emscripten.html @@ -0,0 +1,59 @@ + + + + +NVIDIA PhysX SDK for Emscripten ReadMe + + + + +

NVIDIA® PhysX® SDK for Emscripten/Web ReadMe

+ +
+

Location of Binaries:

+ + +

Required packages to generate projects:

+ + +

Generating Makefiles:

+ + +

Building SDK:

+ + +

PhysX GPU Acceleration:

+ + +

PhysX Snippets and Samples:

+ + + This build type generates physx.wasm and physx.js files using the emscripten toolchain. + +
+ +


+Copyright (c) 2008-2019 NVIDIA Corporation, 2701 San Thomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com +

+ + diff --git a/physx/source/compiler/cmake/emscripten/CMakeLists.txt b/physx/source/compiler/cmake/emscripten/CMakeLists.txt new file mode 100644 index 000000000..306aa7e1c --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/CMakeLists.txt @@ -0,0 +1,99 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +STRING(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWERCASE) + +SET(CLANG_WARNINGS "-ferror-limit=0 -Wall -Wextra -Werror -Wstrict-aliasing=2 -Weverything -Wno-documentation-deprecated-sync -Wno-documentation-unknown-command -Wno-gnu-anonymous-struct -Wno-undef -Wno-unused-function -Wno-nested-anon-types -Wno-float-equal -Wno-padded -Wno-weak-vtables -Wno-cast-align -Wno-conversion -Wno-missing-noreturn -Wno-missing-variable-declarations -Wno-shift-sign-overflow -Wno-covered-switch-default -Wno-exit-time-destructors -Wno-global-constructors -Wno-missing-prototypes -Wno-unreachable-code -Wno-unused-macros -Wno-unused-member-function -Wno-used-but-marked-unused -Wno-weak-template-vtables -Wno-deprecated -Wno-non-virtual-dtor -Wno-invalid-noreturn -Wno-return-type-c-linkage -Wno-reserved-id-macro -Wno-c++98-compat-pedantic -Wno-unused-local-typedef -Wno-old-style-cast -Wno-newline-eof -Wno-unused-private-field -Wno-format-nonliteral -Wno-implicit-fallthrough -Wno-undefined-reinterpret-cast -Wno-disabled-macro-expansion -Wno-zero-as-null-pointer-constant -Wno-shadow -Wno-unknown-warning-option -Wno-atomic-implicit-seq-cst -Wno-extra-semi-stmt -Wno-dollar-in-identifier-extension -Wno-alloca -Wno-anon-enum-enum-conversion -Wno-dtor-name") +SET(CMAKE_STATIC_LIBRARY_PREFIX "") + +SET(PHYSX_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-exceptions -ffunction-sections -fdata-sections -fstrict-aliasing ${CLANG_WARNINGS}" CACHE INTERNAL "PhysX CXX") + +SET(CMAKE_CXX_FLAGS ${PHYSX_CXX_FLAGS}) + +SET(PHYSX_EMSCRIPTEN_COMPILE_DEFS "${CUDA_FLAG};${PHYSX_AUTOBUILD}" CACHE INTERNAL "Base PhysX preprocessor definitions") + +SET(PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS "NDEBUG;PX_DEBUG=1;PX_CHECKED=1;${NVTX_FLAG};PX_SUPPORT_PVD=1" CACHE INTERNAL "Debug PhysX preprocessor definitions") +SET(PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS "NDEBUG;PX_CHECKED=1;${NVTX_FLAG};PX_SUPPORT_PVD=1" CACHE INTERNAL "Checked PhysX preprocessor definitions") +SET(PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS "NDEBUG;PX_PROFILE=1;${NVTX_FLAG};PX_SUPPORT_PVD=1" CACHE INTERNAL "Profile PhysX preprocessor definitions") +SET(PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS "NDEBUG;PX_SUPPORT_PVD=0" CACHE INTERNAL "Release PhysX preprocessor definitions") + +# TODO: Turn on SIMD +ADD_DEFINITIONS(-DPX_SIMD_DISABLED) + + +# We need to output .bc files instead of .a files for our emscripten build +SET(CMAKE_STATIC_LIBRARY_SUFFIX ".bc") +SET(CMAKE_AR "emcc") +SET(CMAKE_CXX_CREATE_STATIC_LIBRARY " -o ") + + + + + +INCLUDE(PhysXFoundation.cmake) +INCLUDE(LowLevel.cmake) +INCLUDE(LowLevelAABB.cmake) +INCLUDE(LowLevelDynamics.cmake) +INCLUDE(PhysX.cmake) +INCLUDE(PhysXCharacterKinematic.cmake) +INCLUDE(PhysXCommon.cmake) +INCLUDE(PhysXCooking.cmake) +INCLUDE(PhysXExtensions.cmake) +INCLUDE(PhysXVehicle.cmake) +INCLUDE(SceneQuery.cmake) +INCLUDE(SimulationController.cmake) +INCLUDE(FastXml.cmake) +INCLUDE(PhysXPvdSDK.cmake) +INCLUDE(PhysXTask.cmake) +INCLUDE(emscripten/PhysXWebBindings.cmake) + +# Set folder PhysX SDK to all common SDK source projects +SET_PROPERTY(TARGET PhysX PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET PhysXCharacterKinematic PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET PhysXCommon PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET PhysXCooking PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET PhysXExtensions PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET PhysXVehicle PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET LowLevel PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET LowLevelAABB PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET LowLevelDynamics PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET SceneQuery PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET SimulationController PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET FastXml PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET PhysXPvdSDK PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET PhysXTask PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET PhysXFoundation PROPERTY FOLDER "PhysX SDK") +SET_PROPERTY(TARGET PhysXWebBindings PROPERTY FOLDER "PhysX SDK") + +SET(PHYSXDISTRO_LIBS PhysXFoundation PhysX PhysXCharacterKinematic PhysXPvdSDK PhysXCommon PhysXCooking PhysXExtensions PhysXVehicle PhysXWebBindings) + +INSTALL( + TARGETS ${PHYSXDISTRO_LIBS} + EXPORT PhysXSDK + DESTINATION $<$:${PX_ROOT_LIB_DIR}/debug>$<$:${PX_ROOT_LIB_DIR}/release>$<$:${PX_ROOT_LIB_DIR}/checked>$<$:${PX_ROOT_LIB_DIR}/profile> + ) + diff --git a/physx/source/compiler/cmake/emscripten/FastXml.cmake b/physx/source/compiler/cmake/emscripten/FastXml.cmake new file mode 100644 index 000000000..a3fd9d90c --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/FastXml.cmake @@ -0,0 +1,43 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build FastXml +# + +# Use generator expressions to set config specific preprocessor definitions +SET(FASTXML_COMPILE_DEFS + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS}; + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + +SET(FASTXML_LIBTYPE OBJECT) diff --git a/physx/source/compiler/cmake/emscripten/LowLevel.cmake b/physx/source/compiler/cmake/emscripten/LowLevel.cmake new file mode 100644 index 000000000..228f6b06e --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/LowLevel.cmake @@ -0,0 +1,67 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build LowLevel +# + + +SET(LOWLEVEL_PLATFORM_INCLUDES + ${PHYSX_SOURCE_DIR}/Common/src/linux + ${PHYSX_SOURCE_DIR}/LowLevel/software/include/linux + ${PHYSX_SOURCE_DIR}/LowLevelDynamics/include/linux + ${PHYSX_SOURCE_DIR}/LowLevel/common/include/pipeline/linux +) + +SET(LOWLEVEL_COMPILE_DEFS + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};PX_PHYSX_STATIC_LIB +) + +IF(PX_GENERATE_GPU_STATIC_LIBRARIES) + SET(LOWLEVEL_GPU_LIBTYPE_DEFS + PX_PHYSX_GPU_STATIC; + ) +ENDIF() + +SET(LOWLEVEL_COMPILE_DEFS + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};PX_PHYSX_STATIC_LIB;${LOWLEVEL_GPU_LIBTYPE_DEFS} + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + +SET(LOWLEVEL_PLATFORM_LINK_FLAGS " ") + +SET(LOWLEVEL_LIBTYPE OBJECT) + +# NOTE: Is this a UE4 specific change? +# enable -fPIC so we can link static libs with the editor +#SET_TARGET_PROPERTIES(LowLevel PROPERTIES POSITION_INDEPENDENT_CODE TRUE) diff --git a/physx/source/compiler/cmake/emscripten/LowLevelAABB.cmake b/physx/source/compiler/cmake/emscripten/LowLevelAABB.cmake new file mode 100644 index 000000000..905199c64 --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/LowLevelAABB.cmake @@ -0,0 +1,53 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build LowLevelAABB +# + +SET(LOWLEVELAABB_PLATFORM_INCLUDES + ${PHYSX_SOURCE_DIR}/Common/src/linux + ${PHYSX_SOURCE_DIR}/LowLevelAABB/linux/include + ${PHYSX_SOURCE_DIR}/GpuBroadPhase/include + ${PHYSX_SOURCE_DIR}/GpuBroadPhase/src +) + + +SET(LOWLEVELAABB_COMPILE_DEFS + + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};PX_PHYSX_STATIC_LIB + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + +SET(LOWLEVELAABB_LIBTYPE OBJECT) + +SET(LOWLEVELAABB_PLATFORM_LINK_FLAGS " ") diff --git a/physx/source/compiler/cmake/emscripten/LowLevelDynamics.cmake b/physx/source/compiler/cmake/emscripten/LowLevelDynamics.cmake new file mode 100644 index 000000000..f93146d1d --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/LowLevelDynamics.cmake @@ -0,0 +1,53 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build LowLevelDynamics +# + + +SET(LOWLEVELDYNAMICS_PLATFORM_INCLUDES + ${PHYSX_SOURCE_DIR}/common/src/linux + ${PHYSX_SOURCE_DIR}/lowlevel/software/include/linux + ${PHYSX_SOURCE_DIR}/lowleveldynamics/include/linux + ${PHYSX_SOURCE_DIR}/lowlevel/common/include/pipeline/linux +) + +# Use generator expressions to set config specific preprocessor definitions +SET(LOWLEVELDYNAMICS_COMPILE_DEFS + + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};PX_PHYSX_STATIC_LIB + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + +SET(LOWLEVELDYNAMICS_LIBTYPE OBJECT) + diff --git a/physx/source/compiler/cmake/emscripten/PhysX.cmake b/physx/source/compiler/cmake/emscripten/PhysX.cmake new file mode 100644 index 000000000..051ca179b --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/PhysX.cmake @@ -0,0 +1,120 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build PhysX (PROJECT not SOLUTION) +# + +SET(PHYSX_GPU_HEADERS + ${PHYSX_ROOT_DIR}/include/gpu/PxGpu.h +) +SOURCE_GROUP(include\\gpu FILES ${PHYSX_GPU_HEADERS}) + +SET(PHYSX_CUDACONTEXT_MANAGER_GPU_HEADERS + ${PHYSX_ROOT_DIR}/include/cudamanager/PxCudaContextManager.h + ${PHYSX_ROOT_DIR}/include/cudamanager/PxCudaMemoryManager.h +) +SOURCE_GROUP(include\\cudamanager FILES ${PHYSX_CUDACONTEXT_MANAGER_GPU_HEADERS}) + +SET(PHYSX_PLATFORM_INCLUDES + ${NVTOOLSEXT_INCLUDE_DIRS} +) + +SET(PHYSX_PLATFORM_OBJECT_FILES + $ + $ + $ + $ + $ + $ +) + +SET(PHYSX_PLATFORM_SRC_FILES + ${PX_SOURCE_DIR}/device/linux/PhysXIndicatorLinux.cpp + ${PX_SOURCE_DIR}/gpu/PxGpu.cpp + ${PX_SOURCE_DIR}/gpu/PxPhysXGpuModuleLoader.cpp + ${PHYSX_PLATFORM_OBJECT_FILES} +) + +INSTALL(FILES ${PHYSX_GPU_HEADERS} DESTINATION include/gpu) +INSTALL(FILES ${PHYSX_CUDACONTEXT_MANAGER_GPU_HEADERS} DESTINATION include/cudamanager) + +IF(PX_GENERATE_STATIC_LIBRARIES) + SET(PHYSX_LIBTYPE STATIC) + SET(PXPHYSX_LIBTYPE_DEFS + PX_PHYSX_STATIC_LIB; + ) +ELSE() + SET(PHYSX_LIBTYPE SHARED) + SET(PXPHYSX_LIBTYPE_DEFS + PX_PHYSX_CORE_EXPORTS; + ) +ENDIF() + +IF(PX_GENERATE_GPU_STATIC_LIBRARIES) + SET(PXPHYSX_GPU_DEFS PX_PHYSX_GPU_STATIC) +ENDIF() + +# Set default PhysXGpu shared library name +IF(NV_USE_GAMEWORKS_OUTPUT_DIRS) + IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(BITNESS_STRING "64") + ELSE() + SET(BITNESS_STRING "32") + ENDIF() + SET(PHYSX_GPU_SHARED_LIB_NAME_DEF PX_PHYSX_GPU_SHARED_LIB_NAME=libPhysXGpu_${BITNESS_STRING}.so) +ELSE() + SET(CONFIG_STRING $<$:DEBUG>$<$:CHECKED>$<$:PROFILE>) + IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(BITNESS_STRING "x64") + ELSE() + SET(BITNESS_STRING "x86") + ENDIF() + SET(PHYSX_GPU_SHARED_LIB_NAME_DEF PX_PHYSX_GPU_SHARED_LIB_NAME=libPhysXGpu${CONFIG_STRING}_${BITNESS_STRING}.so) +ENDIF() + +SET(PHYSX_COMPILE_DEFS + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};${PXPHYSX_LIBTYPE_DEFS};${PHYSX_GPU_SHARED_LIB_NAME_DEF};${PXPHYSX_GPU_DEFS} + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + + +SET(PHYSX_PLATFORM_LINK_FLAGS " ") +SET(PHYSX_PLATFORM_LINK_FLAGS_DEBUG " ") +SET(PHYSX_PLATFORM_LINK_FLAGS_CHECKED " ") +SET(PHYSX_PLATFORM_LINK_FLAGS_PROFILE " ") +SET(PHYSX_PLATFORM_LINK_FLAGS_RELEASE " ") + +SET(PHYSX_PLATFORM_LINKED_LIBS dl) + +SET(CMAKE_STATIC_LIBRARY_SUFFIX ".bc") + diff --git a/physx/source/compiler/cmake/emscripten/PhysXCharacterKinematic.cmake b/physx/source/compiler/cmake/emscripten/PhysXCharacterKinematic.cmake new file mode 100644 index 000000000..08c403f89 --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/PhysXCharacterKinematic.cmake @@ -0,0 +1,49 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build PhysXCharacterKinematic +# + +# Use generator expressions to set config specific preprocessor definitions +SET(PHYSXCHARACTERKINEMATICS_COMPILE_DEFS + + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS}; + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + +SET(PHYSXCHARACTERKINEMATIC_LIBTYPE STATIC) + + +# enable -fPIC so we can link static libs with the editor +#SET_TARGET_PROPERTIES(PhysXCharacterKinematic PROPERTIES POSITION_INDEPENDENT_CODE TRUE) + diff --git a/physx/source/compiler/cmake/emscripten/PhysXCommon.cmake b/physx/source/compiler/cmake/emscripten/PhysXCommon.cmake new file mode 100644 index 000000000..bbd89dab5 --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/PhysXCommon.cmake @@ -0,0 +1,65 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build PhysXCommon +# + +SET(PXCOMMON_PLATFORM_SRC_FILES +) + +SET(PXCOMMON_PLATFORM_INCLUDES + ${PHYSX_SOURCE_DIR}/common/src/linux +) + + + +IF(PX_GENERATE_STATIC_LIBRARIES) + SET(PXCOMMON_LIBTYPE_DEFS + PX_PHYSX_STATIC_LIB; + ) + SET(PHYSXCOMMON_LIBTYPE STATIC) +ELSE() + SET(PXCOMMON_LIBTYPE_DEFS + PX_PHYSX_FOUNDATION_EXPORTS;PX_PHYSX_COMMON_EXPORTS; + ) + SET(PHYSXCOMMON_LIBTYPE SHARED) +ENDIF() + + +SET(PXCOMMON_COMPILE_DEFS + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};${PXCOMMON_LIBTYPE_DEFS} + + # Switch platforms here? + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS}> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS}> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS}> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS}> +) + +SET(PXCOMMON_PLATFORM_LINK_FLAGS " ") diff --git a/physx/source/compiler/cmake/emscripten/PhysXCooking.cmake b/physx/source/compiler/cmake/emscripten/PhysXCooking.cmake new file mode 100644 index 000000000..2705057f7 --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/PhysXCooking.cmake @@ -0,0 +1,64 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build PhysXCooking +# + + +SET(PHYSXCOOKING_PLATFORM_SRC_FILES +) + +IF(PX_GENERATE_STATIC_LIBRARIES) + SET(PHYSXCOOKING_LIBTYPE STATIC) + SET(PXCOOKING_LIBTYPE_DEFS + PX_PHYSX_STATIC_LIB; + ) +ELSE() + SET(PHYSXCOOKING_LIBTYPE SHARED) + SET(PXCOOKING_LIBTYPE_DEFS + PX_PHYSX_FOUNDATION_EXPORTS;PX_PHYSX_COMMON_EXPORTS;PX_PHYSX_COOKING_EXPORTS;PX_PHYSX_LOADER_EXPORTS;PX_PHYSX_CORE_EXPORTS + ) +ENDIF() + +SET(PHYSXCOOKING_COMPILE_DEFS + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};PX_COOKING;${PXCOOKING_LIBTYPE_DEFS} + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> + +) + + +SET(PHYSXCOOKING_LINK_FLAGS " ") +SET(PHYSXCOOKING_LINK_FLAGS_DEBUG " ") +SET(PHYSXCOOKING_LINK_FLAGS_CHECKED " ") +SET(PHYSXCOOKING_LINK_FLAGS_PROFILE " ") +SET(PHYSXCOOKING_LINK_FLAGS_RELEASE " ") diff --git a/physx/source/compiler/cmake/emscripten/PhysXExtensions.cmake b/physx/source/compiler/cmake/emscripten/PhysXExtensions.cmake new file mode 100644 index 000000000..5d92df75b --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/PhysXExtensions.cmake @@ -0,0 +1,56 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build PhysXExtensions +# + +SET(PHYSXEXTENSIONS_PLATFORM_INCLUDES + PRIVATE ${PHYSX_SOURCE_DIR}/Common/src/linux +) + +SET(PHYSXEXTENSIONS_PLATFORM_OBJECT_FILES + $ +) + +SET(PHYSXEXTENSIONS_PLATFORM_SRC_FILES + ${PHYSXEXTENSIONS_PLATFORM_OBJECT_FILES} +) + +# Use generator expressions to set config specific preprocessor definitions +SET(PHYSXEXTENSIONS_COMPILE_DEFS + + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};PX_PHYSX_STATIC_LIB; + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + +SET(PHYSXEXTENSIONS_LIBTYPE STATIC) diff --git a/physx/source/compiler/cmake/emscripten/PhysXFoundation.cmake b/physx/source/compiler/cmake/emscripten/PhysXFoundation.cmake new file mode 100644 index 000000000..829d248c5 --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/PhysXFoundation.cmake @@ -0,0 +1,102 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build PhysXFoundation +# + +SET(PXSHARED_PLATFORM_HEADERS + ${PXSHARED_PATH}/include/foundation/unix/PxUnixIntrinsics.h +) +SOURCE_GROUP(shared\\include\\unix FILES ${PXSHARED_PLATFORM_HEADERS}) + +SET(PXFOUNDATION_LIBTYPE STATIC) + +SET(PHYSXFOUNDATION_PLATFORM_SOURCE + ${LL_SOURCE_DIR}/src/unix/PsUnixAtomic.cpp + ${LL_SOURCE_DIR}/src/unix/PsUnixCpu.cpp + ${LL_SOURCE_DIR}/src/unix/PsUnixFPU.cpp + ${LL_SOURCE_DIR}/src/unix/PsUnixMutex.cpp + ${LL_SOURCE_DIR}/src/unix/PsUnixPrintString.cpp + ${LL_SOURCE_DIR}/src/unix/PsUnixSList.cpp + ${LL_SOURCE_DIR}/src/unix/PsUnixSocket.cpp + ${LL_SOURCE_DIR}/src/unix/PsUnixSync.cpp + ${LL_SOURCE_DIR}/src/unix/PsUnixThread.cpp + ${LL_SOURCE_DIR}/src/unix/PsUnixTime.cpp +) +SOURCE_GROUP("src\\src\\unix" FILES ${PHYSXFOUNDATION_PLATFORM_FILES}) + +SET(PHYSXFOUNDATION_PLATFORM_INCLUDES + ${LL_SOURCE_DIR}/include/linux +) + +SET(PHYSXFOUNDATION_NEON_FILES + ${LL_SOURCE_DIR}/include/unix/neon/PsUnixNeonAoS.h + ${LL_SOURCE_DIR}/include/unix/neon/PsUnixNeonInlineAoS.h +) + +SET(PHYSXFOUNDATION_SSE2_FILES + ${LL_SOURCE_DIR}/include/unix/sse2/PsUnixSse2AoS.h + ${LL_SOURCE_DIR}/include/unix/sse2/PsUnixSse2InlineAoS.h +) + +SET(PHYSXFOUNDATION_PLATFORM_SOURCE_HEADERS + ${LL_SOURCE_DIR}/include/unix/PsUnixAoS.h + ${LL_SOURCE_DIR}/include/unix/PsUnixFPU.h + ${LL_SOURCE_DIR}/include/unix/PsUnixInlineAoS.h + ${LL_SOURCE_DIR}/include/unix/PsUnixIntrinsics.h + ${LL_SOURCE_DIR}/include/unix/PsUnixTrigConstants.h +) +SOURCE_GROUP("src\\include\\unix" FILES ${PHYSXFOUNDATION_PLATFORM_SOURCE_HEADERS}) + +INSTALL(FILES ${PHYSXFOUNDATION_PLATFORM_SOURCE_HEADERS} DESTINATION source/foundation/include/unix) +INSTALL(FILES ${PHYSXFOUNDATION_NEON_FILES} DESTINATION source/foundation/include/unix/neon) +INSTALL(FILES ${PHYSXFOUNDATION_SSE2_FILES} DESTINATION source/foundation/include/unix/sse2) +INSTALL(FILES ${PXSHARED_PLATFORM_HEADERS} DESTINATION ${PXSHARED_INSTALL_PREFIX}/include/foundation/unix) + +SET(PHYSXFOUNDATION_PLATFORM_FILES + ${PHYSXFOUNDATION_PLATFORM_SOURCE} + ${PHYSXFOUNDATION_PLATFORM_SOURCE_HEADERS} + ${PHYSXFOUNDATION_NEON_FILES} + ${PHYSXFOUNDATION_SSE2_FILES} + ${PHYSXFOUNDATION_RESOURCE_FILE} +) + + + +# Use generator expressions to set config specific preprocessor definitions +SET(PHYSXFOUNDATION_COMPILE_DEFS + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};${PXFOUNDATION_LIBTYPE_DEFS} + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + +SET(PXFOUNDATION_PLATFORM_LINK_FLAGS "-m64") diff --git a/physx/source/compiler/cmake/emscripten/PhysXPvdSDK.cmake b/physx/source/compiler/cmake/emscripten/PhysXPvdSDK.cmake new file mode 100644 index 000000000..f4bf2b43e --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/PhysXPvdSDK.cmake @@ -0,0 +1,44 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build PhysXPvdSDK +# + +SET(PHYSXPVDSDK_LIBTYPE STATIC) + +# Use generator expressions to set config specific preprocessor definitions +SET(PHYSXPVDSDK_COMPILE_DEFS + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};PX_PHYSX_STATIC_LIB; + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + diff --git a/physx/source/compiler/cmake/emscripten/PhysXTask.cmake b/physx/source/compiler/cmake/emscripten/PhysXTask.cmake new file mode 100644 index 000000000..d0cc38934 --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/PhysXTask.cmake @@ -0,0 +1,45 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build PhysXTask +# + +SET(PHYSXTASK_COMPILE_DEFS + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS}; +) + +SET(PHYSXTASK_COMPILE_DEFS + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};_LIB + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + +SET(PHYSXTASK_LIBTYPE OBJECT) diff --git a/physx/source/compiler/cmake/emscripten/PhysXVehicle.cmake b/physx/source/compiler/cmake/emscripten/PhysXVehicle.cmake new file mode 100644 index 000000000..7f4ab536d --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/PhysXVehicle.cmake @@ -0,0 +1,47 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build PhysXVehicle +# + +# Use generator expressions to set config specific preprocessor definitions +SET(PHYSXVEHICLE_COMPILE_DEFS + + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};PX_PHYSX_STATIC_LIB + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + + +SET(PHYSXVEHICLE_LIBTYPE STATIC) + + diff --git a/physx/source/compiler/cmake/emscripten/PhysXWebBindings.cmake b/physx/source/compiler/cmake/emscripten/PhysXWebBindings.cmake new file mode 100644 index 000000000..cf8a901b2 --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/PhysXWebBindings.cmake @@ -0,0 +1,111 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +SET(EMSCRIPTEN_USE_ASSERTIONS "1") +SET(EMSCRIPTEN_BASE_OPTIONS "--bind -s MODULARIZE=1 -s EXPORT_NAME=PHYSX") + + +SET(LL_SOURCE_DIR ${PHYSX_SOURCE_DIR}/physxwebbindings/src) + +SET(PHYSX_WEB_BINDINGS_INCLUDES + ${NVTOOLSEXT_INCLUDE_DIRS} +) + +SET(PHYSX_WEB_BINDINGS_OBJECT_FILES + $ + $ + $ + $ + $ + $ +) + +SET(PHYSX_WEB_BINDINGS_SRC_FILES + #${PX_SOURCE_DIR}/emscripten/jsbindings.cpp +) + +SET(PHYSX_WEB_BINDINGS_LIBTYPE STATIC) +SET(PXPHYSX_LIBTYPE_DEFS + PX_PHYSX_STATIC_LIB; +) + +SET(PHYSX_WEB_BINDINGS_COMPILE_DEFS + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};${PXPHYSX_LIBTYPE_DEFS};${PHYSX_GPU_SHARED_LIB_NAME_DEF};${PXPHYSX_GPU_DEFS} + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + +SET(PHYSX_WEB_BINDINGS_LINK_FLAGS " ") +SET(PHYSX_WEB_BINDINGS_LINK_FLAGS_DEBUG " ") +SET(PHYSX_WEB_BINDINGS_LINK_FLAGS_CHECKED " ") +SET(PHYSX_WEB_BINDINGS_LINK_FLAGS_PROFILE " ") +SET(PHYSX_WEB_BINDINGS_LINK_FLAGS_RELEASE " ") + +SET(PHYSX_WEB_BINDINGS_LINKED_LIBS dl) + +SET(CMAKE_STATIC_LIBRARY_SUFFIX ".bc") + +SET(PHYSX_WEB_BINDINGS_SOURCE + ${LL_SOURCE_DIR}/PxWebBindings.cpp +) +SOURCE_GROUP(src FILES ${PHYSX_WEB_BINDINGS_SOURCE}) + +ADD_EXECUTABLE(PhysXWebBindings ${PHYSX_WEB_BINDINGS_SOURCE} +) + +SET_TARGET_PROPERTIES(PhysXWebBindings PROPERTIES + OUTPUT_NAME PhysXWebBindings +) + +TARGET_COMPILE_DEFINITIONS(PhysXWebBindings + PRIVATE ${PHYSX_WEB_BINDINGS_COMPILE_DEFS} +) + + +SET_TARGET_PROPERTIES(PhysXWebBindings PROPERTIES + LINK_FLAGS "${EMSCRIPTEN_BASE_OPTIONS} -s ASSERTIONS=${EMSCRIPTEN_USE_ASSERTIONS}" +) + +TARGET_LINK_LIBRARIES(PhysXWebBindings + PUBLIC PhysXCharacterKinematic PhysXCooking PhysXExtensions PhysXVehicle +) +GET_TARGET_PROPERTY(PHYSXFOUNDATION_INCLUDES PhysXFoundation INTERFACE_INCLUDE_DIRECTORIES) + +TARGET_INCLUDE_DIRECTORIES(PhysXWebBindings + PRIVATE ${PHYSX_ROOT_DIR}/include + PRIVATE ${PHYSXFOUNDATION_INCLUDES} + PRIVATE ${PHYSX_SOURCE_DIR}/common/include +) + +# name the output library 'physx' as this is really a union of all of js-bound PhysX +set_target_properties(PhysXWebBindings PROPERTIES OUTPUT_NAME "physx.${CMAKE_BUILD_TYPE}") + +SET_TARGET_PROPERTIES(PhysXWebBindings PROPERTIES POSITION_INDEPENDENT_CODE TRUE) diff --git a/physx/source/compiler/cmake/emscripten/SceneQuery.cmake b/physx/source/compiler/cmake/emscripten/SceneQuery.cmake new file mode 100644 index 000000000..561041996 --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/SceneQuery.cmake @@ -0,0 +1,50 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build SceneQuery +# + +SET(SCENEQUERY_PLATFORM_INCLUDES + PRIVATE ${PHYSX_SOURCE_DIR}/Common/src/linux +) + + +# Use generator expressions to set config specific preprocessor definitions +SET(SCENEQUERY_COMPILE_DEFS + + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};PX_PHYSX_STATIC_LIB + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + +SET(SCENEQUERY_LIBTYPE OBJECT) + diff --git a/physx/source/compiler/cmake/emscripten/SimulationController.cmake b/physx/source/compiler/cmake/emscripten/SimulationController.cmake new file mode 100644 index 000000000..4258418b7 --- /dev/null +++ b/physx/source/compiler/cmake/emscripten/SimulationController.cmake @@ -0,0 +1,51 @@ +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## * Neither the name of NVIDIA CORPORATION nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## Copyright (c) 2018-2019 NVIDIA Corporation. All rights reserved. + +# +# Build SimulationController +# + +SET(SIMULATIONCONTROLLER_PLATFORM_INCLUDES + ${PHYSX_SOURCE_DIR}/common/src/linux + ${PHYSX_SOURCE_DIR}/lowlevel/linux/include +) + +# Use generator expressions to set config specific preprocessor definitions +SET(SIMULATIONCONTROLLER_COMPILE_DEFS + + # Common to all configurations + ${PHYSX_EMSCRIPTEN_COMPILE_DEFS};PX_PHYSX_STATIC_LIB + + $<$:${PHYSX_EMSCRIPTEN_DEBUG_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_CHECKED_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_PROFILE_COMPILE_DEFS};> + $<$:${PHYSX_EMSCRIPTEN_RELEASE_COMPILE_DEFS};> +) + +SET(SIMULATIONCONTROLLER_LIBTYPE OBJECT) + + diff --git a/physx/source/foundation/include/PsHash.h b/physx/source/foundation/include/PsHash.h index 328909ee1..60f099ba2 100644 --- a/physx/source/foundation/include/PsHash.h +++ b/physx/source/foundation/include/PsHash.h @@ -66,6 +66,12 @@ PX_FORCE_INLINE uint32_t hash(const uint32_t key) return uint32_t(k); } +// size_t in emscripten is an unsigned long +PX_FORCE_INLINE uint32_t hash(const unsigned long key) +{ + return hash(uint32_t(key)); +} + PX_FORCE_INLINE uint32_t hash(const int32_t key) { return hash(uint32_t(key)); diff --git a/physx/source/geomutils/src/convex/GuBigConvexData.cpp b/physx/source/geomutils/src/convex/GuBigConvexData.cpp index a299a06dc..66678dfd9 100644 --- a/physx/source/geomutils/src/convex/GuBigConvexData.cpp +++ b/physx/source/geomutils/src/convex/GuBigConvexData.cpp @@ -149,13 +149,13 @@ bool BigConvexData::Load(PxInputStream& stream) // Load base gaussmap // if(!GaussMap::Load(stream)) return false; - // Import header - if(!ReadHeader('G', 'A', 'U', 'S', Version, Mismatch, stream)) - return false; + // Import header + if(!ReadHeader('G', 'A', 'U', 'S', Version, Mismatch, stream)) + return false; - // Import basic info - mData.mSubdiv = Ps::to16(readDword(Mismatch, stream)); - mData.mNbSamples = Ps::to16(readDword(Mismatch, stream)); + // Import basic info + mData.mSubdiv = Ps::to16(readDword(Mismatch, stream)); + mData.mNbSamples = Ps::to16(readDword(Mismatch, stream)); // Load map data mData.mSamples = reinterpret_cast(PX_ALLOC(sizeof(PxU8)*mData.mNbSamples*2, "BigConvex Samples Data")); diff --git a/physx/source/geomutils/src/gjk/GuGJKType.h b/physx/source/geomutils/src/gjk/GuGJKType.h index a0099e2fd..f5cac3b93 100644 --- a/physx/source/geomutils/src/gjk/GuGJKType.h +++ b/physx/source/geomutils/src/gjk/GuGJKType.h @@ -151,7 +151,7 @@ namespace Gu virtual Ps::aos::Vec3V getCenter() const { return mAToB.transform(getConvex().getCenter()); } - PX_FORCE_INLINE Ps::aos::PsMatTransformV& getRelativeTransform(){ return mAToB; } + PX_FORCE_INLINE const Ps::aos::PsMatTransformV& getRelativeTransform() const { return mAToB; } //ML: we can't force inline function, otherwise win modern will throw compiler error PX_INLINE RelativeConvex::Type > getGjkConvex() const diff --git a/physx/source/physxcooking/src/convex/BigConvexDataBuilder.cpp b/physx/source/physxcooking/src/convex/BigConvexDataBuilder.cpp index 5f38a5ea2..d943b488f 100644 --- a/physx/source/physxcooking/src/convex/BigConvexDataBuilder.cpp +++ b/physx/source/physxcooking/src/convex/BigConvexDataBuilder.cpp @@ -83,15 +83,15 @@ bool BigConvexDataBuilder::save(PxOutputStream& stream, bool platformMismatch) c // Save base gaussmap // if(!GaussMapBuilder::Save(stream, platformMismatch)) return false; - // Export header - if(!WriteHeader('G', 'A', 'U', 'S', gVersion, platformMismatch, stream)) - return false; + // Export header + if(!WriteHeader('G', 'A', 'U', 'S', gVersion, platformMismatch, stream)) + return false; - // Export basic info + // Export basic info // stream.StoreDword(mSubdiv); - writeDword(mSVM->mData.mSubdiv, platformMismatch, stream); // PT: could now write Word here + writeDword(mSVM->mData.mSubdiv, platformMismatch, stream); // PT: could now write Word here // stream.StoreDword(mNbSamples); - writeDword(mSVM->mData.mNbSamples, platformMismatch, stream); // PT: could now write Word here + writeDword(mSVM->mData.mNbSamples, platformMismatch, stream); // PT: could now write Word here // Save map data // It's an array of bytes so we don't care about 'PlatformMismatch' diff --git a/physx/source/physxextensions/src/serialization/Xml/SnXmlMemoryPool.h b/physx/source/physxextensions/src/serialization/Xml/SnXmlMemoryPool.h index 57098e717..8bb3ae446 100644 --- a/physx/source/physxextensions/src/serialization/Xml/SnXmlMemoryPool.h +++ b/physx/source/physxextensions/src/serialization/Xml/SnXmlMemoryPool.h @@ -323,7 +323,7 @@ namespace physx { m8ItemPool.deallocate(inMemory); else */ - mVariablePool.deallocate(inMemory); + mVariablePool.deallocate(inMemory); } /** * allocate an object. Calls constructor on the new memory. diff --git a/physx/source/physxwebbindings/src/PxWebBindings.cpp b/physx/source/physxwebbindings/src/PxWebBindings.cpp new file mode 100644 index 000000000..f53ad60ae --- /dev/null +++ b/physx/source/physxwebbindings/src/PxWebBindings.cpp @@ -0,0 +1,575 @@ +#include +#include +#include "PxPhysicsAPI.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace physx; +using namespace emscripten; + +struct PxRaycastCallbackWrapper : public wrapper { + EMSCRIPTEN_WRAPPER(PxRaycastCallbackWrapper) + PxAgain processTouches(const PxRaycastHit *buffer, PxU32 nbHits) { + for (PxU32 i = 0; i < nbHits; i++) { + bool again = call("processTouches", buffer[i]); + if (!again) { + return false; + } + } + return true; + } +}; + +PxRaycastHit* allocateRaycastHitBuffers(PxU32 nb) { + PxRaycastHit *myArray = new PxRaycastHit[nb]; + return myArray; +} + +struct PxSimulationEventCallbackWrapper : public wrapper { + EMSCRIPTEN_WRAPPER(PxSimulationEventCallbackWrapper) + void onConstraintBreak(PxConstraintInfo *, PxU32) {} + void onWake(PxActor **, PxU32) {} + void onSleep(PxActor **, PxU32) {} + void onContact(const PxContactPairHeader &, const PxContactPair *pairs, PxU32 nbPairs) { + for(PxU32 i=0; i < nbPairs; i++) + { + const PxContactPair& cp = pairs[i]; + + if (cp.flags & (PxContactPairFlag::eREMOVED_SHAPE_0 | PxContactPairFlag::eREMOVED_SHAPE_1)) + continue; + + if(cp.events & PxPairFlag::eNOTIFY_TOUCH_FOUND) { + call("onContactBegin", cp.shapes[0], cp.shapes[1]); + } else if(cp.events & PxPairFlag::eNOTIFY_TOUCH_LOST) { + call("onContactEnd", cp.shapes[0], cp.shapes[1]); + } else if(cp.events & PxPairFlag::eNOTIFY_TOUCH_PERSISTS) { + call("onContactPersist", cp.shapes[0], cp.shapes[1]); + } + } + } + void onTrigger(PxTriggerPair *pairs, PxU32 count) { + for(PxU32 i=0; i < count; i++) + { + const PxTriggerPair& tp = pairs[i]; + if (tp.flags & (PxTriggerPairFlag::eREMOVED_SHAPE_TRIGGER | PxTriggerPairFlag::eREMOVED_SHAPE_OTHER)) + continue; + + if(tp.status & PxPairFlag::eNOTIFY_TOUCH_FOUND) { + call("onTriggerBegin", tp.triggerShape, tp.otherShape); + } else if(tp.status & PxPairFlag::eNOTIFY_TOUCH_LOST) { + call("onTriggerEnd", tp.triggerShape, tp.otherShape); + } + } + } + void onAdvance(const PxRigidBody *const *, const PxTransform *, const PxU32) {} +}; + +PxFilterFlags DefaultFilterShader( + PxFilterObjectAttributes attributes0, PxFilterData , + PxFilterObjectAttributes attributes1, PxFilterData , + PxPairFlags& pairFlags, const void* , PxU32 ) +{ + if(PxFilterObjectIsTrigger(attributes0) || PxFilterObjectIsTrigger(attributes1)) + { + pairFlags = PxPairFlag::eTRIGGER_DEFAULT | PxPairFlag::eDETECT_CCD_CONTACT; + return PxFilterFlag::eDEFAULT; + } + pairFlags = PxPairFlag::eCONTACT_DEFAULT | PxPairFlag::eNOTIFY_TOUCH_FOUND | PxPairFlag::eNOTIFY_TOUCH_LOST | PxPairFlag::eNOTIFY_TOUCH_PERSISTS |PxPairFlag::eDETECT_CCD_CONTACT; + return PxFilterFlag::eDEFAULT; +} + +// TODO: Getting the global PxDefaultSimulationFilterShader into javascript +// is problematic, so let's provide this custom factory function for now + +PxSceneDesc *getDefaultSceneDesc(PxTolerancesScale &scale, int numThreads, PxSimulationEventCallback* callback) +{ + PxSceneDesc *sceneDesc = new PxSceneDesc(scale); + sceneDesc->gravity = PxVec3(0.0f, -9.81f, 0.0f); + sceneDesc->cpuDispatcher = PxDefaultCpuDispatcherCreate(numThreads); + sceneDesc->filterShader = DefaultFilterShader; + sceneDesc->simulationEventCallback = callback; + sceneDesc->kineKineFilteringMode = PxPairFilteringMode::eKEEP; + sceneDesc->staticKineFilteringMode = PxPairFilteringMode::eKEEP; + sceneDesc->flags |= PxSceneFlag::eENABLE_CCD; + return sceneDesc; +} + +PxConvexMesh* createConvexMesh(std::vector& vertices, PxCooking& cooking, PxPhysics& physics) { + PxConvexMeshDesc convexDesc; + convexDesc.points.count = vertices.size(); + convexDesc.points.stride = sizeof(PxVec3); + convexDesc.points.data = vertices.data(); + convexDesc.flags = PxConvexFlag::eCOMPUTE_CONVEX; + + PxConvexMesh* convexMesh = cooking.createConvexMesh(convexDesc, physics.getPhysicsInsertionCallback()); + + return convexMesh; +} + +PxConvexMesh* createConvexMeshFromBuffer(int vertices, PxU32 vertCount, PxCooking& cooking, PxPhysics& physics) { + PxConvexMeshDesc convexDesc; + convexDesc.points.count = vertCount; + convexDesc.points.stride = sizeof(PxVec3); + convexDesc.points.data = (PxVec3*)vertices; + convexDesc.flags = PxConvexFlag::eCOMPUTE_CONVEX; + + PxConvexMesh* convexMesh = cooking.createConvexMesh(convexDesc, physics.getPhysicsInsertionCallback()); + + return convexMesh; +} + +PxTriangleMesh* createTriMesh(int vertices, PxU32 vertCount, int indices, PxU32 indexCount, bool isU16, PxCooking& cooking, PxPhysics& physics) { + PxTriangleMeshDesc meshDesc; + meshDesc.points.count = vertCount; + meshDesc.points.stride = sizeof(PxVec3); + meshDesc.points.data = (PxVec3*)vertices; + + meshDesc.triangles.count = indexCount; + if (isU16) { + meshDesc.triangles.stride = 3*sizeof(PxU16); + meshDesc.triangles.data = (PxU16*)indices; + meshDesc.flags = PxMeshFlag::e16_BIT_INDICES; + } else { + meshDesc.triangles.stride = 3*sizeof(PxU32); + meshDesc.triangles.data = (PxU32*)indices; + } + + PxTriangleMesh* triangleMesh = cooking.createTriangleMesh(meshDesc, physics.getPhysicsInsertionCallback()); + return triangleMesh; +} + +EMSCRIPTEN_BINDINGS(physx) +{ + + constant("PX_PHYSICS_VERSION", PX_PHYSICS_VERSION); + + // Global functions + // These are generaly system/scene level initialization + function("PxCreateFoundation", &PxCreateFoundation, allow_raw_pointers()); + function("PxInitExtensions", &PxInitExtensions, allow_raw_pointers()); + function("PxDefaultCpuDispatcherCreate", &PxDefaultCpuDispatcherCreate, allow_raw_pointers()); + function("PxCreatePvd", &PxCreatePvd, allow_raw_pointers()); + function("PxCreatePhysics", &PxCreateBasePhysics, allow_raw_pointers()); + function("PxCreateCooking", &PxCreateCooking, allow_raw_pointers()); + function("PxCreatePlane", &PxCreatePlane, allow_raw_pointers()); + function("getDefaultSceneDesc", &getDefaultSceneDesc, allow_raw_pointers()); + + + class_("PxSimulationEventCallback") + .allow_subclass("PxSimulationEventCallbackWrapper"); + + // Joints + function("PxFixedJointCreate", &PxFixedJointCreate, allow_raw_pointers()); + function("PxRevoluteJointCreate", &PxRevoluteJointCreate, allow_raw_pointers()); + function("PxSphericalJointCreate", &PxSphericalJointCreate, allow_raw_pointers()); + function("PxDistanceJointCreate", &PxDistanceJointCreate, allow_raw_pointers()); + function("PxPrismaticJointCreate", &PxPrismaticJointCreate, allow_raw_pointers()); + function("PxD6JointCreate", &PxD6JointCreate, allow_raw_pointers()); + + class_("PxJoint") + .function("release", &PxJoint::release); + class_>("PxSphericalJoint"); + class_>("PxRevoluteJoint"); + class_>("PxFixedJoint"); + class_>("PxDistanceJoint"); + class_>("PxPrismaticJoint"); + class_>("PxD6Joint"); + + + class_("PxAllocatorCallback"); + class_>("PxDefaultAllocator").constructor<>(); + class_("PxTolerancesScale").constructor<>() + .property("speed", &PxTolerancesScale::speed); + + // Define PxVec3, PxQuat and PxTransform as value objects to allow sumerian Vector3 and Quaternion to be used directly without the need to free the memory + value_object("PxVec3") + .field("x", &PxVec3::x) + .field("y", &PxVec3::y) + .field("z", &PxVec3::z) + ; + register_vector("PxVec3Vector"); + value_object("PxQuat") + .field("x", &PxQuat::x) + .field("y", &PxQuat::y) + .field("z", &PxQuat::z) + .field("w", &PxQuat::w) + ; + value_object("PxTransform") + .field("translation", &PxTransform::p) + .field("rotation", &PxTransform::q) + ; + + enum_("PxIDENTITY") + .value("PxIdentity", PxIDENTITY::PxIdentity); + + enum_("PxPvdInstrumentationFlag") + .value("eALL", PxPvdInstrumentationFlag::Enum::eALL) + .value("eDEBUG", PxPvdInstrumentationFlag::Enum::eDEBUG) + .value("ePROFILE", PxPvdInstrumentationFlag::Enum::ePROFILE) + .value("eMEMORY", PxPvdInstrumentationFlag::Enum::eMEMORY); + + enum_("PxForceMode") + .value("eFORCE", PxForceMode::Enum::eFORCE) + .value("eIMPULSE", PxForceMode::Enum::eIMPULSE) + .value("eVELOCITY_CHANGE", PxForceMode::Enum::eVELOCITY_CHANGE) + .value("eACCELERATION", PxForceMode::Enum::eACCELERATION); + + + class_("PxSceneDesc").constructor() + .property("gravity", &PxSceneDesc::gravity); + + class_("PxFoundation").function("release", &PxFoundation::release); + + class_("PxSceneFlags"); + enum_("PxSceneFlag") + .value("eENABLE_ACTIVE_ACTORS ", PxSceneFlag::Enum::eENABLE_ACTIVE_ACTORS) + .value("eENABLE_CCD", PxSceneFlag::Enum::eENABLE_CCD) + .value("eDISABLE_CCD_RESWEEP", PxSceneFlag::Enum::eDISABLE_CCD_RESWEEP) + .value("eADAPTIVE_FORCE", PxSceneFlag::Enum::eADAPTIVE_FORCE) + .value("eENABLE_PCM", PxSceneFlag::Enum::eENABLE_PCM) + .value("eDISABLE_CONTACT_REPORT_BUFFER_RESIZE", PxSceneFlag::Enum::eDISABLE_CONTACT_REPORT_BUFFER_RESIZE) + .value("eDISABLE_CONTACT_CACHE", PxSceneFlag::Enum::eDISABLE_CONTACT_CACHE) + .value("eREQUIRE_RW_LOCK", PxSceneFlag::Enum::eREQUIRE_RW_LOCK) + .value("eENABLE_STABILIZATION", PxSceneFlag::Enum::eENABLE_STABILIZATION) + .value("eENABLE_AVERAGE_POINT", PxSceneFlag::Enum::eENABLE_AVERAGE_POINT) + .value("eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS", PxSceneFlag::Enum::eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS) + .value("eENABLE_ENHANCED_DETERMINISM", PxSceneFlag::Enum::eENABLE_ENHANCED_DETERMINISM) + .value("eENABLE_FRICTION_EVERY_ITERATION", PxSceneFlag::Enum::eENABLE_FRICTION_EVERY_ITERATION); + + class_("PxScene") + .function("setGravity", &PxScene::setGravity) + .function("getGravity", &PxScene::getGravity) + .function("addActor", &PxScene::addActor, allow_raw_pointers()) + .function("removeActor", &PxScene::removeActor, allow_raw_pointers()) + .function("getScenePvdClient", &PxScene::getScenePvdClient, allow_raw_pointers()) + .function("getActors", &PxScene::getActors, allow_raw_pointers()) + .function("setVisualizationCullingBox", &PxScene::setVisualizationCullingBox) + .function("simulate", optional_override( + [](PxScene &scene, PxReal elapsedTime, bool controlSimulation) { + scene.simulate(elapsedTime, NULL, 0, 0, controlSimulation); + return; + })) + .function("fetchResults", optional_override( + [](PxScene &scene, bool block) { + // fetchResults uses an out pointer + // which embind can't represent + // so let's override. + bool fetched = scene.fetchResults(block); + return fetched; + })) + .function("raycast", &PxScene::raycast, allow_raw_pointers()); + + class_("PxLocationHit") + .property("position", &PxLocationHit::position) + .property("normal", &PxLocationHit::normal) + .property("distance", &PxLocationHit::distance); + class_>("PxRaycastHit").constructor<>() + .function("getShape", optional_override( + [](PxRaycastHit &block){ + return block.shape; + }), allow_raw_pointers()); + class_("PxRaycastCallback") + .property("block", &PxRaycastCallback::block) + .property("hasBlock", &PxRaycastCallback::hasBlock) + .allow_subclass("PxRaycastCallbackWrapper", constructor()); + class_>("PxRaycastBuffer").constructor<>(); + + function("allocateRaycastHitBuffers", &allocateRaycastHitBuffers, allow_raw_pointers()); + + class_("PxHitFlags").constructor(); + enum_("PxHitFlag") + .value("eDEFAULT", PxHitFlag::Enum::eDEFAULT) + .value("eMESH_BOTH_SIDES", PxHitFlag::Enum::eMESH_BOTH_SIDES) + .value("eMESH_MULTIPLE", PxHitFlag::Enum::eMESH_MULTIPLE); + + class_("PxQueryFilterData").constructor<>() + .property("flags", &PxQueryFilterData::flags); + class_("PxQueryFlags").constructor(); + enum_("PxQueryFlag") + .value("eANY_HIT", PxQueryFlag::Enum::eANY_HIT) + .value("eDYNAMIC", PxQueryFlag::Enum::eDYNAMIC) + .value("eSTATIC", PxQueryFlag::Enum::eSTATIC) + .value("eNO_BLOCK", PxQueryFlag::Enum::eNO_BLOCK); + + class_("PxQueryFilterCallback"); + class_("PxQueryCache"); + + class_("PxMaterial") + .function("release", &PxMaterial::release); + register_vector("VectorPxMaterial"); + // setMaterials has 'PxMaterial**' as an input, which is not representable with embind + // This is overrided to use std::vector + class_("PxShape") + .function("release", &PxShape::release) + .function("getFlags", &PxShape::getFlags) + .function("setFlag", &PxShape::setFlag) + .function("setLocalPose", &PxShape::setLocalPose) + .function("setGeometry", &PxShape::setGeometry) + .function("getBoxGeometry", &PxShape::getBoxGeometry, allow_raw_pointers()) + .function("getSphereGeometry", &PxShape::getSphereGeometry, allow_raw_pointers()) + .function("getPlaneGeometry", &PxShape::getPlaneGeometry, allow_raw_pointers()) + .function("setMaterials", optional_override( + [](PxShape &shape, std::vector materials) { + return shape.setMaterials(materials.data(), materials.size()); + })); + + class_("PxPhysics") + .function("release", &PxPhysics::release) + .function("getTolerancesScale", &PxPhysics::getTolerancesScale) + .function("createScene", &PxPhysics::createScene, allow_raw_pointers()) + .function("createShape", select_overload(&PxPhysics::createShape), allow_raw_pointers()) + .function("createMaterial", &PxPhysics::createMaterial, allow_raw_pointers()) + .function("createRigidDynamic", &PxPhysics::createRigidDynamic, allow_raw_pointers()) + .function("createRigidStatic", &PxPhysics::createRigidStatic, allow_raw_pointers()); + + class_("PxPvd"); + + class_("PxShapeFlags").constructor().function("isSet", &PxShapeFlags::isSet); + enum_("PxShapeFlag") + .value("eSIMULATION_SHAPE", PxShapeFlag::Enum::eSIMULATION_SHAPE) + .value("eSCENE_QUERY_SHAPE", PxShapeFlag::Enum::eSCENE_QUERY_SHAPE) + .value("eTRIGGER_SHAPE", PxShapeFlag::Enum::eTRIGGER_SHAPE) + .value("eVISUALIZATION", PxShapeFlag::Enum::eVISUALIZATION); + + enum_("PxActorFlag") + .value("eDISABLE_GRAVITY", PxActorFlag::Enum::eDISABLE_GRAVITY); + + class_("PxErrorCallback"); + class_>("PxDefaultErrorCallback").constructor<>(); + + class_("PxCooking") + .function("createConvexMesh", optional_override( + [](PxCooking& cooking, std::vector& vertices, PxPhysics& physics) { + return createConvexMesh(vertices, cooking, physics); + }), allow_raw_pointers()) + .function("createConvexMeshFromBuffer", optional_override( + [](PxCooking& cooking, int vertices, PxU32 vertCount, PxPhysics& physics) { + return createConvexMeshFromBuffer(vertices, vertCount, cooking, physics); + }), allow_raw_pointers()) + .function("createTriMesh", optional_override( + [](PxCooking& cooking, int vertices, PxU32 vertCount, int indices, PxU32 indexCount, bool isU16, PxPhysics& physics) { + return createTriMesh(vertices, vertCount, indices, indexCount, isU16, cooking, physics); + }), allow_raw_pointers()); + class_("PxCookingParams").constructor(); + class_("PxCpuDispatcher"); + class_("PxBVHStructure"); + class_("PxBaseTask"); + class_>("PxDefaultCpuDispatcher"); + + class_("PxFilterData"); + class_("PxPairFlags"); + class_("PxFilterFlags"); + + enum_("PxPairFlag"); + enum_("PxFilterFlag"); + + class_("PxActor") + .function("setActorFlag", &PxActor::setActorFlag) + .function("release", &PxActor::release); + + class_>("PxRigidActor") + .function("attachShape", &PxRigidActor::attachShape) + .function("detachShape", &PxRigidActor::detachShape) + .function("getGlobalPose", &PxRigidActor::getGlobalPose, allow_raw_pointers()) + .function("setGlobalPose", &PxRigidActor::setGlobalPose, allow_raw_pointers()); + + class_>("PxRigidBody") + .function("setAngularDamping", &PxRigidBody::setAngularDamping) + .function("getAngularDamping", &PxRigidBody::getAngularDamping) + .function("setLinearDamping", &PxRigidBody::setLinearDamping) + .function("getLinearDamping", &PxRigidBody::getLinearDamping) + .function("setAngularVelocity", &PxRigidBody::setAngularVelocity) + .function("getAngularVelocity", &PxRigidBody::getAngularVelocity) + .function("setMass", &PxRigidBody::setMass) + .function("setLinearVelocity", &PxRigidBody::setLinearVelocity) + .function("getLinearVelocity", &PxRigidBody::getLinearVelocity) + .function("addForceAtPos", optional_override( + [](PxRigidBody &body, const PxVec3 &force, const PxVec3 &pos) { + PxRigidBodyExt::addForceAtPos(body, force, pos, PxForceMode::eFORCE, true); + })) + .function("addForceAtLocalPos", optional_override( + [](PxRigidBody &body, const PxVec3 &force, const PxVec3 &pos) { + PxRigidBodyExt::addForceAtLocalPos(body, force, pos, PxForceMode::eFORCE, true); + })) + .function("addLocalForceAtLocalPos", optional_override( + [](PxRigidBody &body, const PxVec3 &force, const PxVec3 &pos) { + PxRigidBodyExt::addLocalForceAtLocalPos(body, force, pos, PxForceMode::eFORCE, true); + })) + .function("addImpulseAtPos", optional_override( + [](PxRigidBody &body, const PxVec3 &impulse, const PxVec3 &pos) { + PxRigidBodyExt::addForceAtPos(body, impulse, pos, PxForceMode::eIMPULSE, true); + })) + .function("addImpulseAtLocalPos", optional_override( + [](PxRigidBody &body, const PxVec3 &impulse, const PxVec3 &pos) { + PxRigidBodyExt::addForceAtLocalPos(body, impulse, pos, PxForceMode::eIMPULSE, true); + })) + .function("addLocalImpulseAtLocalPos", optional_override( + [](PxRigidBody &body, const PxVec3 &impulse, const PxVec3 &pos) { + PxRigidBodyExt::addLocalForceAtLocalPos(body, impulse, pos, PxForceMode::eIMPULSE, true); + })) + .function("addTorque", optional_override( + [](PxRigidBody &body, const PxVec3 &torque) { + body.addTorque(torque, PxForceMode::eFORCE, true); + })) + .function("setRigidBodyFlag", &PxRigidBody::setRigidBodyFlag) + .function("getRigidBodyFlags", optional_override( + [](PxRigidBody &body) { + return (bool)(body.getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC); + })) + .function("setMassAndUpdateInertia", optional_override( + [](PxRigidBody &body, PxReal mass) { + return PxRigidBodyExt::setMassAndUpdateInertia(body, mass, NULL, false); + })) + .function("setMassSpaceInertiaTensor", &PxRigidBody::setMassSpaceInertiaTensor); + + class_("PxRigidBodyFlags"); + enum_("PxRigidBodyFlag") + .value("eKINEMATIC", PxRigidBodyFlag::Enum::eKINEMATIC) + .value("eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES", PxRigidBodyFlag::Enum::eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES) + .value("eENABLE_CCD", PxRigidBodyFlag::Enum::eENABLE_CCD) + .value("eENABLE_CCD_FRICTION", PxRigidBodyFlag::Enum::eENABLE_CCD_FRICTION) + .value("eENABLE_POSE_INTEGRATION_PREVIEW", PxRigidBodyFlag::Enum::eENABLE_POSE_INTEGRATION_PREVIEW) + .value("eENABLE_SPECULATIVE_CCD", PxRigidBodyFlag::Enum::eENABLE_SPECULATIVE_CCD) + .value("eENABLE_CCD_MAX_CONTACT_IMPULSE", PxRigidBodyFlag::Enum::eENABLE_CCD_MAX_CONTACT_IMPULSE) + .value("eRETAIN_ACCELERATIONS", PxRigidBodyFlag::Enum::eRETAIN_ACCELERATIONS); + + class_>("PxRigidStatic"); + class_>("PxRigidDynamic") + .function("wakeUp", &PxRigidDynamic::wakeUp) + .function("setWakeCounter", &PxRigidDynamic::setWakeCounter) + .function("isSleeping", &PxRigidDynamic::isSleeping) + .function("getWakeCounter", &PxRigidDynamic::getWakeCounter) + .function("setSleepThreshold", &PxRigidDynamic::setSleepThreshold) + .function("getSleepThreshold", &PxRigidDynamic::getSleepThreshold) + .function("setKinematicTarget", &PxRigidDynamic::setKinematicTarget) + .function("setRigidDynamicLockFlags", &PxRigidDynamic::setRigidDynamicLockFlags); + class_("PxRigidDynamicLockFlags").constructor(); + enum_("PxRigidDynamicLockFlag") + .value("eLOCK_LINEAR_X", PxRigidDynamicLockFlag::Enum::eLOCK_LINEAR_X) + .value("eLOCK_LINEAR_Y", PxRigidDynamicLockFlag::Enum::eLOCK_LINEAR_Y) + .value("eLOCK_LINEAR_Z", PxRigidDynamicLockFlag::Enum::eLOCK_LINEAR_Z) + .value("eLOCK_ANGULAR_X", PxRigidDynamicLockFlag::Enum::eLOCK_ANGULAR_X) + .value("eLOCK_ANGULAR_Y", PxRigidDynamicLockFlag::Enum::eLOCK_ANGULAR_Y) + .value("eLOCK_ANGULAR_Z", PxRigidDynamicLockFlag::Enum::eLOCK_ANGULAR_Z); + + /** Geometry **/ + class_("PxGeometry"); + class_>("PxBoxGeometry").constructor<>().constructor().function("isValid", &PxBoxGeometry::isValid).property("halfExtents", &PxBoxGeometry::halfExtents); + class_>("PxSphereGeometry").constructor<>().constructor().function("isValid", &PxSphereGeometry::isValid); + + class_>("PxCapsuleGeometry").constructor(); + + class_("PxTriangleMesh") + .function("release", &PxTriangleMesh::release); + class_>("PxTriangleMeshGeometry").constructor(); + + class_("PxMeshGeometryFlags").constructor(); + enum_("PxMeshGeometryFlag") + .value("eDOUBLE_SIDED", PxMeshGeometryFlag::Enum::eDOUBLE_SIDED); + + class_>("PxPlaneGeometry").constructor<>(); + + class_("PxConvexMesh") + .function("release", &PxConvexMesh::release); + class_>("PxConvexMeshGeometry").constructor(); + + class_("PxMeshScale").constructor(); + + class_("PxConvexMeshGeometryFlags").constructor(); + enum_("PxConvexMeshGeometryFlag") + .value("eTIGHT_BOUNDS", PxConvexMeshGeometryFlag::Enum::eTIGHT_BOUNDS); + + /** End Geometry **/ + + class_("PxPlane").constructor(); +} + + +namespace emscripten +{ +namespace internal +{ +// Physx uses private destructors all over the place for its own reference counting +// embind doesn't deal with this well, so we have to override the destructors to keep them private +// in the bindings +// See: https://github.com/emscripten-core/emscripten/issues/5587 +template <> +void raw_destructor(PxFoundation *) +{ /* do nothing */ +} +template <> +void raw_destructor(PxPvd *) +{ /* do nothing */ +} +template <> +void raw_destructor(PxPvdTransport *) +{ /* do nothing */ +} +template <> +void raw_destructor(PxMaterial *) +{ /* do nothing */ +} +template <> +void raw_destructor(PxScene *) +{ /* do nothing */ +} +template <> +void raw_destructor(PxRigidDynamic *) +{ /* do nothing */ +} +template <> +void raw_destructor(PxRigidBody *) +{ /* do nothing */ +} +template <> +void raw_destructor(PxRigidActor *) +{ /* do nothing */ +} +template <> +void raw_destructor(PxActor *) +{ /* do nothing */ +} +template <> +void raw_destructor(PxShape *) +{ /* do nothing */ +} +template <> +void raw_destructor(PxBVHStructure *) +{ /* do nothing */ +} +template <> +void raw_destructor(PxRigidStatic *) +{ /* do nothing */ +} +template <> +void raw_destructor(PxJoint *) +{ /* do nothing */ +} +template <> +void raw_destructor(PxPvdSceneClient *) +{ /* do nothing */ +} +template<> +void raw_destructor(PxCooking *) +{ /* do nothing */ +} +template<> +void raw_destructor(PxConvexMesh *) +{ /* do nothing */ +} +template<> +void raw_destructor(PxTriangleMesh *) +{ /* do nothing */ +} +} // namespace internal +} // namespace emscripten