GAMEDEV.NET
Alternatives to Octrees?
Author I am interested in replacing my octree system with something simpler, with the following characteristics.Insertion, removal, and relocation of tens of thousands of entities with a defined bounding box into the scene.Fast ray intersection test, with some method of optimization.Fast bounding box intersection test, to retrieve all entities that intersect an arbitrary box.Fast convex hull intersection test, for culling against the camera frustum.No maximum boundary has to be defined; limited only by floating point precision.These systems can be very hard to test, so it should be simple enough that I can just look at the code to verify it works as expected.I have some ideas how this could be done but would like to hear yours. Is there a know technique that will provide good results with modern CPUs? Maybe an existing library specifically for this purpose? I am thinking that with superoptimized C++ code, you could use a very rough optimization step, and then brute-force the rest. Josh Klint said:I am interested in replacing my octree systemOne interesting option is to use a higher brancing factor, e.g. 4^3 children instead the usual 2^3 with octree.This way you need much fewer tree levels, so less cache misses while traversing.Finding adjacent nodes also requires less traversals, since more neighbours are likely in the same block.Implementation remains basically the same to octree.For something simpler, a multilevel grid with a dense top level and sparse child levels is an option. E.g. we have a large horizontal 256^2 grid for the whole world, and only if there are a lot of elements in a cell we subdivide them once (or maybe two times) more.Both those ideas can be combined. In my fluid particles simulator i use a large but low res dense grid at the top, expanding to 4^3 subdivisions where needed.Another option i often use is a horizontal 2D grid, where each cell points to a ‘column’ of vertical nodes for the 3rd dimension.If we sort the column by height, we can find any node first from trivial 2D grid coords, then doing binary 1D search for height.So we get a sparse grid not requiring a tree traversal.Nice, but it depends on content how optimal this is. Game worlds are usually flat, so that works well.In general, the main alternaive to octree is BVH i would say. Advantage of BVH is we can refit instead rebuild with moving elements. But we need more memory for the bounds.
0 Comments 0 Shares 72 Views