SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
Collision Detection: an Overview

          James McLaren
           June 19 2009
About this talk
• Brief overview of the Collision detection.
• Deliberately not heavy on the math
  (Otherwise I’ll stand here all day).
• Not exhaustive – It’s a big area, lots of ways of
  doing things. Hopefully this will provide some
  kind of cook book.
Stages of Collision Detection
• Broad Phase
   – Use a some kind of Spatial Subdivision to reduce our
     algorithmic complexity.
• Narrow Phase
   – Volume x Volume
   – Polygon tests
• Response
   – Try to do something sensible when collisions occur.
• Ray Casts
   – Auxiliary tests used for line of sight, bullets etc.
Broad Phase
• Naïve checking of all objects against each
  other would be O(n2) == BAD!
• Need to find ways to trivially reject objects
  that are far away
• Typically use a spatial data structure
• May also take advantage of frame to frame
  coherence.
Spatial Data Structures
•   Uniform Grids
•   Hierarchical Grids
•   Octree/Quad-Tree
•   BSP-Tree
•   KD-Tree
•   Axis sorted lists (i.e. Sweep and Prune)
Uniform Grid
•   Simply divide geometry/objects into a grid
•   Easy to work with.
•   Fast insertion.
•   Grid size is important.
    – Objects can be in many cells.
    – Too small -> explosion in storage
    – Too large -> reduced benefit
• Can be combined with hashing.
• Various hierarchical schemes exist.
Octree
• Each branch node divides space into 8 octants
• Can be expensive to update if dataset is
  dynamic (i.e. moving objects).
KD-Tree
• Each node is a axis aligned hyper-plane in a k-
  dimensional space (usually 2 or 3 for us)
• Point in front of the plane are in the left
  branch, those behind are in the right
Binary Space Partition Tree
• Same principle as a KD-Tree, but more
  generalized.
• Each node stores a full plane (no axis alignment
  restrictions).
• For our purposes leaf nodes usually end up
  containing convex sets of polygons .
• Often used for Ray casting
• Also useful for rendering (can easily sort polygons
  back to front with respect to the camera)
Binary Space Partition Tree
Sweep and Prune
• Popular Broad Phase method for dealing with
  lots of dynamic objects.
• Makes good use of frame to frame coherence
• Objects are represented by an axis aligned
  bounding box
• Algorithm maintains sorted lists of min and
  max edges for each dimension (typically 3)
• Also maintains a set of objects that are
  currently overlapping
Sweep and Prune
• Each frame an insertion sort is performed on
  each list with the objects new positions
• When min and max edges are swapped for two
  objects we know a collision may have occurred,
  or that the objects no longer overlap.
• AABB tests can be done to confirm an overlap
• A bit set for each object-object pair can also be
  used (less testing but much bigger memory
  overhead).
Sweep and Prune
Broad Phase Considerations
• Many options, important to appropriate data
  structures.
• Often best to treat static and dynamic objects
  differently. Some Data structures handle real
  time updates much better than others i.e.
  – Grids/ Sweep and Prune good for dynamic scenes.
  – Octree/BSP Tree etc often better suited to static
    scenes.
Broad Phase Considerations
• An important recent consideration for the Broad
  Phase is multi-core. If possible we want to
  identify “Islands” of objects that for the purposes
  of this time step can be treated independently
  (possibly by multiple cores).
• Proximity queries can be integrated into the
  broad phase (Tell me all the objects in this area).
• Often want to filter based on object groups (No
  point checking bullets vs bullets or proximity
  checks vs proximity checks).
Narrow Phase
• Need to perform more exact tests on the set
  of potentially colliding candidates found in the
  Broad Phase
• Object representations will typically take the
  form of either:
  – A bounding volume (usually convex)
  – A hierarchy of bounding volumes
  – Polygon soup (possibly underneath the volumes)
Bounding Volumes
• Objects can be represented as a single
  bounding volume.
• Usually these are convex
  – Simpler to deal with than non-convex
  – Can make use of Separating Axis Theorem:
  – Several popular algorithms based on convexity
Separating Axis Theorem
• Theorem: “Given two convex shapes, there exists an axis
  where their projections can be separated if and only if they
  are not intersecting”.
