Iterative Dynamics with Temporal Coherence Erin Catto - - PowerPoint PPT Presentation

iterative dynamics with temporal coherence
SMART_READER_LITE
LIVE PREVIEW

Iterative Dynamics with Temporal Coherence Erin Catto - - PowerPoint PPT Presentation

Iterative Dynamics with Temporal Coherence Erin Catto ecatto@crystald.com Crystal Dynamics Menlo Park, California Game Developers Conference, 2005 Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 1 / 15 Introduction The Problem


slide-1
SLIDE 1

Iterative Dynamics with Temporal Coherence

Erin Catto ecatto@crystald.com

Crystal Dynamics Menlo Park, California

Game Developers Conference, 2005

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 1 / 15

slide-2
SLIDE 2

Introduction

The Problem

Many rigid body physics algorithms are slow, use too much memory, are difficult to implement, or have other nasty limitations.

The Idea

Use an approximate contact model that is easy to solve. Use a sloppy but fast constraint solver. Clean up the solution over several frames.

The Toolkit

Contact point calculator. Rigid bodies, constraints, and Jacobians. Gauss-Seidel constraint solver and simple integrator. Contact cache.

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 2 / 15

slide-3
SLIDE 3

High Level Algorithm

Time Stepping

1

Generate contact points.

2

Initialize contact forces λ using a contact cache (generated in the previous step).

3

Compute the Jacobian J for non-penetration and friction constraints.

4

Form an equation for λ.

5

Use a Gauss-Seidel solver to refine λ.

6

Compute new velocities v and ω using λ.

7

Compute new positions x and q from v and ω.

8

Store λ in the contact cache.

9

Go to step 1.

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 3 / 15

slide-4
SLIDE 4

Constraints

Pairwise position constraint C(xi, qi, xj, qj) = 0 Velocity constraint and Jacobian dC dt = JV

The Recipe

1

Determine each constraint equation as a function of body positions and rotations.

2

Differentiate the constraint equation with respect to time.

3

Identify the coefficient matrix of V. This matrix is J.

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 4 / 15

slide-5
SLIDE 5

Contact Constraint

n1 x1 x2 r2 r1

Normal constraint Cn = (x2 + r2 − x1 − r1) · n1 dCn dt = (v2 + ω2 × r2 − v1 − ω1 × r1) · n1 Friction constraint dCu1 dt = (v2 + ω2 × r2 − v1 − ω1 × r1) · u1 dCu2 dt = (v2 + ω2 × r2 − v1 − ω1 × r1) · u2

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 5 / 15

slide-6
SLIDE 6

Equations of Motion

Kinematics dx dt = v dq dt = 1 2q ∗ ω Newton’s Law for a system of constrained rigid bodies M dV dt = JTλ + Fext JV = ζ

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 6 / 15

slide-7
SLIDE 7

Time Stepping

Approximate acceleration dV dt ≈ V 2 − V 1 ∆t Eliminate V 2 JBλ = η where B = M−1JT and η = 1 ∆t ζ − J( 1 ∆t V 1 + M−1Fext)

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 7 / 15

slide-8
SLIDE 8

Constraint Forces

Contact and friction are simulated by bounding λ. Normal force: 0 ≤ λn < ∞ Approximate friction model: −µmcg ≤ λu1 ≤ µmcg −µmcg ≤ λu2 ≤ µmcg In general: λ−

i ≤ λi ≤ λ+ i

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 8 / 15

slide-9
SLIDE 9

Gauss-Seidel

An iterative method for solving linear equations. The basic algorithm: approximately solve Ax = b given x0. Iterate for a fixed number of steps. x = x0 for iter = 1 to iteration limit do for i = 1 to n do ∆xi =

  • bi − n

j=1 Aijxj

  • /Aii

xi = xi + ∆xi end for end for

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 9 / 15

slide-10
SLIDE 10

Projected Gauss-Seidel

Solve JBλ = η given λ0. Clamp λi to its bounds. Use sparsity to avoid forming the s-by-s matrix JB. See the paper for details. The Jacobian J is sparse because constraints are pairwise. Jsp =    J11 J12 . . . . . . Js1 Js2    Jmap =    b11 b12 . . . . . . bs1 bs2   

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 10 / 15

slide-11
SLIDE 11

Temporal Coherence

Why?

When things move fast, sloppiness is okay. When things settle down, jiggle looks bad. Gauss-Seidel is iterative. It needs a good starting guess to be accurate.

Issues

Contact points appear and disappear. How can contact points persist? There is too much stuff to keep track of (n2 pairs).

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 11 / 15

slide-12
SLIDE 12

Contact Caching

The Idea

Build a contact cache at the end of each time step. Rediscover all the contact points at the beginning of the next time step. Try to match the the new points to the cached points. If there is a cache hit then λ = λcache, else λ = 0.

Matching Points

1

Compare global coordinates of the points

2

Compare local coordinates of the points.

3

Compare contact identifiers.

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 12 / 15

slide-13
SLIDE 13

Contact Identifiers

Typical contact configuration:

n1 Box 2 Box 1

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 13 / 15

slide-14
SLIDE 14

Edge Labels

Clipping leads to contact identifiers.

e1,1 e1,2 e1,3 e1,4 e2,1 p(1,4)(2,1) p(1,3)(1,4) p(2,2)(1,3) p(2,1)(2,2) e2,2 e2,3 e2,4

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 14 / 15

slide-15
SLIDE 15

Box Stacking

Without Caching With Caching

Erin Catto (Crystal Dynamics) Iterative Dynamics GDC 2005 15 / 15