112
Physics for Games Physics for Games Programmers Programmers Reframing the Reframing the Problem Problem Squirrel Eiserloh Technical Director MumboJumbo Games [email protected] www.algds.org

Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games [email protected] [email protected]

Embed Size (px)

Citation preview

Page 1: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

Physics for Games Physics for Games Programmers Programmers Reframing the Reframing the

ProblemProblem

Squirrel Eiserloh

Technical DirectorMumboJumbo Games

[email protected]

Page 2: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

Physics for Games Physics for Games Programmers Programmers Reframing the Reframing the

ProblemProblema.k.a. “It’s All Relative”a.k.a. “It’s All Relative”

Squirrel Eiserloh

Technical DirectorMumboJumbo Games

[email protected]

Page 3: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

3

Overview

Tunneling Movement Bounds Swept Shapes Einstein Says... Minkowski Says... Rotation

Page 4: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

Tunneling(Sucks)

Page 5: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

5

Tunneling

Question #1: Do objects A and B overlap?

Plenty of reference material to help solve this, but...

...this is often the wrong question to ask (begs tunneling).

Page 6: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

6

Tunneling

Page 7: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

7

Tunneling

Page 8: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

8

Tunneling

Page 9: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

9

Tunneling

Page 10: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

10

Tunneling (cont’d)

Tunneling is very, very bad – this is not a “mundane detail” Things falling through world Bullets passing through people or walls Players getting places they shouldn’t Players missing a trigger boundary

Tunneling is a false negative Okay, so tunneling really sucks.

What can we do about it?

Page 11: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

Movement Bounds

Page 12: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

12

Movement Bounds

Disc / Sphere

Page 13: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

13

Movement Bounds

Disc / Sphere

AABB (Axis-Aligned Bounding Box)

Page 14: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

14

Movement Bounds

Disc / Sphere

AABB (Axis-Aligned Bounding Box)

OBB (Oriented Bounding Box)

Page 15: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

15

Movement Bounds

Question #2: Could A and B have collided during the frame?

Better than Question #1 (solves tunneling!), but...

Page 16: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

16

Movement Bounds

Question #2: Could A and B have collided during the frame?

Better than Question #1 (solves tunneling!), but...

...even if the answer is “yes”, we still don’t know for sure (false positive).

Page 17: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

17

Movement Bounds

Conclusion Good: They prevent tunneling! (i.e. no

false negatives)

Bad: They don’t actually tell us whether A and B collided (still have false positives).

Good: They can be used as a cheap, effective early rejection test.

Page 18: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

Swept Shapes

Page 19: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

19

Swept Shapes

Swept disc / sphere (n-sphere): capsule

Page 20: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

20

Swept Shapes

Swept disc / sphere (n-sphere): capsule

Swept AABB: convex polytope (polygon in 2d, polyhedron in 3d)

Page 21: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

21

Swept Shapes

Swept disc / sphere (n-sphere): capsule

Swept AABB: convex polytope (polygon in 2d, polyhedron in 3d)

Swept triangle / tetrahedron (simplex): convex polytope

Page 22: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

22

Swept Shapes

Swept disc / sphere (n-sphere): capsule

Swept AABB: convex polytope (polygon in 2d, polyhedron in 3d)

Swept triangle / tetrahedron (simplex): convex polytope

Swept polytope: convex polytope

Page 23: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

23

Swept Shapes (cont’d)

Like movement bounds, only with a perfect fit!

Page 24: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

24

Swept Shapes (cont’d)

Like movement bounds, only with a perfect fit!

Still no false negatives (tunneling).

Page 25: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

25

Swept Shapes (cont’d)

Like movement bounds, only with a perfect fit!

Still no false negatives (tunneling).

Finally, no false positives, either!

Page 26: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

26

Swept Shapes (cont’d)

Like movement bounds, only with a perfect fit!

Still no false negatives (tunneling).

Finally, no false positives, either!

No, wait, nevermind. Still have ‘em. Rats.

Page 27: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

27

Swept Shapes (cont’d)

Like movement bounds, only with a perfect fit!

Still no false negatives (tunneling).

Finally, no false positives, either!

No, wait, nevermind. Still have ‘em. Rats.

