Constructing a KD-Tree from a cube-based world

658 views Asked by At

This question should be pretty easy to answer and I have a feeling there's probably a lot of documentation on the subject but I couldn't find anything in my searches so I presume I'm searching for the wrong thing.

Let's imagine I have a world of equal sized cubes, each with a value either 1 or 0.

What's the best method for merging cubes of a similar value into the largest possible cuboid. I considered just grabbing one at random and checking the adjacent nodes and combination them if they're all the same vague and repeating, but obviously the result would not be particularly optimised. I also considered checking every possible combination of cubes and comparing the results but that would be incredibly expensive.

Any help anyone could render would be very helpful.

Oh, to clarify, I'm looking for a method of constructing a KD tree out of orthogonal collision data to help optimise path finding.

1

There are 1 answers

6
Tom On

I'm assuming your world is a 3D "grid" of cubes. Is this correct? If so, a typical way to subdivide and organize a cubic space is using an Octree. http://en.wikipedia.org/wiki/Octree

EDIT: you may want to implement a 3D version of this: http://en.wikipedia.org/wiki/Connected_Component_Labeling