Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.

Slides:



Advertisements
Similar presentations
2.4. Primitive Tests - Closest point
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 CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
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.
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.
CSE 381 – Advanced Game Programming Scene Management
Computational Geometry & Collision detection
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
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.
1 Terrain Following & Collision Detection. 2 Both of topics are very game-type-oriented Both of topics are very game-type-oriented Terrain Terrain For.
1Notes. 2Heightfields  Especially good for terrain - just need a 2d array of heights (maybe stored as an image)  Displacement map from a plane  Split.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Collision Detection Week.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1cs533d-winter-2005 Notes  More optional reading on web for collision detection.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
OBBTree: A Hierarchical Structure for Rapid Interference Detection Gottschalk, M. C. Lin and D. ManochaM. C. LinD. Manocha Department of Computer Science,
1cs533d-term Notes  list Even if you’re just auditing!
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 Michael Fuller. Overlap testing Most Common Technique Most Error Prone Test if two bodies overlap.
1Notes. 2 Time integration for particles  Back to the ODE problem, either  Accuracy, stability, and ease-of- implementation are main issues  Obviously.
Collision Detection David Johnson Cs6360 – Virtual Reality.
Computer graphics & visualization Collision Detection – Narrow Phase.
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.
COMP 175: Computer Graphics March 24, 2015
CSE 381 – Advanced Game Programming Quickhull and GJK.
Collision handling: detection and response
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.
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.
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.
Presented by Paul Phipps
Ray Tracing Optimizations
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Ray Tracing Acceleration (5). Ray Tracing Acceleration Techniques Too Slow! Uniform grids Spatial hierarchies K-D Octtree BSP Hierarchical grids Hierarchical.
A Fast Algorithm for Incremental Distance Calculation Ming C. Lin & John Canny University of California, Berkeley 1991 Presentation by Adit Koolwal.
Ray Tracing Acceleration (3)
Hierarchical Data Structure in Game Programming Yanci Zhang Game Programming Practice.
1 Geometry for Game. Geometry Geometry –Position / vertex normals / vertex colors / texture coordinates Topology Topology –Primitive »Lines / triangles.

Bounding Volume Hierarchies and Spatial Partitioning
Collision Detection Spring 2004.
Bounding Volume Hierarchies and Spatial Partitioning
Deformable Collision Detection
Parts of these slides are based on
Collision handling: detection and response
2.5. Basic Primitive Intersection
Collision Detection CSE169: Computer Animation
Computer Animation Algorithms and Techniques
Collision Detection.
Deformable Collision Detection
GPAT – Chapter 7 Physics.
Presentation transcript:

Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg

Collision Detection Geometric intersection detection Main subjects Intersection testing Optimization structures Pair reduction

Intersection Testing

General goals: given two objects with current and previous orientations specified, determine where and when the two objects will first intersect Alternative: given two objects with only current orientations, determine if they intersect Sometimes, we need to find all intersections. Other times, we just want the first one. Sometimes, we just need to know if the two objects intersect and don’t need the actual intersection data.

Triangle Normals n=(v 1 -v 0 )×(v 2 -v 0 ) Length of n is twice the area of the triangle (ABsinθ) v0v0 v1v1 v2v2 v 1 -v 0 v 2 -v 0 n

Segment vs. Triangle a b Does segment (ab) intersect triangle (v 0 v 1 v 2 ) ? First, compute signed distances of a and b to plane d a =(a-v 0 )·nd b =(b-v 0 )·n Reject if both are above or both are below triangle Otherwise, find intersection point x=(b*d a -a*d b )/(d a -d b ) x

Segment vs. Triangle Is point x inside the triangle? (x-v 0 )·((v 2 -v 0 )×n) > 0 Test all 3 edges x v0v0 v1v1 v2v2 v 2 -v 0 (v 2 -v 0 )×n x-v 0

