Querying neighbors by ray casting

Started by
0 comments, last by Nanoha 7 years, 5 months ago

Hello, In one particular case, I use regular octree to query neighbors, which exhibits no problems.

In another, as I want to save computer resources on computations and all that stuff,

I changed to an irregular octree, the pathfinder does find the destination,

But the ray cast was a bit off-track. Because When I do a ray in a direction of (1,0,0),

which normally hits the EAST node somehow, now not hitting anything,

which then resorts to hitting a SOUTHEAST node.

As a result, the agent will travel in a diagonal move, but sometimes go thru walls.

Are there anyways I can prevent the agent going thru walls, as a SOUTHEAST cast does work,

since the EAST nodes are in different shapes?

Thanks

Jack

Advertisement

I am not sure how you are doing this but the idea would be to first ray cast against the root node (whatever shape that may be), if it hits then you cast against any objects contained with in and store any hits. You then cast against any child nodes, the shape of those shouldn't matter as long as you can ray cast against it. If you hit any then you ray cast against any objects in those. You then ray cast against the child nodes of those and so on until you you run out of nodes to check. You then will have a list of objects that were hit (if any) and you just select the closest one.

There are some opportunities for optimisation there, firstly if the ray always originates in the root node then you don't need to do that check. You could probably do something with culling siblings if you have already found a hit that is closer than another sibling could provide.

If you are missing nodes out then I would think there's an issue with your ray-volume check and you should check there especially as you are merging some of those siblings which could throw up some difficulties

When you do your checks do you have it hard coded that (1, 0, 0) would go east and have the east node already selected rather than going down the tree in turn?

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.

This topic is closed to new replies.

Advertisement