About Chipmunk2D

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.

Why Chipmunk?

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).

Autogeometry

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!

Indie Friendly

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.

Performance

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.

Benchmarks:

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 and spend minimal time in the solver. If you are using Box2D only for its collision detection and ignoring the collision response, you might want to consider switching. Chipmunk2D offers a richer collision API, much higher performance, and doesn't require you to rescale 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.

Chipmunk Chipmunk2D Pro* Box2D
SimpleTerrainCircles_1000
17711.68 10875.91 27333.87
SimpleTerrainCircles_500
7893.71 4903.25 9663.08
SimpleTerrainCircles_100
1318.14 1102.51 1682.14
SimpleTerrainBoxes_1000
34794.06 24841.11 51386.70
SimpleTerrainBoxes_500
11701.03 7898.51 15077.12
SimpleTerrainBoxes_100
2100.96 1732.54 2437.21
SimpleTerrainHexagons_1000
29434.59 21952.09 34609.11
SimpleTerrainHexagons_500
13269.92 9736.09 14513.95
SimpleTerrainHexagons_100
2307.68 1957.62 2537.53
SimpleTerrainVCircles_200
2967.15 2084.33 3338.19
SimpleTerrainVBoxes_200
4408.18 3121.41 5262.79
SimpleTerrainVHexagons_200
4947.09 3850.76 5148.81
ComplexTerrainCircles_1000
18831.02 12337.92 29682.58
ComplexTerrainHexagons_1000
35205.27 26115.87 46755.10
BouncyTerrainCircles_500
1843.89 1734.72 8667.23
BouncyTerrainHexagons_500
2678.24 2579.44 9998.63
NoCollide 50.88 50.46 590.74

* The Chipmunk2D Pro features are now included in the free version of Chipmunk2D. Enjoy!