Max number of colliding pairs

User avatar
tasora
Posts: 26
Joined: Mon Aug 15, 2005 8:57 am
Location: Italy

Max number of colliding pairs

Post by tasora »

Hallo Erwin,

looking in the btDefaultCollisionConfiguration C++ code, I see that
there is a
#define DEFAULT_MAX_OVERLAPPING_PAIRS 65535
and this means that the pool allocator for allocating colliding
pairs is limited to that amount, and cannot be modified at configuration
creation. Please have it as a parameter. (I modified the class so it is
a parameter at configuration's creation.)

By the way.. a PROBLEM: since I am using the bt32BitAxisSweep3 and more than
100'000 bodies, the number of pairs must be really high (>400'000), but it cannot
be predicted exactly at the beginning. On the other hand, if I make
the DEFAULT_MAX_OVERLAPPING_PAIRS very huge (>600'000) to be sure
that they are enough, I risk to waste all my RAM (I am approaching the 2Gb
limit, I must be very careful in wasting memory!).
I mean, ok, it would be nice that in Bullet one can choose to use the
btDefaultCollisionConfiguration with the pool allocator for fast
performance - but there should be also the possibility of using the classical
heap allocation for 'memory-critical' large projects where you do not want
to allocate everything at the beginning..

LAST MINUTE NOTE: I tried to do
#define DEFAULT_MAX_OVERLAPPING_PAIRS 2
for a simulation with 1000 bodies, and it worked anyway! Does this mean
that the pool allocation in btDefaultCollisionConfiguration is not yet
used in Bullet? Is Bullet still using the old heap allocation (which is good
for my projects with 100k spheres, anyway...) ?

Alessandro Tasora
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Max number of colliding pairs

Post by Erwin Coumans »

Hi,

The memory pools are used, and Bullet will automatically fallback to heap allocations when the pool runs out of elements. See Bullet/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp

Code: Select all

btPersistentManifold*	btCollisionDispatcher::getNewManifold(void* b0,void* b1) 
{
[....]

if (m_persistentManifoldPoolAllocator->getFreeCount())
	{
		mem = m_persistentManifoldPoolAllocator->allocate(sizeof(btPersistentManifold));
	} else
	{
		mem = btAlignedAlloc(sizeof(btPersistentManifold),16);

	}
[...]
}
The user can provide their own (smaller are bigger) memory pools in the constructor of btDefaultCollisionConfiguration. You cannot resize the pool afterwards, because objects maintain pointers inside the original pool.

Thanks for the feedback,
Erwin
User avatar
tasora
Posts: 26
Joined: Mon Aug 15, 2005 8:57 am
Location: Italy

Re: Max number of colliding pairs

Post by tasora »

Hallo Erwin,

thank you for pointing out this nice feature (i.e. fallback to heap allocation
when pools are filled) because I thought it was a more 'basic' pool ... Really interesting!
So this means that I can leave the 65k pairs limit without worrying too
much about the effective number of contact pairs. Perfect.

Thank you!

Alessandro Tasora