Top Banner
2.6. BOUNDING VOLUME HIERARCHIES Overview of different forms of bounding volume hierarchy
22

2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Mar 28, 2015

Download

Documents

Tristan Akin
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

2.6. BOUNDING VOLUME HIERARCHIES

Overview of different forms of bounding volume hierarchy

Page 2: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

BOUNDING VOLUME HIERARCHIESExploration of different types of bounding volume hierarchy

Page 3: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Bounding Volume HierarchiesGiven a total of n objects, a simple brute force approach towards producing a list of intersecting objects is to consider all object pairings (i.e. n2/2 comparisons).

Assuming each object can be described in terms of one of more bounding volumes, by arranging the object’s bounding volumes into a tree-based hierarchy (known as a bounding volume hierarchy), a logarithmic order time complexity can be obtained.

Page 4: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

BVH Design Issues: Desirable Characteristics

Desirable characteristics of a game-oriented BVH are likely to include:

• The nodes contained in any given sub-tree should be spatially ‘close’ to each other.

• Each node in the hierarchy should be of minimal volume.

Aside: BVH differ from spatial partitioning schemes (explored next lecture) in that two BVH volumes can cover the same space and objects are typically only found in a single volume. Spatial partitioning schemes typically require non-overlapping regions but permit objects to be in two or more partitions.

• Pruning a node near the root of the tree should remove more objects from further consideration than removal of a deeper node.

• The volume of overlap between sibling nodes should be minimal.

• The hierarchy should be balanced with respect to both its node structure and its content.

• The worst-case time for queries should not be much worse than the average-case query time.

Page 5: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

BVH Building Strategies

As the number of possible BVH trees grows exponentially as the number of objects increase it is not possible to use an exhaustive (optimal) search. Instead, heuristic rules are used to direct the BVH construction (selecting the best option from a small number of hopefully near optimal options at each step).

There are three main categories of tree construction methods:

•top-down

•bottom-up

•insertion

Page 6: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

BVH Building Strategies

• Top-down: partitioning input set into two (or more) subsets, introduce bounds, and recursing over bounded subsets (typically does not produce best trees, but is easy to implement and hence popular).

• Bottom-up: start with leaves of the tree, group two (or more) to form a bounding node, progressively grouping bounded volumes until a single node is reached (typically produces best quality BVH, but more difficult to implement).

• Insertion: incrementally insert an object into the tree so as to minimize some insertion cost measurement

Top-down and bottom-up are off-line methods as they require all primitives to be available before construction starts. Insertion construction is considered on-line as it can be used at game run-time.

Page 7: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Forms of BVH Construction

Consult the recommended course text for full details of the following approaches:

•Top-down Construction•Bottom-up Construction•Incremental (Insertion) Construction

Top-down construction is explored next by way of an example.

Page 8: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

TOP-DOWN CONSTRUCTIONTop-down construction of a bounding volume hierarchy

Page 9: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Top-down Construction of a BVHThe process of top-down construction can be algorithmically described as:

