Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
endforeach()
1 change: 1 addition & 0 deletions src/BulletCollision/BroadphaseCollision/btDispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This is a modified version of the Bullet Continuous Collision Detection and Phys
#include <set>
#include <map>
#include <unordered_map>
#include <cstdint>

class btCollisionAlgorithm;
struct btBroadphaseProxy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void btCollisionObject::applyLastSafeWorldTransform(const std::map<int, StuckTet
// We sacrifice few iterations to move to the safe position only gradually. This significantly reduces the jitter of
// jumping between the safe and stuck positions. The unstuck position will be much closer to the real point of contact.
btScalar fraction = getLastSafeApplyCounter() / maxApplySteps;
fraction = std::min(fraction, 1.0);
fraction = std::min((double)fraction, 1.0);

btTransform dst = getLastSafeWorldTransform();
btTransform src = getWorldTransform();
Expand Down
2 changes: 2 additions & 0 deletions src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ class btDispatcher;
#include "btGImpactCollisionAlgorithmEval.h"

#include <vector>
#ifdef BT_USE_TBB
#include <tbb/tbb.h>
#endif

//! Collision Algorithm for GImpact Shapes
/*!
Expand Down
2 changes: 2 additions & 0 deletions src/BulletCollision/Gimpact/btGImpactCollisionAlgorithmEval.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <tbb/tbb.h>
#endif

enum class btFindOnlyFirstPairEnum : uint8_t
{
Expand Down
9 changes: 8 additions & 1 deletion src/BulletCollision/Gimpact/btGImpactQuantizedBvh.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ This is a modified version of the Bullet Continuous Collision Detection and Phys
#include <atomic>
#include <map>
#include <vector>
#ifdef BT_USE_TBB
#include <tbb/tbb.h>
#endif

class GIM_QUANTIZED_BVH_NODE_ARRAY : public btAlignedObjectArray<BT_QUANTIZED_BVH_NODE>
{
Expand Down Expand Up @@ -197,15 +199,20 @@ 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))
{
// Issue X86 PAUSE or ARM YIELD instruction to reduce contention between
// hyper-threads
#ifdef _M_ARM64
__yield();
#else
#elif defined(__i386__)
_mm_pause();
#else
nanosleep(&ns, NULL);
#endif
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/BulletSoftBody/btDeformableContactConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/BulletSoftBody/btDeformableMultiBodyConstraintSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ 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)
{
auto existingPen = 0.0;
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
Expand Down
5 changes: 4 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)


Expand Down