Physics for Games Programmers
Download
1 / 112

Overview - PowerPoint PPT Presentation


  • 273 Views
  • Uploaded on

Squirrel Eiserloh. Technical Director. MumboJumbo Games. squirrel ... Or confusing. 112. Questions? Feel free to reach me by email at: [email protected] ...

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Overview' - Kelvin_Ajay


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Slide1 l.jpg

Physics for Games Programmers Reframing the Problem

Squirrel EiserlohTechnical DirectorMumboJumbo [email protected]


Slide2 l.jpg

Physics for Games Programmers Reframing the Problema.k.a. “It’s All Relative”

Squirrel EiserlohTechnical DirectorMumboJumbo [email protected]


Overview l.jpg
Overview

  • Tunneling

  • Movement Bounds

  • Swept Shapes

  • Einstein Says...

  • Minkowski Says...

  • Rotation


Tunneling l.jpg

Tunneling

(Sucks)


Tunneling5 l.jpg
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).






Tunneling cont d l.jpg
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?



Movement bounds12 l.jpg
Movement Bounds

  • Disc / Sphere


Movement bounds13 l.jpg
Movement Bounds

  • Disc / Sphere

  • AABB (Axis-Aligned Bounding Box)


Movement bounds14 l.jpg
Movement Bounds

  • Disc / Sphere

  • AABB (Axis-Aligned Bounding Box)

  • OBB (Oriented Bounding Box)


Movement bounds15 l.jpg
Movement Bounds

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

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


Movement bounds16 l.jpg
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).


Movement bounds17 l.jpg
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.



Swept shapes19 l.jpg
Swept Shapes

  • Swept disc / sphere (n-sphere): capsule


Swept shapes20 l.jpg
Swept Shapes

  • Swept disc / sphere (n-sphere): capsule

  • Swept AABB: convexpolytope (polygon in 2d, polyhedron in 3d)


Swept shapes21 l.jpg
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 shapes22 l.jpg
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: convexpolytope


Swept shapes cont d l.jpg
Swept Shapes (cont’d)

  • Like movement bounds, only with a perfect fit!


Swept shapes cont d24 l.jpg
Swept Shapes (cont’d)

  • Like movement bounds, only with a perfect fit!

  • Still no false negatives (tunneling).


Swept shapes cont d25 l.jpg
Swept Shapes (cont’d)

  • Like movement bounds, only with a perfect fit!

  • Still no false negatives (tunneling).

  • Finally, no false positives, either!


Swept shapes cont d26 l.jpg
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.


Swept shapes cont d27 l.jpg
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.


Swept shapes cont d28 l.jpg
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.


Swept shapes cont d29 l.jpg
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.


Einstein says l.jpg
Einstein Says...

  • Coordinate systems are relative



Relative coordinate systems33 l.jpg
Relative Coordinate Systems

  • World coordinates


Relative coordinate systems34 l.jpg
Relative Coordinate Systems

  • World coordinates

  • A’s local coordinates


Relative coordinate systems35 l.jpg
Relative Coordinate Systems

  • World coordinates

  • A’s local coordinates

  • B’s local coordinates


Relative coordinate systems36 l.jpg
Relative Coordinate Systems

  • World coordinates

  • A’s local coordinates

  • B’s local coordinates

  • Many others (e.g. origin at point of impact)


Relative coordinate systems cont d l.jpg
Relative Coordinate Systems (cont’d)

  • Ball vs. world...


Relative coordinate systems cont d38 l.jpg
Relative Coordinate Systems (cont’d)

  • Ball vs. world...

  • in world coordinates


Relative coordinate systems cont d39 l.jpg
Relative Coordinate Systems (cont’d)

  • Ball vs. world...

  • in world coordinates

    • x component

    • y component


Relative coordinate systems cont d40 l.jpg
Relative Coordinate Systems (cont’d)

  • Ball vs. world...

  • in world coordinates

    • x component

    • y component

  • in impact coordinates


Relative coordinate systems cont d41 l.jpg
Relative Coordinate Systems (cont’d)

  • Ball vs. world...

  • in world coordinates

    • x component

    • y component

  • in impact coordinates

    • parallel component

    • perpendicular component


Relative coordinate systems cont d42 l.jpg
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


Relative coordinate systems cont d43 l.jpg
Relative Coordinate Systems (cont’d)

  • Ball vs. ball...


Relative coordinate systems cont d44 l.jpg
Relative Coordinate Systems (cont’d)

  • Ball vs. ball...

  • in world coordinates


Relative coordinate systems cont d45 l.jpg
Relative Coordinate Systems (cont’d)

  • Ball vs. ball...

  • in world coordinates

    • x component

    • y component


Relative coordinate systems cont d46 l.jpg
Relative Coordinate Systems (cont’d)

  • Ball vs. ball...

  • in world coordinates

    • x component

    • y component

  • in impact coordinates


Relative coordinate systems cont d47 l.jpg
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


Relative coordinate systems cont d48 l.jpg
Relative Coordinate Systems (cont’d)

Also, math is often nicer at the origin.

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

x2 + y2 = r2


Einstein says49 l.jpg
Einstein Says...

  • Coordinate systems are relative

  • Motion is relative



