Professional Documents
Culture Documents
GDC2006 Catto Erin PhysicsTutorial
GDC2006 Catto Erin PhysicsTutorial
Sequential Impulses
Erin Catto
Crystal Dynamics
Physics Engine Checklist
m
P
v
P m
Making Impulses not Suck
Accept penetration
Remember the past
Apply impulses early and often
Pursue the true impulse
Update position last
Penetration
Performance
Simplicity
Coherence
Game logic
Fewer cracks
Algorithm Overview
incident
reference
Box-Box Clipping
clipping planes
Clip incident face
against reference face
side planes (but not
the reference face). n
Consider clip points
with positive
penetration.
Feature Flip-Flop
Newton’s Law mv F
Iω ω Iω T
Ignore gyroscopic term for
improved stability
v 2 v1 t m 1F
Use Euler’s rule ω 2 ω1 t I 1T
Impulses
Impulses are applied at each contact point.
Normal impulses to prevent penetration.
Tangent impulses to impose friction.
Pn 0
Pt
t Pt Pn
Pnn
Computing the Impulse
r2
2
n
P
P
1 r1
Linear Momentum
v1 v1 P / m1
The normal impulse ω1 ω1 I11r1 P
causes an instant v 2 v 2 P / m2
change in velocity.
ω 2 ω 2 I 21r2 P
2 v v 2 ω2 r2 v1 ω1 r1
r2 n
Along Normal:
r1
1 vn v n
The Normal Impulse
Want: vn 0 Pn 0
v n
Get: Pn max ,0
kn
Fine Print:
v v 2 ω2 r2 v1 ω1 r1
1 1
kn I11 r1 n r1 I 21 r2 n r2 n
m1 m2
Bias Impulse
n
Bias Factor: 0.1, 0.3
slop
Bias velocity:
vbias max 0, slop
t
Bias Impulse
With bias velocity, this:
v n
Pn max ,0
kn
Becomes:
v n vbias
Pn max ,0
kn
Friction Impulse
Tangent Velocity: vt v t
Want: vt 0 Pn Pt Pn
v t
Get: Pt clamp( , Pn , Pn )
kt
Fine Print:
1 1
kt I11 r1 t r1 I 21 r2 t r2 t
m1 m2
Sequential Impulses
velocity
P1 P2
Where Did We Go Wrong?
P1 P2 P1 P2
The True Impulse
Accumulated impulses:
Pn Pt
Correct Clamping
Normal Clamping: temp Pn
Pn max Pn Pn , 0
Pn Pn temp
Coherence
Feature-based contact points
Joints
Engine layout
Loose ends
3D Issues
Coherence
c1 c2
e3 c2 box 2 edge 3
1 box 2 edge 4
Joints
r1
1
Relative Velocity
P
Linear Momentum
Fine Print:
1 1 1 1
K 1 r I
1 1 1r r2 2 r2
I
m1 m2
Tilde (~) for the cross-product matrix.
K Matrix
M c K 1
Bias Impulse
Center of mass: x
Bias velocity and impulse:
v bias p
t
KP v v bias
Engine Layout
2
n
Arbiter
c1
c2
1
Collision Coherence