Skip to content

Sopiro/Muli

Repository files navigation

logo

Muli

CMake Build

2D Rigidbody physics engine

Features

Collision

  • Continuous collision detection (Bilateral advancement by Erin Catto of box2d)
  • Shapes: circle, capsule and convex polygon
  • Support for rounded polygons
  • Multiple shapes attached to a single body
  • Dynamic, static and kinematic bodies
  • Collision filtering
  • Dynamic AABB tree broadphase
  • Dynamic tree accelerated raycast, shapecast and world query
  • Easy-to-use collision detection and distance funtions

Physics Simulation

  • Continuous physics simulation (Time of impact solver and sub-stepping)
  • Efficient and persistent contact management from box2d
  • Constraint islanding and sleeping
  • Stable stacking with 2-contact LCP solver (Block solver)
  • Decoupled position correction iteration
  • Contact callbacks: begin, touching, end, pre-solve, post-solve and destroy event
  • Physics material: friction, restitution and surface speed
  • Various joints: angle, distance, grab, line, motor, prismatic, pulley, revolute and weld

ETC

  • 50+ Demos
  • OpenGL based demo framework
  • Cross platform library
  • Intuitive and straightforward API
  • Utilizes specialized memory allocators

Example

#include "muli/muli.h"

using namespace muli;

int main()
{
    WorldSettings settings;
    World world(settings);
  
    RigidBody* box = world.CreateBox(1.0f);
    box->SetPosition(0.0f, 5.0f);
  
    // Run simulation for one second
    float dt = 1.0f / 60.0f;
    for(int i = 0; i < 60; ++i)
    {
        world.Step(dt);
    }
  
    return 0;
}

Building and running

  • Install CMake
  • Ensure CMake is in the system PATH
  • Clone the repository git clone --recursive https://github.com/Sopiro/Muli
  • Run CMake build script depend on your system
    • Visual Studio: Run build.bat
    • Otherwise: Run build.sh
  • You can find the executable demo in the build/bin

Installation

You can install the library using this commands

mkdir build
cd build
cmake -DMULI_BUILD_DEMO=OFF ..
cmake --build . --config Release
cmake --install . --prefix "installation-path"

Assuming you've added "installation-path" to your system PATH, you can now integrate the library into your project

find_package(muli REQUIRED)

target_link_libraries(your-project PRIVATE muli::muli)

Todo

  • Implement position solve step for joints
  • Multithreading

References

Here are some great resources to learn how to build a physics engine!