01 GDC08 Eiserloh Squirrel Physics Overview
-
Upload
carloslarico9950 -
Category
Documents
-
view
219 -
download
0
Transcript of 01 GDC08 Eiserloh Squirrel Physics Overview
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
1/96
1
Physics for Games ProgrammersProblem Overview
Squirrel Eiserloh
Technical DirectorMumboJumbo Games
mailto:[email protected]://www.algds.org/http://www.algds.org/mailto:[email protected] -
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
2/96
2
Types of Problems
Knowing when to cheat
Simplifying things
Giving shape to things
Moving things around Simulation baggage
Detecting (and resolving) collisions
Sustained interactions Dealing with the impossible
Making it fast enough
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
3/96
3
Knowing When To Cheat
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
4/96
4
Knowing When to Cheat
Discrete physics simulation fallsembarrassingly short of reality.
Real physics is prohibitively expensive...
...so we cheat. We need to cheat enough to be able to
run in real time.
We need to not cheat so much that things
break in a jarring and unrecoverable way. Much of the challenge is knowing how and
when to cheat.
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
5/96
5
Knowing When to Cheat
Ask:
Will the player notice?
Will the player care?
Will the results be predictable?
Are we at least cheating in a consistent way?
Will the simulation break? If the simulation breaks, they will notice and theywill care
Some crimes are greater than others
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
6/96
6
Simplifying Things
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
7/96
7
Simplifying Things
Simplified bodies
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
8/96
8
Simplifying Things
Simplified bodies
Even more simplifiedbodies
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
9/96
9
Simplifying Things
Simplified bodies
Even more simplifiedbodies
Convex bodies
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
10/96
10
Simplifying Things
Simplified bodies
Even more simplifiedbodies
Convex bodies
Homogeneous bodies
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
11/96
11
Simplifying Things
Simplified bodies
Even more simplifiedbodies
Convex bodies
Homogeneous bodies
Rigid bodies
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
12/96
12
Simplifying Things
Simplified bodies
Even more simplifiedbodies
Convex bodies
Homogeneous bodies
Rigid bodies
Indestructible bodies
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
13/96
13
Simplifying Things
Movement is oftenassumed to be in avacuum (ignoring air
resistance)
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
14/96
14
Simplifying Things
Movement is oftenassumed to be in avacuum (ignoring air
resistance)
Even when airresistance doesget
simulated, it is hugelyoversimplified
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
15/96
15
Simplifying Things
Collisions are oftenassumed to be perfectand elastic
That is, 100% of theenergy before thecollision is maintained
after the collision
Think billiard balls
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
16/96
16
Giving Shape to Things
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
17/96
17
Giving Shape to Things
N-sphere
2d: Disc
3d: Sphere
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
18/96
18
Giving Shape to Things
N-sphere
2d: Disc
3d: Sphere
Simplex
2d: Triangle
3d: Tetrahedron
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
19/96
19
Giving Shape to Things
N-sphere
2d: Disc
3d: Sphere
Simplex
2d: Triangle
3d: Tetrahedron
Convex Polytope
2d: Convex Polygon
3d: Convex Polyhedron
a.k.a. Convex Hull
a.k.a. Brush (Quake)
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
20/96
20
Giving Shape to Things
Discrete OrientedPolytope (DOP)
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
21/96
21
Giving Shape to Things
Discrete OrientedPolytope (DOP)
Oriented BoundingBox (OBB)
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
22/96
22
Giving Shape to Things
Discrete OrientedPolytope (DOP)
Oriented BoundingBox (OBB)
Axis-Aligned BoundingBox (AABB)
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
23/96
23
Giving Shape to Things
Discrete OrientedPolytope (DOP)
Oriented BoundingBox (OBB)
Axis-Aligned BoundingBox (AABB)
Capsule
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
24/96
24
Giving Shape to Things
Discrete OrientedPolytope (DOP)
Oriented BoundingBox (OBB)
Axis-Aligned BoundingBox (AABB)
Capsule
Cylinder (3d only)
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
25/96
25
Moving Things Around
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
26/96
26
Moving Things Around Kinematics
Describesmotion
Uses position, velocity,momentum,
acceleration
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
27/96
27
Moving Things Around Kinematics
Describesmotion
Uses position, velocity,momentum,
acceleration Dynamics
Explainsmotion
Uses forces
...and impulses
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
28/96
28
Moving Things Around Kinematics
Describesmotion
Uses position, velocity,momentum,
acceleration Dynamics
Explainsmotion
Forces (F=ma)
Impulses
Rotation
Torque
Angular momentum
Moment of inertia
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
29/96
29
Moving Things Around
How to compute thenext position andvelocity from current
position and velocity? This process is called
integration;
An algorithm for doing
this in an integrator
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
30/96
30
Moving Things Around
How to compute thenext position andvelocity from current
position and velocity? This process is called
integration;
An algorithm for doing
this in an integrator
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
31/96
31
Moving Things Around
How to compute thenext position andvelocity from current
position and velocity? This process is called
integration;
An algorithm for doing
this in an integrator
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
32/96
32
Moving Things Around
How to compute thenext position andvelocity from current
position and velocity? This process is called
integration;
An algorithm for doing
this in an integrator
33
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
33/96
33
Moving Things Around
How to compute thenext position andvelocity from current
position and velocity? This process is called
integration;
An algorithm for doing
this in an integrator
34
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
34/96
34
Moving Things Around
How to compute thenext position andvelocity from current
position and velocity? This process is called
integration;
An algorithm for doing
this in an integrator Which integration
method to use?
35
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
35/96
35
Moving Things Around
How to compute thenext position andvelocity from current
position and velocity? This process is called
integration;
An algorithm for doing
this in an integrator Which integration
method to use?
36
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
36/96
36
Moving Things Around
How to compute thenext position andvelocity from current
position and velocity? This process is called
integration;
An algorithm for doing
this in an integrator Which integration
method to use?
37
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
37/96
37
Moving Things Around
How to compute thenext position andvelocity from current
position and velocity? This process is called
integration;
An algorithm for doing
this in an integrator Which integration
method to use?
38
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
38/96
38
Moving Things Around
How to compute thenext position andvelocity from current
position and velocity? This process is called
integration;
An algorithm for doing
this in an integrator Which integration
method to use?
39
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
39/96
39
Simulation Baggage
40
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
40/96
40
Simulation Baggage
Flipbook syndrome
41
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
41/96
41
Simulation Baggage
Flipbook syndrome
Things can happenin-between snapshots
42
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
42/96
42
Simulation Baggage
Flipbook syndrome
Things mostlyhappenin-between snapshots
43
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
43/96
43
Simulation Baggage
Flipbook syndrome
Things mostlyhappenin-between snapshots
Curved trajectoriestreated as piecewiselinear
44
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
44/96
44
Simulation Baggage
Flipbook syndrome
Things mostlyhappenin-between snapshots
Curved trajectoriestreated as piecewiselinear
Terms often assumed
to be constantthroughout the frame
45
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
45/96
45
Simulation Baggage (contd)
Error accumulates
46
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
46/96
46
Simulation Baggage (contd)
Error accumulates
Energy is not alwaysconserved
Energy loss can beundesirable
Energy gain is evil
Simulations explode!
47
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
47/96
47
Simulation Baggage (contd)
Error accumulates
Energy is not alwaysconserved
Energy loss can beundesirable
Energy gain is evil
Simulations explode!
Rotations are often
assumed to happeninstantaneously atframe boundaries
48
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
48/96
Simulation Baggage (contd)
Error accumulates
Energy is not alwaysconserved
Energy loss can beundesirable
Energy gain is evil
Simulations explode!
Rotations are often
assumed to happeninstantaneously atframe boundaries
Numerical nightmares!
49
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
49/96
Collision Detection
50
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
50/96
Collision Detection
We need to determineifAand B intersect
51
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
51/96
Collision Detection
We need to determineif A and B intersect
Worse yet, they could
be (and probably are)in motion
52
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
52/96
Collision Detection
We need to determineif A and B intersect
Worse yet, they could
be (and probably are)in motion
If they did collide, weprobably also need to
know when theycollided
53
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
53/96
Collision Response
...and we need tofigure out how toresolve the collision
54
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
54/96
Sustained Interactions
55
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
55/96
Sustained Interactions
Surface contact
56
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
56/96
Sustained Interactions
Surface contact
Edge contact
57
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
57/96
Sustained Interactions
Surface contact
Edge contact
Contact points
Different solutions
58
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
58/96
Sustained Interactions
Surface contact
Edge contact
Contact points
Different solutions
59
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
59/96
Sustained Interactions
Surface contact
Edge contact
Contact points
Different solutions
Stacking
60
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
60/96
Sustained Interactions
Surface contact
Edge contact
Contact points
Different solutions
Stacking
Friction
Static & Kinetic
61
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
61/96
Sustained Interactions
Surface contact
Edge contact
Contact points
Different solutions
Stacking
Friction
Static & Kinetic
Constraints & Joints
62
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
62/96
Dealing With the Impossible
63
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
63/96
Dealing With the Impossible
Interpenetration
64
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
64/96
Dealing With the Impossible
Interpenetration
Tunneling
65
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
65/96
Dealing With the Impossible
Interpenetration
Tunneling
66
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
66/96
Dealing With the Impossible
Interpenetration
Tunneling
67
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
67/96
Dealing With the Impossible
Interpenetration
Tunneling
68
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
68/96
Tunneling(Sucks)
69
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
69/96
Tunneling
Small objects tunnel more easily
70
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
70/96
Tunneling (contd)
Possible solutions
Minimum size requirement?
Inadequate; fast objects still tunnel
71
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
71/96
Tunneling (contd)
Fast-moving objects tunnel more easily
72
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
72/96
Tunneling (contd)
Possible solutions
Minimum size requirement?
Inadequate; fast objects still tunnel
Maximum speed limit?
Inadequate; since speed limit is a function of objectsize, this would mean small & fast objects (bullets)would not be allowed
Smaller time step? Helpful, but inadequate; this is essentially the same
as a speed limit
73
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
73/96
Tunneling (contd)
Besides, even withmin. size requirementsandspeed limits anda
small timestep, youstill have degeneratecases that causetunneling!
74
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
74/96
Tunneling (contd)
Besides, even withmin. size requirementsandspeed limits anda
small timestep, youstill have degeneratecases that causetunneling!
75
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
75/96
Tunneling (contd)
Besides, even withmin. size requirementsandspeed limits anda
small timestep, youstill have degeneratecases that causetunneling!
76
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
76/96
Tunneling (contd)
Besides, even withmin. size requirementsandspeed limits anda
small timestep, youstill have degeneratecases that causetunneling!
77
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
77/96
Tunneling (contd)
Tunneling is very, very bad this is not amundane detail
Things falling through world
Bullets passing through people or walls
Players getting places they shouldnt
Players missing a trigger boundary
78
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
78/96
Tunneling (contd)
Interpenetration
Tunneling
Rotational tunneling
79
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
79/96
Making It Fast Enough
80
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
80/96
Making It Fast Enough
Dont be too particulartoo soon
Avoid unnecessary
work
81
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
81/96
Making It Fast Enough
Dont be too particulartoo soon
Avoid unnecessary
work Eschew n-squared
operations
Avoid the everythingvs. everything case
82
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
82/96
Making It Fast Enough
Dont be too particulartoo soon
Avoid unnecessary
work Eschew n-squared
operations
Avoid the everythingvs. everything case
Try using simulationislandsand spacepartitioning to divideand conquer
83
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
83/96
Simulation Islands
Consider:
1000 objects, 1 island
1000x1000 checks
= 1 Million checks
84
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
84/96
Simulation Islands
Consider:
1000 objects, 1 island
1000x1000 checks
= 1 Million checks Verses:
1000 objects, dividedinto 10 islands of 100
10 x (100x100) checks
= 100,000 checks
1/10th as many!
85
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
85/96
Simulation Islands
Simulation islands cango to sleep whenthey become stable
i.e. when forces andmotion remainunchanged
86
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
86/96
Simulation Islands
Simulation islands cango to sleep whenthey become stable
i.e. when forces andmotion remainunchanged
87
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
87/96
Simulation Islands
Simulation islands cango to sleep whenthey become stable
i.e. when forces andmotion remainunchanged
When an object entersthe islands bounds...
88
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
88/96
Simulation Islands
Simulation islands cango to sleep whenthey become stable
i.e. when forces andmotion remainunchanged
When an object entersthe islands bounds...
89
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
89/96
Simulation Islands
Simulation islands cango to sleep whenthey become stable
i.e. when forces andmotion remainunchanged
When an object entersthe islands bounds...
...the island wakes up
90
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
90/96
Simulation Islands
Add the newcomer tothis simulation island
91
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
91/96
Simulation Islands
Add the newcomer tothis simulation island
...and put it back to
sleep once it stabilizes
This is just one ofmany ways to reduce
complexity
Well be coveringseveral others later on
92
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
92/96
Making It Fast Enough
Can also exploit work previously done
Make educated assumptions using: Temporal / frame coherence:Things tend not
to have changed a whole lot in the 15ms or sosince the previous frame, so save the previousframes results!
Spatial coherence:Things tend to miss each
other far more often than they collide, andonly things in the same neighborhood cancollide with each other
93
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
93/96
Summary
94
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
94/96
Summary
The nature of simulation causes us realproblems... problems which cant beignored
So we cheatAnd we simplify things
And even then, it can get quite complex...
95
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
95/96
Summary (contd)
Problems were concerned with: How should we choose to represent physical bodies?
How should we simulate and compute motion?
How can we prevent energy build-up?
How do we cope with floating point error? How can we detect collisions especially when large
numbers of objects are involved?
How can we prevent tunneling?
How should we resolve penetration?
How should we handle contact?
How do we deal with non-rigid bodies?
How can we relieve CPU burden?
96
-
8/4/2019 01 GDC08 Eiserloh Squirrel Physics Overview
96/96
Questions?
Feel free to reach me by email at:
mailto:[email protected]:[email protected]