void BuildTopDownBVH(BVHNode treeNode, ArrayList objects) { Node newNode = new Node(); treeNode.add(newNode);

newNode.BoundingVolume = ComputeBoundingVolume(objects);

if( objects.Count <= MIN_OBJECTS_PER_LEAF ) { newNode.Type = LEAF; newNode. Objects = objects; } else { newNode.Type = NODE; int splitIdx = RearrangeAndPartitionObjects(objects);

BuildTopDownBVH( newNode.LeftTree, objects.Subset(0,splitIdx)); BuildTopDownBVH( newNode.RightTree, objects.Subset(splitIdx,objects.Count); }}

Create an empty node and add to the treeBuild a suitable bounding volume around the specified object list

If needed, simply store the object list within this node

Sort and split the objects into two partitions

Recursively build the BVH along the defined left and right sub-trees

Page 10: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Top-down partitioning strategyOther than selecting which bounding volume to use, the top-down strategy need only define how an input set of objects can be partitioned into two subsets.

Typically the input set is divided using a splitting hyperplane.

Any primitives intersected by the splitting plane are commonly assigned to the subset within which its centroid belongs, alongside extending subset bounding volume by half the width of the primitive (thereby fully enclosing the primitive and minimising overlap between sibling bounding volumes).

Page 11: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Top-down partitioning strategy

A number of different partitioning strategies might be adopted (depending upon the performance/memory needs, etc. of the application), including:

• Minimize the sum of the volumes (or surface areas) of the child volumes.

• Minimize the volume (surface area) of the intersection of the child volumes.

• Maximize the separation of child volumes.

• Divide primitives equally between the child volumes (known as a median-cut algorithm, and tends to produced balanced trees)

• Combinations of above strategies.

Assuming spherical bounding volumesMinimal child volume, but high overlap volume

Larger child volume, but smaller overlap volume

Page 12: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Top-down partitioning: Halting recursion

The recursive partitioning stops (thereby forming a leaf node) when some termination condition is reached. This can include:

• The node contains less than some k primitives.

• The volume of the bounding volume falls below a cut-off limit.

• The depth of the node has reached a predefined cut-off depth.

Partitioning might also fail because:

• All primitives fall on one side of the split plane.

• One or both child volumes end up with as many (or nearly as many) primitives as the parent volume.

• Both child volumes are (almost) as large as the parent volume.

In these cases, it is reasonable to try other partitioning criteria before terminating the recursion.

Page 13: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Top-down partitioning: Choice of axis

The choice of which separating axis to use is often restricted to the following:

• Local x, y, and z coordinate axes (easy to use, also form orthogonal set, i.e. good coverage).

• Axes from some aligned bounding volume (e.g. from a reference k-DOP).

• Axes of the parent bounding volume

• Axis along which variance is greatest (using the dimension with largest spread serves to minimise the size of the child volumes).

Page 14: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Top-down partitioning: Choice of split pointThe choice of which split point to use is (also) often restricted to the following:

(a) Splits at object median, (b) splits at object mean, (c) splits at spatial median

• Object median: splitting at the middle object (thereby evenly distributing the primitives and providing a balanced tree).

• Object mean: splitting at the mean object offset (e.g. along the axis with greatest variance).

• Bounding volume median: splitting at the middle of the bounding volume (thereby splitting into two equal parts).

Page 15: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

HIERARCHY TRAVERSALApproaches to traversing bounding volumes hierarchies

Page 16: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Hierarchy Traversal

Given two BVHs a descent rule is used to determine overlap status when the top-level volumes overlap.

Approaches include breadth-first (BFS) and depth-first (DFS) searches. BFS explores all nodes at a given depth before descending. DFS descends down into the tree, backtracking up once a leaf is hit.

A decent method is blind (or uninformed) if it only uses the tree structure to select the next node. Informed methods examine node data (e.g. using heuristics) to select the next node (e.g. a best-first search maintains a list of best-scoring moves).

For collision detection systems, DFS (possibly a simple heuristic – i.e. basically a best-first approach) is typically favoured over BFS.

Page 17: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Descent RulesGiven two BVHs the following descent strategies

might be adopted:

1.Descend A before B (or vice versa). Fully descend into the leaves of A before starting to descend into B. This will be very expensive if B’s root bound fully contains A and/or if A contains lots of nodes.

2.Descend the larger volume. Dynamically determine which BVH node is currently larger and descend into (avoiding the problems of Approach 1).

Which type of

traversal is most

effective depends

entirely on the

structure of the

data, as indicated

by the refinery

example.

3.Descend A and B simultaneously. Similar to Approach 2 but without any cost evaluation overhead (but it may not prune space as efficiently).

4.Descend based on overlap. Similar to Approach 2, priortise descent on degree of overlap between BVH regions.

Page 18: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Generic Informed Depth-first traversalAn example informed depth-first traversal algorithm is:

void BVHInformedDFS(CollisionResult r, BVHNode a, BVHNode b){ if (!BVOverlap(a, b)) return;

if (IsLeaf(a) && IsLeaf(b)) { CollidePrimitives(r, a, b); } else { if (DescendA(a, b)) { BVHInformedDFS (r, a->left, b); BVHInformedDFS (r, a->right, b); } else { BVHInformedDFS (r, a, b->left); BVHInformedDFS (r, ,a, b->right); } }}

CollisionResult is assumed to store relevant collision detection/contact information

If the bounding volumes do not overlap then simply return

If two leaf nodes are found, then perform collision detection on the primitives

Descent rule to determine which BVH to follow

bool DescendA(BVHNode a, BVHNode b){ return IsLeaf(b) || (!IsLeaf(a) && (SizeOfBV(a) >= SizeOfBV(b)));}

Descend into the larger volume

Page 19: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Descent RulesSee the source text book for:

• A non-recursive, faster, implementation of the generic informed depth-first traversal

• Simultaneous depth-first traversal algorithm

• Optimised leaf-directed depth-first traversal

Page 20: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

DIRECTED READINGDirected mathematical reading

Directed

reading

Page 21: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Directed reading Directed

reading• Read Chapter 6 of Real

Time Collision Detection (pp235-284)

• Related papers can be found from:

http://realtimecollisiondetection.net/books/rtcd/references/

Page 22: 2.6. B OUNDING V OLUME H IERARCHIES Overview of different forms of bounding volume hierarchy.

Summary

To do:Read the directed

material

After reading the

directed material, have

a ponder if this is the

type of material you

would like to explore

within a project.

Today we explored:

Bounding volume hierarchies

Overview of top-down construction approaches