Page 28: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

28

Swept Shapes (cont’d)

Like movement bounds, only with a perfect fit!

Still no false negatives (tunneling).

Finally, no false positives, either!

No, wait, nevermind. Still have ‘em. Rats.

Page 29: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

29

Swept Shapes (cont’d)

Conclusion Suck? Can be used as early rejection test, but... ...movement bounds are better for that. If you’re not too picky... ...they DO solve a large number of nasty

problems (especially tunneling) ...and can serve as a poor man’s

continuous collision detection for a basic engine.

Page 30: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

30

Page 31: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

31

Einstein Says...

Coordinate systems are relative

Page 32: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

Relative Coordinate Systems

Page 33: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

33

Relative Coordinate Systems

World coordinates

Page 34: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

34

Relative Coordinate Systems

World coordinates A’s local

coordinates

Page 35: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

35

Relative Coordinate Systems

World coordinates A’s local

coordinates B’s local

coordinates

Page 36: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

36

Relative Coordinate Systems

World coordinates A’s local

coordinates B’s local

coordinates Many others (e.g.

origin at point of impact)

Page 37: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

37

Relative Coordinate Systems (cont’d)

Ball vs. world...

Page 38: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

38

Relative Coordinate Systems (cont’d)

Ball vs. world... in world

coordinates

Page 39: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

39

Relative Coordinate Systems (cont’d)

Ball vs. world... in world

coordinates x component y component

Page 40: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

40

Relative Coordinate Systems (cont’d)

Ball vs. world... in world

coordinates x component y component

in impact coordinates

Page 41: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

41

Relative Coordinate Systems (cont’d)

Ball vs. world... in world

coordinates x component y component

in impact coordinates parallel component perpendicular

component

Page 42: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

42

Relative Coordinate Systems (cont’d)

Ball vs. world... in world coordinates

x component y component

in impact coordinates parallel component perpendicular

component Change in motion

happens along the perpendicular axis

Page 43: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

43

Relative Coordinate Systems (cont’d)

Ball vs. ball...

Page 44: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

44

Relative Coordinate Systems (cont’d)

Ball vs. ball... in world

coordinates

Page 45: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

45

Relative Coordinate Systems (cont’d)

Ball vs. ball... in world

coordinates x component y component

Page 46: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

46

Relative Coordinate Systems (cont’d)

Ball vs. ball... in world

coordinates x component y component

in impact coordinates

Page 47: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

47

Relative Coordinate Systems (cont’d)

Ball vs. ball... in world coordinates

x component y component

in impact coordinates parallel component perpendicular

component Energy is exchanged

along the perpendicular axis

Page 48: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

48

Relative Coordinate Systems (cont’d)

x2 + y2 = r2x2 - 2xh + h2 + y2 - 2yk + k2 = r2

Also, math is often nicer at the origin.

Page 49: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

49

Einstein Says...

Coordinate systems are relative Motion is relative

Page 50: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

Relative Motion

Page 51: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

51

Relative Motion

"Frames of Reference"

World frame

Page 52: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

52

Relative Motion

"Frames of Reference"

World frame A's frame

Page 53: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

53

Relative Motion

"Frames of Reference"

World frame A's frame B's frame

Page 54: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

54

Relative Motion

"Frames of Reference"

World frame A's frame B's frame Inertial frame

Page 55: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

55

Relative Motion (cont’d)

A Rule of Relativistic Collision Detection:

It is always possible to reduce a collision check between two moving objects to a collision check between a moving object and a stationary object (by reframing)

Page 56: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

56

(Does Not Suck)

Page 57: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

Relative Collision Bodies

Page 58: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

58

Relative Collision Bodies

Collision check equivalencies (disc)

Page 59: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

59

Relative Collision Bodies

Collision check equivalencies (disc)

...AABB

Page 60: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

60

Relative Collision Bodies

Collision check equivalencies (disc)

...AABB Can even reduce

one body to a singularity

Page 61: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

61

Relative Collision Bodies

Collision check equivalencies (disc)

...AABB Can even reduce

one body to a singularity

“Tracing” or “Rubbing” collision bodies together

Page 62: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

62

