Sign in to follow this  
Northernlight

Need suggestions on navigation map implementation

Recommended Posts

Hi
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this