spatial data structures
play

Spatial Data Structures Hierarchical Bounding Volumes Hierarchical - PowerPoint PPT Presentation

Spatial Data Structures Hierarchical Bounding Volumes Hierarchical Bounding Volumes Grids Grids Octrees Octrees BSP Trees BSP Trees 11/7/02 Thursday, April 1, 2010 Speeding Up Computations Ray Tracing Spend a lot of time doing


  1. Spatial Data Structures Hierarchical Bounding Volumes Hierarchical Bounding Volumes Grids Grids Octrees Octrees BSP Trees BSP Trees 11/7/02 Thursday, April 1, 2010

  2. Speeding Up Computations • Ray Tracing – Spend a lot of time doing ray object intersection tests • Hidden Surface Removal – painters algorithm – Sorting polygons front to back • Collision between objects – Quickly determine if two objects collide Spatial data-structures n 2 computations 3 Thursday, April 1, 2010

  3. Speeding Up Computations • Ray Tracing – Spend a lot of time doing ray object intersection tests • Hidden Surface Removal – painters algorithm – Sorting polygons front to back • Collision between objects – Quickly determine if two objects collide Spatial data-structures n 2 computations 3 Thursday, April 1, 2010

  4. Speeding Up Computations • Ray Tracing – Spend a lot of time doing ray object intersection tests • Hidden Surface Removal – painters algorithm – Sorting polygons front to back • Collision between objects – Quickly determine if two objects collide Spatial data-structures n 2 computations 3 Thursday, April 1, 2010

  5. Speeding Up Computations • Ray Tracing – Spend a lot of time doing ray object intersection tests • Hidden Surface Removal – painters algorithm – Sorting polygons front to back • Collision between objects – Quickly determine if two objects collide Spatial data-structures n 2 computations 3 Thursday, April 1, 2010

  6. Speeding Up Computations • Ray Tracing – Spend a lot of time doing ray object intersection tests • Hidden Surface Removal – painters algorithm – Sorting polygons front to back • Collision between objects – Quickly determine if two objects collide Spatial data-structures n 2 computations 3 Thursday, April 1, 2010

  7. Spatial Data Structures • We’ll look at – Hierarchical bounding volumes – Grids – Octrees – K-d trees and BSP trees • Good data structures can give speed up ray tracing by 10x or 100x 4 Thursday, April 1, 2010

  8. Bounding Volumes • Wrap things that are hard to check for intersection in things that are easy to check – Example: wrap a complicated polygonal mesh in a box – Ray can’t hit the real object unless it hits the box – Adds some overhead, but generally pays for itself. • Most common bounding volume types: sphere and box – box can be axis-aligned or not • You want a snug fit! • But you don’t want expensive intersection tests! Bad! Good! 5 Thursday, April 1, 2010

  9. Bounding Volumes • Wrap things that are hard to check for intersection in things that are easy to check – Example: wrap a complicated polygonal mesh in a box – Ray can’t hit the real object unless it hits the box – Adds some overhead, but generally pays for itself. • Most common bounding volume types: sphere and box – box can be axis-aligned or not • You want a snug fit! • But you don’t want expensive intersection tests! Bad! Good! 5 Thursday, April 1, 2010

  10. Bounding Volumes • Wrap things that are hard to check for intersection in things that are easy to check – Example: wrap a complicated polygonal mesh in a box – Ray can’t hit the real object unless it hits the box – Adds some overhead, but generally pays for itself. • Most common bounding volume types: sphere and box – box can be axis-aligned or not • You want a snug fit! • But you don’t want expensive intersection tests! Bad! Good! 5 Thursday, April 1, 2010

  11. Bounding Volumes • You want a snug fit! • But you don’t want expensive intersection tests! • Use the ratio of the object volume to the enclosed volume as a measure of fit. • Cost = n*B + m*I n - is the number of rays tested against the bounding volume B - is the cost of each test (Do not need to compute exact intersection!) m - is the number of rays which actually hit the bounding volume I - is the cost of intersecting the object within 6 Thursday, April 1, 2010

  12. Bounding Volumes • You want a snug fit! • But you don’t want expensive intersection tests! • Use the ratio of the object volume to the enclosed volume as a measure of fit. • Cost = n*B + m*I n - is the number of rays tested against the bounding volume B - is the cost of each test (Do not need to compute exact intersection!) m - is the number of rays which actually hit the bounding volume I - is the cost of intersecting the object within 7 Thursday, April 1, 2010

  13. Hierarchical Bounding Volumes • Still need to check ray against every object --- O(n) • Use tree data structure – Larger bounding volumes contain smaller ones 8 Thursday, April 1, 2010

  14. Hierarchical Bounding Volumes • Still need to check ray against every object --- O(n) • Use tree data structure – Larger bounding volumes contain smaller ones 9 Thursday, April 1, 2010

  15. Hierarchical Bounding Volumes • Still need to check ray against every object --- O(n) • Use tree data structure – Larger bounding volumes contain smaller ones 10 Thursday, April 1, 2010

  16. Hierarchical Bounding Volumes • Still need to check ray against every object --- O(n) • Use tree data structure – Larger bounding volumes contain smaller ones 11 Thursday, April 1, 2010

  17. Hierarchical Bounding Volumes • Still need to check ray against every object --- O(n) • Use tree data structure – Larger bounding volumes contain smaller ones Check intersect root If not return no intersections 12 Thursday, April 1, 2010

  18. Hierarchical Bounding Volumes • Still need to check ray against every object --- O(n) • Use tree data structure – Larger bounding volumes contain smaller ones Check intersect root If intersect check intersect left sub-tree check intersect right sub-tree 13 Thursday, April 1, 2010

  19. Hierarchical Bounding Volumes • Still need to check ray against every object --- O(n) • Use tree data structure – Larger bounding volumes contain smaller ones Check intersect root If intersect check intersect left sub-tree check intersect right sub-tree 14 Thursday, April 1, 2010

  20. Hierarchical Bounding Volumes • Still need to check ray against every object --- O(n) • Use tree data structure – Larger bounding volumes contain smaller ones Check intersect root If intersect check intersect left sub-tree check intersect right sub-tree 15 Thursday, April 1, 2010

  21. Hierarchical Bounding Volumes • Still need to check ray against every object --- O(n) • Use tree data structure – Larger bounding volumes contain smaller ones Check intersect root If intersect check intersect left sub-tree check intersect right sub-tree 16 Thursday, April 1, 2010

  22. Hierarchical Bounding Volumes • Many ways to build a tree for the hierarchy • Works well: – Binary – Roughly balanced – Boxes of sibling trees not overlap too much 17 Thursday, April 1, 2010

  23. Hierarchical Bounding Volumes • Sort the surfaces along the axis before dividing into two boxes • Carefully choose axis each time • Choose axis that minimizes sum of volumes 18 Thursday, April 1, 2010

  24. Hierarchical Bounding Volumes • Sort the surfaces along the axis before dividing into two boxes • Carefully choose axis each time • Choose axis that minimizes sum of volumes 19 Thursday, April 1, 2010

  25. Hierarchical Bounding Volumes • Works well if you use good (appropriate) bounding volumes and hierarchy • Should give O(log n) rather than O(n) complexity (n=# of objects) • Can have multiple classes of bounding volumes and pick the best for each enclosed object 20 Thursday, April 1, 2010

  26. Questions y 6 y 2 r 3 x 1 x 2 r 1 r 2 y 4 x 6 x 5 y 1 x 1 ,y 1 x 2 ,y 2 x 3 x 4 x 3 ,y 3 y 2 y 5 Given two bounding boxes at one level of the hierarchy, How about for how do you compute the bounding spheres? boxes for the next level? Thursday, April 1, 2010

  27. Tight Bounding Spheres Figure 3: The wrapped hierarchy (left) has smaller spheres than the layered hierarchy (right). The base geometry is shown in green, with five vertices. Notice that in a wrapped hierarchy the bounding sphere of a node at one level need not contain the spheres of its de- scendents and so can be significantly smaller. However, since each sphere contains all the points in the base geometry, it is sufficient for collision detection. Thursday, April 1, 2010

  28. Hierarchical bounding volumes Spatial Subdivision • Grids • Octrees • K-d trees and BSP trees 21 Thursday, April 1, 2010

  29. 3D Spatial Subdivision • Bounding volumes enclose the objects (object- centric) • Instead could divide up the space—the further an object is from the ray the less time we want to spend checking it – Grids – Octrees – K-d trees and BSP trees 22 Thursday, April 1, 2010

  30. Grids • Data structure: a 3-D array of cells (voxels) that tile space – Each cell points to list of all surfaces intersecting that cell • Intersection testing: – Start tracing at cell where ray begins – Step from cell to cell, searching for the first intersection point – At each cell, test for intersection with all surfaces pointed to by that cell – If there is an intersection, return the closest one 23 Thursday, April 1, 2010

  31. Grids • Cells are traversed in an incremental fashion • Hits of sets of parallel lines are very regular 24 Thursday, April 1, 2010

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend