Download presentation
Presentation is loading. Please wait.
Published byMadeleine Warner Modified over 8 years ago
1
Continuous Collision Detection of General Convex Objects Under Translation Gino van den Bergen Playlogic Game Factory gino@acm.org
2
Overview Explain the concept of Continuous 4D Collision Detection.Explain the concept of Continuous 4D Collision Detection. Briefly discuss the GJK algorithm.Briefly discuss the GJK algorithm. Present the GJK Ray Cast algorithm.Present the GJK Ray Cast algorithm. Present a 4D Broad Phase based on the Sweep and Prune algorithm.Present a 4D Broad Phase based on the Sweep and Prune algorithm.
3
The Problem (1/2) Object placements are computed for discrete moments in time.Object placements are computed for discrete moments in time. Object trajectories are assumed to be continuous.Object trajectories are assumed to be continuous.
4
The Problem (2/2) If collisions are checked only for the sampled moments, some collisions are missed (tunneling).If collisions are checked only for the sampled moments, some collisions are missed (tunneling). Humans easily spot such artifacts.Humans easily spot such artifacts.
5
The Fix Perform collision detection in continuous 4D space-time:Perform collision detection in continuous 4D space-time: –Construct a plausible trajectory for each moving object. –Check for collisions along these trajectories.
6
Plausible Trajectory? (1/3) Use of physically correct trajectories in real-time 4D collision detection is something for the not-so-near future.Use of physically correct trajectories in real-time 4D collision detection is something for the not-so-near future. In game development real-time constraints are met by cheating.In game development real-time constraints are met by cheating. We cheat by using simplified trajectories.We cheat by using simplified trajectories.
7
Plausible Trajectory? (2/3) Limited to trajectories with piecewise constant derivatives.Limited to trajectories with piecewise constant derivatives. Thus, linear and angular velocities are fixed between sampled frames.Thus, linear and angular velocities are fixed between sampled frames.
8
Plausible Trajectory? (3/3) Lots of fixed-velocity trajectories result in the same displacement.Lots of fixed-velocity trajectories result in the same displacement. Obtain unique trajectories by:Obtain unique trajectories by: –Fixing translation and rotation to the same axis (screw motion). –Fixing the rotation axis to a given point in the object’s local frame.
9
Screw Motions Redon uses piecewise screw motions for 4D collision detection.Redon uses piecewise screw motions for 4D collision detection. Screw motions often appear unnatural, e.g., a rolling ball:Screw motions often appear unnatural, e.g., a rolling ball:
10
Rotate about Center of Mass Corresponds more closely to Newtonian mechanics.Corresponds more closely to Newtonian mechanics. Unconstrained rigid body motion:Unconstrained rigid body motion: –Translations of center of mass. –Rotations leave center of mass fixed. Decoupling of translations and rotations adds DOFs and constraints.Decoupling of translations and rotations adds DOFs and constraints.
11
Only Translations (for now) Only translations are interpolated.Only translations are interpolated. Rotations are instantaneous.Rotations are instantaneous. The center of mass still follows a continuous piecewise linear path.The center of mass still follows a continuous piecewise linear path. Points off the rotation axis may suffer from tunneling, but we’ll fix that later.Points off the rotation axis may suffer from tunneling, but we’ll fix that later.
12
Configuration Space (1/2) The configuration space obstacle of objects A and B is the set of all vectors from a point of B to a point of A.The configuration space obstacle of objects A and B is the set of all vectors from a point of B to a point of A.
13
Configuration Space (2/2) A and B intersect: zero vector is contained in A – B.A and B intersect: zero vector is contained in A – B. Distance between A and B : length of shortest vector in A – B.Distance between A and B : length of shortest vector in A – B.
14
Translation Translation of A and/or B results in a translation of A – B.Translation of A and/or B results in a translation of A – B.
15
Rotation Rotation of A and/or B changes the shape of A - B.Rotation of A and/or B changes the shape of A - B.
16
Support Mappings A support mapping s A of an object A maps vectors to points of A, such thatA support mapping s A of an object A maps vectors to points of A, such that Any point on this face may be returned as support point
17
Primitives
18
More Primitives
19
Affine Transformation Primitives can be translated, rotated, and scaled. For T(x) = Bx + c, we havePrimitives can be translated, rotated, and scaled. For T(x) = Bx + c, we have
20
Convex Hull Convex hulls of arbitrary convex shapes are readily available.Convex hulls of arbitrary convex shapes are readily available.
21
Minkowski Sum Objects can be fattened by Minkowksi addition.Objects can be fattened by Minkowksi addition.
22
GJK Algorithm An iterative method for computing the point of an object closest to the origin.An iterative method for computing the point of an object closest to the origin. Uses a support mapping as the object’s geometric representation.Uses a support mapping as the object’s geometric representation. Support mapping for A – B isSupport mapping for A – B is
23
Basic Steps (1/6) Suppose we have a simplex inside the object…Suppose we have a simplex inside the object…
24
Basic Steps (2/6) …and the point v of the simplex closest to the origin.…and the point v of the simplex closest to the origin.
25
Basic Steps (3/6) Compute support point w for the vector - v.Compute support point w for the vector - v.
26
Basic Steps (4/6) Add support point w to the current simplex.Add support point w to the current simplex.
27
Basic Steps (5/6) Compute the closest point of the simplex.Compute the closest point of the simplex.
28
Basic Steps (6/6) Discard all vertices that do not contribute to v.Discard all vertices that do not contribute to v.
29
Shape Casting For objects A and B being translated over respectively vectors s and t, find the first time of contact.For objects A and B being translated over respectively vectors s and t, find the first time of contact. Boils down to a ray cast from the origin along the vector r = t – s onto A – B.Boils down to a ray cast from the origin along the vector r = t – s onto A – B.
30
Normals A normal at the hit point of the ray is normal to the contact plane.A normal at the hit point of the ray is normal to the contact plane.
31
Ray Clipping (1/2)
32
Ray Clipping (2/2) For, we know thatFor, we know that If v∙r > 0 then λ is a lower bound for the hit spot, and if also v·w > 0, the ray is clipped.If v∙r > 0 then λ is a lower bound for the hit spot, and if also v·w > 0, the ray is clipped. If v·r 0, then the ray misses.If v·r 0, then the ray misses. If v·r = 0 and v·w > 0, the ray misses as well.If v·r = 0 and v·w > 0, the ray misses as well.
33
GJK Ray Cast (1/2) Do a standard GJK iteration, and use the support planes as clipping planes.Do a standard GJK iteration, and use the support planes as clipping planes. Each time the ray is clipped, the origin is “shifted” to λr,Each time the ray is clipped, the origin is “shifted” to λr, …and the current simplex is set to the last-found support point.…and the current simplex is set to the last-found support point. The vector -v that corresponds to the latest clipping plane is the normal at the hit point.The vector -v that corresponds to the latest clipping plane is the normal at the hit point.
34
The vector -v is the latest normal. GJK Ray Cast (2/2) The origin advances to the new lower bound.
35
Termination (1/2) The origin advances only if v·w > 0, which must happen within a finite number of iterations if the origin is not contained in the query object.The origin advances only if v·w > 0, which must happen within a finite number of iterations if the origin is not contained in the query object. Terminate as soon as the origin is close enough to the query object, or we have evidence that the ray misses.Terminate as soon as the origin is close enough to the query object, or we have evidence that the ray misses.
36
Termination (2/2) As termination condition we use where v is the current closest point, W is the set of vertices of the current simplex, and ε is the error tolerance.As termination condition we use where v is the current closest point, W is the set of vertices of the current simplex, and ε is the error tolerance.
37
Accuracy vs. Performance Accuracy can be traded for performance by tweaking the error tolerance ε.Accuracy can be traded for performance by tweaking the error tolerance ε. A greater tolerance results in fewer iterations but less accurate hit points and normals.A greater tolerance results in fewer iterations but less accurate hit points and normals.
38
Accuracy vs. Performance ε = 10 -7, avg. time: 3.65 μs @ 2.6 GHzε = 10 -7, avg. time: 3.65 μs @ 2.6 GHz
39
Accuracy vs. Performance ε = 10 -6, avg. time: 2.80 μs @ 2.6 GHzε = 10 -6, avg. time: 2.80 μs @ 2.6 GHz
40
Accuracy vs. Performance ε = 10 -5, avg. time: 2.03 μs @ 2.6 GHzε = 10 -5, avg. time: 2.03 μs @ 2.6 GHz
41
Accuracy vs. Performance ε = 10 -4, avg. time: 1.43 μs @ 2.6 GHzε = 10 -4, avg. time: 1.43 μs @ 2.6 GHz
42
Accuracy vs. Performance ε = 10 -3, avg. time: 1.02 μs @ 2.6 GHzε = 10 -3, avg. time: 1.02 μs @ 2.6 GHz
43
Accuracy vs. Performance ε = 10 -2, avg. time: 0.77 μs @ 2.6 GHzε = 10 -2, avg. time: 0.77 μs @ 2.6 GHz
44
Accuracy vs. Performance ε = 10 -1, avg. time: 0.62 μs @ 2.6 GHzε = 10 -1, avg. time: 0.62 μs @ 2.6 GHz
45
Rotations (1/2) All trajectories of points on a rotating object are contained by a disk of radius where ρ is the max. distance from the axis to a point of the object, and α the rotation angle clamped between –π and π.All trajectories of points on a rotating object are contained by a disk of radius where ρ is the max. distance from the axis to a point of the object, and α the rotation angle clamped between –π and π.
46
Rotations (2/2) Add the disk to the rotating object by Minkowski addition to obtain a conservative bound.Add the disk to the rotating object by Minkowski addition to obtain a conservative bound. If necessary, reduce the bound by bisection of the time interval. Shorter intervals result in smaller angles, and thus tighter bounds.If necessary, reduce the bound by bisection of the time interval. Shorter intervals result in smaller angles, and thus tighter bounds.
47
4D Broad Phase Find pairs of objects whose axis- aligned bounding boxes overlap.Find pairs of objects whose axis- aligned bounding boxes overlap. Take translations of objects over the time interval into account.Take translations of objects over the time interval into account. No false positives: box pairs must overlap at some point in the time interval.No false positives: box pairs must overlap at some point in the time interval.
48
AABB Computation The projection of an object A onto an axis e is the interval:The projection of an object A onto an axis e is the interval: Compute an object’s AABB by projecting it onto the world axes.Compute an object’s AABB by projecting it onto the world axes.
49
Sweep and Prune (1/3) For each world axis, maintain a sorted list of interval endpoints.For each world axis, maintain a sorted list of interval endpoints. Maintain also the set of overlapping box pairs.Maintain also the set of overlapping box pairs. When a box moves, re-sort the lists by swapping the endpoints with their neighbors.When a box moves, re-sort the lists by swapping the endpoints with their neighbors.
50
Sweep and Prune (2/3) Re-order endpoints of moving objects. B A
51
Sweep and Prune (2/3) Re-order endpoints of moving objects. B A
52
Sweep and Prune (3/3) When swapping “][“ to “[]”, the intervals start to overlap.When swapping “][“ to “[]”, the intervals start to overlap. When swapping “[]“ to “][”, the intervals cease to overlap.When swapping “[]“ to “][”, the intervals cease to overlap. If the intervals on the other axes overlap, then the box pair starts or ceases to overlap.If the intervals on the other axes overlap, then the box pair starts or ceases to overlap.
53
Adding Time: a Simple Solution Enlarge AABBs of moving objects, such that they encapsulate the swept AABBs.Enlarge AABBs of moving objects, such that they encapsulate the swept AABBs. Creates false positives: Encapsulating AABBs overlap where in 4D, the actual AABBs do not.Creates false positives: Encapsulating AABBs overlap where in 4D, the actual AABBs do not.
54
B Adding Time: a Simple Solution Encapsulation results in false positives. A
55
Adding Time: a Better Solution Perform endpoint swaps in the proper order.Perform endpoint swaps in the proper order. Calculate swap times and prioritize swaps on earliest time.Calculate swap times and prioritize swaps on earliest time. Needs a priority queue that offers a decrease-key operation (as in Dijkstra’s algorithm or A*).Needs a priority queue that offers a decrease-key operation (as in Dijkstra’s algorithm or A*).
56
Adding Time: a Better Solution Swap endpoints in the proper order. B A
57
A Adding Time: a Better Solution Swap endpoints in the proper order. B
58
Adding Time: a Better Solution Swap endpoints in the proper order. B A
59
Performance Queuing endpoint swaps does not take a lot of extra processing time when implemented using a binary heap (O(log n), Cormen et al.).Queuing endpoint swaps does not take a lot of extra processing time when implemented using a binary heap (O(log n), Cormen et al.). In fact, it can save you time in cases where many objects are moving in the same direction.In fact, it can save you time in cases where many objects are moving in the same direction.
60
Conclusion Exact 4D collision detection of convex objects under translation is doable in real time.Exact 4D collision detection of convex objects under translation is doable in real time. Next big step: Exact 4D collision detection of rotating objects.Next big step: Exact 4D collision detection of rotating objects.
61
References Gino van den Bergen. Collision Detection in Interactive 3D Environments. Morgan Kaufmann Publishers, 2004.Gino van den Bergen. Collision Detection in Interactive 3D Environments. Morgan Kaufmann Publishers, 2004. Thomas H. Cormen et al. Introduction to Algorithms, Second Edition. MIT Press, 2001.Thomas H. Cormen et al. Introduction to Algorithms, Second Edition. MIT Press, 2001. F.C. Park and B. Ravani. Smooth Invariant Interpolation of Rotations. ACM Transactions on Graphics, 16(3):277-295, 1997.F.C. Park and B. Ravani. Smooth Invariant Interpolation of Rotations. ACM Transactions on Graphics, 16(3):277-295, 1997. Stephane Redon. Continuous Collision Detection for Rigid and Articulated Bodies. ACM SIGGRAPH Course Notes, 2004.Stephane Redon. Continuous Collision Detection for Rigid and Articulated Bodies. ACM SIGGRAPH Course Notes, 2004.
62
Thank You! For papers and other information, check: www.dtecta.comFor papers and other information, check: www.dtecta.com For information about Playlogic, please visit:For information about Playlogic, please visit: www.playlogicgames.com www.playlogicgames.com
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.