Crash when raycast start/end point are outside broadphase

Crash when raycast start/end point are outside broadphase


I want to do raycasting for picking objects in an editor. The problem is, that i need to be very conservative with the ray-length, since it is an editor and objects could be "anywhere" along a line (ie. very far away).

So i start my raycast at some position and then fire into the desired direction with a length of about 10000 units.The problem is, that at least the end-point of that raycast is usually outside the broadphase and thus an assert lets my app crash.

I really don't want to be forced to clip my raycasts to the size of the Havok world, so is there a way to get raycasts that may even start outside of the world and are infinitely long ?


5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Ok, i DID clip my ray to the world-boundaries and it works now.

I don't care very much, that my ray needs to start within the world-boundaries, since that is usually a given (except for editors). However, it annoys a bit, that even the end-point needs to be within the boundaries, because in a game you might want to shoot a ray very far, to simply find the first hit, even if that is very far away. Depending on where you stand and where you look, it is possible that your "very long ray" does leave the boundaries. And in a game you really don't want to clip each and every ray, just to make sure.

I realize, that this is an assert, that is only fired in Debug-builds and not in a final product, so i don't see this as a bug. But it is an aid, that can become annoying, because during development one wants to link to the debug-libs and thus your game might be crashing only because some ray was too long.

My suggestion is this: Keep the assert for ray-cast, whose origin is outside the world, because then the "false miss" problem is real. But ignore the case, when the end-point is outside the world, i don't think there could be any false misses, anyway. Or does this have something to do with the possibility to shift the world boundaries around ?


Hi Jan,

If you find asserts being a little *too* helpful you can always disable them with the following code:

hkError::getInstance().setEnabled(0xffffffff, false);

(Just replace 0xffffffff with the ID of the assert you're seeing).


Wow, great!

Hi Jan,
Just FYI, we changed the assert to a warning for Havok 6.0, since a lot of other people were complaining about it too.

There *is* an honest-to-goodness bug when linear casting (not raycasting) outside the broadphase; that will likely crash if you try it. That bug is fixed in 6.0 too.


Leave a Comment

Please sign in to add a comment. Not a member? Join today