• Is the basis of many collision detection checks.
• Typically there are a fixed number of axis that need to be
  checked in order to guarantee there is no collision.
   – For OBB-OBB checks, this is 15 (6 for the axis for each box, and 9 from
     the cross products between them).
• Often gives good “early out” behaviour.
   – If the objects don’t collide, we will usually find a separating axis after
     the first few tests.
Separating Axis
Typical bounding volumes
•   Spheres
•   Ellipsoids (easy to reduce to being spheres)
•   Oriented bounding box
•   Capsules
•   Cylinders
•   Convex hulls
V-Clip
• One of several algorithms which work with pairs
  of convex hulls.
• Theorem: Let FA and FB be a pair of features from
  two disjoint convex polyhedra, A and B, and let
  VR(FA) and VR(FB) denote their Voronoi regions.
  Let PA ∈ FA and PB ∈ FB be a pair of closest points
  between the features. Then, if PA ∈ VR(FB) and PB
  ∈ VR(FA), FA and FB are a globally closest pair of
  features and PA and PB are a globally closest pair
  of points between A and B (albeit not necessarily
  unique).
V-Clip
• Based on the Voronoi diagrams of the two hulls
• Makes use of frame to frame coherence by
  tracking the closest features between the two
  objects
• In most cases the closest features from the last
  frame will be the same.
• If not then we search for the new closest features
  using the old ones as an initial best guess
V-Clip




• The vertex feature pair V and F constitute the
  closest pair of features and containing the closest
  pair of points Pa and Pb
Bounding Volume Hierarchies
• Convex volumes often don’t give a very good
  representation of the object
• Subdividing using a hierarchy of volumes allows us to
  represent more complex shapes.
• (Yes this is another spatial data structure!)
• Sphere trees and OBB trees are both popular.
Triangle tests
• Often at the bottom of our hierarchy we need to
  test against the individual triangles of our mesh.
• This might be a test against other triangles, or
  possibly simple volumes such as a sphere.
• Several well know algorithms for these tests.
• If there is a collision then we want to return the
  position , time and normal of the collision.
• Also need to return the penetration distance if
  the objects intersect.
Collision Response
• Once we have detected a collision, we need to
  resolve it somehow.
• Dependent on the requirements of the simulation
• In a physics based simulation will probably either:
   – Apply impulses to the objects to instantaneously
     change their velocity.
   – Let objects penetrate and apply repulsion forces
     based on the penetration distance ( Can have some
     instability issues).
   – Possibly also generate contact points to specify
     constraints.
Collision Response
• If we are non physics based:
  – We can just wind the objects back to the point of
    collision, and inform the game.
  – Punt and just inform the game.
  – We also have the freedom to move objects in turn
    rather than together, at fast frame rates the effects of
    this can be negligable
• Must also take note of the fact that if we are
  simulating collisions mid frame, then our objects
  now have the potential to collide with different
  objects
Penetration
• In an ideal world we detect all our collisions at the
  instant they occur.
• However, various things can cause this to not be the
  case:
   – We are not using swept collision tests
   – We are dealing with rotating objects
   – The game logic has decided to teleport you somewhere 
• Finding the right direction to move objects to stop
  penetrating can be challenging.
   – Resolving one penetration may well cause another
   – Often use relaxation (resolve, check, resolve, check) until
     we are ok, or hit some maximum iteration count.
Wonderful Rotation
• Most of the standard swept primitive/volume
  algorithms quietly ignore the angular velocity.
• This means that you have to make instantaneous
  changes in rotation combined with swept
  updates along the velocity vector.
• When this causes a penetration you have to
  either:
  – Move the objects out of each other.
  – Subdivide down to a smaller fraction of your time step
    and try again.
Ray Casts
• The other main form of collision query in games.
• Used for line of sight checks, bullets etc.
• Rich history in Ray Tracing literature.
• Also generally make use of some form of spatial
  data structure to accelerate the checks
• Test can be optimized if the ray is walked from
  front to back through the spatial subdivision.
• Also possible to batch ray traversals to try to get
  better cache behavior.
Ray Traversal
• Example below is a ray walking over a uniform grid
  (Technique used in PMC and FTB3).
• Note the difference from typical Bresenham line.
• We can early out the algorithm once we detect a collision.
• This kind of traversal is also possible with BSP/Octrees etc.
References
• Real-Time Collision Detection by Christer
  Ericson.
