# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: get list of collision pairsPosted: Fri Apr 13, 2012 4:20 am

Joined: Fri Apr 13, 2012 4:11 am
Posts: 2
Can you please tell how to Bullet can get a list of objects of class btRigidBody, collided with this object.

Top

 Post subject: Re: get list of collision pairsPosted: Fri Apr 13, 2012 4:35 pm

Joined: Fri Jun 24, 2011 8:53 am
Posts: 130
The broadphase adds and removes overlapping pairs from a pair cache. The developer can choose the type of pair cache.
A collision dispatcher iterates over each pair, searches for a matching collision algorithm based on the types of objects involved and executes the collision algorithm computing contact points.

So, get all the manifolds and loop on them. I was pretty sure the manual included a code snippet in the past but I'm unable to find it myself so for your convenience, the code will be like
Code:
const int manifoldCount(dispatcher.getNumManifolds());
for(int loop = 0; loop < manifoldCount; loop++) {
const btPersistentManifold *mf = dispatcher.getManifoldByIndexInternal(loop);
const void *obja = mf->getBody0();
const void *objb = mf->getBody1();
if(obja == object || objb == object) {
// This manifold deals with the btRigidBody we are looking for.
// A manifold is a RB-RB pair containing a list of potential (predicted) contact points.
const unsigned int numContacts(mf->getNumContacts());
for(int check = 0; check < numContacts; check++) {
const btManifoldPoint &pt(mf->getContactPoint(check));
// do something here, in case you're interested.
}
}
}

Top

 Post subject: Re: get list of collision pairsPosted: Fri Apr 13, 2012 6:08 pm

Joined: Fri Apr 13, 2012 4:11 am
Posts: 2
thank you very much

Top

 Post subject: Re: get list of collision pairsPosted: Tue Jul 31, 2012 4:04 am

Joined: Fri Jun 15, 2012 7:11 am
Posts: 43
just what i am looking for.
is the 'object' in the code referring to our btRigidBody object?
as getBody doesn't seem to be specify type.

Top

 Post subject: Re: get list of collision pairsPosted: Tue Jul 31, 2012 8:49 am

Joined: Sun Jan 07, 2007 4:29 pm
Posts: 44
Location: Oxford, England
Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 5 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Exabot [Bot] and 4 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities