Ray Testing
3 posters
Ray Testing
I've got some objects in my scene and I've got to do a ray test from one object to another and get to know what object has been hit.
I tried th raytest that comes with bullet and this successfully tells me if there was a hit or not, but doesn't tell me with wich object. How can I do this?
ps: I tried to post on the bullets forum, but no one has replied. Maybe someone here knows..
I tried th raytest that comes with bullet and this successfully tells me if there was a hit or not, but doesn't tell me with wich object. How can I do this?
ps: I tried to post on the bullets forum, but no one has replied. Maybe someone here knows..
william- Posts : 15
Join date : 2009-09-09
Re: Ray Testing
I did a little research but can't find the topic. Anyway I've see that the
Maybe I'm missing something..
- Code:
btCollisionWorld::ClosestRayResultCallback ray( from, to );
Maybe I'm missing something..
william- Posts : 15
Join date : 2009-09-09
Re: Ray Testing
This is good, but too much expensive for what I have to do: all I need is a ray test and if the ray hits something, get the CollisionObject from it.
Here's my solution:
Thank you very much
Here's my solution:
- Code:
btCollisionWorld::ClosestRayResultCallback ray( from, to );
sio2->_SIO2physic->_btSoftRigidDynamicsWorld->getCollisionWorld()->rayTest( from, to, ray );
btCollisionObject* pColObject=ray.m_collisionObject;
//and then for every object
if( pColObject == myRefObject->_SIO2objectphysic->_btRigidBody)
{
//I've found the sio2object who was hit by the ray
}
Thank you very much
william- Posts : 15
Join date : 2009-09-09
Re: Ray Testing
Well, yes of course it is good enough if you don't need the contact points ;-)
Btw, you can get the SIO2object directly from the btCollisionObject.
( SIO2object * )( ( btRigidBody * )rayCallback.m_collisionObject )->getUserPointer();
Btw, you can get the SIO2object directly from the btCollisionObject.
( SIO2object * )( ( btRigidBody * )rayCallback.m_collisionObject )->getUserPointer();
Francescu- Posts : 136
Join date : 2009-03-18
Re: Ray Testing
Yes could be useful but if I can avoid the calling time of the getUserPointer() it's better
william- Posts : 15
Join date : 2009-09-09
Re: Ray Testing
I'm not sure you would actually save much. In your case, you have to loop through your objects to compare pointers and derefence myRefObject where you can get the object pointer directly with that getter - tradeoffs. But hey, to each their own!william wrote:Yes could be useful but if I can avoid the calling time of the getUserPointer() it's better
Francescu- Posts : 136
Join date : 2009-03-18
Re: Ray Testing
The Sio2object is a reference inside an another structure, wich we can call class Player for example, so the loop is necessesary:
Otherwise yes, your're right!
- Code:
//check raytest, if yes get collision body then..
for each player
if player->sio2object->_sio2objectPhysic == collisionbody
dosomething
Otherwise yes, your're right!
william- Posts : 15
Join date : 2009-09-09
Similar topics
» Basic collision testing
» Testing and failing Object duplication
» SIO2 Remote Application for Testing
» Testing and failing Object duplication
» SIO2 Remote Application for Testing
Permissions in this forum:
You cannot reply to topics in this forum
|
|