polygons in octree

Started by
1 comment, last by __fold 18 years, 10 months ago
Hello, I am creating a ray tracer. I want to use an octree to store the polygons of an object. I have some questions about building it and using it. 1 Build: the maximum polygons in an octree node is defined to 50. If there are more than 50 polygons in an octreenode: - I create his 8 children. - I test each polygon against the 8 new children (the same polygon can be in more than one child). - If the polygon is in one child, i add it to this child. - If all polygons are tested and inserted in the proper child or children, then the parentnode holds no polygons anymore. 2 Using it: - I shoot a ray. - if i hit an octreenode and it is not a leaf, then i check which children i hit. - I go on only with the children that i have hit. - If i hit a leaf, then i test which face is hit. Is this good thinking about using an octree for ray tracing? greetins takis
Advertisement
Yes that sounds pretty reasonable - I would suggest that you thoroughly test your intersection routines though, they can easily break your octree. One other point is that you may want to stop the octree recursion once a certain depth has been reached. Best of Luck!
Quote:Original post by moagstar
I would suggest that you thoroughly test your intersection routines though, they can easily break your octree.


I had this problem when I used an octree for collsion determination between objects at triangle-level. I used Möllers code for intersection between a triangle and a box and for some rare cases the triangles slipped inbetween the nodes. I solved it by increasing some of the epsilon values. It resulted in that some triangles were added to nodes that they didn't intersect but is not really an issue.

Also be careful when you create the octree and make sure that all the nodes really spans the space you intended it to span. This may seem to be obvious but here is where your knowledge about floating point math comes in. :)

This topic is closed to new replies.

Advertisement