3

I am implementing frustum culling for dynamic objects into my engine and have been reading as mush as I can about "loose octrees". Unfortunately most sources are quite vague and really it's just lots of posts of people saying how good they are and that they gave O(1) insertion and deletion but without explaining any of the logic behind it.

I understand the main principles that the octants are treated as being larger than they are and that the loose factor can go up to 2. This means that an object can be inserted into a single node based on it's size. The trouble is that alot of the articles don't use a "k-factor" of 2 (probably to get a tighter fit) and therefore lose the fast insertion/deletion; instead they maintain an adjacency structure so you can traverse all nodes at a given depth and test the centre of the object with each node.

I only need a rough culling test and I'd like to have the O(1) insertion time and have worked out the formula for calculating the depth (level) that an object should be inserted. However I cannot find any articles that discuss a formula to calculate an exact node from the size and position of an object.

Have I totally misunderstood the algorithm and am I looking for something that isn't possible? If anyone can point me to any good papers or articles (I've read http://tulrich.com/geekstuff/) then that would be great.

PS It may be worth mentioning that I am using a linear octree stored in a 1D array

Thanks for any help

Downie
  • 193
  • 1
  • 13

2 Answers2

2

I got the answer on the gamedev forum. The equation I was looking for was actually really simple

int NodeIndex = depth*(bb.centre.x / sceneBB.width);

Downie
  • 193
  • 1
  • 13
1

You didn't mean a multidimensional search in an octree? What about a space-filling-curve?

Micromega
  • 12,486
  • 7
  • 35
  • 72
  • I don't think space-filling curves are that common for frustum culling (don't know exactly why but I assume there must be a reason). Really the main issue is trying to find a relationship between the centre point of an object and a node in the tree (after having worked out the depth). For instance a world of size 100x100x100 represented by a complete tree would have objects of size 60 at depth level 1 (0 being the root level). I have heard of a way to work out the node at that level to insert into without having to loop all nodes at that level (and have to hold complex sibling relationships) – Downie Mar 14 '11 at 14:06
  • Yes, but you forgot to vote for me and also a space-filling-curve is used to detect colisions and also insert to a sfc-tree is quite simple if you don't use a recursive algorithm. – Micromega Mar 15 '11 at 12:43
  • Apparently I can't vote for you until I have 15 (what is it reputation?, XP? lol). I'll look more into the curves though. I was just hoping to use the code I had already :( – Downie Mar 15 '11 at 17:21
  • What I did is a kart-trie. It's a radix-trie or crit-bit trie. The decicision to split the node is based on the binary key at this position meaning if it is 1 then right node or if it is 0 then left node. I don't know how it is solve in an octree and also what I suggest to you might be even more complicated then you have asked for! – Micromega Mar 16 '11 at 12:18
  • I was reading about using keys for octrees the other day. I'm sure I can find someway round my issue. Even if I just have to traverse some of the nodes. Cheers for your help anyway - sorry I can't vote you up lol – Downie Mar 16 '11 at 13:45