Chipmunk2D is a simple, lightweight, fast and portable 2D rigid body physics library written in C. It’s licensed under the unrestrictive, OSI approved MIT license. Hundreds of shipping games have chosen Chipmunk because of the high quality, speed, and accuracy of its 2D physics simulations.
Cross Platform and Optimized
Mobile development offers unique performance challenges, and Chipmunk2D is specifically optimized for speed by offering a multi-threaded and vectorized solver. New in Chipmunk 7, everyone has access to an alternative cpSpace type, cpHastySpace, which will automatically use the ARM NEON vector coprocessor available to most Android and iOS mobile devices. Even if you don't need the extra performance, it will help save your player's batteries. cpHastySpace also allows you to enable extra threads for the solver to use as well.
Chipmunk is widely used for 2D physics rich games on Mac, Windows, Linux, Android, iOS, and game consoles. If you have a C or C++ compiler, you can use Chipmunk2D. Some functionality is platform specific, such as the Objective-Chipmunk wrapper (iOS, Mac OS X, or an alternative Obj-C runtime), the NEON optimizations (requires an ARM CPU with a NEON coprocessor), or multi-threading (currently requires pthread support).
Level design and asset creation is a time consuming portion of game development, and Chipmunk2D can significantly aid in creating your physics shapes. Chipmunk2D's automatic geometry generation can create fitted collision geometry from images. Gone are the days of typing coordinates to generate collision shapes. The Autogeometry generation can create the physics shape for the terrain of your game from an image in milliseconds, allowing rapid iteration with just your graphics tools. This geometry can even be generated on the fly at runtime providing for spectacular techniques, such as deformable objects and terrain (Demo video on youtube). See Scott's walkthrough of collision shape generation from images.
Accelerate iOS Development
For iOS development, Chipmunk2D includes "Objective-Chipmunk2D", an Objective-C wrapper around all Chipmunk functionality. This provides greatly simplified memory management (especially when combined with automatic reference counting), an object oriented syntax, convenience classes for multi-touch input, and more. This speeds your development and reduces debugging. Your time is valuable!
Chipmunk2D offers AAA-quality physics features and performance, but it doesn't come with a AAA price. All versions of Chipmunk2D are open source under the MIT license, and it's probably already integrated into your favorite engine.
Don't compromise your game design by with sluggish physics performance. Chipmunk2D is designed for speed and nearly every algorithm in Chipmunk2D has been profiled, benchmarked, and optimized to give you the maximum performance possible. This is especially important on mobile devices with limited CPU power where every cycle counts.
Chipmunk2D 7.0 now features platform specific optimizations, available for free to all users. Currently this includes an ARM NEON optimized solver that can speed up most Chipmunk2D simulations by 20-40%. If there is demand, we would also be interested in implementing SIMD optimizations for other platforms such as x86 or PPC. We also have a working multithreaded solver available in the Git repository that will be part of 6.0.4 and are working on multithreaded collision detection as well for even more performance improvements.
So how much faster is Chipmunk2D? Let's run some benchmarks to find out!
The benchmarks are all included with Chipmunk2D and can be run by passing the
-bench argument to the demo application.
An iPhone benchmarking app can be found as part of the Chipmunk2D Xcode project.
You can also view the first couple seconds of each benchmark to see what it was doing by clicking the icons in the chart below.
We also get asked quite often how Chipmunk2D's performance compares to Box2D, so we included that in the comparison as well. Chipmunk2D's solver was originally based on Box2D's, but our implementations have diverged over several years as features have been added and the performance has been extensively tuned. Despite requiring a higher iteration count to achieve the same stability, Chipmunk2D's performance is very competitive, easily besting Box2D's performance in every single test. The optimizations in Chipmunk2D further boost that beyond double in many tests. Chipmunk2D's broadphase collision detection is very fast. The "bouncy" demos stress test the collision detection an spend minimal time in the solver. If you are using Box2D only for it's collision detection and ignoring the physics, you might want to consider switching. Chipmunk2D offers a richer collision API, much higher performance, and doesn't requie you to scale all of your units in order get acceptable performance or accuracy.
All benchmarks were run on a iPhone 4S using the release compile settings for each library. Versions used were Chipmunk 6.0.3, Chipmunk2D Pro 6.0.4 (which is now included the latest free versions of Chipmunk2D) from Git (with the NEON and multi-threaded solver enabled), and Box2D 2.2. Chipmunk 6.0.3 was used as the baseline comparison for Chipmunk2D and Box2D. The times in the chart below are measured in milliseconds. Sleeping was disabled in all libraries to compare just the solver and collision detection performance. (CPU usage of sleeping objects is very minimal) Continuous collision detection was disabled in Box2D as it incurs a fairly large overhead. The scale used with Box2D was also tuned to give it the best performance. Scaling the units is unnecessary with Chipmunk. Chipmunk was using 10 velocity/position iterations while Box2D was using 10 velocity iterations and 3 position iterations. All simulations were run at 60Hz for 1000 steps. Only the simulation is included in the time trials, no rendering is performed.
* The Chipmunk2D Pro features are now included in the free version of Chipmunk2D. Enjoy!