960 likes | 977 Views
Physics for Games Programmers Problem Overview. Squirrel Eiserloh Technical Director MumboJumbo Games squirrel@eiserloh.net www.algds.org. Types of Problems. Knowing when to cheat Simplifying things Giving shape to things Moving things around Simulation baggage
E N D
Physics for Games Programmers Problem Overview Squirrel EiserlohTechnical DirectorMumboJumbo Gamessquirrel@eiserloh.netwww.algds.org
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
Knowing When to Cheat • Discrete physics simulation falls embarrassingly 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.
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 they will care • Some crimes are greater than others
Simplifying Things • Simplified bodies
Simplifying Things • Simplified bodies • Even more simplified bodies
Simplifying Things • Simplified bodies • Even more simplified bodies • Convex bodies
Simplifying Things • Simplified bodies • Even more simplified bodies • Convex bodies • Homogeneous bodies
Simplifying Things • Simplified bodies • Even more simplified bodies • Convex bodies • Homogeneous bodies • Rigid bodies
Simplifying Things • Simplified bodies • Even more simplified bodies • Convex bodies • Homogeneous bodies • Rigid bodies • Indestructible bodies
Simplifying Things • Movement is often assumed to be in a vacuum (ignoring air resistance)
Simplifying Things • Movement is often assumed to be in a vacuum (ignoring air resistance) • Even when air resistance does get simulated, it is hugely oversimplified
Simplifying Things • Collisions are often assumed to be perfect and elastic • That is, 100% of the energy before the collision is maintained after the collision • Think billiard balls
Giving Shape to Things • N-sphere • 2d: Disc • 3d: Sphere
Giving Shape to Things • N-sphere • 2d: Disc • 3d: Sphere • Simplex • 2d: Triangle • 3d: Tetrahedron
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)
Giving Shape to Things • Discrete Oriented Polytope (DOP)
Giving Shape to Things • Discrete Oriented Polytope (DOP) • Oriented Bounding Box (OBB)
Giving Shape to Things • Discrete Oriented Polytope (DOP) • Oriented Bounding Box (OBB) • Axis-Aligned Bounding Box (AABB)
Giving Shape to Things • Discrete Oriented Polytope (DOP) • Oriented Bounding Box (OBB) • Axis-Aligned Bounding Box (AABB) • Capsule
Giving Shape to Things • Discrete Oriented Polytope (DOP) • Oriented Bounding Box (OBB) • Axis-Aligned Bounding Box (AABB) • Capsule • Cylinder (3d only)
Moving Things Around • Kinematics • Describes motion • Uses position, velocity, momentum, acceleration
Moving Things Around • Kinematics • Describes motion • Uses position, velocity, momentum, acceleration • Dynamics • Explains motion • Uses forces • ...and impulses
Moving Things Around • Kinematics • Describes motion • Uses position, velocity, momentum, acceleration • Dynamics • Explains motion • Forces (F=ma) • Impulses • Rotation • Torque • Angular momentum • Moment of inertia
Moving Things Around • How to compute the next position and velocity from current position and velocity? • This process is called integration; • An algorithm for doing this in an integrator
Moving Things Around • How to compute the next position and velocity from current position and velocity? • This process is called integration; • An algorithm for doing this in an integrator
Moving Things Around • How to compute the next position and velocity from current position and velocity? • This process is called integration; • An algorithm for doing this in an integrator
Moving Things Around • How to compute the next position and velocity from current position and velocity? • This process is called integration; • An algorithm for doing this in an integrator
Moving Things Around • How to compute the next position and velocity from current position and velocity? • This process is called integration; • An algorithm for doing this in an integrator
Moving Things Around • How to compute the next position and velocity from current position and velocity? • This process is called integration; • An algorithm for doing this in an integrator • Which integration method to use?
Moving Things Around • How to compute the next position and velocity from current position and velocity? • This process is called integration; • An algorithm for doing this in an integrator • Which integration method to use?
Moving Things Around • How to compute the next position and velocity from current position and velocity? • This process is called integration; • An algorithm for doing this in an integrator • Which integration method to use?
Moving Things Around • How to compute the next position and velocity from current position and velocity? • This process is called integration; • An algorithm for doing this in an integrator • Which integration method to use?
Moving Things Around • How to compute the next position and velocity from current position and velocity? • This process is called integration; • An algorithm for doing this in an integrator • Which integration method to use?
Simulation Baggage • Flipbook syndrome
Simulation Baggage • Flipbook syndrome • Things can happen in-between snapshots
Simulation Baggage • Flipbook syndrome • Things mostly happen in-between snapshots
Simulation Baggage • Flipbook syndrome • Things mostly happen in-between snapshots • Curved trajectories treated as piecewise linear
Simulation Baggage • Flipbook syndrome • Things mostly happen in-between snapshots • Curved trajectories treated as piecewise linear • Terms often assumed to be constant throughout the frame
Simulation Baggage (cont’d) • Error accumulates
Simulation Baggage (cont’d) • Error accumulates • Energy is not always conserved • Energy loss can be undesirable • Energy gain is evil • Simulations explode!
Simulation Baggage (cont’d) • Error accumulates • Energy is not always conserved • Energy loss can be undesirable • Energy gain is evil • Simulations explode! • Rotations are often assumed to happen instantaneously at frame boundaries
Simulation Baggage (cont’d) • Error accumulates • Energy is not always conserved • Energy loss can be undesirable • Energy gain is evil • Simulations explode! • Rotations are often assumed to happen instantaneously at frame boundaries • Numerical nightmares!
Collision Detection • We need to determine if A and B intersect