Relative Collision Bodies

Collision check equivalencies (disc)

...AABB Can even reduce one

body to a singularity “Tracing” or

“Rubbing” collision bodies together

Spirograph-out the reduced body’s origin

Page 63: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

63

Relative Collision Bodies

Collision check equivalencies (disc)

...AABB Can even reduce one

body to a singularity “Tracing” or

“Rubbing” collision bodies together

Spirograph-out the reduced body’s origin

Page 64: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

64

Relative Collision Bodies

Collision check equivalencies (disc)

...AABB Can even reduce one

body to a singularity “Tracing” or

“Rubbing” collision bodies together

Spirograph-out the reduced body’s origin

Page 65: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

65

Relative Collision Bodies

Collision check equivalencies (disc)

...AABB Can even reduce one

body to a singularity “Tracing” or

“Rubbing” collision bodies together

Spirograph-out the reduced body’s origin

Page 66: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

66

Relative Collision Bodies

Collision check equivalencies (disc)

...AABB Can even reduce one

body to a singularity “Tracing” or

“Rubbing” collision bodies together

Spirograph-out the reduced body’s origin

Page 67: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

67

Relative Collision Bodies

Collision check equivalencies (disc)

...AABB Can even reduce one

body to a singularity “Tracing” or

“Rubbing” collision bodies together

Spirograph-out the reduced body’s origin

Page 68: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

68

Relative Collision Bodies

Collision check equivalencies (disc)

...AABB Can even reduce one

body to a singularity “Tracing” or

“Rubbing” collision bodies together

Spirograph-out the reduced body’s origin

Page 69: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

69

Relative Collision Bodies

Collision check equivalencies (disc)

...AABB Can even reduce one

body to a singularity “Tracing” or

“Rubbing” collision bodies together

Spirograph-out the reduced body’s origin

Page 70: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

70

Relative Collision Bodies (cont’d)

Disc + disc

Page 71: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

71

Relative Collision Bodies (cont’d)

Disc + disc AABB + AABB

Page 72: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

72

Relative Collision Bodies (cont’d)

Disc + disc AABB + AABB Triangle + AABB

Page 73: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

73

Relative Collision Bodies (cont’d)

Disc + disc AABB + AABB Triangle + AABB AABB + triangle

Page 74: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

74

Relative Collision Bodies (cont’d)

Disc + disc AABB + AABB Triangle + AABB AABB + triangle Polytope +

polytope

Page 75: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

75

Relative Collision Bodies (cont’d)

Disc + disc AABB + AABB Triangle + AABB AABB + triangle Polytope +

polytope Polytope + disc

Page 76: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

76

Relative Collision Bodies (cont’d)

Things start to get messy when combining bodies explicitly / manually.

(Especially in 3d.) General solution?

Page 77: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

Minkowski Arithmetic

Page 78: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

78

Minkowski Sums

The Minkowski Sum (A+B) of A and B is the result of adding every point in A to every point in B.

Page 79: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

79

Minkowski Differences

The Minkowski Difference (A-B) of A and B is the result of subtracting every point in B from every point in A (or A + -B)

Page 80: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

80

Minkowski Differences

The Minkowski Difference (A-B) of A and B is the result of subtracting every point in B from every point in A

Resulting shape is different from A+B.

Page 81: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

81

Minkowski Differences (cont’d)

Minkowski Differences are not commutative:A-B != B-A

Minkowski Difference of convex objects is convex (since A-B = A+ -B)

Page 82: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

82

Minkowski Differences (cont’d)

Minkowski Differences are not commutative:A-B != B-A

Minkowski Difference of convex objects is convex (since A-B = A+ -B)

Minkowski Difference produces the same shape as “Spirograph”

Page 83: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

83

Minkowski Differences (cont’d)

If the singularity is outside the combined body, A and B do not overlap.

Page 84: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

84

Minkowski Differences (cont’d)

If the singularity is outside the combined body, A and B do not overlap.

If the singularity is inside the combined body (A-B), then A and B overlap.

Page 85: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

85

Minkowski Differences (cont’d)

In world space, A-B is “near” the origin

Page 86: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

86

Minkowski Differences (cont’d)

