12/4/2001CS 638, Fall 2001 Today Managing large numbers of objects Some special cases.

Slides:



Advertisements
Similar presentations
Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
Advertisements

Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
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.
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.
2.1. C OLLISION D ETECTION Overview. Collision detection is used within many types of application, e.g. from robotics, through engineering simulations,
03/12/02 (c) 2002 University of Wisconsin, CS559 Last Time Some Visibility (Hidden Surface Removal) algorithms –Painter’s Draw in some order Things drawn.
CSE 380 – Computer Game Programming Collision Detection & Response Erin Catto’s Box2D.
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.
Lecture 12 : Special Case of Hidden-Line-Elimination Computational Geometry Prof. Dr. Th. Ottmann 1 Special Cases of the Hidden Line Elimination Problem.
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
Special Cases of the Hidden Line Elimination Problem Computational Geometry, WS 2007/08 Lecture 16 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen,
Introduction General Data Structures - Arrays, Linked Lists - Stacks & Queues - Hash Tables & Binary Search Trees - Graphs Spatial Data Structures -Why.
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.
Hidden-Line Elimination Computational Geometry, WS 2006/07 Lecture 14 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
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!
Haptic Cloth Rendering 6th Dutch-Belgian Haptics Meeting TUDelft, 21 st June 2006 Lode Vanacken Expertise centre for Digital Media (EDM) Hasselt University.
Bounding Volume Hierarchies and Spatial Partitioning Kenneth E. Hoff III COMP-236 lecture Spring 2000.
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 David Johnson Cs6360 – Virtual Reality.
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
10/02/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Octrees.
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.
11/25/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Managing large numbers of objects Colliding spheres with things (spheres being common.
12/4/2001CS 638, Fall 2001 Today Using separating planes/axes for collision testing Collision detection packages.
Computer Graphics 2 Lecture x: Acceleration Techniques for Ray-Tracing Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
INTERACTION TECHNIQUES Collision Detection and Other Interactions Collision Detection and Other Interactions.
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
4/15/04© University of Wisconsin, CS559 Spring 2004 Last Time More modeling: –Hierarchical modeling –Instancing and Parametric Instancing –Constructive.
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.
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.
GPU Broad Phase Collision Detection GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from articles taken from GPU Gems III.
Collision/Acceleration University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
Real-time Graphics for VR Chapter 23. What is it about? In this part of the course we will look at how to render images given the constrains of VR: –we.
1 KIPA Game Engine Seminars Jonathan Blow Ajou University December 6, 2002 Day 10.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
CS 325 Introduction to Computer Graphics 03 / 22 / 2010 Instructor: Michael Eckmann.
Binary Space Partitioning Trees Ray Casting Depth Buffering
10/23/2001CS 638, Fall 2001 Today Terrain –Terrain LOD.
Controlling a Virtual Camera Ross Ptacek University of Alabama Birmingham.
Computer Graphics Zhen Jiang West Chester University.
CSE 380 – Advanced Game Programming Sweep & Prune.
11/20/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Collision Detection Overview Player-Environment handling.
Maths & Technologies for Games Spatial Partitioning 2
Ray Tracing Optimizations
David Luebke 3/5/2016 Advanced Computer Graphics Lecture 4: Faster Ray Tracing David Luebke
1 Advanced Scene Management. 2 This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake”
APE'07 IV INTERNATIONAL CONFERENCE ON ADVANCES IN PRODUCTION ENGINEERING June 2007 Warsaw, Poland M. Nowakiewicz, J. Porter-Sobieraj Faculty of.
Minkowski Sums and Distance Computation Eric Larsen COMP
Bounding Volume Hierarchies and Spatial Partitioning
CS679 - Fall Copyright Univ. of Wisconsin
Collision Detection Spring 2004.
Bounding Volume Hierarchies and Spatial Partitioning
Chapter 4.2 Collision Detection and Resolution
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
CS679 - Fall Copyright Univ. of Wisconsin
Computer Animation Algorithms and Techniques
Collision Detection.
Presentation transcript:

12/4/2001CS 638, Fall 2001 Today Managing large numbers of objects Some special cases

12/4/2001CS 638, Fall 2001 Case Study 2: Multi-Body Problems Multi-body problems have many objects that could be colliding –Most common case in games is lots of players or agents –“Collision” may not mean intersecting, could just mean being close enough to react It is essential to avoid considering every pair (n 2 cost) Spatial subdivision schemes provide one solution –Object interactions are detected in a two step process: which cell am I in, then who else is in my cell? Bounding volume schemes provide another, single step, solution –Objects supply their own bounds, and overlapping pairs of bounds are found directly

12/4/2001CS 638, Fall 2001 Broad-Phase Collision Detection The task of rapidly eliminating most collision pairs is referred to as broad-phase collision detection The task of finding out precisely which of the remaining pairs intersect is called narrow-phase collision detection Spatial subdivisions provide one means of doing broad phase detection Bounding volume schemes provide other approaches –Hierarchies of bounding volumes –Dimension reduction methods –Spatial hashing methods Assumptions: each object maintains a spatial bound of some form, and these are updated from frame to frame –Most common is AABBs, but also spheres and OBBs

12/4/2001CS 638, Fall 2001 Bounding Volume Hierarchies Basic idea is to build a tree, bottom up, where each level of the tree bounds its children Generally used for large numbers of static obstacles and a few moving things –Put all the static obstacles into the tree –Test for intersection between moving object and tree Intersection test looks a lot like testing against an octree or BSP tree The major difference is that a bounding volume hierarchy does not subdivide all of space, only those parts of space that are occupied Also used for subdividing a single object, as we will see later

12/4/2001CS 638, Fall 2001 Bounding Tree Example

12/4/2001CS 638, Fall D and 2D Collisions It’s easy to find all the overlaps between intervals on a line (1D collisions) –Sort all the start and endpoints –Sweep a point the line looking for overlaps –Maintain a set of intervals the point is currently inside, initially empty –If you reach an new interval start point, report overlap with all the intervals currently in the set, and add the new interval to the set –If you reach an interval end point, remove the interval from the set A similar algorithm works in 2D for finding overlaps of rectangles, but in 3D, the same algorithm becomes quite expensive The solution is to reduce the 3D problem to multiple instances of the 1D or 2D problem - reduce the dimension

12/4/2001CS 638, Fall 2001 Dimension Reduction Algorithm works with AABBs In order for two AABBs to overlap in 3D, they must overlap along every 1D axis –This is a special case of the separating plane theorem, more on it later Sort the box extents in each dimension Find all the 1D overlaps Tag pairs that overlap in all dimensions (can be done without overhead on the 1D problems) How expensive is this? x y X overlaps: green-red, red-blue Y overlaps: orange-red,orange green, green-red, green-blue 2D overlaps: green-red

12/4/2001CS 638, Fall 2001 Exploiting Coherence Sometime you can claim that the sorted order of the bound extents will not change much between tests –If objects don’t move far in each frame, and don’t frequently change direction This assumption fails for bouncing objects Using bubble sort, the cost of sorting depends on the number of swaps in sort order (linear + #swaps) –Bubble sort looks at each element in the list, and “bubbles” it down until it is greater than the preceding element If the sort order doesn’t change much, bubble sort is nearly linear, hence finding overlaps is nearly linear –Requires some messy coding and some other data structures to handle big numbers of objects without n 2 storage cost

12/4/2001CS 638, Fall 2001 Spatial Hashing Spatial hashing was developed to avoid the bouncing problem with dimension reduction Claims near linear time overlap detection Basic idea: –Pretend space is broken up into a regular subdivision, but don’t store the cells –Determine the indexes of the cells that each bound overlaps Regular subdivision makes finding cell indices easy –Turn the indexes into hash keys, one for each overlapped cell (just concatenate the bits) –Hash the object into a table based on the keys –Hash table collisions indicate overlaps

12/4/2001CS 638, Fall D Spatial Hashing Orange is hashed into 0100 Green is hashed into 0100, 0000, 0101 and 0001 Red is hashed into 1001, 0101 Blue is hashed into 0101, 0110, 0001, 0010 Orange-green, green-red, green-blue, red- blue are all potential collisions Would clean up with an explicit bounding volume test Note this is just like using a subdivision, but gets around the problem of storing the subdivision cells

12/4/2001CS 638, Fall 2001 More on Hashing The problem with spatial hashing (like any regular grid technique) is choosing the grid resolution A good heuristic is that a cell should be about twice as large as the bounds But if the bounds vary widely in size, there’s a problem Solution is hierarchical hashing: –Have a range of grid resolutions - append level to hash keys, or have separate tables –Hash an object into the most appropriate grid size, and all larger grids At most hashed into 4x as many cells as depth of hierarchy –All collisions will be found - convince yourself of this Textbook has a little to say about it

12/4/2001CS 638, Fall 2001 Choosing a Broad-Phase Reasons to use spatial subdivision (a la visibility): –Space is densely occupied –You can easily track which cells an object is in –Very efficient if the object per cell ratio is controllable Reasons to use a hierarchy of bounding volumes: –Many objects are static and well spaced –To integrate into object hierarchies Reasons to use dimension reduction: –Under some algorithms (asynchronous), it’s efficient Reasons to use spatial hashing: –Sparsely occupied, very large space –Cases where it is hard to explicitly track cell occupancy –But overall, probably the best, although it needs a publicist

12/4/2001CS 638, Fall 2001 Special Collision Cases We’ll look at some important cases, and some that are the base-case for other schemes –Testing spheres against anything, because it’s fast and spheres are commonly used bounding volumes –Testing two triangles, because meshes are ultimately made up of triangles, as is cloth, subdivision surfaces, … –Testing AABBs against each other, and testing OBBs against each other Along the way we will learn about Voronoi regions and separating planes

12/4/2001CS 638, Fall 2001 Sphere-Anything Testing The key observation is that collision testing with a sphere can be converted into a closest point problem: To test for collision with a sphere, find out if the point closest to the sphere’s center is closer than the sphere’s radius –Small problem if the sphere is inside the object There is a different way to solve the closest point problem for each type of geometry –We’ll look at other spheres, plane, triangles and boxes, and a hack Given a point and an object, find the point on the object that is closest to the given point

12/4/2001CS 638, Fall 2001 Sphere-Sphere and Sphere-Plane To test two spheres for collision: –Compute the square of the Euclidian distance between their centers –Compare it to the sum of the radii, squared –In math speak: (c 1 -c 2 )(c 1 -c 2 ) < (r 1 +r 2 ) 2 –How do you find the closest points? To test a sphere against a plane: –Find the distance from the sphere to the plane –For a plane given by the equation: nx+d=0, what is the computation? –Test the distance against the radius –How do you find the closest points?

12/4/2001CS 638, Fall 2001 Sphere-Triangle Testing First do a sphere-plane test with the triangle’s plane –What case can we eliminate? Several ways to proceed: –Find the closest point on the plane, find the closest point in 2D, then test the distance against the radius of the sphere –Test each triangle edge against the sphere Not enough, what else do you have to test? –Use a minimization procedure in 3D Requires the idea of Voronoi regions

12/4/2001CS 638, Fall 2001 Voronoi Regions A Voronoi region is associated with each feature of an object: each vertex, edge and face Each region is the set of points that are closest to that feature –For a triangle, sets are infinite –Sets are bounded by planes (in 3D) –How are the planes defined? To find the closest feature to a given point, find the Voronoi region that contains it –Can be done with an efficient walk procedure –Easy to exploit coherence (remember the closest feature from the last frame) Face Edge 1 Edge 2 Edge 3 Vert 1 Vert 2 Vert 3

12/4/2001CS 638, Fall 2001 Triangle Voronoi Example Outside Voronoi region: planes in error guide us to next region Done Note that regions share planes, so plane tests can be cached. Also, algorithm cannot infinite loop if careful.       