Advertisement Jump to content
Sign in to follow this  

Distance to the nearest wall

This topic is 809 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


Currently, I am comparing the distance by using a raycast from the object to the static mesh.

which isn't quite correct, since the static mesh can have a hollow body, so the ray won't hit anything,

or get hit at a far distance, the wall at the very far end.


So I try to compare against the bounding boxes of each frame in the hierarchy which will lead to

a performance hit if the hierarchy is very huge.


Is it possible to form a large irregular tight bounding volume of the static geometry.

So that a ray can be casted on it?






Share this post

Link to post
Share on other sites
Is it possible? Sure. You can design a system that uses a coarse mesh and a fine mesh for testing, often called narrow-phase and broad-phase tests.

Generally the solution is to start with smaller objects and use a spatial tree. After that another solution is to tag items with a specific attribute, which can help if you need to further reduce your search. Combining them, you would have your spatial grid look in concentric rings for objects with the tag.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!