PhysXLoop is a physics-first simulation engine built from scratch in modern C++ using OpenGL 4.6 for rendering and Eigen for mathematical precision. It’s designed for accurate, real-time physical interaction — with core focus on robust collision detection/resolution, a modular entity model, and an event-controlled runtime that enables seamless switching between simulation and camera control.
Unlike traditional render-first engines, PhysXLoop prioritizes physics determinism and logical accuracy over GPU performance. While it integrates rendering using OpenGL, its strength lies in a cleanly separated physics loop that runs in sync (or optionally detached) from the rendering loop using a lambda-controlled runner.
- 🧱 AABB–AABB Collision Detection + Resolution
- 🟣 Sphere–Sphere Collision Handling
- ⚡ Elastic & Inelastic Collision Types
- 🌌 Accurate Penetration Depth Handling
- 🔃 Deterministic Collision Resolution Logic
- 🔂 Toggleable Physics Loop (Pause/Resume) via space key
- 🎯 Lambda-based Loop Binding for physics and rendering sync
- ⏸️ Event-controlled Simulation State
- 🖱️ Arcball-style Camera Control active when simulation is paused
- 📦 Modular Renderer (Custom-built)
- 🔢 ImGui Docking UI Integration
- 🎲 Visual Debug Tools for viewing entities & bounding volumes
- 🧩 Custom OOP Entity System (vs ECS used in prior engine)
| Component | Stack |
|---|---|
| Renderer | OpenGL 4.6 |
| Math Engine | Eigen |
| GUI | Dear ImGui (Docking) |
| Entity System | Custom OOP-based Model |
| Loop Control | Lambda-driven loop binding |
| Input Handling | GLFW |
| Build System | CMake |
| Key | Action |
|---|---|
Space |
Pause / Resume Physics Loop |
Mouse |
Arcball-style camera (on pause) |
Esc |
Exit Simulation |
Tab |
Toggle ImGui Dock |
- PhysicsEngine.run() is passed as a lambda to the main loop, allowing full detachment if needed.
- Clear separation between
Renderer,Entity,CollisionSolver, andPhysicsEnginemodules. - Minimal ImGui overlay for controlling simulation state and inspecting runtime data.
- Dynamic Object Creation via GUI
- Particle Systems (Boids, Verlet)
- Fluid Simulation (SPH-based or grid-based)
- Rigid Body Dynamics
- Advanced constraint solver (springs, hinges)
- Performance profiling & GPU-acceleration
Sphere–Sphere Collision Demo Two spheres collide elastically with position correction and velocity exchange. Penetration is resolved using impulse-based solver.
AABB Stack Stress Test Multiple stacked AABBs fall and resolve collisions, showcasing broad-phase + narrow-phase handling.
MIT License – open for educational, academic, and commercial experimentation.
Aman Gupta Driven by physics. Rendered with code. From graphics to gravity — one frame at a time.