rayTest improvements: face normal and broad phase filter
Posted: Tue Aug 26, 2008 9:42 pm
Hi there,
I'm one of the maintainer of the Blender game engine, which uses Bullet as you know. I am working on a set of improvements for the rayCast function for which some minor changes are required in Bullet:
1) possibility to filter out collision objects through callback before testing the ray. This would avoid testing an object that the game engine wants to ignore in any case (X-Ray function). => this is now available in 2.70
2) possibility to return the true face normal on concave mesh shapes. Currently the normal returned by the rayTest function is always oriented towards the ray origin. By returning the true face normal, the application can easily test if it is inside or outside the mesh.
3) possibility to retrieve the hit face on concave mesh shapes. Currently, only the triangle index is returned, which is insufficient in case of compound shape; the collision shape pointer is necessary to identify which child shape got the hit.
I've prepared a patch based on the Bullet version used in Blender (2.67?) but it won't be applicable to Bullet 2.70 because there has been several other changes in this area. I can prepare a patch for 2.70 if there is a consensus to integrate those features for the next release.
The patch can be found here
There is another useful feature for which I don't have a patch yet: the possibility to return more than one hit, by order of proximity. This would require sorting the hits rather than keeping the closest one only. Currently this function can be implemented by running multiple rayTest, each starting from the hit point of the previous rayTest. But it would be faster and more reliable to sort the hit points during the first run of rayTest as the algorithm computes them all in any case.
I'm one of the maintainer of the Blender game engine, which uses Bullet as you know. I am working on a set of improvements for the rayCast function for which some minor changes are required in Bullet:
1) possibility to filter out collision objects through callback before testing the ray. This would avoid testing an object that the game engine wants to ignore in any case (X-Ray function). => this is now available in 2.70
2) possibility to return the true face normal on concave mesh shapes. Currently the normal returned by the rayTest function is always oriented towards the ray origin. By returning the true face normal, the application can easily test if it is inside or outside the mesh.
3) possibility to retrieve the hit face on concave mesh shapes. Currently, only the triangle index is returned, which is insufficient in case of compound shape; the collision shape pointer is necessary to identify which child shape got the hit.
I've prepared a patch based on the Bullet version used in Blender (2.67?) but it won't be applicable to Bullet 2.70 because there has been several other changes in this area. I can prepare a patch for 2.70 if there is a consensus to integrate those features for the next release.
The patch can be found here
There is another useful feature for which I don't have a patch yet: the possibility to return more than one hit, by order of proximity. This would require sorting the hits rather than keeping the closest one only. Currently this function can be implemented by running multiple rayTest, each starting from the hit point of the previous rayTest. But it would be faster and more reliable to sort the hit points during the first run of rayTest as the algorithm computes them all in any case.