Spatial Data Structures What is it? Data structures that organize - - PowerPoint PPT Presentation

spatial data structures what is it
SMART_READER_LITE
LIVE PREVIEW

Spatial Data Structures What is it? Data structures that organize - - PowerPoint PPT Presentation

Spatial Data Structures What is it? Data structures that organize geometry in 2D,3D or higher dimensions or higher dimensions Used for every search related problem Very important mathematical tool in CG: Ray tracing/Photon mapping ay t ac g/


slide-1
SLIDE 1

Spatial Data Structures

slide-2
SLIDE 2

What is it?

Data structures that organize geometry in 2D,3D

  • r higher dimensions
  • r higher dimensions

Used for every search related problem Very important mathematical tool in CG: Ray tracing/Photon mapping ay t ac g/

  • to

app g Collision/Intersection C lli Culling Data compression p Level of detail

Goal is faster processing and searching

2

Goal is faster processing and searching

slide-3
SLIDE 3

How

Organize geometry in a hierarchy

Data structure In 2D space Data structure

3

slide-4
SLIDE 4

Example

Assume we click on screen, and want to find which object we clicked on which object we clicked on

Data structure

click 1) Test the root first 2) Descend recursively as needed 3) Terminate traversal when possible

4

In general: get O(log n) instead of O(n)

slide-5
SLIDE 5

Grid

Most simple data structure Regular subdivision Regular subdivision

Directly addressable cells Simple neighborhood finding in O(1)

Problem: Problem:

Too few/many cells Hi hi l id

  • Hierarchical grid

Good for uniformly distributed problems

5

distributed problems

slide-6
SLIDE 6

Bounding Volume Hierarchy (BVH)

Most used structure in real-time graphics Most common bounding volumes (BVs): g ( )

Sphere Boxes (AABB) ( )

BVs give information about maximum extend

  • f an object

j

Encloses complete object

Data structure is a k-ary tree Data structure is a k ary tree

Leaves hold geometry Internal nodes have at most k Internal nodes have at most k children Internal nodes hold BVs that

6

enclose all geometry in its subtree

slide-7
SLIDE 7

How to create a BVH

Find minimal box, then split along longest axis

x is longest Find minimal boxes Split along longest axis Find minimal boxes Called TOP-DOWN method More complex for other BVs

7

slide-8
SLIDE 8

Stopping Criteria for BVH

We need to stop recursion when:

BV is empty BV is empty Only one primitive (e.g. Triangle, object) is inside B di V l Bounding Volume <n primitives is inside BV Recursion level l has been reached

Similar critera for other BSP trees

8

slide-9
SLIDE 9

Octree (3D) Quadtree (2D)

Split at half the length axis aligned p g g

Always 4 children

In 3D each square becomes a box with

9

In 3D each square becomes a box with 8 children

slide-10
SLIDE 10

Octree (3D) Quadtree (2D)

Expensive to rebuild (all BSPs are) Easy to implement Easy to implement

No geometry analysis needed Just test if something is in leaf

Used to speed up Used to speed up

Culling, Raytracing,Picking

L t Loose octree:

Each octant child of the octree actually overlaps it's siblings by a factor of 0.5 Guarantees that any thing that is half the size of

10

y g the parent will fit completely into a child

slide-11
SLIDE 11

Octree (3D) Quadtree (2D)

11

slide-12
SLIDE 12

Kd-tree

Split along axis alinged planes/lines which results in minimum search time in minimum search time

Minimal box Split along plane Split along Split along plane plane

12

slide-13
SLIDE 13

Kd-tree

B D E

P P Plane 1a Plane 1b Plane 2

1a 1b A C

Plane 0 Plane 1a

A B C 2 D E A C D E

Each internal node holds a divider plane Leafs hold geometry Leafs hold geometry Problem: splitting criteria is complicated

Surface area heuristic (SAH) is best

13

Surface area heuristic (SAH) is best

slide-14
SLIDE 14

Kd-tree

14

slide-15
SLIDE 15

General BSP-Tree

Same as kd-tree but without axis aligned splitting splitting

Splitting criteria is even harder for general generation generation Intersection calculations more expensive th kd t than kd-tree

Usually used on a per triangle/quad splitting y g g basis

Good for per triangle or Good for per triangle or quad collision detection

15

detection

slide-16
SLIDE 16

Scenegraphs

BVH is used most often in real-time graphics

Simple to understand Simple to understand Easy to implement

But contains only geometric objects Scenegraph is and extended BVH with: Scenegraph is and extended BVH with:

Lights T f Transforms Textures …

16