Function GridNode.FilterDiagonalConnections
Filters diagonal connections based on the non-diagonal ones to prevent corner cutting and similar things.
int FilterDiagonalConnections (
int | conns | |
neighbours | ||
bool | cutCorners |
Filters diagonal connections based on the non-diagonal ones to prevent corner cutting and similar things.
This involves some complicated bitshifting to calculate which diagonal connections should be active based on the non-diagonal ones. For example a path should not be able to pass from A to B if the #s represent nodes that we cannot traverse.
# B
A #
Additionally if corner cutting is disabled we will also prevent a connection from A to B in this case:
B
A #
If neighbours = 4 then only the 4 axis aligned connections will be enabled.
If neighbours = 6 then only the connections which are valid for hexagonal graphs will be enabled.