Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Aug 06, 2010 5:21 pm 
Offline

Joined: Wed Apr 29, 2009 11:45 pm
Posts: 6
Hello. I am the author of the irrBullet wrapper for Irrlicht. Bullet is a great physics library!

I have one problem. My raycast vehicles work fine until I add collision filters to the objects in the the simulation world. Then it simply stops contacts and acts as if the vehicle's wheel don't even exist.

I have the filters so that the vehicle collides with terrain, and the terrain collides with vehicles, so why wouldn't the raycast vehicle work at all? I've looked through the source files of the raycast vehicle but can't find any mention of filters, so it must be in the rigid body or collision object's code.

An answer to this would be great! Thanks.

- Josiah


Top
 Profile  
 
PostPosted: Sat Aug 07, 2010 7:45 pm 
Offline

Joined: Wed Apr 29, 2009 11:45 pm
Posts: 6
Any ideas? I can't figure out why such a strange problem happens.


Top
 Profile  
 
PostPosted: Sun Aug 08, 2010 7:05 am 
Offline

Joined: Tue Dec 25, 2007 1:06 pm
Posts: 315
Cobra wrote:
I have the filters so that the vehicle collides with terrain, and the terrain collides with vehicles, so why wouldn't the raycast vehicle work at all? I've looked through the source files of the raycast vehicle but can't find any mention of filters, so it must be in the rigid body or collision object's code.
First of all, I've never tried to use raycast vehicles + collision masks myself.
Anyway I believe that raycasts can be done with collision masks themselves in this way (note: this is a generic raycast, not specific to raycast vehicles; also this code is a bit old, I hope it works):
Code:
btCollisionWorld::ClosestRayResultCallback rayCallback(rayFrom,rayTo);
m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback);
rayCallback.m_collisionFilterMask = btBroadphaseProxy::AllFilter & ~btBroadphaseProxy::SensorTrigger;
if (rayCallback.hasHit())
{
btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
[...]
}
The filters are present in the line:
Code:
rayCallback.m_collisionFilterMask = btBroadphaseProxy::AllFilter & ~btBroadphaseProxy::SensorTrigger;
I would try to apply filters both to the car chassis and to raycasts.

Hope it helps.


Top
 Profile  
 
PostPosted: Mon Aug 09, 2010 4:09 am 
Offline

Joined: Wed Apr 29, 2009 11:45 pm
Posts: 6
Ah, I see. I really appreciate your reply. If I would have looked a little harder, I would have seen that I can derive my own class from btVehicleRaycaster and used that with the raycast vehicle.

I fixed it using this:

Code:
void* IVehicleRaycaster::castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result)
{
   btCollisionWorld::ClosestRayResultCallback rayCallback(from,to);

   if(useFilter)
   {
        rayCallback.m_collisionFilterMask = collisionFilterMask;
        rayCallback.m_collisionFilterGroup = collisionFilterGroup;
   }

   m_dynamicsWorld->rayTest(from, to, rayCallback);

   if (rayCallback.hasHit())
   {

      btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
        if (body && body->hasContactResponse())
      {
         result.m_hitPointInWorld = rayCallback.m_hitPointWorld;
         result.m_hitNormalInWorld = rayCallback.m_hitNormalWorld;
         result.m_hitNormalInWorld.normalize();
         result.m_distFraction = rayCallback.m_closestHitFraction;
         return body;
      }
   }
   return 0;
}


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 2 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:  
Powered by phpBB® Forum Software © phpBB Group