• http://realtimecollisiondetection.net/
• http://www.its.caltech.edu/~jiegao/collision-
  detection.html
Questions?

Contenu connexe

En vedette

Machine Learning and Robotics
Machine Learning and RoboticsMachine Learning and Robotics
Machine Learning and Roboticsbutest
 
7 Common Types of Car Accidents
7 Common Types of Car Accidents7 Common Types of Car Accidents
7 Common Types of Car AccidentsTennycut
 
AIIA - Charting the Path to Intelligent Operations with Machine Learning - At...
AIIA - Charting the Path to Intelligent Operations with Machine Learning - At...AIIA - Charting the Path to Intelligent Operations with Machine Learning - At...
AIIA - Charting the Path to Intelligent Operations with Machine Learning - At...BigML, Inc
 
Computed Tomography (CT): Market Shares, Strategies, and Forecasts, Worldwide...
Computed Tomography (CT): Market Shares, Strategies, and Forecasts, Worldwide...Computed Tomography (CT): Market Shares, Strategies, and Forecasts, Worldwide...
Computed Tomography (CT): Market Shares, Strategies, and Forecasts, Worldwide...Market Research Reports, Inc.
 
Cmm softwares
Cmm softwaresCmm softwares
Cmm softwaressgrsoni45
 
Metris 2009
Metris 2009Metris 2009
Metris 2009Yann Nee
 
Practical Occlusion Culling on PS3
Practical Occlusion Culling on PS3Practical Occlusion Culling on PS3
Practical Occlusion Culling on PS3Guerrilla
 
Science10 activity 3
Science10 activity 3Science10 activity 3
Science10 activity 3Jonalyn Furog
 
Uncertainty of Coordinate Measuring Machines
Uncertainty of Coordinate Measuring MachinesUncertainty of Coordinate Measuring Machines
Uncertainty of Coordinate Measuring MachinesHassan Habib
 
Practical Occlusion Culling in Killzone 3
Practical Occlusion Culling in Killzone 3Practical Occlusion Culling in Killzone 3
Practical Occlusion Culling in Killzone 3Guerrilla
 
Coordinate measuring machine
Coordinate measuring machineCoordinate measuring machine
Coordinate measuring machinevishal patidar
 
Momentum & Collisions
Momentum & CollisionsMomentum & Collisions
Momentum & CollisionsTimothy Welsh
 
Collision theory
Collision theoryCollision theory
Collision theorybeckydaw
 
Cmm ( coordinate measuring machine )
Cmm ( coordinate measuring machine )Cmm ( coordinate measuring machine )
Cmm ( coordinate measuring machine )Agung O
 

En vedette (17)

HEAD COLLISION PREVENTION SYSTEM
HEAD COLLISION PREVENTION SYSTEMHEAD COLLISION PREVENTION SYSTEM
HEAD COLLISION PREVENTION SYSTEM
 
Machine Learning and Robotics
Machine Learning and RoboticsMachine Learning and Robotics
Machine Learning and Robotics
 
7 Common Types of Car Accidents
7 Common Types of Car Accidents7 Common Types of Car Accidents
7 Common Types of Car Accidents
 
AIIA - Charting the Path to Intelligent Operations with Machine Learning - At...
AIIA - Charting the Path to Intelligent Operations with Machine Learning - At...AIIA - Charting the Path to Intelligent Operations with Machine Learning - At...
AIIA - Charting the Path to Intelligent Operations with Machine Learning - At...
 
Computed Tomography (CT): Market Shares, Strategies, and Forecasts, Worldwide...
Computed Tomography (CT): Market Shares, Strategies, and Forecasts, Worldwide...Computed Tomography (CT): Market Shares, Strategies, and Forecasts, Worldwide...
Computed Tomography (CT): Market Shares, Strategies, and Forecasts, Worldwide...
 
Cmm softwares
Cmm softwaresCmm softwares
Cmm softwares
 
Metris 2009
Metris 2009Metris 2009
Metris 2009
 
Practical Occlusion Culling on PS3
Practical Occlusion Culling on PS3Practical Occlusion Culling on PS3
Practical Occlusion Culling on PS3
 
Science10 activity 3
Science10 activity 3Science10 activity 3
Science10 activity 3
 
