page 1
play

Page 1 1 Collision Detection Applications Naive Collision - PDF document

University of British Columbia Project 3 CPSC 314 Computer Graphics extra credit explained Jan-Apr 2005 can earn up to 110% of total points Tamara Munzner grading scheme: buckets minus, check-minus, check, check-plus, plus


  1. University of British Columbia Project 3 CPSC 314 Computer Graphics � extra credit explained Jan-Apr 2005 � can earn up to 110% of total points Tamara Munzner � grading scheme: buckets � minus, check-minus, check, check-plus, plus � plus = extra credit realm Collision Detection Week 10, Wed Mar 16 http://www.ugrad.cs.ubc.ca/~cs314/Vjan2005 � Review: Picking Methods Review: Select/Hit Picking � manual ray intersection � assign (hierarchical) integer key/name(s) y � small region around cursor as new viewport VCS x � bounding extents � redraw in selection mode � equivalent to casting pick “tube” � backbuffer coding � store keys, depth for drawn objects in hit list � examine hit list � usually use frontmost, but up to application � � Collision Detection � do objects collide/intersect? � static, dynamic � simple case: picking as collision detection � check if ray cast from cursor position collides Collision Detection with any object in scene � simple shooting � projectile arrives instantly, zero travel time � better: projectile and target move over time � see if collides with object during trajectory � � Page 1 1

  2. Collision Detection Applications Naive Collision Detection � determining if player hit wall/floor/obstacle � for each object i containing polygons p � terrain following (floor), maze games (walls) � test for intersection with object j containing � stop them walking through it polygons q � determining if projectile has hit target � for polyhedral objects, test if object i � determining if player has hit target penetrates surface of j � punch/kick (desired), car crash (not desired) � detecting points at which behavior should change � test if vertices of i straddle polygon q of j � car in the air returning to the ground � if straddle, then test intersection of polygon q � cleaning up animation with polygon p of object i � making sure a motion-captured character’s feet do not pass through the floor � very expensive! O(n 2 ) � simulating motion � physics, or cloth, or something else � � Choosing an Algorithm Terminology Illustrated � primary factor: geometry of colliding objects � “object” could be a point, or line segment � object could be specific shape: sphere, triangle, cube � objects can be concave/convex, solid/hollow, deformable/rigid, manifold/non-manifold � secondary factor: way in which objects move Convex Concave Manifold Non-Manifold � different algorithms for fast or slow moving objects An object is convex if for every pair of points inside An surface is manifold if every point � different algorithms depending on how frequently the the object, the line joining on it is homeomorphic to a disk. object must be updated them is also inside the object Roughly, every edge has two faces � other factors: speed, simplicity, robustness joining it, and there are no isolated vertices. � �� Robustness Types of Geometry AABB � for our purposes, collision detection code is robust if � points OBB � doesn’t crash or infinite loop on any case that might � lines, rays and line segments occur � spheres, cylinders and cones 8-dop � better if it doesn’t fail on any case at all, even if the � cubes, rectilinear boxes case is supposed to be “impossible” � AABB: axis aligned bounding box � always gives some answer that is meaningful, or � OBB: oriented bounding box, arbitrary alignment explicitly reports that it cannot give an answer � k-dops – shapes bounded by planes at fixed orientations � can handle many forms of geometry � convex, manifold meshes – any mesh can be triangulated � can detect problems with the input geometry, � concave meshes can be broken into convex chunks, by hand particularly if that geometry is supposed to meet � triangle soup some conditions (such as convexity) � more general curved surfaces, but often not used in games � robustness is remarkably hard to obtain �� �� Page 2 2

  3. Fundamental Design Principles Fundamental Design Principles � several principles to consider when designing � fast simple tests first , eliminate many potential collisions collision detection strategy � test bounding volumes before testing individual � if more than one test available, with different triangles costs: how do you combine them? � exploit locality , eliminate many potential collisions � how do you avoid unnecessary tests? � use cell structures to avoid considering distant objects � how do you make tests cheaper? � use as much information as possible about geometry � spheres have special properties that speed collision testing � exploit coherence between successive tests � things don’t typically change much between two frames �� �� Player-Wall Collisions Stupid Algorithm � first person games must prevent the player � on each step, do a general mesh-to-mesh from walking through walls and other intersection test to find out if the player obstacles intersects the wall � most general case: player and walls are � if they do, refuse to allow the player to move polygonal meshes � problems with this approach? how can we � each frame, player moves along path not improve: known in advance � in speed? � assume piecewise linear: straight steps on � in accuracy? each frame � in response? � assume player’s motion could be fast �� �� Ways to Improve Collision Proxies � even seemingly simple problem of � proxy: something that takes place of real object determining if the player hit the wall reveals a � cheaper than general mesh-mesh intersections wealth of techniques � collision proxy (bounding volume) is piece of geometry used to represent complex object for � collision proxies purposes of finding collision � spatial data structures to localize � if proxy collides, object is said to collide � finding precise collision times � collision points mapped back onto original object � responding to collisions � good proxy: cheap to compute collisions for, tight fit to the real geometry � common proxies: sphere, cylinder, box, ellipsoid � consider: fat player, thin player, rocket, car … �� �� Page 3 3

  4. Why Proxies Work Trade-off in Choosing Proxies � proxies exploit facts about human perception � we are extraordinarily bad at determining correctness of collision between two complex objects � the more stuff is happening, and the faster it happens, the more problems we have Sphere AABB OBB 6-dop Convex Hull detecting errors � players frequently cannot see themselves increasing complexity & tightness of fit � we are bad at predicting what should happen in response to a collision decreasing cost of (overlap tests + proxy update) �� �� Pair Reduction Spatial Data Structures � want proxy for any moving object requiring collision � can only hit something that is close detection � spatial data structures tell you what is close � before pair of objects tested in any detail, quickly to object test if proxies intersect � uniform grid, octrees, kd-trees, BSP trees, � when lots of moving objects, even this quick OBB trees, k-dop trees bounding sphere test can take too long: N 2 times if � for player-wall problem, typically use same there are N objects � reducing this N 2 problem is called pair reduction spatial data structure as for rendering � pair testing isn’t a big issue until N>50 or so… � BSP trees most common �� �� Uniform Grids Bounding Volume Hierarchies �� �� Page 4 4

  5. Octrees KD Trees �� �� BSP Trees OBB Trees �� �� K-Dops 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) } �� �� } Page 5 5

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend