Give your iPhone games a dynamic real-world feel by integrating a physics engine. This session will give an overview of the current physics engines available for iPhone development, discussing the pros and cons of each. We will also discuss how to decide if a physics engine is right for your project or you are better off with custom code. We'll dive into some real world examples with Ragdoll Blaster which uses the Open Dynamics Engine and talk about optimization, debugging and other tips and tricks.
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Physics Solutions for Innovative Game Design
1. Physics Solutions for
Innovative Game Design
Give your iPhone games a dynamic real-world
feel by integrating a physics engine.
Andrei Gradinari
Lead Engineer - Backflip Studios
Tom Blind
Lead Designer - Backflip Studios
20. Physics Engine
A physics engine is a set of
functions that lets you describe
layout of your system of physics
objects and then tells you how the
state of this system changes over
time.
21. Physics Engine
Define layout of your system of objects (shapes, positions,
masses, dimensions, global gravity vector, etc...)
23. Physics Simulation
The process handled by a physics engine that figures out what
happens to the given set of objects over a certain period of time
is called physics simulation
->Simulation->
24. Physics Simulation
Can be:
Not Interactive (user input is not taken in consideration)
Interactive (user input affects the simulation). Interactive
simulations are used in most games
26. Do you need a physics engine?
Sometimes, it's easier to do it yourself!
Less memory & CPU usage
Less disk space
Less time spent linking libraries
Simpler, if you don't need anything fancy
27. Do you need a physics engine?
Rolling your own physics:
acceleration = force / mass
Things get trickier with collisions...
28. The Physics of Paper Toss
Forces are one-dimensional
Add flick force and wind force
to determine landing point
Animate to make it look pretty
No physics library needed!
31. Typical Physics Engine
Building blocks of your physics world:
Geometric Shapes (describe what your objects look like)
Joints (describe how your objects are connected to each other)
32. Typical Physics Engine
Simulation Step:
Collision contact points generation (collision detection
engine)
Creating temporary joints based on contact points, and
attaching them to respective physics objects
Performing actual simulation step (rigid body dynamics
engine)
37. Performance Tips and Tricks
Keep things simple
More objects in your physics simulation = more time
spent to simulate the system = lower framerate as a
result.
Approximate complex volumes with sets of simple
volumes
Performance gain is well worth it.
User will never see the difference, as long as you do it
right.
It's still fine to render fully detailed models, while
simulating simple shapes on the physics side.
38. Performance Tips and Tricks
Example of complex volumes approximation.
Rendered models:
39. Performance Tips and Tricks
Example of complex volumes approximation.
Simulated shapes:
40. Performance Tips and Tricks
Do not simulate static objects
They should never be simulated in Rigid Bodies
Dynamics Engine, because they never move.
Do not simulate dynamic objects that are
stationary at the moment.
ODE, for example, automatically does this for you. It is
called Auto Disable.
Use spatial partitioning
Setup collision detection engine to generate as
few contact points as possible
41. Performance Tips and Tricks
Several small steps vs one large step
Several small steps: One large step:
More realistic simulation, Less realistic simulation
especially when
simulating dynamically Better performance
changing forces
Less problems with
objects flying through
each other.
42. Performance Tips and Tricks
Probable instability problems with simulation and
their causes:
Large simulation step
Large forces applied to bodies
Large masses, especially when mixed with small masses
High speeds of the objects
Fast spinning objects
High friction
43. A Brief Comparison of Physics Engines
Used on the iPhone
2D 3D
Box2D ODE
Chipmunk Bullet
44. Comparison of Physics Engines
Box2D
Optimized for 2D games
Works well with cocos2d
Used in many iPhone games such as Crayon Physics and
Rolando
45. Comparison of Physics Engines
Chipmunk
Very lightweight
Written in pure C
Made by the creators of Crayon Ball for the iPhone
"Makes you smarter, stronger, and more attractive to the
opposite gender!"
46. Comparison of Physics Engines
Open Dynamics Engine (ODE)
Industry veteran
Supports full 3D simulation
Fast, even on the iPhone
Used in Touchgrind and Ragdoll Blaster
47. Comparison of Physics Engines
Bullet Physics Library
Highly optimized for many architectures
Multi-threaded
Third most popular physics library according to survey by
Game Developer Magazine (Aug. 2009)
Used by Oolong Engine (Kids vs. Zombies, iPhysics)
48. Contemporary physics in games on
consoles and PC's = the nearest future
of physics in mobile games...