kd-tree generation, not used yet though