A lightweight 3D rigid body physics engine written in Python, focusing on collision detection, contact generation, and impulse-based resolution.
This project is designed as a learning-oriented and research-oriented engine with clear algorithmic structure and explicit physical modeling.
Precompiled executables for this engine can be found at the releases page for Windows and Linux. Or you can just:
git clone https://github.com/EMEEEEMMMM/AtlasPhys.git
uv sync
uv run python main.py
- 3D rigid body dynamics (linear + angular)
- Semi-implicit Euler integrator
- Gravity and basic for accumulation
- Collision detection:
- Plane-Cube
- Plane-Sphere
- Cube-Sphere
- Cube-cube
- Sphere-Sphere
- Contact generation
- Acceleration & Impulse visualization (Arrows in red and green)
- Based on OpenGL and Pyqt6
- Interactive demo (camera control, object generation)
Each physics step/frame follows this order:
-
Integration
- Semi-implicit Euler
- Updates velocity -> position
- Updates angular velocity -> orientation
- Updates for the Arrows
-
Broad Phase
- Simple AABB overlap test
-
Narrow Phase
- GJK for collision detection
- EPA for penetration depth & contact normal
-
Contact Generation
- Analytical contacts for simple shapes
- Face selection + polygon clipping for Cube-Cube
-
Constraint Solving
- Impulse-based normal resolution
- Iterative solver
- Split impulse formulation no Baumgarte bias in velocity solve
-
Positional Correction
- Pure position-level correction
flowchart TD
A[Start] --> B[Integrate Motion]
B --> C[Broad Phase AABB Test]
C -->|Overlap| D[GJK Collision Detection]
D -->|Colliding| E[EPA Penetration Solve]
E --> F[Contact Generation]
F --> G[Impulse Solver]
G --> H[Positional Correction]
H --> I[End Step]