From 2127f060c04c0917c517a5809ce4392bf1c612dc Mon Sep 17 00:00:00 2001 From: Jon Daniel Date: Wed, 22 Apr 2026 15:31:25 +0200 Subject: [PATCH 1/2] Add BUILD_BULLET3_OPENCL option allowing PSP build --- CMakeLists.txt | 3 ++- src/CMakeLists.txt | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf91d6cdd3..ed201286f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -333,6 +333,7 @@ IF (APPLE) ENDIF() OPTION(BUILD_BULLET3 "Set when you want to build Bullet 3" ON) +OPTION(BUILD_BULLET3_OPENCL "Set when you want to build Bullet 3 with OpenCL" ON) # Optional Python configuration # Will not probe environment for Python configuration (which can abort the @@ -564,4 +565,4 @@ get_property(ALL_TARGETS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYS foreach(target ${ALL_TARGETS}) add_dependencies(post_build ${target}) -endforeach() \ No newline at end of file +endforeach() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c30125c539..3c64219ce0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,9 @@ IF(BUILD_BULLET3) - SUBDIRS( Bullet3OpenCL Bullet3Serialize/Bullet2FileLoader Bullet3Dynamics Bullet3Collision Bullet3Geometry ) +IF(BUILD_BULLET3_OPENCL) + add_subdirectory( Bullet3OpenCL ) +ENDIF(BUILD_BULLET3_OPENCL) + SUBDIRS( Bullet3Serialize/Bullet2FileLoader Bullet3Dynamics Bullet3Collision Bullet3Geometry ) ENDIF(BUILD_BULLET3) From a342d8844c7f7a473235d76500b1ef97e77e1816 Mon Sep 17 00:00:00 2001 From: Jon Daniel Date: Wed, 13 May 2026 21:50:52 +0200 Subject: [PATCH 2/2] nanosleep, typecast and tbb fixes --- src/BulletCollision/BroadphaseCollision/btDispatcher.h | 1 + .../CollisionDispatch/btCollisionObject.cpp | 2 +- .../Gimpact/btGImpactCollisionAlgorithm.h | 2 ++ .../Gimpact/btGImpactCollisionAlgorithmEval.h | 2 ++ src/BulletCollision/Gimpact/btGImpactQuantizedBvh.h | 9 ++++++++- src/BulletSoftBody/btDeformableContactConstraint.cpp | 8 ++++---- .../btDeformableMultiBodyConstraintSolver.cpp | 4 ++-- 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/BulletCollision/BroadphaseCollision/btDispatcher.h b/src/BulletCollision/BroadphaseCollision/btDispatcher.h index 4ca4d5f43b..c74c6ad63c 100644 --- a/src/BulletCollision/BroadphaseCollision/btDispatcher.h +++ b/src/BulletCollision/BroadphaseCollision/btDispatcher.h @@ -24,6 +24,7 @@ This is a modified version of the Bullet Continuous Collision Detection and Phys #include #include #include +#include class btCollisionAlgorithm; struct btBroadphaseProxy; diff --git a/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp b/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp index 50042d987b..7295b28991 100644 --- a/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp +++ b/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp @@ -159,7 +159,7 @@ void btCollisionObject::applyLastSafeWorldTransform(const std::map +#ifdef BT_USE_TBB #include +#endif //! Collision Algorithm for GImpact Shapes /*! diff --git a/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithmEval.h b/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithmEval.h index 15d27b9ef2..f42a5997c3 100644 --- a/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithmEval.h +++ b/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithmEval.h @@ -33,7 +33,9 @@ This is a modified version of the Bullet Continuous Collision Detection and Phys #include "LinearMath/btTransform.h" #include "gim_pair.h" +#ifdef BT_USE_TBB #include +#endif enum class btFindOnlyFirstPairEnum : uint8_t { diff --git a/src/BulletCollision/Gimpact/btGImpactQuantizedBvh.h b/src/BulletCollision/Gimpact/btGImpactQuantizedBvh.h index 54d6e59862..623232609e 100644 --- a/src/BulletCollision/Gimpact/btGImpactQuantizedBvh.h +++ b/src/BulletCollision/Gimpact/btGImpactQuantizedBvh.h @@ -37,7 +37,9 @@ This is a modified version of the Bullet Continuous Collision Detection and Phys #include #include #include +#ifdef BT_USE_TBB #include +#endif class GIM_QUANTIZED_BVH_NODE_ARRAY : public btAlignedObjectArray { @@ -197,6 +199,9 @@ struct spinlock { return; } +#if !defined(_M_ARM64) && !defined(__i386__) + static const timespec ns = { 0, 1 }; +#endif // Wait for lock to be released without generating cache misses while (lock_.load(std::memory_order_relaxed)) { @@ -204,8 +209,10 @@ struct spinlock // hyper-threads #ifdef _M_ARM64 __yield(); -#else +#elif defined(__i386__) _mm_pause(); +#else + nanosleep(&ns, NULL); #endif } } diff --git a/src/BulletSoftBody/btDeformableContactConstraint.cpp b/src/BulletSoftBody/btDeformableContactConstraint.cpp index 9d4c4fcaee..fc921d8951 100644 --- a/src/BulletSoftBody/btDeformableContactConstraint.cpp +++ b/src/BulletSoftBody/btDeformableContactConstraint.cpp @@ -97,9 +97,9 @@ btScalar btDeformableNodeAnchorConstraint::solveConstraint(const btContactSolver // This greatly improves convergence. if (m_previous_residual_velocity_match != -1.0) if (residualSquare > m_previous_residual_velocity_match) - m_convergence_based_relaxation_velocity_match = std::max(0.1, m_convergence_based_relaxation_velocity_match * misconvergenceRelaxationFactor); + m_convergence_based_relaxation_velocity_match = std::max(0.1, (double)m_convergence_based_relaxation_velocity_match * misconvergenceRelaxationFactor); else - m_convergence_based_relaxation_velocity_match = std::min(1.0, m_convergence_based_relaxation_velocity_match * convergenceRelaxationFactor); + m_convergence_based_relaxation_velocity_match = std::min(1.0, (double)m_convergence_based_relaxation_velocity_match * convergenceRelaxationFactor); m_previous_residual_velocity_match = residualSquare; // dn is the normal component of velocity diffrerence. Approximates the residual. // todo xuchenhan@: this prob needs to be scaled by dt @@ -255,9 +255,9 @@ btScalar btDeformableNodeAnchorConstraint::solveSplitImpulse(const btContactSolv // This greatly improves convergence. if (m_previous_residual_position_drift != -1.0) if (residualSquare > m_previous_residual_position_drift) - m_convergence_based_relaxation_position_drift = std::max(0.1, m_convergence_based_relaxation_position_drift * misconvergenceRelaxationFactor); + m_convergence_based_relaxation_position_drift = std::max(0.1, (double)m_convergence_based_relaxation_position_drift * misconvergenceRelaxationFactor); else - m_convergence_based_relaxation_position_drift = std::min(1.0, m_convergence_based_relaxation_position_drift * convergenceRelaxationFactor); + m_convergence_based_relaxation_position_drift = std::min(1.0, (double)m_convergence_based_relaxation_position_drift * convergenceRelaxationFactor); m_previous_residual_position_drift = residualSquare; btVector3 rigid_impulse = (pos_diff * rigid_impulse_fraction * m_convergence_based_relaxation_position_drift) / infoGlobal.m_timeStep; diff --git a/src/BulletSoftBody/btDeformableMultiBodyConstraintSolver.cpp b/src/BulletSoftBody/btDeformableMultiBodyConstraintSolver.cpp index 7fed65db04..e3fc07cde0 100644 --- a/src/BulletSoftBody/btDeformableMultiBodyConstraintSolver.cpp +++ b/src/BulletSoftBody/btDeformableMultiBodyConstraintSolver.cpp @@ -220,7 +220,7 @@ void btDeformableMultiBodyConstraintSolver::solveGroupCacheFriendlySplitImpulseI auto it = bodyPenetrations.find(origBodyA); if (it != bodyPenetrations.end()) existingPen = it->second; - bodyPenetrations.insert_or_assign(origBodyA, std::max(existingPen, solveManifold.m_rhsPenetration)); + bodyPenetrations.insert_or_assign(origBodyA, std::max(existingPen, (double)solveManifold.m_rhsPenetration)); } if (origBodyB) { @@ -228,7 +228,7 @@ void btDeformableMultiBodyConstraintSolver::solveGroupCacheFriendlySplitImpulseI auto it = bodyPenetrations.find(origBodyB); if (it != bodyPenetrations.end()) existingPen = it->second; - bodyPenetrations.insert_or_assign(origBodyB, std::max(existingPen, solveManifold.m_rhsPenetration)); + bodyPenetrations.insert_or_assign(origBodyB, std::max(existingPen, (double)solveManifold.m_rhsPenetration)); } } // solve the position correction between deformable and rigid/multibody