Faster Way Reduce to 2D: remove smallest dimension Compute barycentric coordinates x' =x-v 0 e 1 =v 1 -v 0 e 2 =v 2 -v 0 α =(x'×e 2) /(e 1 ×e 2 ) β =(x'×e 1) /(e 1 ×e 2 ) Reject if α 1 x v0v0 v1v1 v2v2 α β

Segment vs. Mesh To test a line segment against a mesh of triangles, simply test the segment against each triangle Sometimes, we are interested in only the ‘first’ hit. Other times, we want all intersections. We will look at ways to optimize this later

Segment vs. Moving Mesh M 0 is the object’s matrix at time t 0 M 1 is the matrix at time t 1 Compute delta matrix: M 1 =M 0 ·M Δ M Δ = M 0 -1 ·M 1 Transform A by M Δ A'=A·M Δ Test segment A'B against object with matrix M 1

Triangle vs. Triangle Given two triangles: T 1 (u 0 u 1 u 2 ) and T 2 (v 0 v 1 v 2 ) u0u0 u2u2 u1u1 v0v0 v1v1 v2v2 T1T1 T2T2

Triangle vs. Triangle Step 1: Compute plane equations n 2 =(v 1 -v 0 )×(v 2 -v 0 ) d 2 =-n 2 ·v 0 v0v0 v1v1 v2v2 v 1 -v 0 v 2 -v 0 n

Triangle vs. Triangle Step 2: Compute signed distances of T 1 vertices to plane of T 2 : d i =n 2 ·u i +d 2 (i=0,1,2) Reject if all d i 0 Repeat for vertices of T 2 against plane of T 1 d0d0 u0u0

Triangle vs. Triangle Step 3: Find intersection points Step 4: Determine if segment pq is inside triangle or intersects triangle edge p q

Mesh vs. Mesh Geometry: points, edges, faces Collisions: p2p, p2e, p2f, e2e, e2f, f2f Relevant ones: p2f, e2e (point to face & edge to edge) Multiple collisions

Moving Mesh vs. Moving Mesh Two options: ‘point sample’ and ‘extrusion’ Point sample: If objects intersect at final positions, do a binary search backwards to find the time when they first hit and compute the intersection This approach can tend to miss thin objects Extrusion: Test ‘4-dimensional’ extrusions of objects In practice, this can be done using only 3D math

Moving Meshes: Point Sampling Requires instantaneous mesh-mesh intersection test Binary search

Moving Meshes: Extrusion Use ‘delta matrix’ trick to simplify problem so that one mesh is moving and one is static Test moving vertices against static faces (and the opposite, using the other delta matrix) Test moving edges against static edges (moving edges form a quad (two triangles))

Convex Geometry: V-Clip Tracks closest features Fails when objects intersect Requires pairwise updates

Box vs. Box Separating Axis Theorem If boxes A and B do not overlap, then there should exist a separating axis such that the projections of the boxes on the axis don’t overlap. This axis can be normal to the face of one object or connecting two edges between the two objects. Up to 15 axes must be tested to check if two boxes overlap

Triangle vs. Box 1.Test if triangle is outside any of the 6 box planes 2.Test if the box is entirely on one side of the triangle plane 3.Test separating axis from box edge to triangle edge

Intersection Issues Performance Memory Accuracy Floating point precision

Optimization Structures

BV, BVH (bounding volume hierarchies) Octree KD tree BSP (binary separating planes) OBB tree (oriented bounding boxes- a popular form of BVH) K-dop Uniform grid

Testing BVH’s TestBVH(A,B) { if(not overlap(A BV, B BV ) return FALSE; else if(isLeaf(A)) { if(isLeaf(B)) { for each triangle pair (T a,T b ) if(overlap(T a,T b )) AddIntersectionToList(); } else { for each child C b of B TestBVH(A,C b ); } else { for each child C a of A TestBVH(C a,B) }

Bounding Volume Hierarchies

Octrees

KD Trees

BSP Trees

OBB Trees

K-Dops

Uniform Grids

Optimization Structures All of these optimization structures can be used in either 2D or 3D Packing in memory may affect caching and performance

Pair Reduction

Reduce number of n^2 pair tests Pair reduction isn’t a big issue until n>50 or so…

Uniform Grid All objects are tracked by their location in a uniform grid Grid cells should be larger than diameter of largest object’s bound sphere To check collisions, test all objects in cell & neighboring cells Hierarchical grids can be used also

Hashing Grid Cells don’t exist unless they contain an object When an object moves, it may cross to a new cell

Conclusion

Preview of Next Week Physics Particles Rigid bodies Vehicles

Reading Assignment “Real Time Rendering” Chapter 14