-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Physx5 updatePhysX Split support for PhysX5 (#241)
Updates to the PhysX 3rd Party script to support the o3de/sig-simulation#85. * Support to rename FindPhysX.cmake -> FindPhysX5.cmake * Update the FindPhysX5.cmake to only use static libraries instead of the shared equivalent. This is necessary to prevent collision of the same shared libraries from both versions that have the same name. This will also reduce the 3rd Party package size. * Fix a macos specific compiile error when using the current macos sdk * Update the PhysX5 3P package to rev4 --------- Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com>
- Loading branch information
1 parent
742fff0
commit dd4f27a
Showing
9 changed files
with
275 additions
and
214 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# | ||
# Copyright (c) Contributors to the Open 3D Engine Project. | ||
# For complete copyright and license terms please see the LICENSE at the root of this distribution. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
# | ||
# | ||
|
||
set(MY_NAME "PhysX5") | ||
set(TARGET_WITH_NAMESPACE "3rdParty::${MY_NAME}") | ||
if (TARGET ${TARGET_WITH_NAMESPACE}) | ||
return() | ||
endif() | ||
|
||
set(_PACKAGE_DIR ${CMAKE_CURRENT_LIST_DIR}/PhysX/physx) | ||
|
||
set(${MY_NAME}_INCLUDE_DIR | ||
${_PACKAGE_DIR}/include | ||
${_PACKAGE_DIR}/include/foundation | ||
${_PACKAGE_DIR}/include/geometry | ||
) | ||
|
||
# We will only use the static libs for linking | ||
set(${MY_NAME}_COMPILE_DEFINITIONS PX_PHYSX_STATIC_LIB) | ||
|
||
# LY_PHYSX_PROFILE_USE_CHECKED_LIBS allows to override what PhysX configuration to use on O3DE profile. | ||
set(LY_PHYSX_PROFILE_USE_CHECKED_LIBS OFF CACHE BOOL "When ON it uses PhysX SDK checked libraries on O3DE profile configuration") | ||
if(LY_PHYSX_PROFILE_USE_CHECKED_LIBS) | ||
set(PHYSX_PROFILE_CONFIG "checked") | ||
else() | ||
set(PHYSX_PROFILE_CONFIG "profile") | ||
endif() | ||
|
||
# Set the generator-expression path to the static libs | ||
set(PATH_TO_LIBS ${_PACKAGE_DIR}/bin/static/$<IF:$<CONFIG:profile>,${PHYSX_PROFILE_CONFIG},$<CONFIG>>) | ||
|
||
if(DEFINED CMAKE_IMPORT_LIBRARY_SUFFIX) | ||
set(import_lib_prefix ${CMAKE_IMPORT_LIBRARY_PREFIX}) | ||
set(import_lib_suffix ${CMAKE_IMPORT_LIBRARY_SUFFIX}) | ||
else() | ||
set(import_lib_prefix ${CMAKE_SHARED_LIBRARY_PREFIX}) | ||
set(import_lib_suffix ${CMAKE_SHARED_LIBRARY_SUFFIX}) | ||
endif() | ||
|
||
set(extra_static_libs ${EXTRA_STATIC_LIBS}) | ||
set(extra_shared_libs ${EXTRA_SHARED_LIBS}) | ||
|
||
# The order of PhysX 5.x static libraries is important for static targets. We will loop through in order and define | ||
# each static library explicitly, while setting their dependency as a chain to ensure the order is preserved | ||
|
||
set(IMPORTED_PHYSICS_LIBS_SUFFIX | ||
PhysX_static_64 | ||
PhysXPvdSDK_static_64 | ||
PhysXVehicle_static_64 | ||
PhysXCharacterKinematic_static_64 | ||
PhysXExtensions_static_64 | ||
PhysXCooking_static_64 | ||
PhysXCommon_static_64 | ||
PhysXFoundation_static_64 | ||
) | ||
|
||
foreach(PHYSICS_LIB ${IMPORTED_PHYSICS_LIBS_SUFFIX}) | ||
|
||
# Set the individual target names to include a ${MY_NAME} prefix in order to prevent collisions | ||
# with other 3rd party PhysX Packages of different versions while retaining the same actual | ||
# filename | ||
|
||
set(PHYSICS_LIB_NAME ${MY_NAME}${PHYSICS_LIB}) | ||
|
||
add_library(${PHYSICS_LIB_NAME}::imported STATIC IMPORTED GLOBAL) | ||
|
||
# Set the import location (note: generator expressions are not supported as properties here, so each config needs to be explicit for its location) | ||
set_target_properties(${PHYSICS_LIB_NAME}::imported | ||
PROPERTIES | ||
IMPORTED_LOCATION_DEBUG ${CMAKE_CURRENT_LIST_DIR}/PhysX/physx/bin/static/debug/${CMAKE_STATIC_LIBRARY_PREFIX}${PHYSICS_LIB}${CMAKE_STATIC_LIBRARY_SUFFIX} | ||
IMPORTED_LOCATION_PROFILE ${CMAKE_CURRENT_LIST_DIR}/PhysX/physx/bin/static/${PHYSX_PROFILE_CONFIG}/${CMAKE_STATIC_LIBRARY_PREFIX}${PHYSICS_LIB}${CMAKE_STATIC_LIBRARY_SUFFIX} | ||
IMPORTED_LOCATION_RELEASE ${CMAKE_CURRENT_LIST_DIR}/PhysX/physx/bin/static/release/${CMAKE_STATIC_LIBRARY_PREFIX}${PHYSICS_LIB}${CMAKE_STATIC_LIBRARY_SUFFIX} | ||
) | ||
|
||
# Set the target libraries dependency on any previous lib to build the order chain | ||
target_link_libraries(${PHYSICS_LIB_NAME}::imported INTERFACE | ||
${PREVIOUS_PHYSICS_LIB} | ||
${PATH_TO_LIBS}/${CMAKE_STATIC_LIBRARY_PREFIX}${PHYSICS_LIB}${CMAKE_STATIC_LIBRARY_SUFFIX} | ||
) | ||
set (PREVIOUS_PHYSICS_LIB ${PHYSICS_LIB_NAME}::imported) | ||
|
||
endforeach() | ||
|
||
add_library(${MY_NAME}_STATIC_LIBS::imported INTERFACE IMPORTED GLOBAL) | ||
|
||
# Set the final ${MY_NAME}_STATIC_LIBS to the last static target defined to complete the chain | ||
target_link_libraries(${MY_NAME}_STATIC_LIBS::imported INTERFACE | ||
${PREVIOUS_PHYSICS_LIB} | ||
${extra_static_libs} | ||
) | ||
|
||
# Add any optional shared library dependency as a runtime dependency | ||
if(extra_shared_libs) | ||
set(${MY_NAME}_RUNTIME_DEPENDENCIES | ||
${extra_shared_libs} | ||
) | ||
endif() | ||
|
||
add_library(${TARGET_WITH_NAMESPACE} INTERFACE IMPORTED GLOBAL) | ||
|
||
ly_target_include_system_directories(TARGET ${TARGET_WITH_NAMESPACE} INTERFACE ${${MY_NAME}_INCLUDE_DIR}) | ||
|
||
target_link_libraries(${TARGET_WITH_NAMESPACE} INTERFACE ${MY_NAME}_STATIC_LIBS::imported) | ||
|
||
target_compile_definitions(${TARGET_WITH_NAMESPACE} INTERFACE ${${MY_NAME}_COMPILE_DEFINITIONS}) | ||
|
||
if(DEFINED ${MY_NAME}_RUNTIME_DEPENDENCIES) | ||
ly_add_target_files(TARGETS ${TARGET_WITH_NAMESPACE} FILES ${${MY_NAME}_RUNTIME_DEPENDENCIES}) | ||
endif() | ||
|
||
set(${MY_NAME}_FOUND True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
diff --git a/physx/include/foundation/PxVecQuat.h b/physx/include/foundation/PxVecQuat.h | ||
index 0822c17..c24ae5f 100644 | ||
--- a/physx/include/foundation/PxVecQuat.h | ||
+++ b/physx/include/foundation/PxVecQuat.h | ||
@@ -308,7 +308,7 @@ PX_FORCE_INLINE bool isValidQuatV(const QuatV q) | ||
const FloatV unitTolerance = FLoad(1e-4f); | ||
const FloatV tmp = FAbs(FSub(QuatLength(q), FOne())); | ||
const BoolV con = FIsGrtr(unitTolerance, tmp); | ||
- return isFiniteVec4V(q) & (BAllEqTTTT(con) == 1); | ||
+ return isFiniteVec4V(q) && (BAllEqTTTT(con) == 1); | ||
} | ||
|
||
PX_FORCE_INLINE bool isSaneQuatV(const QuatV q) | ||
@@ -316,7 +316,7 @@ PX_FORCE_INLINE bool isSaneQuatV(const QuatV q) | ||
const FloatV unitTolerance = FLoad(1e-2f); | ||
const FloatV tmp = FAbs(FSub(QuatLength(q), FOne())); | ||
const BoolV con = FIsGrtr(unitTolerance, tmp); | ||
- return isFiniteVec4V(q) & (BAllEqTTTT(con) == 1); | ||
+ return isFiniteVec4V(q) && (BAllEqTTTT(con) == 1); | ||
} | ||
|
||
#if PX_LINUX && PX_CLANG | ||
diff --git a/physx/include/foundation/PxVecTransform.h b/physx/include/foundation/PxVecTransform.h | ||
index bd29307..d00a4e0 100644 | ||
--- a/physx/include/foundation/PxVecTransform.h | ||
+++ b/physx/include/foundation/PxVecTransform.h | ||
@@ -133,7 +133,7 @@ class PxTransformV | ||
PX_FORCE_INLINE bool isValid() const | ||
{ | ||
// return p.isFinite() && q.isFinite() && q.isValid(); | ||
- return isFiniteVec3V(p) & isFiniteQuatV(q) & isValidQuatV(q); | ||
+ return isFiniteVec3V(p) && isFiniteQuatV(q) && isValidQuatV(q); | ||
} | ||
|
||
/** | ||
@@ -144,7 +144,7 @@ class PxTransformV | ||
PX_FORCE_INLINE bool isSane() const | ||
{ | ||
// return isFinite() && q.isSane(); | ||
- return isFinite() & isSaneQuatV(q); | ||
+ return isFinite() && isSaneQuatV(q); | ||
} | ||
|
||
/** | ||
@@ -153,7 +153,7 @@ class PxTransformV | ||
PX_FORCE_INLINE bool isFinite() const | ||
{ | ||
// return p.isFinite() && q.isFinite(); | ||
- return isFiniteVec3V(p) & isFiniteQuatV(q); | ||
+ return isFiniteVec3V(p) && isFiniteQuatV(q); | ||
} | ||
|
||
#if PX_LINUX && PX_CLANG |
Oops, something went wrong.