Aorigin vs. Borigin

-Borigin -Borigin

___ ___(A-B)origin vs. 0

Page 87: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

87

Minkowski Differences (cont’d)

Since the singularity point is always at the origin (B-B), we can say...

If (A-B) does not contain the origin, A and B do not overlap.

Page 88: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

88

Minkowski Differences (cont’d)

If (A-B) contains the origin, A and B overlap.

In other words, we reduce A vs. B to:

combined body (A-B) vs.point (B-B, or origin)

Page 89: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

89

Minkowski Differences (cont’d)

If A and B are in the same coordinate system, the comparison between A-B and the origin is said to happen in configuration space

...in which case A-B is said to be a configuration space obstacle (CSO)

Page 90: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

90

Minkowski Differences (cont’d)

Translations in A or B simply translate the CSO

Page 91: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

91

Minkowski Differences (cont’d)

Rotations in A or B mutate the CSO

Page 92: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

92

(Does Not Suck)

Page 93: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

Relative Everything

Page 94: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

94

Relative Everything

Let’s combine: Relative Coordinate Systems Relative Motion Relative Collision Bodies

Page 95: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

95

Relative Everything (cont’d)

A vs. B in world frame

Page 96: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

96

Relative Everything (cont’d)

A vs. B in world frame

A is CSO, B is point

Page 97: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

97

Relative Everything (cont’d)

A vs. B in world frame

A is CSO, B is point A is moving CSO, B

is still point

Page 98: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

98

Relative Everything (cont’d)

A vs. B in world frame

A is CSO, B is point A is moving CSO, B

is still point A is still CSO, B is

moving point This is the one we

want!

Page 99: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

99

Relative Everything (cont’d)

Question #3: Did A and B collide during the frame? Yes! We can now

get an exact answer.

No false negatives, no false positives!

However, we still don’t know WHEN they collided...

Page 100: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

100

Relative Everything (cont’d)

Why does the exact collision time matter? Outcomes can be

different Order of events (e.g.

multiple collisions) is relevant

Collision response is easier when you can reconstruct the exact moment of impact

Page 101: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

101

Relative Everything (cont’d)

Question #4: When, during the frame, did A and B collide? The time at which

the ray intersects the CSO is the time at which the collision occurred.

Finally, the right question - and we have a complete answer!

Page 102: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

102

Relative Everything (cont’d)

The Minkowski Difference (A-B) / CSO can also be thought of as “the set of all translations [from the origin] that would cause a collision”.

A.K.A. the set of “inadmissible translations”.

Page 103: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

Quality vs. Quantity

or

“You Get What You Pay For”

Page 104: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

104

Quality vs. Quantity

The more you ask, the more you pay. Question #1: Do A and B overlap? Question #2: Could A and B have

collided during the frame? Question #3: Did A and B collide

during the frame? Question #4: When, during the

frame, did A and B collide?

Page 105: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

Rotations(Suck)

Page 106: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

106

Rotations

Continuous rotational collision detection sucks

Rotational tunneling alone is problematic

Page 107: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

107

Rotations

Continuous rotational collision detection sucks

Rotational tunneling alone is problematic

Methods we’ve discussed here often don’t work on rotations, or their rotational analogue is quite complex

Page 108: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

108

Rotations (cont’d)

However: Rotational tunneling is usually not as

jarring as translational tunneling Rotational speed limits are actually

feasible Can do linear approximations of swept

rotations Can use bounding shapes to contain pre-

and post-rotated positions This is something that many engines

never solve robustly

Page 109: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

Summary

Page 110: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

110

Summary Have to worry about false negatives

(tunneling!) as well as false positives. Knowing when a collision event took

place can be very important (especially when resolving it).

Sometimes a problem (and math) looks easier when we look at it from a different viewpoint.

Can combine bodies in cheaty ways to simplify things even further.

Page 111: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

111

Summary (cont’d)

Einstein and Minkowski are cool. Rotations suck. Doing real-time collision detection

doesn’t have to be hard. Or expensive. Or confusing.

Page 112: Physics for Games Programmers Reframing the Problem Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net  squirrel@eiserloh.net

112

Questions?

Feel free to reach me by email at:

[email protected]