Jump to content
  • Advertisement
Sign in to follow this  

Need suggestions on navigation map implementation

This topic is 2802 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

Not sure if this should go in the AI programming section but the question is not really an AI programming issue.

I'm implementing a map of graphnodes for A* navigation. The nodes and their edges are created by "flood filling" on a terrain. The nodes are then stored in a std::vector. The nodemap is dynamic which means that nodes can be removed and added during runtime.

The problem is this: When the user is clicking on the terrain I have to find out which node is the closest one to the point which was clicked.

I'm thinking that iterating through the entire vector, and then testing each node's distance to the clicked point, would be a very expensive operation. (Calculating distance between two 3D vectors and the comparing two floating point numbers). My first thought was to first check the X value of the nodes in the vector and then check the Y value of the nodes with the closest X value I find first. I'm still thinking that this is too expensive, and there must be a more elegant solution than that.

Have anyone else had this problem? Or do anyone have a suggestion?

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!