Chapter 4.2 Collision Detection and Resolution

Slides:



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

Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
Sources of the Magnetic Field
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/
Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.
2.1. C OLLISION D ETECTION Overview. Collision detection is used within many types of application, e.g. from robotics, through engineering simulations,
CSE 380 – Computer Game Programming Collision Detection & Response Erin Catto’s Box2D.
Computational Geometry & Collision detection
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
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.
Game Mathematics & Game State The Complexity of Games Expectations of Players Efficiency Game Mathematics o Collision Detection & Response o Object Overlap.
CSCE 590E Spring 2007 Graphics I By Jijun Tang. Announcements Second presentation will be held on April 16 th and 18 th  April 16 th : Space Banditos,
CSCE 590E Spring 2007 Collision Detection By Jijun Tang.
Mechanics, Dynamics & Aesthetics The Complexity of Games Expectations of Players Efficiency Game Mathematics o Collision Detection & Response o Object.
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.
CIS 487/587 Bruce R. Maxim UM-Dearborn
Game Physics What is meant by Physics in games (old)? –Collision Detection (testing) But want the physical effect of hitting an immovable object. Also.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Computer graphics & visualization Collision Detection – Narrow Phase.
CS 4730 Collision Detection CS 4730 – Computer Game Design.
Vectors and Two-Dimensional Motion
Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Section 13.4 The Cross Product. Torque Torque is a measure of how much a force acting on an object causes that object to rotate –The object rotates around.
Chapter 3 Vectors and Two-Dimensional Motion. Vector vs. Scalar Review All physical quantities encountered in this text will be either a scalar or a vector.
CSE 381 – Advanced Game Programming Quickhull and GJK.
Collision handling: detection and response
CSCE 552 Spring 2009 Math, Physics and Collision Detection By Jijun Tang.
Week 13 - Friday.  What did we talk about last time?  Ray/sphere intersection  Ray/box intersection  Slabs method  Line segment/box overlap test.
3D Graphics for Game Programming Chapter XII Physics-based Simulation.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Math / Physics 101 GAM 376 Robin Burke Fall 2006.
Chapter 2 Section 2.4 Lines and Planes in Space. x y z.
Kinematics in 2-D Concept Map
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
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.
Computer Game Design and Development Mathematics, Collision, and Physics Havok Destruction.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
ENGINEERING STATICS COURSE INTRODUCTION.
CSCE 552 Fall 2012 Math, Physics and Collision Detection By Jijun Tang.
Controlling a Virtual Camera Ross Ptacek University of Alabama Birmingham.
Introduction to Particle Simulations Daniel Playne.
Chapter 11 Angular Momentum. Angular momentum plays a key role in rotational dynamics. There is a principle of conservation of angular momentum.  In.
Collision Detection And Response Jae Chun KyungSoo Im Chau Vo Hoang Vu.
Computer Game Design and Development
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
CS274 Spring 01 Lecture 7 Copyright © Mark Meyer Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Computer Game Design and Development Collision Detection Havok Destruction.
Game Programming 13 Physics in Games (cont.) 2010 년 2 학기 디지털콘텐츠전공.
Introduction to Game Programming & Design III Lecture III.
CSCE 552 Fall 2012 Math, Physics and Collision Detection By Jijun Tang.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Collision Detection Spring 2004.
2.1. Collision Detection Overview.
Math, Physics and Collision Detection
Scalars vs Vectors Scalars – a quantity that only needs a magnitude (with a unit) to describe it Ex: time, distance, speed, mass, volume, temperature Vectors.
Mechanics, Dynamics & Aesthetics
Devil Physics Baddest Class on Campus AP Physics
Kinematics Vectors and Motion
Motion in Real and Virtual Worlds
Computer Animation Algorithms and Techniques
Collision Detection.
CO Games Concepts Week 12 Collision Detection
GPAT – Chapter 7 Physics.
Presentation transcript:

Chapter 4.2 Collision Detection and Resolution

Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring expensive testing 2. Naïve solution is O(n2) time complexity, since every object can potentially collide with every other object

Collision Detection Two basic techniques 1. Overlap testing Detects whether a collision has already occurred 2. Intersection testing Predicts whether a collision will occur in the future

Overlap Testing Facts Concept Most common technique used in games Exhibits more error than intersection testing Concept For every simulation step, test every pair of objects to see if they overlap Easy for simple volumes like spheres, harder for polygonal models

Overlap Testing: Useful Results Useful results of detected collision Time collision took place Collision normal vector

Overlap Testing: Collision Time Collision time calculated by moving object back in time until right before collision Bisection is an effective technique

Overlap Testing: Limitations Fails with objects that move too fast Unlikely to catch time slice during overlap Possible solutions Design constraint on speed of objects Reduce simulation step size

