Collision Detection Spring 2004
Content Classification Types of bounding volumes Discrete, or continuous Types of bounding volumes Bounding volume hierarchy
We talked about … Taxonomy Collision detection Continuous, discrete Collision detection, response Collision detection Particle vs. plane Response and Contact problem Sphere vs. plane (particle vs. offset plane)
Point-Plane Collision Detection x e p v (p: any point on plane) Collision might occur if 1. Close enough and 2. Head toward plane Fall 2014
Point-Plane Collision Response 1/2 x- x+ The projection of x- on the plane Fall 2014
Point-Plane Collision Response 2/2 x v vT vN frictionless CR: Coefficient of Restitution 0 CR 1 Fall 2014
Sphere-Plane Collision x n p v and e Fall 2014
Contact Problem
Types of Bounding Volumes (ref) Sphere Ellipsoid Cylinder OBB (oriented bounding box) AABB (axis-aligned bounding box) K-DOP’s (K-discrete orientation polytopes) Sphere packing Swept sphere volume Spherical shells Convex hull
Types of Bounding Volumes
Oriented Bounding Boxes An oriented bounding box is always smaller (maybe equal to) an axis-aligned bounding box.
Bounding Volumes Hierarchy We used simple geometric entities to bound our polytopes. We keep different levels of bounding volumes in a hierarchy tree.
Bounding Volume Hierarchies So far, we have had subdivisions that break the world into cell General Bounding Volume Hierarchies (BVHs) start with a bounding volume for each object Many possibilities: Spheres, AABBs, OBBs, k-dops, …DOP (discrete oriented polytope) More on these later Parents have a bound that bounds their children’s bounds Typically, parent’s bound is of the same type as the children’s Can use fixed or variable number of children per node No notion of cells in this structure
BVH Example
BVH Construction Top-down: simplest to build Bound everything Choose a split plane (or more), divide objects into sets Recurse on child sets Can also be built incrementally Insert one bound at a time, growing as required Good for environments where things are created dynamically Can also be built bottom-up Bound individual objects, group them into sets, create parent, recurse What’s the hardest part about this?
BVH Operations Some of the operations we’ve looked at so far work with BVHs Frustum culling Collision detection BVHs are good for moving objects Updating the tree is easier than for other methods Incremental construction also helps (don’t need to rebuild the whole tree if something changes) But, BVHs lack some convenient properties For example, not all space is filled, so algorithms that “walk” through cells won’t work
Hierarchical bounding volume AABB OBB Convex polytopes (polyhedra)
Separation of Convex Polytopes H Try to find a hyperplane that separates the two polytopes. A B
Separation of Bounding Boxes l Two boxes do not intersect ↔ there exists a line l such that their projections onto this line do not overlap.
The Separating Axis Theorem The separating axis of two oriented boxes is either perpendicular to one of the faces, or can be obtained as the vector multiplication of two box axes. The interference query between two oriented boxes can be answered by checking 15 axes.
Separating Axis (Vertex-Vertex) u v w L A1 A2 A3 B1 B2 B3 We can show that there exists a vector L such that all three terms have the same sign. Thus:
OBB Intersection Exhaustive search of separation plane
Temporal Coherence
Interference of OBBs Using careful analysis for the various 15 possible axes, it is possible to implement the interference test for two OBBs using about 200 floating-point operations. This method has been implemented and successfully applied to large models.
Problem: Fitting OBBs The OBB fitting problem requires finding the orientation of the box that best fits the data Ideally, you want the minimum volume for the box, but that’s hard Instead, turn to an idea from statistics: principal components Point sample the convex hull of the geometry to be bound Find the mean and covariance matrix of the samples The mean will be the center of the box The eigenvectors of the covariance matrix are the principal directions – they are used for the axes of the box The principal directions tend to align along the longest axis, then the next longest that is orthogonal, and then the other orthogonal axis
OBB (Oriented Bounding Box)
Collision of n Bodies Naïve pairwise comparison: time complexity O(n2) Sweep and prune Sort: O(nlogn) Sweep: O(n) Output: O(k) Further improvement is possible by considering time coherence (later)
Sort/Sweep [one-dimensional]
Coherance-based Method If two intervals i and j overlap at the previous time step, but not at the current time step, one or more exchanges involving either a bi or ei value and a bj or ej value must occur.
Three-Dimensional Cases Can be more complicated Considering AABB: perform 3 one-dimensional tests