32
Contact Manifolds Contact Manifolds Erin Catto Blizzard Entertainment

Contact Manifolds Erin Catto Blizzard Entertainment

Embed Size (px)

Citation preview

Page 1: Contact Manifolds Erin Catto Blizzard Entertainment

Contact ManifoldsContact Manifolds

Erin CattoBlizzard Entertainment

Page 2: Contact Manifolds Erin Catto Blizzard Entertainment

Executive Summary

Constraint solvers need contact points to prevent penetration.

We can use SAT to compute a contact manifold in one shot.

We can use GJK to build up a contact manifold point-by-point.

Page 3: Contact Manifolds Erin Catto Blizzard Entertainment

Contact

Contact occurs when two shapes touch.

We model contact to prevent penetration and to simulate friction.

Modeling contact requires some geometry and a lot of finesse.

Page 4: Contact Manifolds Erin Catto Blizzard Entertainment

Contact Manifolds

For convex polyhedra, a contact manifold is ideally a single point, a line segment, or a convex polygon.

For general convex 3D shapes, the contact manifold is a convex 2D shape.

Did I mention overlap?

Page 5: Contact Manifolds Erin Catto Blizzard Entertainment

Overlap Happens

What we want. What we get.

Page 6: Contact Manifolds Erin Catto Blizzard Entertainment

Approximate Manifolds

We use a collection of contact points to approximate the contact manifold.

Our goal is fast, stable, and plausible simulation.

In this sense, computing good manifolds is an art.

Page 7: Contact Manifolds Erin Catto Blizzard Entertainment

Contact PointsContact Points

Position Normal Penetration Contact ID

n

p

Page 8: Contact Manifolds Erin Catto Blizzard Entertainment

Example Manifold

Two points and a common normal

n

Page 9: Contact Manifolds Erin Catto Blizzard Entertainment

Contact Manifold QualityContact Manifold Quality

When objects penetrate significantly the contact manifold is fuzzy.

Contact solvers like coherence. Be consistent from step-to-step.

Page 10: Contact Manifolds Erin Catto Blizzard Entertainment

Fuzziness

manifold 1 manifold 2 manifold 3

n

n n

Page 11: Contact Manifolds Erin Catto Blizzard Entertainment

Extreme Fuzziness

manifold 1

n

manifold 2

n

Page 12: Contact Manifolds Erin Catto Blizzard Entertainment

Using the SATUsing the SAT

Mainly useful for convex polyhedra (boxes, triangles, etc).

Find the axis of minimum penetration. For edge-edge contact, find the

midpoint. For face contact, use Sutherland-

Hodgeman clipping.

Page 13: Contact Manifolds Erin Catto Blizzard Entertainment

Example: 2D Box-Box SATExample: 2D Box-Box SAT

First find the separating axis with the minimum penetration.

In 2D the separating axis is a face normal.

n

Page 14: Contact Manifolds Erin Catto Blizzard Entertainment

Box-Box Clipping SetupBox-Box Clipping Setup

Identify reference face

Identify incident face

n

incident

reference

Page 15: Contact Manifolds Erin Catto Blizzard Entertainment

Box-Box ClippingBox-Box Clipping

Clip incident face against reference face side planes (but not the reference face).

Consider clip points with positive penetration.

n

clipping planes

Page 16: Contact Manifolds Erin Catto Blizzard Entertainment

Feature Flip-FlopFeature Flip-Flop

Which normal is the min separating axis?

Apply weightings to prefer one axis over another.

Improved coherence.

1n

2n

Page 17: Contact Manifolds Erin Catto Blizzard Entertainment

CoherenceCoherence

Apply old force/impulse solution at the beginning of the step.

Fewer iterations and greater stability.

We need a way to match old and new contacts.

Page 18: Contact Manifolds Erin Catto Blizzard Entertainment

Feature-Based Contact Feature-Based Contact PointsPoints Each contact point is the result of

clipping. It is the junction of two different

edges. An edge may come from either box. Store the two edge numbers with each

contact point – this is the Contact ID.

Page 19: Contact Manifolds Erin Catto Blizzard Entertainment

Contact Point IDsContact Point IDs

1c

box 1 edge 2

box 2 edge 3

2c

box 2 edge 3

box 2 edge 4

1e

4e

3e

2e n

1

2

1c2c

Page 20: Contact Manifolds Erin Catto Blizzard Entertainment

GJK Contact Points

Three cases: - No contact - Shallow contact - Deep contact

Page 21: Contact Manifolds Erin Catto Blizzard Entertainment

GJK Shallow Contact

The support points are scaled up by a small margin to detect contact.

Compute the closest points (no margin).

This gives the position and normal. The penetration is the margin minus

the true distance.

Page 22: Contact Manifolds Erin Catto Blizzard Entertainment

GJK Contact Margins

Core Shape

MarginCore Shape

Page 23: Contact Manifolds Erin Catto Blizzard Entertainment

GJK Contact Point

point

normal

distance

Page 24: Contact Manifolds Erin Catto Blizzard Entertainment

GJK Deep Contact

An awkward encounter …

Page 25: Contact Manifolds Erin Catto Blizzard Entertainment

Deep Contact

Use some other algorithm. It will be slower than GJK, but it

won’t last long. SAT, EPA, brute force. Read Gino’s book to learn EPA.

Page 26: Contact Manifolds Erin Catto Blizzard Entertainment

GJK Manifolds

GJK only gives one contact point at a time.

We hold on to and treasure each contact point.

Build a manifold over several time steps.

This automatically provides coherence.

Page 27: Contact Manifolds Erin Catto Blizzard Entertainment

Building the Manifold

t = 0 t = 1

1p

t = 2

1p 2p

Page 28: Contact Manifolds Erin Catto Blizzard Entertainment

Manifold Persistence

Track the points in each body. If the points move too far apart,

dismiss them. This is bad for sliding. Use Contact IDs?

Page 29: Contact Manifolds Erin Catto Blizzard Entertainment

Adding New Points

Keep a minimal set of points per manifold (e.g. 4 points).

Reject new points that are too close to old points.

Page 30: Contact Manifolds Erin Catto Blizzard Entertainment

Manifold Reduction

This applies to one-shot and incremental manifolds.

We want to keep the minimum number of contact points for a stable simulation.

This improves performance drastically.

Page 31: Contact Manifolds Erin Catto Blizzard Entertainment

Example Reduction

A Table

Before After

Page 32: Contact Manifolds Erin Catto Blizzard Entertainment

Further Reading

http://www.gphysics.com/downloads/ http://www.continuousphysics.com Collision Detection in Interactive 3D

Environments by Gino van den Bergen Fast Contact Reduction for Dynamics

Simulation by Adam Moravanszky and Pierre Terdiman in Game Programming Gems 4.