290 likes | 316 Views
Collision Detection and Acceleration. Rama Hoetzlein, 2008 Lecture Notes Cornell University. What is Collision Detection?. What if we have lots of objects?. What are some solutions?. 1. Spatial partitioning. Spatial partitioning. Cells. A. B. C. D. 1.
E N D
Collision Detection and Acceleration Rama Hoetzlein, 2008Lecture NotesCornell University
What if we have lots of objects? What are some solutions?
Spatial partitioning Cells A B C D 1 • Each grid cell can contain multiple objects- How do we map position to cell number? 2 E F 3 .. n
2. Octree partitioning - Insertion and retrieval are O( log n )- What are some limitations?
Bounding Volumes – 3D Sphere OBB AABB • Bounding Volume (BV) – a volume that encloses a set of objects • The idea is to use a much similar geometric shape for quick tests (frustum culling for example) • Easy to compute, as tight as possible • AABB, Sphere – easy to compute, but poor fit
Conservative Bounds • tight → avoid false positives • fast to intersect axis-aligned bounding box(AABB) non-aligned oriented bounding box (OBB) bounding sphere arbitrary convex region (bounding half-spaces)
AABB Ray Intersection • Many acceleration structures can be used for both collision detection & raytracing • For all 3 axes, calculate the intersection distances t1 and t2 • tnear= max (t1x, t1y, t1z)tfar= min (t2x, t2y, t2z) • If tnear> tfar, box is missed • If tfar< tnclip, box is behind • If box survived tests, report intersection at tnear t2x tfar y=Y2 t2y tnear t1x y=Y1 t1y x=X2 x=X1
Bounding Volume Hierarchies • Use hierarchicy of scene to create a tree of bounding volumes.- Volumes can overlap Parent volume Child volume
4. Binary Space Partition (BSP-Tree) • Main purpose – depth sorting • Consisting of a dividing plane, and a BSP tree on each side of the dividing plane (note the recursive definition) • The back to front traversal order can be decided right away according to where the eye is
Binary Space Partition... cont’d. • Two possible implementations: Axis-Aligned BSP Polygon-Aligned BSP Divide space along world axis. Divide space along scene planes. Intersecting?
0 1a 1b B A C 2 D E BSP Trees - Axis-Aligned (k-d tree) • Starting with an AABB • Recursively subdivide into small boxes • One possible strategy: cycle through the axes (also called k-d trees) D E B 2 1b 1a A C 0 Q: Objects intersect the boundaries?
BSP Trees - Polygon-Aligned - Recursively divide space along polygons in the scene- Each leaf is a convex, enclosed space- Fast traversal, but slow to create.. So, create only once.
BSP Trees - Polygon-Aligned • Combined with raycasting- First real-time 3D first person No slanted walls = 2D BSP
5. Axis-Aligned Sorting What is the total run time?
Narrow phase Example from Computer Games... What is broad phase here?What is narrow phase?
Narrow Phase: Polyhedral mesh intersection (3D) • Hard problem - Near constant time methods exist. • What is the result? Simplify. Don’t need full intersections.
Narrow Phase: Cell occupancy Special case: Objects exactly fill a grid cell..
Applications of Mesh Intersections: 1. Raytracing - Ray-mesh intersection 2. Machine industry - CSG, Computational Solid Geometry Tool part subtracts from solid part 3. Boolean Shapes - Modeling by add / subtract / intersect 4. Games - Real-time rigid body collisions 5. Medical - When does instrument (scalpel, etc.) intersect with body anatomy.