ClosestRayResultCallback crash

vexator
Posts: 10
Joined: Thu Nov 01, 2007 11:12 am

ClosestRayResultCallback crash

Post by vexator »

i'm trying to perform a basic ray test. everything's set up fine, my physics world is populated with both static and dynamic meshes. however, this crashes as soon as a body is hit:

Code: Select all

btVector3 rayTo = cameraPosition+viewDir*1000.0f;

btCollisionWorld::ClosestRayResultCallback rayCallback( cameraPosition, rayTo );
g_rkWorld->rayTest( cameraPosition, rayTo, rayCallback);
any ideas? I'm using Bullet 2.75.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: ClosestRayResultCallback crash

Post by Erwin Coumans »

It can be anything. Can you reproduce it in a Bullet demo?

Can you update to Bullet 2.76 and export the scene to a .bullet file, zip and attach it?

Thanks,
Erwin
vexator
Posts: 10
Joined: Thu Nov 01, 2007 11:12 am

Re: ClosestRayResultCallback crash

Post by vexator »

hi erwin, i got it working by upgrading to 2.76 and using btBvhTriangleMeshShapes for my static geometry. I was still using the old triangle mesh classes. picking now works, but the casted rays do not always seem to be right.

first question: is rayEnd only the direction vector, or should it also include the start offset?

Code: Select all

btVector3 rayStart = cameraPosition;
btVector3 rayEnd = /*cameraPosition+*/viewDir*1000.0f; <- do I have to add cameraPosition?

// perform ray cast
btCollisionWorld::ClosestRayResultCallback rayCallback( rayStart, rayEnd );
g_rkWorld->rayTest( rayStart, rayEnd, rayCallback );
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: ClosestRayResultCallback crash

Post by pico »

vexator wrote:hi erwin, i got it working by upgrading to 2.76 and using btBvhTriangleMeshShapes for my static geometry. I was still using the old triangle mesh classes. picking now works, but the casted rays do not always seem to be right.

first question: is rayEnd only the direction vector, or should it also include the start offset?

Code: Select all

btVector3 rayStart = cameraPosition;
btVector3 rayEnd = /*cameraPosition+*/viewDir*1000.0f; <- do I have to add cameraPosition?

// perform ray cast
btCollisionWorld::ClosestRayResultCallback rayCallback( rayStart, rayEnd );
g_rkWorld->rayTest( rayStart, rayEnd, rayCallback );
Hi,

RayEnd is not a direction vector nor includes RayStart.

RayStart is the start of the ray in world coordinates.
RayEnd is the end of the ray in world coordinates.
vexator
Posts: 10
Joined: Thu Nov 01, 2007 11:12 am

Re: ClosestRayResultCallback crash

Post by vexator »

yeah but if i want to shoot a ray from the camera position along the view direction, then it should be right like this, shouldn't it?
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: ClosestRayResultCallback crash

Post by pico »

vexator wrote:yeah but if i want to shoot a ray from the camera position along the view direction, then it should be right like this, shouldn't it?
then rayStart=cameraPos and rayEnd=rayStart+viewDir*distance