com s 567 physically based animation..\01 intro\bridson_curtain.mov. bvh construction from [ericson...

32
COM S 567 Physically Based Animation Collision Detection (Blackboard Helper Slides) Doug James Cornell University Spring 2007

Upload: others

Post on 29-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

COM S 567 Physically Based Animation

Collision Detection (Blackboard Helper Slides)

Doug JamesCornell University

Spring 2007

Page 2: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Narrow Phase Tests

Page 3: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Convex Bounding Volumes

Page 4: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Intersect(sphere, polygon)

Page 5: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Robust Cloth [Bridson et al. 2002]

..\01 Intro\bridson_curtain.mov

Page 6: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split
Page 7: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split
Page 8: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

BVH Construction

From [Ericson 2005]

Page 9: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

AABB parent-child relationship

Page 10: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Top-down Construction

• Recursively split & bound geometric primitives

Use splitplane

Sort usingplane, w.r.t

triangle centroids

+Find minimal

boxes=

…and so on.From [Moller and Haines 2002]

Page 11: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Bottom-up construction

• Wrap all primitives– Tile geometry

[Quinlan 94]• Parent bounds can

enclose child bounds for fitting speed (layered hierarchy)

From [Quinlan 94]

Page 12: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

BVH-BVH Overlap Tests

• Also proximity (distance) queries

From [Ericson 2005]

Page 13: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Pseudocode: BVH vs BVH Test

Pseudocodedeals with 4 cases:

1) Leaf againstleaf node

2) Internal nodeagainst internal node

3) Internal against leaf4) Leaf against internal

From [Moller and Haines 2002]

NOTE: Should test for overlap here.

Page 14: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Comments on pseudocode

• The code terminated when it found the first triangle pair that collided

• Simple to modify code to continuetraversal and put each pair in a list

• Reasonably simple to include rotations for objects as well

• Note that if we use AABB for both BVHs, then the AABB-AABB test becomes a AABB-OBB test

From [Moller and Haines 2002]

Page 15: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Tradeoffs• The choice of BV

– AABB, OBB, k-DOP, sphere• In general, the tighter BV, the slower test

Less tight BV, gives more triangle-triangle tests in the end (if needed)Cost function:

From [Moller and Haines 2002]

Page 16: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

BVH-BVH Collision Front Tracking

• [Klosowski 1998; Li and Chen 1998]

Page 17: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Other issues

• Time-critical tests• Space-time bounds• Good reference: Phillip Hubbard’s thesis

– P. M. Hubbard. Approximating polyhedra with spheres for time-critical collision detection. ACM Transactions on Graphics, 15(3):179–210, July 1996.

Page 18: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Refitting after deformation

From [van den Bergen 1998]

Page 19: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Broad Phase Tests

Page 20: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Spatial Subdivisions: Uniform Grids

Page 21: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Hierarchical Grids [Brian Mirtich]

Page 22: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Hierarchical Grids [Brian Mirtich]

Page 23: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Octrees (and Quadtrees)

Page 24: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Linear Octrees

• Sparse representation• Avoid pointer storage• Use Morton index

Page 25: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Many other spatial partitions…

• Kd-trees

• Hybrids

Page 26: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split
Page 27: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

CD betweenmany objects

• Why needed?• Consider several hundreds of rocks tumbling

down a slope…• This system is often called ”First-Level CD”• We execute this system because we want to

execute the 2nd system less frequently• Assume high frame-to-frame coherency

– Means that object is close to where it was previousframe

– Reasonable

From [Moller and Haines 2002]

Page 28: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Sweep-and-prune algorithm[by Ming Lin]

• Assume objects may translate and rotate• Then we can find a minimal cube, which is

guaranteed to contain object for all rotations

• Do collision overlap three times– One for x,y, and z-axes

• Let’s concentrate on one axis at a time• Each cube on this axis is an interval, from

si to ei, where i is cube numberFrom [Moller and Haines 2002]

Page 29: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Sweep-and-prune algorithm

• Sort all si and ei into a list• Traverse list from start to end• When an s is encounted, mark

corresponding interval as active in an active_interval_list

• When an e is encountered, delete the interval in active_interval_list

• All intervals in active_interval_ list are overlapping!

From [Moller and Haines 2002]

Page 30: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Sweep-and-prune algorithm

• Keep a boolean for each pair of intervals• Invert when sort order changes• If all boolean for all three axes are true,

overlapFrom [Moller and Haines 2002]

Page 31: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Sweep-and-prune algorithm

• Now sorting is expensive: O(n*log n)• But, exploit frame-to-frame coherency!• The list is not expected to change much• Therefore, ”resort” with bubble-sort, or

insertion-sort• Expected: O(n)

From [Moller and Haines 2002]

Page 32: COM S 567 Physically Based Animation..\01 Intro\bridson_curtain.mov. BVH Construction From [Ericson 2005] AABB parent-child relationship. Top-down Construction • Recursively split

Failure Mode