This avoids copy-pasting the BLI_kdtree API for a 4D version (needed to fix T62595).
The way macros are used here isn't great, alternatives could be to duplicate the code, make the dimensions a property of the tree (at the cost of efficiency) or move it to C++ and use a C-API wrapper.
- This includes a fix for T62595 (to show how it works).
- BLI_kdtree is currently being used for 2D trees for select similar and edge-net-filling, so the ability to have use different dimensions isn't limited to this case.
Details:
- If this is included BLI_kdtree_* should be renamed to BLI_kdtree_3d_* since it's strange to have both BLI_kdtree_new & BLI_kdtree_4d_new.
- Could rename 3d/4d -> v3/v4 (named this way because BLI API's have 3d and 2d versions of functions).