Skip to content

Sopiro/Muli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8a5f714 · Mar 18, 2025
Aug 21, 2024
Mar 18, 2025
Dec 4, 2024
Mar 17, 2025
Mar 17, 2025
Jul 14, 2024
Dec 4, 2024
May 21, 2024
Aug 15, 2024
Nov 12, 2022
Mar 17, 2025
Dec 4, 2024
Oct 2, 2022
Dec 4, 2024

Repository files navigation

logo

Muli

Build library

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 functions

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

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 depending 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 these 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!