slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Physics for Games Programmers Problem Overview PowerPoint Presentation
Download Presentation
Physics for Games Programmers Problem Overview

Loading in 2 Seconds...

play fullscreen
1 / 79

Physics for Games Programmers Problem Overview - PowerPoint PPT Presentation


  • 84 Views
  • Uploaded on

Physics for Games Programmers Problem Overview. Squirrel Eiserloh Technical Director Ritual Entertainment squirrel@eiserloh.net www.ritual.com www.algds.org. Types of Problems. Knowing when to cheat Simplifying things Giving shape to things Moving things around Simulation baggage

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 'Physics for Games Programmers Problem Overview' - lali


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

Physics for Games Programmers Problem Overview

Squirrel EiserlohTechnical DirectorRitual Entertainmentsquirrel@eiserloh.netwww.ritual.comwww.algds.org

types of problems
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 cheat1
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 cheat2
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 things1
Simplifying Things
  • Simplified bodies
simplifying things2
Simplifying Things
  • Simplified bodies
  • Even more simplified bodies
simplifying things3
Simplifying Things
  • Simplified bodies
  • Even more simplified bodies
  • Convex bodies
simplifying things4
Simplifying Things
  • Simplified bodies
  • Even more simplified bodies
  • Convex bodies
  • Homogeneous bodies
simplifying things5
Simplifying Things
  • Simplified bodies
  • Even more simplified bodies
  • Convex bodies
  • Homogeneous bodies
  • Rigid bodies
simplifying things6
Simplifying Things
  • Simplified bodies
  • Even more simplified bodies
  • Convex bodies
  • Homogeneous bodies
  • Rigid bodies
  • Indestructible bodies
simplifying things7
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 things8
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 things1
Giving Shape to Things
  • N-sphere
    • 2d: Disc
    • 3d: Sphere
giving shape to things2
Giving Shape to Things
  • N-sphere
    • 2d: Disc
    • 3d: Sphere
  • Simplex
    • 2d: Triangle
    • 3d: Tetrahedron
giving shape to things3
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 things4
Giving Shape to Things
  • Discrete Oriented Polytope (DOP)
giving shape to things5
Giving Shape to Things
  • Discrete Oriented Polytope (DOP)
  • Oriented Bounding Box (OBB)
giving shape to things6
Giving Shape to Things
  • Discrete Oriented Polytope (DOP)
  • Oriented Bounding Box (OBB)
  • Axis-Aligned Bounding Box (AABB)
giving shape to things7
Giving Shape to Things
  • Discrete Oriented Polytope (DOP)
  • Oriented Bounding Box (OBB)
  • Axis-Aligned Bounding Box (AABB)
  • Capsule
giving shape to things8
Giving Shape to Things
  • Discrete Oriented Polytope (DOP)
  • Oriented Bounding Box (OBB)
  • Axis-Aligned Bounding Box (AABB)
  • Capsule
  • Cylinder (3d only)
moving things around1
Moving Things Around
  • Kinematics
    • Describes motion
    • Uses position, velocity, momentum, acceleration
moving things around2
Moving Things Around
  • Kinematics
    • Describes motion
    • Uses position, velocity, momentum, acceleration
  • Dynamics
    • Explains motion
    • Uses forces
    • ...and impulses
moving things around3
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
simulation baggage1
Simulation Baggage
  • Flipbook syndrome
simulation baggage2
Simulation Baggage
  • Flipbook syndrome
  • Things can happen in-between snapshots
simulation baggage3
Simulation Baggage
  • Flipbook syndrome
  • Things mostly happen in-between snapshots
simulation baggage4
Simulation Baggage
  • Flipbook syndrome
  • Things mostly happen in-between snapshots
  • Curved trajectories treated as piecewise linear
simulation baggage5
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 d1
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 d2
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 d3
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 detection1
Collision Detection
  • We need to determine if A and B intersect
collision detection2
Collision Detection
  • We need to determine if A and B intersect
  • Worse yet, they could be (and probably are) in motion
collision detection3
Collision Detection
  • We need to determine if A and B intersect
  • Worse yet, they could be (and probably are) in motion
  • If they did collide, we probably also need to know when they collided
collision response
Collision Response
  • ...and we need to figure out how to resolve the collision
sustained interactions1
Sustained Interactions
  • Surface contact
sustained interactions2
Sustained Interactions
  • Surface contact
  • Edge contact
sustained interactions3
Sustained Interactions
  • Surface contact
  • Edge contact
  • Contact points
