[ODE] "synchronous" ray intersection tests?
cledwith at d-a-s.com
Fri Aug 5 15:53:08 MST 2005
> Hi all,
> Let me see if I can explain my problem. I'm in the process of
> replanting an existing game to use ODE and this issue confuses me. In
> the game, I have a collision test in the main loop which can easily be
> refactored to be used as the collision callback method in ODE. So far,
> so good. But in a lot of places outside this method I am doing
> individual line intersection tests. The calls look like this:
> bool result = IsLineOfSightBlocked(Vector from, Vector to)
> This code is stuff like AI routines, weapons simulations and so on.
> Now, in ODE line intersection tests are done as part of the main
> collision call, with ray geoms added to the system for just one step.
> So if I do it this way, it means that the line intersection test is
> asynchronous because the result will only be available later in the
> game loop. This makes my job hard because I need to change a lot of
> Is there a reasonable way, performance-wise, that I can make
> "throw-away" line intersection tests like above with ODE and
> encapsulate it in a method that will give me my result right away? I
> imagine I need to call one of the collide functions, but how do I
> organize it so only the single ray is collision tested?
You can have a special callback that handles rays if your design calls for
it, or you can use the same callback that gets called during the main
simulation loop. You don't have to make assumptions about or restrict when
a callback will get called.
So if you want to know the result right away, write a raycast function
that does something like call dSpaceCollide2 (passing in a callback that
modifies the passed in data), and then test the data.
More information about the ODE