Intersection Testing Predict future collisions When predicted: Move simulation to time of collision Resolve collision Simulate remaining time step

Intersection Testing: Swept Geometry Extrude geometry in direction of movement Swept sphere turns into a “capsule” shape

Reminder about nomenclature A (bolded variables are vectors) A (italicized variables are scalars) In cases where the name is the same, the scalar is the magnitude of the Vector (Pythagoras).

Intersection Testing: Special Case, Sphere-Sphere

Intersection Testing: Sphere-Sphere Collision Smallest distance ever separating two spheres: If there is a collision

Intersection Testing: Limitations More costly then object overlap Issue with networked games Future predictions rely on exact state of world at present time Due to packet latency, current state not always coherent Assumes constant velocity and zero acceleration over simulation step Has implications for physics model and choice of integrator

Dealing with Complexity Two issues 1. Complex geometry must be simplified 2. Reduce number of object pair tests

Dealing with Complexity: Simplified Geometry Approximate complex objects with simpler geometry, like this ellipsoid Or multiple spheres

Dealing with Complexity: Minkowski Sum Two complex shapes might take dozens of test to determine if they overlap. By taking the Minkowski Sum of two complex volumes and creating a new volume, overlap can be found by testing if a single point is within the new volume

Dealing with Complexity: Minkowski Sum

Dealing with Complexity: Minkowski Sum

Dealing with Complexity: Bounding Volumes Bounding volume is a simple geometric shape Completely encapsulates object If no collision with bounding volume, no more testing is required Common bounding volumes Sphere Box

Dealing with Complexity: Box Bounding Volumes

Dealing with Complexity: Achieving O(n) Time Complexity One solution is to partition space Game Entities – Identification (Hash Maps) UID's allow multiple different lists or data structure over same object set. Observer model (objects could register their current quadrant with CD object)

Dealing with Complexity: Achieving O(n) Time Complexity Another solution is the plane sweep algorithm Find bounds in the X, Y and Z planes. Add values to appropriate lists. Lists are sorted initially with quicksort Θ(n(log(n)) Object coherence says that objects from frame to frame won't move much. Use bubblesort to do fast update Θ(n).

Terrain Collision Detection: Height Field Landscape Polygonal mesh with/without height field

Terrain Collision Detection: Locate Triangle on Height Field Q is the heel of the foot of the character. With triangle located determine height.

Flashback Remember: Dot product of two perpendicular vectors is 0. Cross product of two vectors is a vector perpendicular to the other two vectors. Planes in 3D Given a 3D point P<x,y,x> and a point N<A,B,C> we can define a plane Q as the set of all points Q such that the line from P to Q is perpendicular to the line from P to N.

Definition of a plane restated Definition of a plane: The set of points Q such that: (N – P ) ∙ (Q – P) = 0 Note: We commonly reduce N to a distance vector and when w do the equation becomes: N ∙ (Q – P) = 0 Your book persists in calling N a normal vector, which would only make sense if the plane is already defined.

Terrain Collision Detection: Locate Point on Triangle Plane equation: A, B, C are the x, y, z components of the plane’s normal vector Where with one of the triangles vertices being Giving:

Terrain Collision Detection: Locate Point on Triangle The normal can be constructed by taking the cross product of two sides: Solve for y and insert the x and z components of Q, giving the final equation for point within triangle:

Collision Resolution: Examples Two billiard balls strike Calculate ball positions at time of impact Impart new velocities on balls Play “clinking” sound effect Rocket slams into wall Rocket disappears Explosion spawned and explosion sound effect Wall charred and area damage inflicted on nearby characters Character walks through wall Magical sound effect triggered No trajectories or velocities affected

Collision Resolution: Parts Resolution has three parts 1. Prologue 2. Collision 3. Epilogue

Prologue Collision known to have occurred Check if collision should be ignored Other events might be triggered Sound effects Send collision notification messages

Collision Place objects at point of impact Assign new velocities Using physics Vector mathematics Using some other decision logic

Epilogue Propagate post-collision effects Possible effects Destroy one or both objects Play sound effect Inflict damage Many effects can be done either in the prologue or epilogue

Collision Resolution: Resolving Overlap Testing 1. Extract collision normal 2. Extract penetration depth 3. Move the two objects apart 4. Compute new velocities

Collision Resolution: Extract Collision Normal Find position of objects before impact Use two closest points to construct the collision normal vector

Collision Resolution: Extract Collision Normal Sphere collision normal vector Difference between centers at point of collision

Collision Resolution: Resolving Intersection Testing Simpler than resolving overlap testing No need to find penetration depth or move objects apart Simply 1. Extract collision normal 2. Compute new velocities

The End