1 / 25

Collision Detection and Resolution

Collision Detection and Resolution. Zhi Yuan Course: Introduction to Game Development zyuan@cs.kent.edu 11/28/2011. Overview. Collision Detection Identify the intersection of objects. Collision Response Calculate the appropriate response after collision. Collision Detection.

glyn
Download Presentation

Collision Detection and Resolution

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Collision Detection and Resolution Zhi Yuan Course: Introduction to Game Development zyuan@cs.kent.edu 11/28/2011

  2. Overview • Collision Detection Identify the intersection of objects. • Collision Response Calculate the appropriate response after collision.

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

  4. Dealing with Complexity • Two directions • Complex geometry must be simplified. • Reduce number of object pair tests.

  5. Simplified Geometry • Approximate complex objects with simpler geometry, like this ellipsoid. • Simpler Shape is cheaper to test.

  6. BV: Bounding Volume • Key idea: • Surround the object with a (simpler) bounding object (the Bounding Volume). • If something does not collide with the bounding volume, it does not collide with the object inside. • Often, to intersect two objects, first intersect their bounding volumes.

  7. Choosing a Bounding Volume • Lots of choices, each with tradeoffs. • Tighter fitting is better. More likely to eliminate “false” intersections.

  8. Choosing a Bounding Volume • Lots of choices, each with tradeoffs. • Tighter fitting is better. • Simpler shape is better. Make it faster to compute with.

  9. Choosing a Bounding Volume • Lots of choices, each with tradeoffs. • Tighter fitting is better. • Simpler shape is better. • Rotation Invariant is better. Easier to update as object moves.

  10. Choosing a Bounding Volume • Lots of choices, each with tradeoffs. • Tighter fitting is better. • Simpler shape is better. • Rotation Invariant is better. • Convex is usually better. Gives simpler shape, easier computation.

  11. Common Bounding Volumes: Sphere • Rotationally invariant. • Usually fast to compute with. • Store: center point and radius. • Center point: object’s center of mass. • Radius: distance of farthest point on object from center of mass. • Often not very tight fit.

  12. Common Bounding Volumes:Axis Aligned Bounding Box (AABB) • Very fast to compute with. • Store: max and min along x, y axes. Look at all points and record max, min. • Moderately tight fit. • Must update after rotation.

  13. Common Bounding Volumes:Oriented Bounding Box (OBB) • Store rectangle oriented to best fit the object. • Store: • Center. • Orthonormalset of axes. • Extent along each axis. • Tight fit, but takes work to get good initial fit. • Computation is slower than for AABBs.

  14. Testing for Collision • Will depend on type of objects and bounding volumes. • Specialized algorithms for each: • Sphere/sphere • AABB/AABB • OBB/OBB

  15. Collision Test Sphere vs. Sphere • Find distance between centers of spheres. Compare to sum of sphere radii. • If distance is less, they collide. • For efficiency, check squared distance vs. square of sum of radii. d r2 r1

  16. Collision Test AABB vs. AABB • Project AABBs onto given axes. • If overlapping on all axes, the boxes overlap.

  17. Collision Test OBB vs. OBB • Separating Axis Theorem: Two convex shapes do not overlap if and only if there exists an axis such that the projections of the two shapes do not overlap.

  18. Enumerating Separating Axes • Two convex shapes do not overlap if and only if there exists an axis such that the projections of the two shapes do not overlap. • How do we find axes to test for overlap?

  19. Enumerating Separating Axes • Two convex shapes do not overlap if and only if there exists an axis such that the projections of the two shapes do not overlap.

  20. Enumerating Separating Axes • 2D: check axis aligned with normal of each face. • 3D: check axis aligned with normal of each face and cross product of each pair of edges.

  21. Enumerating Separating Axes • 2D: check axis aligned with normal of each face. • 3D: check axis aligned with normal of each face and cross product of each pair of edges.

  22. Enumerating Separating Axes • Two convex shapes do not overlap if and only if there exists an axis such that the projections of the two shapes do not overlap.

  23. Reduce number of object pair tests • One solution is to partition space uniformly.

  24. Reduce number of object pair tests • Another solution is the plane sweep algorithm.

  25. References • Textbook:Introduction to Game Development by Steve Rabin, 2010, Second Edition, ISBN: 1584506792 • http://coitweb.uncc.edu/~tbarnes2/GameDesignFall05/.../Ch4.2-CollDet.ppt • http://www.sfu.ca/~shaw/iat410/Lectures/08CollDet.ppt • http://www.cs.duke.edu/courses/cps004/spring04/notes/collision.ppt

More Related