Jitter Physics
Project Information
This fork of Jitter Physics aims to implement 128-bit precision to work better for Space Games where shifting the origin is not an option. While still being 100% compatable with the previous Jitter physics with as little API changes as possible.
This goal hasent yet been reached yet as of July 20, 2022
Jitter Physics is a fast and lightweight 3D physics engine written in C#.
Jitter Physics Cloth | Speculative Contacts Jitter Physics |
---|---|
Platforms & Frameworks
- Every platform which supports .NET, Mono or Xamarin
- Works with the Mono framework on Linux/Mac without any recompilation
- Also supports the Xbox360 and Windows Phone (up to v0.1.7)
- No dependencies. Works with every 3D engine/framework.
Overall Design
- Written in pure C# with a clean and object orientated API
- Optimized for low to no garbage collections and maximum speed
- Supported Shapes: TriangleMesh, Terrain, Compound, MinkowskiSum, Box, Sphere, Cylinder, Cone, Capsule, ConvexHull
- Take advantage of multi-core CPUs by using the internal multithreading of the engine
Quick Start
Initialize the Physics System
Create a world class and initialize it with a CollisionSystem
:
CollisionSystem collision = new CollisionSystemSAP();
World world = new World(collision);
Add Objects to the World
Create a shape of your choice and pass it to a body:
Shape shape = new BoxShape(1.0m, 2.0m, 3.0m);
RigidBody body = new RigidBody(shape);
Note the m at the end of numbers instead of f. This is required in this fork since all numbers are stored as Decimals instad of Floats.
It's valid to use the same shape for different bodies.
Set the position and orientation of the body by using it's properties.
The next step is to add the Body
to the world:
world.AddBody(body);
Run the Simulation
Now you can call the Step
method to integrate the world one timestep further.
This should be done in you main game loop:
while (gameRunning)
{
world.Step(1.0m / 100.0m, true);
// do other stuff, like drawing
}
The first parameter is the timestep. This value should be as small as possible
to get a stable simulation. The second parameter is for whether using internal
multithreading or not. That's it the body is now simulated and affected by
default gravity specified in World.Gravity
. After each timestep the Position
of the body should be different.