Autodesk CAM Portfolio – Russ Adams PartMaker
Autodesk CAM Portfolio – Russ Adams PartMakerAutodesk CAM Portfolio – Russ Adams PartMaker
Autodesk CAM Portfolio – Russ Adams PartMaker
 
Uncertainty of Coordinate Measuring Machines
Uncertainty of Coordinate Measuring MachinesUncertainty of Coordinate Measuring Machines
Uncertainty of Coordinate Measuring Machines
 
Practical Occlusion Culling in Killzone 3
Practical Occlusion Culling in Killzone 3Practical Occlusion Culling in Killzone 3
Practical Occlusion Culling in Killzone 3
 
Coordinate measuring machine
Coordinate measuring machineCoordinate measuring machine
Coordinate measuring machine
 
Momentum & Collisions
Momentum & CollisionsMomentum & Collisions
Momentum & Collisions
 
Collision theory
Collision theoryCollision theory
Collision theory
 
Cmm ( coordinate measuring machine )
Cmm ( coordinate measuring machine )Cmm ( coordinate measuring machine )
Cmm ( coordinate measuring machine )
 
Collision Theory
Collision TheoryCollision Theory
Collision Theory
 

Similaire à Collision Detection: an Overview Explained

generalized_nbody_acs_2015_challacombe
generalized_nbody_acs_2015_challacombegeneralized_nbody_acs_2015_challacombe
generalized_nbody_acs_2015_challacombeMatt Challacombe
 
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNNsplaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNNratnapatil14
 
NoSQL and Einstein's theory of relativity
NoSQL and Einstein's theory of relativityNoSQL and Einstein's theory of relativity
NoSQL and Einstein's theory of relativityLars Marius Garshol
 
Java Hands-On Workshop
Java Hands-On WorkshopJava Hands-On Workshop
Java Hands-On WorkshopArpit Poladia
 
Business Analytics Foundation with R Tools - Part 3
Business Analytics Foundation with R Tools - Part 3Business Analytics Foundation with R Tools - Part 3
Business Analytics Foundation with R Tools - Part 3Beamsync
 
ADS_Lec1_Linear_lists_Stacks
ADS_Lec1_Linear_lists_StacksADS_Lec1_Linear_lists_Stacks
ADS_Lec1_Linear_lists_StacksHemanth Kumar
 
06 image features
06 image features06 image features
06 image featuresankit_ppt
 
Solid modeling
Solid modelingSolid modeling
Solid modelingKRvEsL
 
NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A ...
 NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A ... NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A ...
NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A ...ssuser4b1f48
 
NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A T...
NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A T...NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A T...
NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A T...ssuser4b1f48
 
Digital origami from geometrically frustrated tiles
Digital origami from geometrically frustrated tilesDigital origami from geometrically frustrated tiles
Digital origami from geometrically frustrated tilesCK Harnett
 
Data minig.pptx
Data minig.pptxData minig.pptx
Data minig.pptxSabthamiS1
 
Verification with LoLA: 4 Using LoLA
Verification with LoLA: 4 Using LoLAVerification with LoLA: 4 Using LoLA
Verification with LoLA: 4 Using LoLAUniversität Rostock
 
2013 py con awesome big data algorithms
2013 py con awesome big data algorithms2013 py con awesome big data algorithms
2013 py con awesome big data algorithmsc.titus.brown
 

Similaire à Collision Detection: an Overview Explained (20)

SearchAlgorithm.pdf
SearchAlgorithm.pdfSearchAlgorithm.pdf
SearchAlgorithm.pdf
 
AI Robotics
AI RoboticsAI Robotics
AI Robotics
 
generalized_nbody_acs_2015_challacombe
generalized_nbody_acs_2015_challacombegeneralized_nbody_acs_2015_challacombe
generalized_nbody_acs_2015_challacombe
 
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNNsplaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
 
Splay tree
Splay treeSplay tree
Splay tree
 
NoSQL and Einstein's theory of relativity
NoSQL and Einstein's theory of relativityNoSQL and Einstein's theory of relativity
NoSQL and Einstein's theory of relativity
 
Chap11 slides
Chap11 slidesChap11 slides
Chap11 slides
 
Java Hands-On Workshop
Java Hands-On WorkshopJava Hands-On Workshop
Java Hands-On Workshop
 