sustained interactions4
Sustained Interactions
  • Surface contact
  • Edge contact
  • Contact points
    • Different solutions
sustained interactions5
Sustained Interactions
  • Surface contact
  • Edge contact
  • Contact points
    • Different solutions
  • Stacking
sustained interactions6
Sustained Interactions
  • Surface contact
  • Edge contact
  • Contact points
    • Different solutions
  • Stacking
  • Friction
    • Static & Kinetic
sustained interactions7
Sustained Interactions
  • Surface contact
  • Edge contact
  • Contact points
    • Different solutions
  • Stacking
  • Friction
    • Static & Kinetic
  • Constraints & Joints
dealing with the impossible2
Dealing With the Impossible
  • Interpenetration
  • Tunneling
tunneling

Tunneling

(Sucks)

tunneling1
Tunneling
  • Small objects tunnel more easily
tunneling cont d
Tunneling (cont’d)
  • Possible solutions
    • Minimum size requirement?
      • Inadequate; fast objects still tunnel
tunneling cont d1
Tunneling (cont’d)
  • Fast-moving objects tunnel more easily
tunneling cont d2
Tunneling (cont’d)
  • Possible solutions
    • Minimum size requirement?
      • Inadequate; fast objects still tunnel
    • Maximum speed limit?
      • Inadequate; since speed limit is a function of object size, 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
tunneling cont d3
Tunneling (cont’d)
  • Besides, even with min. size requirements and speed limits and a small timestep, you still have degenerate cases that cause tunneling!
tunneling cont d4
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 cont d5
Tunneling (cont’d)
  • Interpenetration
  • Tunneling
  • Rotational tunneling
making it fast enough1
Making It Fast Enough
  • Don’t be too particular too soon
    • Avoid unnecessary work
making it fast enough2
Making It Fast Enough
  • Don’t be too particular too soon
    • Avoid unnecessary work
  • Eschew n-squared operations
    • Avoid the “everything vs. everything” case
making it fast enough3
Making It Fast Enough
  • Don’t be too particular too soon
    • Avoid unnecessary work
  • Eschew n-squared operations
    • Avoid the “everything vs. everything” case
    • Try using simulation islands or other methods to divide and conquer
simulation islands
Simulation Islands
  • Consider:
    • 1000 objects, 1 island
    • 1000x1000 checks
    • = 1 Million checks
simulation islands1
Simulation Islands
  • Consider:
    • 1000 objects, 1 island
    • 1000x1000 checks
    • = 1 Million checks
  • Verses:
    • 1000 objects, divided into 10 islands of 100
    • 10 x (100x100) checks
    • = 100,000 checks
    • 1/10th as many!
simulation islands2
Simulation Islands
  • Simulation islands can “go to sleep” when they become stable
    • i.e. when forces and motion remain unchanged
simulation islands3
Simulation Islands
  • Simulation islands can “go to sleep” when they become stable
    • i.e. when forces and motion remain unchanged
simulation islands4
Simulation Islands
  • Simulation islands can “go to sleep” when they become stable
    • i.e. when forces and motion remain unchanged
  • When an object enters the island’s bounds...
simulation islands5
Simulation Islands
  • Simulation islands can “go to sleep” when they become stable
    • i.e. when forces and motion remain unchanged
  • When an object enters the island’s bounds...
simulation islands6
Simulation Islands
  • Simulation islands can “go to sleep” when they become stable
    • i.e. when forces and motion remain unchanged
  • When an object enters the island’s bounds...
  • ...the island wakes up
simulation islands7
Simulation Islands
  • Add the newcomer to this simulation island
simulation islands8
Simulation Islands
  • Add the newcomer to this simulation island
  • ...and put it back to sleep once it stabilizes
  • This is just one of many ways to reduce complexity
  • We’ll be covering several others later on
making it fast enough4
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 so since the previous frame, so save the previous frame’s results!
    • Spatial coherence: Things tend to miss each other far more often than they collide, and only things in the same neighborhood can collide with each other
summary1
Summary
  • The nature of simulation causes us real problems... problems which can’t be ignored
  • So we cheat
  • And we simplify things
  • And even then, it can get quite complex...
summary cont d
Summary (cont’d)
  • Problems we’re 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 should we resolve penetration?
    • How should we handle contact?
    • How can we prevent tunneling?
    • How do we deal with non-rigid bodies?
questions
Questions?
  • Feel free to reach me by email at:

squirrel@eiserloh.net

or

squirrel@ritual.com