Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Jun 06, 2012 7:56 am 
Offline
User avatar

Joined: Wed May 16, 2012 3:37 pm
Posts: 5
Being a total n00b in Bullet, I seek the wisdom of more seasoned developers in here to help me figure this out without a lot of overhead.

I am looking to perform a "spherical raycast" i.e. give Bullet a position and a distance and have it send back a list of objects within the raycast sphere.

My initial thought was to run through all the bodies in my Bullet scene and test their distance. Then I saw there is a raytest() method in btDynamicsWorld and thought that maybe I could do multiple raycasts in different directions (but that would be way too costly I think).

So, any ideas?

Thanks.


Top
 Profile  
 
PostPosted: Wed Jun 06, 2012 10:52 am 
Offline

Joined: Fri Jan 28, 2011 9:03 pm
Posts: 14
1) add collision object (btCollisionObject or derivative) with collision shape (deriv. from btCollisionShape) to the collision world (btCollisionWorld or deriv.);
2) create btSphereShape;
3) perform convex test (btCollisionWorld::convexSweepTest()) btSphereShape vs. all objects from btCollisionWorld;
4) PROFIT!
see:
Demos\CharacterDemo\CharacterDemo.cpp


Top
 Profile  
 
PostPosted: Mon Jun 11, 2012 7:57 am 
Offline
User avatar

Joined: Wed May 16, 2012 3:37 pm
Posts: 5
Cool thanks!

Quick question though: will this work if my "to" and "from" positions are the same? i.e. my collision sphere is static and does not move?

(sorry for the long delay in responding, but it seems the "subscribe topic" option is not working :( )


Top
 Profile  
 
PostPosted: Mon Jun 11, 2012 1:46 pm 
Offline
User avatar

Joined: Wed May 16, 2012 3:37 pm
Posts: 5
I have a bonus question:

When I do a convex sweep, the callbacks available in Bullet all return btCollisionObject pointers (as far as I know).

Now, in my code, I have wrapper classes each containing its own copy of a Bullet object (mainly btRigidBody and BtSoftBody). How can I find the correct instance of my wrapper class contaiing the body returned by the convex sweep? Can I just simply compare the pointer adresses?

I found the set/get companionID methods for a btCollisionObject, can I use those to assign specific IDs to my objects or are they used internally by the collision algorithms (like it seems to be the case in btParallelConstraintSolver::solveGroup() ).

Thanks for any help/suggestions.


Top
 Profile  
 
PostPosted: Thu Aug 09, 2012 10:01 am 
Offline

Joined: Fri Jan 28, 2011 9:03 pm
Posts: 14
Quote:
will this work if my "to" and "from" positions are the same?

Check it!

Quote:
Can I just simply compare the pointer adresses?

hmm..yeah. You can use btCollisionObject::m_userObjectPointer to get rid of search.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

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


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

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group