Business Analytics Foundation with R Tools - Part 3
Business Analytics Foundation with R Tools - Part 3Business Analytics Foundation with R Tools - Part 3
Business Analytics Foundation with R Tools - Part 3
 
Radcliffe
RadcliffeRadcliffe
Radcliffe
 
ADS_Lec1_Linear_lists_Stacks
ADS_Lec1_Linear_lists_StacksADS_Lec1_Linear_lists_Stacks
ADS_Lec1_Linear_lists_Stacks
 
06 image features
06 image features06 image features
06 image features
 
Solid modeling
Solid modelingSolid modeling
Solid modeling
 
NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A ...
 NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A ... NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A ...
NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A ...
 
NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A T...
NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A T...NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A T...
NS-CUK Joint Journal Club: S.T.Nguyen, Review on "Neural Sheaf Diffusion: A T...
 
Digital origami from geometrically frustrated tiles
Digital origami from geometrically frustrated tilesDigital origami from geometrically frustrated tiles
Digital origami from geometrically frustrated tiles
 
Data minig.pptx
Data minig.pptxData minig.pptx
Data minig.pptx
 
Verification with LoLA: 4 Using LoLA
Verification with LoLA: 4 Using LoLAVerification with LoLA: 4 Using LoLA
Verification with LoLA: 4 Using LoLA
 
november6.ppt
november6.pptnovember6.ppt
november6.ppt
 
2013 py con awesome big data algorithms
2013 py con awesome big data algorithms2013 py con awesome big data algorithms
2013 py con awesome big data algorithms
 

Plus de slantsixgames

Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hdslantsixgames
 
Ask the Producers Feb 8th
Ask the Producers Feb 8thAsk the Producers Feb 8th
Ask the Producers Feb 8thslantsixgames
 
Maximize Your Production Effort (English)
Maximize Your Production Effort (English)Maximize Your Production Effort (English)
Maximize Your Production Effort (English)slantsixgames
 
Maximize Your Production Effort (Chinese)
Maximize Your Production Effort (Chinese)Maximize Your Production Effort (Chinese)
Maximize Your Production Effort (Chinese)slantsixgames
 
SCons an Introduction
SCons an IntroductionSCons an Introduction
SCons an Introductionslantsixgames
 
Confrontation Pipeline and SCons
Confrontation Pipeline and SConsConfrontation Pipeline and SCons
Confrontation Pipeline and SConsslantsixgames
 
Confrontation Audio GDC 2009
Confrontation Audio GDC 2009Confrontation Audio GDC 2009
Confrontation Audio GDC 2009slantsixgames
 
Audio SPU Presentation
Audio SPU PresentationAudio SPU Presentation
Audio SPU Presentationslantsixgames
 
Modern Graphics Pipeline Overview
Modern Graphics Pipeline OverviewModern Graphics Pipeline Overview
Modern Graphics Pipeline Overviewslantsixgames
 
PPU Optimisation Lesson
PPU Optimisation LessonPPU Optimisation Lesson
PPU Optimisation Lessonslantsixgames
 
Event System Presentation
Event System PresentationEvent System Presentation
Event System Presentationslantsixgames
 
Supersize Your Production Pipe
Supersize Your Production PipeSupersize Your Production Pipe
Supersize Your Production Pipeslantsixgames
 

Plus de slantsixgames (12)

Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hd
 
Ask the Producers Feb 8th
Ask the Producers Feb 8thAsk the Producers Feb 8th
Ask the Producers Feb 8th
 
Maximize Your Production Effort (English)
Maximize Your Production Effort (English)Maximize Your Production Effort (English)
Maximize Your Production Effort (English)
 
Maximize Your Production Effort (Chinese)
Maximize Your Production Effort (Chinese)Maximize Your Production Effort (Chinese)
Maximize Your Production Effort (Chinese)
 
SCons an Introduction
SCons an IntroductionSCons an Introduction
SCons an Introduction
 
Confrontation Pipeline and SCons
Confrontation Pipeline and SConsConfrontation Pipeline and SCons
Confrontation Pipeline and SCons
 
Confrontation Audio GDC 2009
Confrontation Audio GDC 2009Confrontation Audio GDC 2009
Confrontation Audio GDC 2009
 
Audio SPU Presentation
Audio SPU PresentationAudio SPU Presentation
Audio SPU Presentation
 
