A bullet in Bullet, ray test missing hits

Post Reply
MajorNr01
Posts: 7
Joined: Sun Aug 04, 2013 8:44 pm

A bullet in Bullet, ray test missing hits

Post by MajorNr01 »

I want to implement a fast moving projectile (bullet) that can hit anything in my collision world (using discrete dynamics world).

I do this by moving a position through space by my own calculations and ray testing everytime that position changes. I simulate gravity, by changing the velocity every frame with a constant acceleration. All this is done outside the collision world, the only interface to Bullet is the ray test every frame.

The result of course is an approximated parabolic arc consisting of straight segments, each representing a ray test, and all together forming a continuous uninterrupted line.

Still my projectiles manage to tunnle through some rigid bodies with box shapes every now and then. I realize that ray tests do not hit when performed inside a convex shape, but in this case it seems they also miss the surface of the box shapes.

I have looked at the actual cases of tunneling and it seems like everytime they occur, one ray test ends very close to the surface of the box, and the next one starts at the same point (obviously) but misses the hit.

So my question, if I may, is this: Is there some kind of margin close to the surface of a convex volume where ray tests neither hit, coming from outside, nor going inside the volume?

And is there possibly a better way of implementing a bullet in Bullet?

Thank you for your time.
BluePrintRandom
Posts: 47
Joined: Sun Oct 27, 2013 4:16 am

Re: A bullet in Bullet, ray test missing hits

Post by BluePrintRandom »

I don't know anything about the internals, but what about raycasting from a point just before the the endpoint? (overlap?)
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: A bullet in Bullet, ray test missing hits

Post by drleviathan »

It sounds like you want to use Continuous Collision Detection (CCD). You should look at the ContinuousConvexCollision Demo or maybe read this wiki page/FAQ.
Post Reply