Q: How can you spot a bald-faced liar in computer graphics? · Q: How can you spot a bald-faced...
Transcript of Q: How can you spot a bald-faced liar in computer graphics? · Q: How can you spot a bald-faced...
Q: How can you spot a bald-faced liar in computer graphics?
A: Ask if they have fully working code for…
TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAAAAA
Collision Handling
TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAA
Collision Handling
Consists of two steps:
• collision detection:
• what has collided?
• what is colliding?
• what will collide?
Collision Handling
Consists of two steps:
• collision detection:
• what has collided?
• what is colliding?
• what will collide?
• collision response: what to do about it?
Collision Handling
Consists of two steps:
• collision detection:
• what has collided?
• what is colliding?
• what will collide?
• collision response: what to do about it?
Completely different problems and methods
Collision Detection Taxonomy
Discrete: are objects colliding right now?
• check every frame
Issues:
• penetration artifacts
Discrete: are objects colliding right now?
• check every frame
Issues:
• penetration artifacts
• tunneling
Collision Detection Taxonomy
Collision Detection Taxonomy
Discrete: are objects colliding right now?
• check every frame
Continuous-time collision detection (CTCD): when will the next collision occur?
Collision Detection Taxonomy
Discrete: are objects colliding right now?
• check every frame
Continuous-time collision detection (CTCD): when will the next collision occur?
• correct but slow
Collision Detection Taxonomy
Discrete vs continuous-time
Rigid vs deforming objects
• rigid objects allow some precomputation
Collision Detection Taxonomy
Discrete vs continuous-time
Rigid vs deforming objects
• rigid objects allow some precomputation
Collision vs promixity
Broad Phase vs Narrow Phase
Collision detection is O(n^2) problem
Broad Phase vs Narrow Phase
Collision detection is O(n^2) problem
Broad phase: detect collision candidates (hopefully n log n) Narrow phase: check if the candidates actually collide
Broad Phase vs Narrow Phase
Collision detection is O(n^2) problem
Broad phase: detect collision candidates (hopefully n log n) Narrow phase: check if the candidates actually collide In practice: BVH with kDOPs very popular/fast broad phase
Discrete CD for Convex Objects
Do these objects collide?
How can you tell?
Discrete CD for Convex Objects
Algorithm 1: check that all points of one object are outside the other
Discrete CD for Convex Objects
Algorithm 1: check that all points of one object are outside the other
• shoot a random ray, count intersections
• (better method exist based on winding #)
Discrete CD for Convex Objects
Algorithm 2: find a separating axis
Discrete CD for Convex Objects
Algorithm 2: find a separating axis
• for each side of object 1, extent to line
• check all verts on object 2 on correct side
Discrete Collision Detection
What if objects aren’t convex?
Discrete Collision Detection
What if objects aren’t convex?
• compute convex decomposition
• then check collisions between pieces
Discrete Collision Detection
What if objects aren’t convex?
• compute convex decomposition
• far from trivial in 3D…
Discrete Collision Detection
What if you want continuous-time detection?
1. Find separating line/plane
Discrete Collision Detection
What if you want continuous-time detection?
1. Find separating line/plane
2. Calculate earliest time an object hits axis
Discrete Collision Detection
What if you want continuous-time detection?
1. Find separating line/plane
2. Calculate earliest time an object hits axis
• is certificate no earlier collision possible
Discrete Collision Detection
What if you want continuous-time detection?
1. Find separating line/plane
2. Calculate earliest time an object hits axis
3. Try to find new line
Discrete Collision Detection
What if you want continuous-time detection?
1. Find separating line/plane
2. Calculate earliest time an object hits axis
3. Try to find new line
4. Repeat until objects “close enough”
Discrete Collision Detection II
Alternate approach for rigid objects:
• signed distance field
precompute on grid distance to object boundary positive outside, negative inside
Discrete Collision Detection II
Alternate approach for rigid objects:
• signed distance field
precompute on grid distance to object boundary positive outside, negative inside grid moves as object moves query grid to tell if point is inside
Discrete Collision Detection II
Alternate approach for rigid objects:
• signed distance field
precompute on grid distance to object boundary positive outside, negative inside grid moves as object moves query grid to tell if point is inside also useful for computing response
Discrete Collision Detection III
What about deformable objects?
Discrete Collision Detection III
What about deformable objects?
Objects intersect if and only if some triangle pair intersects… so check all pairs
(Hopeless without a broad phase)
Continuous Collision Detection
Let’s start with the easiest case…
Continuous Collision Detection
Let’s start with the easiest case…
find when point hits infinite line
Continuous Collision Detection
Let’s start with the easiest case…
find when point hits infinite line
Continuous Collision Detection
Let’s start with the easiest case…
find when point hits infinite line
wait, two roots?
Continuous Collision Detection
Let’s start with the easiest case…
find when point hits infinite line
wait, two roots?
Continuous Collision Detection
Let’s start with the easiest case…
find when point hits infinite line
for each positive root, check if point inside segment
Continuous Collision Detection
Let’s start with the easiest case…
find when point hits infinite line
for each positive root, check if point inside segment
Continuous Collision Detection
Let’s start with the easiest case…
This algorithm has at least 4 bugs
find when point hits infinite line
for each positive root, check if point inside segment
Continuous Collision Detection
Bug #1:
Continuous Collision Detection
Bug #1:
Bug #2:
Continuous Collision Detection
Bug #1:
Bug #2:
becomes zero when segment collapses
Continuous Collision Detection
Bug #3:
problem:
Continuous Collision Detection
Bug #3:
problem:
just check A = 0 and handle specially, right?
Continuous Collision Detection
Bug #4:
has a collision occurred?
Continuous Collision Detection
for each vertex v of O1:
for each edge e of O2:
CTCD(e, v)
Continuous Collision Detection
for each vertex v of O1:
for each edge e of O2:
CTCD(e, v)
for each vertex v of O2:
for each edge e of O1:
CTCD(e, v)
CTCD is still Buggy
thermal exhaust port
CTCD is still Buggy
thermal exhaust port
(literal) corner case causes collisions to (literally) slip through the cracks
Continuous Collision Detection
for each vertex v of O1:
for each edge e of O2:
CTCD(e, v)
for each vertex v of O2:
for each edge e of O1:
CTCD(e, v)
for each vertex v1 of O1:
for each vertex v2 of O2:
CTCD(v1, v2)
Do Any of These Cases Matter?
Bug #1:
Bug #2:
“zero-probability events”
Do Any of These Cases Matter?
Bug #1:
Bug #2:
“zero-probability events”
Harmon’s Law
When dealing with collisions, “zero-probability events” will occur
100% of the time
Harmon’s Law
CTCD in 3D
Triangle-triangle collision can be decomposed into two types of checks:
Vertex-Face
1. Find when vertex and triangle coplanar
2. Check barycentric coords of vertex
Vertex-Face
1. Find when vertex and triangle coplanar
2. Check barycentric coords of vertex
cubic equation
1. Find when edges coplanar
2. Check barycentric coords of intersection
Edge-Edge
1. Find when edges coplanar
2. Check barycentric coords of intersection
Classic problem: parallel edges
Edge-Edge
CTCD in 3D
For each pair of triangles:
• 6 vertex-face tests
• 9 edge-edge tests
CTCD in 3D
For each pair of triangles:
• 6 vertex-face tests
• 9 edge-edge tests
Also needed for robustness:
• 18 vertex-edge tests
• 9 vertex-vertex tests
Solving These Polynomials
Must find all the roots
• missed roots -> missed collisions
Solving These Polynomials
Must find all the roots
• missed roots -> missed collisions
“Cubic formula” exists but not robust
Best practical code: Jenkins-Traub method
• can find FORTRAN code online
Collision Response
Once collision detected, how to prevent it?
Guiding principles:
• conservation of momentum
• conservation of energy
Collision Response
Once collision detected, how to prevent it?
Guiding principles:
• conservation of momentum
• conservation of energy
Other concerns: friction
Importance of Friction
Key ingredient of spin / “English”
Obviously essential to stable stacking
Collision Response
Once collision detected, how to prevent it?
Guiding principles:
• conservation of momentum
• conservation of energy
Other concerns: friction coefficient of restitution
Coefficient of Restitution
Ratio
Measures dissipation due to heat, sound, vibrations etc
Coefficient of Restitution
Ratio
Measures dissipation due to heat, sound, vibrations etc
Perfectly elastic collision: CoR = 1
Perfectly inelastic collision: CoR = 0
Collision Response
Once collision detected, how to prevent it?
Two main approaches:
• penalty method: push apart over time
• impulse method: stop animation and correct velocities instantly
Main idea: insert springs that push objects apart over time
Spring endpoints connect to closest pair of points on the two objects
Penalty Method
Penalty Method
Pros:
• easy to code
• great for gentle, persistent contact
Cons:
• must pick stiffness of springs:
• too soft objects visibly penetrate
• too hard very expensive (blows up)
Impulse Method
Freeze at time of collision
Change the velocities so collision prevented
• change in velocity called impulse
Impulse Method
Freeze at time of collision
Change the velocities so collision prevented
• change in velocity called impulse
Rigid billiard model: apply equal and opposite impulses along contact normal
Impulse Method
Pros:
• stops collisions before they occur
• friction and CoR easy(ier) to include
Cons:
• Zeno issues
Zeno Paradoxes
Infinite steps in finite time
Zeno Paradoxes
Infinite steps in finite time
Zeno Paradoxes
Infinite steps in finite time
Zeno Paradoxes
Infinite steps in finite time
Zeno Paradoxes
Infinite steps in finite time
Zeno Paradoxes
Infinite steps in finite time
Zeno Paradoxes
Infinite steps in finite time
• might need infinite impulses per frame
Zeno Paradoxes
Infinite steps in finite time
• might need infinite impulses per frame
Also arises when CoR < 1
• inelastic collapse phenomena
Other Issues
Rigid object assumption is suspect
Other Issues
Rigid object assumption is suspect
Collisions involving multiple objects
• pool breaks, stacks of blocks, etc
[IncredibleScience]
[Stéphane Dorbolo]
Other Issues
Rigid object assumption is suspect
Collisions involving multiple objects
• pool breaks, stacks of blocks, etc
Friction handling is extremely complex
• paradoxes abound
Even physicists don’t fully understand some phenomena…