Relative motion51 l.jpg
Relative Motion

  • "Frames of Reference"

  • World frame


Relative motion52 l.jpg
Relative Motion

  • "Frames of Reference"

  • World frame

  • A's frame


Relative motion53 l.jpg
Relative Motion

  • "Frames of Reference"

  • World frame

  • A's frame

  • B's frame


Relative motion54 l.jpg
Relative Motion

  • "Frames of Reference"

  • World frame

  • A's frame

  • B's frame

  • Inertial frame


Relative motion cont d l.jpg
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)




Relative collision bodies58 l.jpg
Relative Collision Bodies

  • Collision check equivalencies (disc)


Relative collision bodies59 l.jpg
Relative Collision Bodies

  • Collision check equivalencies (disc)

  • ...AABB


Relative collision bodies60 l.jpg
Relative Collision Bodies

  • Collision check equivalencies (disc)

  • ...AABB

  • Can even reduce one body to a singularity


Relative collision bodies61 l.jpg
Relative Collision Bodies

  • Collision check equivalencies (disc)

  • ...AABB

  • Can even reduce one body to a singularity

  • “Tracing” or “Rubbing” collision bodies together


Relative collision bodies62 l.jpg
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


Relative collision bodies63 l.jpg
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


Relative collision bodies64 l.jpg
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


Relative collision bodies65 l.jpg
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


Relative collision bodies66 l.jpg
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


Relative collision bodies67 l.jpg
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


Relative collision bodies68 l.jpg
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


Relative collision bodies69 l.jpg
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


Relative collision bodies cont d l.jpg
Relative Collision Bodies (cont’d)

  • Disc + disc


Relative collision bodies cont d71 l.jpg
Relative Collision Bodies (cont’d)

  • Disc + disc

  • AABB + AABB


Relative collision bodies cont d72 l.jpg
Relative Collision Bodies (cont’d)

  • Disc + disc

  • AABB + AABB

  • Triangle + AABB


Relative collision bodies cont d73 l.jpg
Relative Collision Bodies (cont’d)

  • Disc + disc

  • AABB + AABB

  • Triangle + AABB

  • AABB + triangle


Relative collision bodies cont d74 l.jpg
Relative Collision Bodies (cont’d)

  • Disc + disc

  • AABB + AABB

  • Triangle + AABB

  • AABB + triangle

  • Polytope + polytope


Relative collision bodies cont d75 l.jpg
Relative Collision Bodies (cont’d)

  • Disc + disc

  • AABB + AABB

  • Triangle + AABB

  • AABB + triangle

  • Polytope + polytope

  • Polytope + disc


Relative collision bodies cont d76 l.jpg
Relative Collision Bodies (cont’d)

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

  • (Especially in 3d.)

  • General solution?



Minkowski sums l.jpg
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.


Minkowski differences l.jpg
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)


Minkowski differences80 l.jpg
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.


Minkowski differences cont d l.jpg
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 differences cont d82 l.jpg
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”


Minkowski differences cont d83 l.jpg
Minkowski Differences (cont’d)

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


Minkowski differences cont d84 l.jpg
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.


Minkowski differences cont d85 l.jpg
Minkowski Differences (cont’d)

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


Minkowski differences cont d86 l.jpg
Minkowski Differences (cont’d)

Aorigin vs. Borigin

-Borigin -Borigin

___ ___

(A-B)origin vs. 0


Minkowski differences cont d87 l.jpg
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.


Minkowski differences cont d88 l.jpg
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)


Minkowski differences cont d89 l.jpg
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)


Minkowski differences cont d90 l.jpg
Minkowski Differences (cont’d)

Translations in A or B simply translate the CSO


Minkowski differences cont d91 l.jpg
Minkowski Differences (cont’d)

Rotations in A or B mutate the CSO




Relative everything94 l.jpg
Relative Everything

  • Let’s combine:

    • Relative Coordinate Systems

    • Relative Motion

    • Relative Collision Bodies


Relative everything cont d l.jpg
Relative Everything (cont’d)

  • A vs. B in world frame


Relative everything cont d96 l.jpg
Relative Everything (cont’d)

  • A vs. B in world frame

  • A is CSO, B is point


Relative everything cont d97 l.jpg
Relative Everything (cont’d)

  • A vs. B in world frame

  • A is CSO, B is point

  • A is moving CSO, B is still point


Relative everything cont d98 l.jpg
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!


Relative everything cont d99 l.jpg
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...


Relative everything cont d100 l.jpg
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


Relative everything cont d101 l.jpg
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!


Relative everything cont d102 l.jpg
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”.


Quality vs quantity l.jpg

Quality vs. Quantity

or

“You Get What You Pay For”


Quality vs quantity104 l.jpg
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?


Rotations l.jpg

Rotations

(Suck)


Rotations106 l.jpg
Rotations

  • Continuous rotational collision detection sucks

  • Rotational tunneling alone is problematic


Rotations107 l.jpg
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


Rotations cont d l.jpg
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



Summary110 l.jpg
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.


Summary cont d l.jpg
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.


Questions l.jpg
Questions?


ad