Commit Graph

66 Commits

Author SHA1 Message Date
Andrea Catania
960cadd919 Fix initialization order
This commit is necessary in order to fix the error that we get in godot with the flag: "-Werror=reorder"
2019-06-03 12:54:19 +02:00
erwincoumans
5ff52e47d9 report constraint solver analytics data, currently for each island the number of solver iterations used and remaining residual error. 2019-04-11 22:19:02 -07:00
erwincoumans
36a9dcf368 remove src/BulletDynamics/Featherstone/btMultiBodyBlockConstraintSolver.cpp and examples/ConstraintSolvers/* code
revert changes to btMultiBodyConstraintSolver/btSequentialImpulseConstraintSolver related to btMultiBodyBlockConstraintSolver
2019-02-27 17:10:17 -08:00
erwincoumans
d7e087de16 prepare small experiment with block solver 2019-02-26 23:27:05 -08:00
erwincoumans
c44471c38c preparation for block solver btRigidBody. 2019-02-26 20:24:15 -08:00
erwincoumans
ab8f16961e Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files.
make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type.
This commit contains no other changes aside from adding and applying clang-format-all.sh
2018-09-23 14:17:31 -07:00
Erwin Coumans
b5495e789d Change constraint solver threshold-based termination condition on residual of velocity threshold, not on residual of impulse threshold.
This avoids issues with systems with large mass ratios.

Test: add this to BasicDemo/BasicExample.cpp in initPhysics

	m_dynamicsWorld->getSolverInfo().m_numIterations = 1000;
	m_dynamicsWorld->getSolverInfo().m_leastSquaresResidualThreshold = 1e-4;
2018-07-22 11:30:16 +02:00
Erwin Coumans
6856334d48 fixes: make argument names in header and cpp the same 2018-03-27 16:54:41 -07:00
Lunkhound
b8720f2161 parallel solver: various changes
- threading: adding btSequentialImpulseConstraintSolverMt
 - task scheduler: added parallelSum so that parallel solver can compute residuals
 - CommonRigidBodyMTBase: add slider for solver least squares residual and allow multithreading without needing OpenMP, TBB, or PPL
 - taskScheduler: don't wait for workers to sleep/signal at the end of each parallel block
 - parallel solver: convertContacts split into an allocContactConstraints and setupContactConstraints stage, the latter of which is done in parallel
 - parallel solver: rolling friction is now interleaved along with normal friction
 - parallel solver: batchified split impulse solving + some cleanup
 - parallel solver: sorting batches from largest to smallest
 - parallel solver: added parallel batch creation
 - parallel solver: added warmstartingWriteBackContacts func + other cleanup
 - task scheduler: truncate low bits to preserve determinism with parallelSum
 - parallel solver: reducing dynamic mem allocs and trying to parallelize more of the batch setup
 - parallel solver: parallelize updating constraint batch ids for merging
 - parallel solver: adding debug visualization
 - task scheduler: make TBB task scheduler parallelSum deterministic
 - parallel solver: split batch gen code into separate file; allow selection of batch gen method
 - task scheduler: add sleepWorkerThreadsHint() at end of simulation
 - parallel solver: added grain size per phase
 - task Scheduler: fix for strange threading issue; also no need for main thread to wait for workers to sleep
 - base constraint solver: break out joint setup into separate function for profiling/overriding
 - parallel solver: allow different batching method for contacts vs joints
 - base constraint solver: add convertJoint and convertBodies to make it possible to parallelize joint and body conversion
 - parallel solver: convert joints and bodies in parallel now
 - parallel solver: speed up batch creation with run-length encoding
 - parallel solver: batch gen: run-length expansion in parallel; collect constraint info in parallel
 - parallel solver: adding spatial grid batching method
 - parallel solver: enhancements to spatial grid batching
 - sequential solver: moving code for writing back into functions that derived classes can call
 - parallel solver: do write back of bodies and joints in parallel
 - parallel solver: removed all batching methods except for spatial grid (others were ineffective)
 - parallel solver: added 2D or 3D grid batching options; and a bit of cleanup
 - move btDefaultTaskScheduler into LinearMath project
2018-02-26 22:47:33 -08:00
Lunkhound
e9ec5044d1 SequentialImpulseConstraintSolver: fix bugs with SOLVER_SIMD flag 2017-06-10 04:33:40 -07:00
Erwin Coumans
b645963879 expose pybullet changeDynamics(spinningFriction=..., rollingFriction=..., restitution=...)
Bullet C-API b3ChangeDynamicsInfoSetSpinningFriction/RollingFriction/Resitution
b3PhysicsParamSetRestitutionVelocityThreshold, / pybullet.setPhysicsEngineParameter restitutionVelocityThreshold:
if the velocity is below this threshhold, the restitution is zero (this prevents energy buildup at near-resting state)
pybullet restitution.py example.
2017-05-26 18:14:38 -07:00
Erwin Coumans
0b017b0f53 fix issue with btMultiBody friction in combination with soft contacts (friction should not re-use normal contact cfm/erp)
implement friction anchors, position friction correction, disabled by default. Use colObj->setCollisionFlag(flag | CF_HAS_FRICTION_ANCHOR); See test/RobotClientAPI/SlopeFrictionMain.cpp. In URDF or SDF, add <friction_anchor/> in <contact> section of <link> to enable.
PhysicsServer: properly restore old activation state after releasing picked object
btMultiBodyConstraintSolver: disable flip/flop of contact/friction constraint solving by default (it breaks some internal flaky unit tests)
2017-03-20 10:58:07 -07:00
Erwin Coumans
379a852f93 fix compile issues 2016-12-16 18:43:21 -08:00
Erwin Coumans
dcd02a1e15 add option to terminate PGS constraint solvers based on a least square residual threshold
(for example solverInfo().m_leastSquaresResidualThreshold = 1e-7 and use large m_numSolverIterations
disable sphere-sphere contact cache, it is buggy (some contact point stay in the cache, when sphere penetrates more than total margins)
tweak some gpu demo settings
2016-12-16 18:09:52 -08:00
Lunkhound
1c3686ca51 MultiThreaded Demo:
- fixing various race conditions throughout (usage of static vars, etc)
 - addition of a few lightweight mutexes (which are compiled out by default)
 - slight code rearrangement in discreteDynamicsWorld to facilitate multithreading
 - PoolAllocator::allocate() can now be called when pool is full without
     crashing (null pointer returned)
 - PoolAllocator allocate and freeMemory, are OPTIONALLY threadsafe
     (default is un-threadsafe)
 - CollisionDispatcher no longer checks if the pool allocator is full
     before calling allocate(), instead it just calls allocate() and
     checks if the return is null -- this avoids a race condition
 - SequentialImpulseConstraintSolver OPTIONALLY uses different logic in
     getOrInitSolverBody() to avoid a race condition with kinematic bodies
 - addition of 2 classes which together allow simulation islands to be run
   in parallel:
    - btSimulationIslandManagerMt
    - btDiscreteDynamicsWorldMt
 - MultiThreadedDemo example in the example browser demonstrating use of
   OpenMP, Microsoft PPL, and Intel TBB
 - use multithreading for other demos
 - benchmark demo: add parallel raycasting
2016-10-30 12:47:27 -07:00
Erwin Coumans
567b003654 separate spinning and rolling friction coefficients, exposed in URDF as spinning_friction / m_rolling_friction
improvements in VR demo, add grasper etc.
2016-09-16 00:57:00 +01:00
erwincoumans
0e1a77047c fix Linux build 2014-05-03 02:50:09 -07:00
Erwin Coumans
0e1b90d708 Added SSE4/FMA optimized constraint row solver implementation for btSequentialImpulseConstraintSolver,
thanks to Vladimir Bondarev (https://github.com/VladimirBondarev/bullet3/tree/c25d)
2014-05-01 17:13:50 -07:00
erwin.coumans@gmail.com
439ab03940 fix Mac OSX build (there is no such member called e.m128_f32[0] 2013-11-03 19:55:08 +00:00
erwin.coumans@gmail.com
644d01d231 added the btNNCGConstraintSolver, based on the paper "Nonsmooth Nonlinear Conjugate Gradient Method for interactive
contact force problems". The solver needs a lot of iterations, before the quality goes up (~ 1000)
Thanks to Gabor PUHR for the contribution!
Improved the btLemkeSolver.
Remove the sparse optimizations from the btMatrixX.h, replace it with explicit call to rowComputeNonZeroElements (only used in the btSolveProjectedGaussSeidel), it was likely slowing things down, without being useful.
Re-enable SIMD in the solver (was accidently disabled in Bullet 2.82 release)
2013-10-31 06:17:08 +00:00
erwin.coumans@gmail.com
a1c962192c Allow the ForkLiftDemo to toggle between MLCP and SI solver, using F6 key.
Apply patch for CMake config, see Issue 754 (Issue 753)
Fix a few issue with the MLCP solver: allow split impulse, and fix offset in friction dependencies
2013-10-23 23:35:13 +00:00
erwin.coumans@gmail.com
a21480c8ca Attempt to fix "Regression in friction and damping behaviour" , see issue 752
Thanks to Sergej Reich for the report and narrowing down the breaking revision!
2013-10-22 09:26:08 +00:00
erwin.coumans@gmail.com
1ca0493dc4 Build full A matrix and b vector for a MLCP solver interface, to explore Lemke, Dantzig, Newton and other MLCP solvers. The A matrix contains sparsity information.
Added a PGS solver that uses the sparsity of the A matrix, just for testing (the equivalent sequential impulse solver is much faster, not having to allocate the big matrices)
2013-10-20 17:38:14 +00:00
erwin.coumans
f02dd51597 Added a first version of a Featherstone multi body implementation.
The original version was written by Stephen Thompson.
I replaced Eigen math by Bullet LinearMath, and added a dedicated 6x6 matrix solver. 
Also I integrated support for collisions/contact constraints between btMultiBody and btRigidBody, and de-activation support.
See Demos/FeatherstoneMultiBodyDemo/Win32FeatherstoneMultiBodyDemo.cpp for example usage.
There is currently only support for contact constraints for btMultiBody. 
Next on the list will be adding support for joint limit constraint for btMultiBody. 
The implementation is still experimental/untested, the quality will improve in upcoming Bullet releases.
2013-10-01 22:50:31 +00:00
erwin.coumans@gmail.com
542c53fb30 Don't pass along unused btStackAlloc everywhere. The API change might user code (derived classes with the old virtual method are not called anymore) 2013-05-08 22:45:35 +00:00
erwin.coumans
7eebb79ced implemented rolling friction, using a contact constraint. Useful to get rolling spheres to rest, even on a slightly sloped plane.
See http://www.youtube.com/watch?v=RV7sBAsKu4M and Bullet/Demos/RollingFrictionDemo
Fixes in FractureDemo (mouse picking constraint needs to be removed, otherwise constraint solver crashes/asserts)
2012-09-15 06:52:17 +00:00
erwin.coumans
84b1774dda improve handling of restitution by using the velocity (linear/angular) before applying forces: this is done by re-introducing the btSolverBody and only apply the forces to solver body, and use the original rigid body velocity for restitution computation.
warmstarting for contact points was broken, fix in btPersistentManifold
enable split impulse by default (at the cost of some performance)
add  the option for zero-length friction (instead of recomputing friction directions using btPlaneSpace), use the solver mode flag SOLVER_ALLOW_ZERO_LENGTH_FRICTION_DIRECTIONS
precompute lateral friction directions (in btManifoldResult)
remove the mConstraintRow[3] from btManifoldPoint, it just took a lot of memory with no benefits: fixed it in btParallelConstraintSolver
2012-08-31 19:46:24 +00:00
erwin.coumans
73b217fb07 Apple contribution for OSX SSE and iOS NEON optimizations unit tests, thanks to Jordan Hubbard, Ian Ollmann and Hristo Hristov.
For OSX:
cd build
./premake_osx xcode4
for iOS:
cd build
./ios_build.sh
./ios_run.sh

Also integrated the branches/StackAllocation to make it easier to multi-thread collision detection in the near future. It avoids changing the btCollisionObject while performing collision detection.

As this is a large patch, some stuff might be temporarily broken, I'll keep an eye out on issues.
2012-06-07 00:56:30 +00:00
erwin.coumans
710954d772 Constraints can override their own number of solver iterations (either more or less than the default) or leave it default (-1)
Bump version to 2.80
2012-03-03 03:07:18 +00:00
erwin.coumans
22915b2344 enable randomization of non-contact constraints (disabled by default)
Thanks to Peter Kyme, http://code.google.com/p/bullet/issues/detail?id=576
2011-12-14 09:06:14 +00:00
erwin.coumans
852fa3ba30 add the BT_ prefix for all #ifdef guards, to avoid conflicts with developers own header defines.
Fixes Issue 497

//license header
#ifndef BT_RIGIDBODY_H
#define BT_RIGIDBODY_H
class btRigidBody
{
};
#endif //BT_RIGIDBODY_H
2011-04-01 17:14:52 +00:00
erwin.coumans
c296122e4e fix build for Intel Compiler 11.1 -> move static ::getFixedBody method from header to cpp file. 2010-09-08 00:38:15 +00:00
erwin.coumans
85724b5500 SerializeDemo: create a testFile.bullet if it is missing
Serialization: remove obsolete autogenerated headers
Minor changes in btSequentialImpulseConstraintSolver: split methods to make it easier to derive from the class and add functionality.
2010-02-19 23:24:04 +00:00
erwin.coumans
d4c3633405 Get rid of btSolverBody and use btRigidBody directly. btSolverBody didn't improve performance after all, due to random-access
Tweak the BenchmarkDemo a bit: 

1) disable deactivation in graphical mode
2) add some settings that increase performance in the BenchmarkDemo2 (1000 stack) from 35ms to 15ms on this quad core (at the cost of a bit of quality)
2010-02-11 20:30:56 +00:00
erwin.coumans
da4a1b14b5 Add support for target motion and slip/cfm for both friction directions.
It can be handy for effects such as powered conveyor belt effect or sideways slipping tyre friction.
2009-09-18 07:48:15 +00:00
erwin.coumans
3e2529fcb5 Minor constraint refactoring, to allow SPU-side processing for PLAYSTATION 3 (added non-virtual methods)
Also comment-out some code for __SPU__ to reduce code size
Added btContactConstraint (only used on PS3 SPU right now, better to use btPersistentManifold directly for contact constraints)
Improved readblend utility library (see also usage in http://gamekit.googlecode.com with Irrlicht)

Fix for btConvexConvexAlgorithm, potential division by zero
Thanks linzner http://code.google.com/p/bullet/issues/detail?id=260
2009-08-05 22:14:46 +00:00
erwin.coumans
acf8ed3de5 Re-enabled split impulse: avoids adding linear/angular momentum due to penetration recovery.
Both SIMD and scalar version is supported.
2009-06-10 22:04:06 +00:00
erwin.coumans
258ef6e25a + Added joint feedback for constraints, needs testing/demo before 2.75 release.
See also http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2677
and http://code.google.com/p/bullet/issues/detail?id=227

To enable, use constraint->enableFeedback(true);
And then either use
constraint->getAppliedImpulse() for an estimated applied impulse,
or constraint-> getAppliedLinearImpulse(), or constraint->getAppliedAngularImpulseA() or constraint->getAppliedAngularImpulseB().

+removed a few warnings.
2009-05-27 01:34:46 +00:00
erwin.coumans
459c22e7cb Synchronized changes of Bullet, from Blender.
Added optional flag btSoftBody::appendAnchor(	int node,btRigidBody* body, bool disableCollisionBetweenLinkedBodies=false), to disable collision between soft body and rigid body, when pinned
Added btCollisionObject::setAnisotropicFriction, to scale friction in x,y,z direction.
Added btCollisionObject::setContactProcessingThreshold(float threshold), to avoid collision resolution of contact above a certain distance.
Avoid collisions between static objects (causes the CharacterDemo to assert, when a dynamic object hits character)
2009-03-03 06:47:52 +00:00
erwin.coumans
d886c06fa5 Add the option for the btSimulationIslandManager to avoid splitting islands (for constraint solving)
Move the convertContact inside constraint solver to its own method
2009-02-13 02:34:46 +00:00
erwin.coumans
e80feca36b Big work-in-progress refactoring of the constraint solver:
1) Add fast branchless SIMD support for constraint solver (Windows only until we get other contributions).
See resolveSingleConstraintRowGenericSIMD in Bullet/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
resolveSingleConstraintRowGenericSIMD can be used for all constraints, including contact, point 2 point, hinge, generic etc.

2) During this refactoring, all constraints support the obsolete 'solveConstraintObsolete' while we add 'getInfo1' and 'getInfo2' support.
This interface is almost identical interface to Open Dynamics Engine, to make it easier to port Dantzig LCP solver.

3) Some minor refactoring to reduce huge constructor overhead in math classes.
2008-12-01 06:41:25 +00:00
erwin.coumans
82047e601e updated Bullet sequential impulse constraint solver, so it matches 100% ODE PGS quickstep solver innerloop, mainly by renaming variables... 2008-11-26 00:27:35 +00:00
erwin.coumans
29bfd06af7 Disable friction warmstarting by default, removing second friction direction. This gives a large performance increase.
friction warmstarting can be turned on using:
dynamicsWorld ->getSolverInfo().m_solverMode |= SOLVER_USE_FRICTION_WARMSTARTING;
2008-11-15 22:20:55 +00:00
erwin.coumans
bcd0f48c28 some doxygen updates, added some comments to classes, fix broken links, rename some prefix some internal GIMPACT collision structures using (for example use GIM_AABB instead of BT_AAABB),
removed obsolete btGjkEpa (it was replaced by btGjkEpa2 ages ago)
2008-11-04 04:01:31 +00:00
erwin.coumans
d49aeb9dff + improved split impulse constraint solver option
+ improved friction warm starting
+ made constraint solver configuration more consistent (moved m_solverMode into btContactSolverInfo)
+ reset timing in CDTestFramework after initialization (SAP init destorts timings)
+ make it easier to change default sizes for stack allocator in btDefaultCollisionConfiguration
2008-05-29 03:33:32 +00:00
ejcoumans
e252f5cadd Bugfix: allow btCollisionObjects (non-btRigidBody) to interact properly with btRigidBody for cache-friendly btSequentialImpulseConstraintSolver.
Thanks Andy O'Neil for pointing this out.
2007-11-28 03:17:09 +00:00
ejcoumans
a101719687 - removed warnings in GLUI, thanks Jorrit Tyberghein for the patch!
- removed memory leaks from BasicDemo and Bullet library (other demos needs to be cleaned up!)
- added memory leak debugging functionality in btAlignedAlloc.h: #define BT_DEBUG_MEMORY_ALLOCATIONS
2007-10-31 08:00:03 +00:00
ejcoumans
811c105c24 align btQuadWord on 16byte boundary
slightly improved friction model
2007-09-25 06:58:53 +00:00
ejcoumans
15df0a7d7a revert to previous version of constraint solver, until the memory allocation issues are sorted properly. 2007-09-10 19:19:52 +00:00
ejcoumans
b054f375bc - Added serialization to btBvhTriangleMeshShape/btOptimizedBvh. See ConcaveDemo for example usage.
- added bt32BitAxisSweep3, which co-exists without recompilation, using template class. This broadphase is recommended for large worlds with many objects (> 16384), until btMultiSwap is finished.
- Fixed some recent issues in Bullet 2.57 related to compound (thanks Proctoid) and memory allocations
2007-09-10 01:14:42 +00:00