Modern Graphics Pipeline Overview
Modern Graphics Pipeline OverviewModern Graphics Pipeline Overview
Modern Graphics Pipeline Overview
 
PPU Optimisation Lesson
PPU Optimisation LessonPPU Optimisation Lesson
PPU Optimisation Lesson
 
Event System Presentation
Event System PresentationEvent System Presentation
Event System Presentation
 
Supersize Your Production Pipe
Supersize Your Production PipeSupersize Your Production Pipe
Supersize Your Production Pipe
 

Dernier

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Dernier (20)

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Collision Detection: an Overview Explained

  • 1. Collision Detection: an Overview James McLaren June 19 2009
  • 2. About this talk • Brief overview of the Collision detection. • Deliberately not heavy on the math (Otherwise I’ll stand here all day). • Not exhaustive – It’s a big area, lots of ways of doing things. Hopefully this will provide some kind of cook book.
  • 3. Stages of Collision Detection • Broad Phase – Use a some kind of Spatial Subdivision to reduce our algorithmic complexity. • Narrow Phase – Volume x Volume – Polygon tests • Response – Try to do something sensible when collisions occur. • Ray Casts – Auxiliary tests used for line of sight, bullets etc.
  • 4. Broad Phase • Naïve checking of all objects against each other would be O(n2) == BAD! • Need to find ways to trivially reject objects that are far away • Typically use a spatial data structure • May also take advantage of frame to frame coherence.
  • 5. Spatial Data Structures • Uniform Grids • Hierarchical Grids • Octree/Quad-Tree • BSP-Tree • KD-Tree • Axis sorted lists (i.e. Sweep and Prune)
  • 6. Uniform Grid • Simply divide geometry/objects into a grid • Easy to work with. • Fast insertion. • Grid size is important. – Objects can be in many cells. – Too small -> explosion in storage – Too large -> reduced benefit • Can be combined with hashing. • Various hierarchical schemes exist.
  • 7. Octree • Each branch node divides space into 8 octants • Can be expensive to update if dataset is dynamic (i.e. moving objects).
  • 8. KD-Tree • Each node is a axis aligned hyper-plane in a k- dimensional space (usually 2 or 3 for us) • Point in front of the plane are in the left branch, those behind are in the right
  • 9. Binary Space Partition Tree • Same principle as a KD-Tree, but more generalized. • Each node stores a full plane (no axis alignment restrictions). • For our purposes leaf nodes usually end up containing convex sets of polygons . • Often used for Ray casting • Also useful for rendering (can easily sort polygons back to front with respect to the camera)
  • 11. Sweep and Prune • Popular Broad Phase method for dealing with lots of dynamic objects. • Makes good use of frame to frame coherence • Objects are represented by an axis aligned bounding box • Algorithm maintains sorted lists of min and max edges for each dimension (typically 3) • Also maintains a set of objects that are currently overlapping
  • 12. Sweep and Prune • Each frame an insertion sort is performed on each list with the objects new positions • When min and max edges are swapped for two objects we know a collision may have occurred, or that the objects no longer overlap. • AABB tests can be done to confirm an overlap • A bit set for each object-object pair can also be used (less testing but much bigger memory overhead).
  • 14. Broad Phase Considerations • Many options, important to appropriate data structures. • Often best to treat static and dynamic objects differently. Some Data structures handle real time updates much better than others i.e. – Grids/ Sweep and Prune good for dynamic scenes. – Octree/BSP Tree etc often better suited to static scenes.
  • 15. Broad Phase Considerations • An important recent consideration for the Broad Phase is multi-core. If possible we want to identify “Islands” of objects that for the purposes of this time step can be treated independently (possibly by multiple cores). • Proximity queries can be integrated into the broad phase (Tell me all the objects in this area). • Often want to filter based on object groups (No point checking bullets vs bullets or proximity checks vs proximity checks).
  • 16. Narrow Phase • Need to perform more exact tests on the set of potentially colliding candidates found in the Broad Phase • Object representations will typically take the form of either: – A bounding volume (usually convex) – A hierarchy of bounding volumes – Polygon soup (possibly underneath the volumes)
  • 17. Bounding Volumes • Objects can be represented as a single bounding volume. • Usually these are convex – Simpler to deal with than non-convex – Can make use of Separating Axis Theorem: – Several popular algorithms based on convexity
  • 18. Separating Axis Theorem • Theorem: “Given two convex shapes, there exists an axis where their projections can be separated if and only if they are not intersecting”. • Is the basis of many collision detection checks. • Typically there are a fixed number of axis that need to be checked in order to guarantee there is no collision. – For OBB-OBB checks, this is 15 (6 for the axis for each box, and 9 from the cross products between them). • Often gives good “early out” behaviour. – If the objects don’t collide, we will usually find a separating axis after the first few tests.
  • 20. Typical bounding volumes • Spheres • Ellipsoids (easy to reduce to being spheres) • Oriented bounding box • Capsules • Cylinders • Convex hulls
  • 21. V-Clip • One of several algorithms which work with pairs of convex hulls. • Theorem: Let FA and FB be a pair of features from two disjoint convex polyhedra, A and B, and let VR(FA) and VR(FB) denote their Voronoi regions. Let PA ∈ FA and PB ∈ FB be a pair of closest points between the features. Then, if PA ∈ VR(FB) and PB ∈ VR(FA), FA and FB are a globally closest pair of features and PA and PB are a globally closest pair of points between A and B (albeit not necessarily unique).
  • 22. V-Clip • Based on the Voronoi diagrams of the two hulls • Makes use of frame to frame coherence by tracking the closest features between the two objects • In most cases the closest features from the last frame will be the same. • If not then we search for the new closest features using the old ones as an initial best guess
  • 23. V-Clip • The vertex feature pair V and F constitute the closest pair of features and containing the closest pair of points Pa and Pb
  • 24. Bounding Volume Hierarchies • Convex volumes often don’t give a very good representation of the object • Subdividing using a hierarchy of volumes allows us to represent more complex shapes. • (Yes this is another spatial data structure!) • Sphere trees and OBB trees are both popular.
  • 25. Triangle tests • Often at the bottom of our hierarchy we need to test against the individual triangles of our mesh. • This might be a test against other triangles, or possibly simple volumes such as a sphere. • Several well know algorithms for these tests. • If there is a collision then we want to return the position , time and normal of the collision. • Also need to return the penetration distance if the objects intersect.
  • 26. Collision Response • Once we have detected a collision, we need to resolve it somehow. • Dependent on the requirements of the simulation • In a physics based simulation will probably either: – Apply impulses to the objects to instantaneously change their velocity. – Let objects penetrate and apply repulsion forces based on the penetration distance ( Can have some instability issues). – Possibly also generate contact points to specify constraints.
  • 27. Collision Response • If we are non physics based: – We can just wind the objects back to the point of collision, and inform the game. – Punt and just inform the game. – We also have the freedom to move objects in turn rather than together, at fast frame rates the effects of this can be negligable • Must also take note of the fact that if we are simulating collisions mid frame, then our objects now have the potential to collide with different objects
  • 28. Penetration • In an ideal world we detect all our collisions at the instant they occur. • However, various things can cause this to not be the case: – We are not using swept collision tests – We are dealing with rotating objects – The game logic has decided to teleport you somewhere  • Finding the right direction to move objects to stop penetrating can be challenging. – Resolving one penetration may well cause another – Often use relaxation (resolve, check, resolve, check) until we are ok, or hit some maximum iteration count.
  • 29. Wonderful Rotation • Most of the standard swept primitive/volume algorithms quietly ignore the angular velocity. • This means that you have to make instantaneous changes in rotation combined with swept updates along the velocity vector. • When this causes a penetration you have to either: – Move the objects out of each other. – Subdivide down to a smaller fraction of your time step and try again.
  • 30. Ray Casts • The other main form of collision query in games. • Used for line of sight checks, bullets etc. • Rich history in Ray Tracing literature. • Also generally make use of some form of spatial data structure to accelerate the checks • Test can be optimized if the ray is walked from front to back through the spatial subdivision. • Also possible to batch ray traversals to try to get better cache behavior.
  • 31. Ray Traversal • Example below is a ray walking over a uniform grid (Technique used in PMC and FTB3). • Note the difference from typical Bresenham line. • We can early out the algorithm once we detect a collision. • This kind of traversal is also possible with BSP/Octrees etc.
  • 32. References • Real-Time Collision Detection by Christer Ericson. • http://realtimecollisiondetection.net/ • http://www.its.caltech.edu/~jiegao/collision- detection.html