# How to check that two nodes of quadtree are neighbours?

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

## Recommended Posts

Sommet way is working to searching neighbours in the quadtree, but what if two nodes are given allready, and only thing is last it is to check that they both are neighbours to the given direction(N,W,S,E)?

In my algorithm I use Sommet way: I traverse up to the common uncestor and watching nodes for reflection(symmetry). But it is not works properly. As result there are a more than one neighbours matched to the given direction, it's impossible, because one direction - one neighbour.

P.S.

I need this for stitching terrain nodes.

##### Share on other sites

How about simply checking the node's edges? E.g. when checking east, you could do

(node1.x+node1width) == node2.x

And the same for other directions. It would be four checks at most.

##### Share on other sites

Sorry, i mean Samet neighbor finding techs. Not edges but neighbors. I am trying to check is two nodes are neighbors. Let's depict:

-------------------------

|      |      |      |      |

|-----|-----|-----------|

|      |  a  |  b  |      |

-------------------------

|             |

|      c     |

|             |

-------------

isNeighbor(a, c,  SOUTH) is true

isNeighbor(a, b, EAST) is true

isNeighbor(a, b, WEST) is false

isNeighbor(c, b, NORTH) is false

etc

##### Share on other sites
TheUnnamable! You are right!

Resolved.

• 13
• 18
• 29
• 11
• 27
×

## Important Information

GameDev.net 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!