bulletphysics / bullet3

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.
http://bulletphysics.org
Other
12.61k stars 2.87k forks source link

btCylinderShape rayTest gives hit when ray starts from inside #459

Closed lefty2 closed 3 years ago

lefty2 commented 9 years ago

If you do a ray test with the ray starting inside a btCylinderShape most of the time the ray does not hit the cylinder (seemingly it's back culled), but every now and again (maybe 1 in 1000 times) it does hit. That seems to be a bug for me - it should either hit all the time, or never.

benelot commented 9 years ago

I tried the same with other shapes, in my case the box and the capsule shape and I also do not get any hits from inside.

I even tried to remove the filter backfaces in case that was the problem, but it does not change it at all.

 rayCallback.m_flags &= !btTriangleRaycastCallback::kF_FilterBackfaces;

My solution here was just to invert the ray to get proper hits. But it should be looked into from the Bullet Physics side.

lefty2 commented 9 years ago

The fact the ray does not hit from inside is not the problem. The problem is that it sometimes hits and sometimes doesn't on a seemly random basis. Also, inverting the ray is not a solution, unless you are using AllHitsRayResultCallback. It's not clear if they ment to use back culling or not. The kF_FilterBackfaces is not used at all in the source code.

erwincoumans commented 9 years ago

Yes, this should be addressed. We lack resources to address this at the moment and fix it once we have time.

benelot commented 8 years ago

I changed the raytest example to show the issue: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=10924