Collision Detection CSCE 441. 2/60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.

Slides:



Advertisements
Similar presentations
Everything you ever wanted to know about collision detection
Advertisements

2.5. B ASIC P RIMITIVE I NTERSECTION Details of common forms of primitive intersection test.
Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
CSE 681 Bounding Volumes. CSE 681 Bounding Volumes Use simple volume enclose object(s) tradeoff for rays where there is extra intersection test for object.
2.3. B OUNDING V OLUMES Bounding volumes of use for collision detection.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
Collision Detection and Resolution Zhi Yuan Course: Introduction to Game Development 11/28/
Computer graphics & visualization Collisions. computer graphics & visualization Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization.
Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.
Ray Tracing CMSC 635. Basic idea How many intersections?  Pixels  ~10 3 to ~10 7  Rays per Pixel  1 to ~10  Primitives  ~10 to ~10 7  Every ray.
Here is where my object is Here is where my object is going to be Here is where I want my object to be.
고려대학교 그래픽스 연구실 Chapter 6 Collision Detection 6.1~6.4 고려대학교 그래픽스연구실 민성환.
Computational Geometry & Collision detection
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Basic 3D collision detection We want to know if objects have touched Objects are considered to.
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Continuous Collision Detection David Knott COMP 259 class presentation.
OBBTree: A Hierarchical Structure for Rapid Interference Detection Gottschalk, M. C. Lin and D. ManochaM. C. LinD. Manocha Department of Computer Science,
Apex Point Map for Constant-Time Bounding Plane Approximation Samuli Laine Tero Karras NVIDIA.
1 Advanced Scene Management System. 2 A tree-based or graph-based representation is good for 3D data management A tree-based or graph-based representation.
Collision Detection CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.
Collision Detection David Johnson Cs6360 – Virtual Reality.
10/02/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Octrees.
Computer graphics & visualization Collision Detection – Narrow Phase.
11/25/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Managing large numbers of objects Colliding spheres with things (spheres being common.
Week 13 - Wednesday CS361.
12/4/2001CS 638, Fall 2001 Today Using separating planes/axes for collision testing Collision detection packages.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Spatial Data Structures Jason Goffeney, 4/26/2006 from Real Time Rendering.
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
1 Speeding Up Ray Tracing Images from Virtual Light Field Project ©Slides Anthony Steed 1999 & Mel Slater 2004.
CSE 381 – Advanced Game Programming Quickhull and GJK.
Collision handling: detection and response
CS 325 Introduction to Computer Graphics 04 / 26 / 2010 Instructor: Michael Eckmann.
Week 13 - Friday.  What did we talk about last time?  Ray/sphere intersection  Ray/box intersection  Slabs method  Line segment/box overlap test.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
Collision/Acceleration University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
12/4/2001CS 638, Fall 2001 Today Managing large numbers of objects Some special cases.
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
Collaborative Visual Computing Lab Department of Computer Science University of Cape Town Graphics Topics in VR By Shaun Nirenstein.
1 KIPA Game Engine Seminars Jonathan Blow Ajou University December 6, 2002 Day 10.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
3D Game Engine Design 1 3D Game Engine Design Ch D MAP LAB.
Computing Inner and Outer Shape Approximations Joseph S.B. Mitchell Stony Brook University.
Comparison of Collision Detection Algorithms Tony Young M.Math Candidate July 19th, 2004.
Chapter 11 Collision Detection 가상현실 입문 그래픽스 연구실 민성환.
11/20/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Collision Detection Overview Player-Environment handling.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Advanced Computer Graphics Spring 2009
Presented by Paul Phipps
Ray Tracing Optimizations
David Luebke 3/5/2016 Advanced Computer Graphics Lecture 4: Faster Ray Tracing David Luebke
Week 13 - Wednesday CS361.
Bounding Volume Hierarchies and Spatial Partitioning
Advanced Computer Graphics Spring 2016
Collision Detection Spring 2004.
Bounding Volume Hierarchies and Spatial Partitioning
Parts of these slides are based on
2.5. Basic Primitive Intersection
CS679 - Fall Copyright Univ. of Wisconsin
Computer Animation Algorithms and Techniques
Collision Detection.
David Johnson Cs6360 – Virtual Reality
GPAT – Chapter 7 Physics.
Presentation transcript:

Collision Detection CSCE 441

2/60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of the objects is a set of triangles.  Rays/lines  Planes  Polygons  Frustums  Spheres  Curved surfaces

3/60 When Used  Often in simulations  Objects move – find when they hit something else  Other examples  Ray tracing speedup  Culling objects/classifying objects in regions  Usually, needs to be fast  Applied to lots of objects, often in real-time applications

4/60 Bounding Volumes  Key idea:  Surround the object with a (simpler) bounding object (the bounding volume).  If something does not collide with the bounding volume, it does not collide with the object inside.  Often, to intersect two objects, first intersect their bounding volumes

5/60 Choosing a Bounding Volume  Lots of choices, each with tradeoffs

6/60 Choosing a Bounding Volume  Lots of choices, each with tradeoffs  Tighter fitting is better  More likely to eliminate “false” intersections

7/60 Choosing a Bounding Volume  Lots of choices, each with tradeoffs  Tighter fitting is better  Simpler shape is better  Makes it faster to compute with

8/60 Choosing a Bounding Volume  Lots of choices, each with tradeoffs  Tighter fitting is better  Simpler shape is better  Rotation Invariant is better  Easier to update as object moves

9/60 Choosing a Bounding Volume  Lots of choices, each with tradeoffs  Tighter fitting is better  Simpler shape is better  Rotation Invariant is better  Convex is usually better  Gives simpler shape, easier computation

10/60 Common Bounding Volumes: Sphere  Rotationally invariant  Usually  Usually fast to compute with  Store: center point and radius  Center point: object’s center of mass  Radius: distance of farthest point on object from center of mass.  Often not very tight fit

11/60 Common Bounding Volumes: Axis Aligned Bounding Box (AABB)  Very fast to compute with  Store: max and min along x,y,z axes.  Look at all points and record max, min  Moderately tight fit  Must update after rotation, unless a loose box that encompasses the bounding sphere

12/60 Common Bounding Volumes: k-dops  k-discrete oriented polytopes  Same idea as AABBs, but use more axes.  Store: max and min along fixed set of axes.  Need to project points onto other axes.  Tighter fit than AABB, but also a bit more work.

13/60 Choosing axes for k-dops  Common axes: consider axes coming out from center of a cube:  Through faces: 6-dop  same as AABB  Faces and vertices: 14-dop  Faces and edge centers: 18-dop  Faces, vertices, and edge centers; 26- dop  More than that not really helpful  Empirical results show 14 or 18-dop performs best.

14/60 Common Bounding Volumes: Oriented Bounding Box (OBB)  Store rectangular parallelepiped oriented to best fit the object  Store:  Center  Orthonormal set of axes  Extent along each axis  Tight fit, but takes work to get good initial fit  OBB rotates with object, therefore only rotation of axes is needed for update  Computation is slower than for AABBs, but not as bad as it might seem

15/60 Common Bounding Volumes: Convex Hull  Very tight fit (tightest convex bounding volume)  Slow to compute with  Store: set of polygons forming convex hull  Can rotate CH along with object.  Can be efficient for some applications

16/60 Testing for Collision  Will depend on type of objects and bounding volumes.  Specialized algorithms for each:  Sphere/sphere  AABB/AABB  OBB/OBB  Ray/sphere  Triangle/Triangle

17/60 Collision Test Example Sphere-Sphere  Find distance between centers of spheres  Compare to sum of sphere radii  If distance is less, they collide  For efficiency, check squared distance vs. square of sum of radii d r2r2 r1r1

18/60 Collision Test Example AABB vs. AABB  Project AABBs onto axes  i.e. look at extents  If overlapping on all axes, the boxes overlap.  Same idea for k-dops.

19/60 Collision Test Example OBB vs. OBB  How do we determine if two oriented bounding boxes overlap?

20/60 Separating Axis Theorem  Two convex shapes do not overlap if and only if there exists an axis such that the projections of the two shapes do not overlap

21/60 Enumerating Separating Axes  2D: check axis aligned with normal of each face  3D: check axis aligned with normals of each face and cross product of each pair of edges

22/60 Enumerating Separating Axes  2D: check axis aligned with normal of each face  3D: check axis aligned with normals of each face and cross product of each pair of edges

23/60 Enumerating Separating Axes  2D: check axis aligned with normal of each face  3D: check axis aligned with normals of each face and cross product of each pair of edges

24/60 Enumerating Separating Axes  2D: check axis aligned with normal of each face  3D: check axis aligned with normals of each face and cross product of each pair of edges

25/60 Enumerating Separating Axes  2D: check axis aligned with normal of each face  3D: check axis aligned with normals of each face and cross product of each pair of edges

26/60 Collision Test Example Triangle-Triangle  Many collision detection tests eventually reduce to this.  Two common approaches. Both involve finding the plane a triangle lies in.  Cross product of edges to get triangle normal.  This is the plane normal [A B C] where plane is Ax+By+Cz+D=0  Solve for D by plugging in a triangle vertex

27/60 Triangle-Triangle Collision 1  Find line of intersection between triangle planes.  Find extents of triangles along this line  If extents overlap, triangles intersect.

28/60 Triangle-Triangle Collision 2  Intersect edges of one triangle with plane of the other triangle.  2 edges will intersect – form line segment in plane.  Test that 2D line segment against triangle.

29/60 Bounding Volume Hierarchies  What happens when the bounding volumes do intersect?  We must test whether the actual objects underneath intersect.  For an object made from lots of polygons, this is complicated.  So, we will use a bounding volume hierarchy

30/60 Bounding Volume Hierarchies  Highest level of hierarchy – single BV around whole object  Next level – subdivide the object into two (or maybe more) parts.  Each part gets its own BV  Continue recursively until only one triangle remains

31/60 Bounding Volume Hierarchy Example

32/60 Bounding Volume Hierarchy Example

33/60 Bounding Volume Hierarchy Example

34/60 Bounding Volume Hierarchy Example

35/60 Bounding Volume Hierarchy Example

36/60 Bounding Volume Hierarchy Example

37/60 Bounding Volume Hierarchy Example

38/60 Bounding Volume Hierarchy Example

39/60 Bounding Volume Hierarchy Example

40/60 Bounding Volume Hierarchy Example

41/60 Bounding Volume Hierarchy Example

42/60 Bounding Volume Hierarchy Example

43/60 Intersecting Bounding Volume Hierarcies  For object-object collision detection  Keep a queue of potentially intersecting BVs  Initialize with main BV for each object  Repeatedly pull next potential pair off queue and test for intersection.  If that pair intersects, put pairs of children into queue.  If no child for both BVs, test triangles inside  Stop when we either run out of pairs (thus no intersection) or we find an intersecting pair of triangles

44/60 BVH Collision Test example

45/60 BVH Collision Test example

46/60 BVH Collision Test example

47/60 BVH Collision Test example

48/60 BVH Collision Test example

49/60 BVH Collision Test example

50/60 BVH Collision Test example

51/60 BVH Collision Test example

52/60 BVH Collision Test example

53/60 BVH Collision Test example

54/60 BVH Collision Test example

55/60 BVH Collision Test example

56/60 Broad Phase vs. Narrow Phase  What we have talked about so far is the “narrow phase” of collision detection.  Testing whether two particular objects collide  The “broad phase” assumes we have a number of objects, and we want to find out all pairs that collide.  Testing every pair is inefficient

57/60 Broad Phase Collision Detection  Form an AABB for each object  Pick an axis  Sort objects along that axis  Find overlapping pairs along that axis  For overlapping pairs, check along other axes.  Limits the number of object/object tests  Overlapping pairs then sent to narrow phase

Broad Phase Collision Detection 58/60

59/60 Collision Detection in a Physically- Based Simulation  Must account for object motion  Obeys basic physical laws – integration of differential equations  Collision detection: yes/no  Collision determination: where do they intersect  Collision response: how do we adjust the motion of objects in response to collision  Collision determination/response are more difficult, but are key for physically based simulation.

60/60 Some Other Issues  Constructing an optimal BVH  Convergence of BVH (i.e. how fast do the BVs approach the actual object).  OBBs asymptotically better, here  Optimizing individual tests  Handling stacking and rest contacts