How bepu/bepuphysics2 works
BepuPhysics v2 is a C# 3D rigid-body physics engine. A typical user defines shapes and bodies, advances a simulation, and reads updated poses or query results. Its domain stages include collision candidate detection, contact generation, constraint solving, and sleeping/waking; it also supports CCD and scene-wide ray and sweep queries. The graph emphasizes these runtime responsibilities and the SIMD, memory, and scheduling layers that support them. Several subsystem links are documented by the README but their orchestration code was not sampled, so those links are marked unverified.
Main entry points: Simulation.cs Simulation · Solver.cs Solver · Bodies.cs Bodies · NarrowPhase.cs Narrow phase
Components 22
World State
- Simulation
BepuPhysics/Simulation.cs - Bodies
BepuPhysics/Bodies.cs - Static geometry
BepuPhysics/Statics.cs - Shape registry
BepuPhysics/Collidables/Shapes.cs - Shape types
BepuPhysics/Collidables
Collision and Queries
- Broad phase
BepuPhysics/CollisionDetection/BroadPhase.cs - Narrow phase
BepuPhysics/CollisionDetection/NarrowPhase.cs - Collision tasks
BepuPhysics/CollisionDetection/CollisionTasks - Continuous collision
BepuPhysics/CollisionDetection - Scene queries
BepuPhysics/Simulation_Queries.cs - Spatial tree
BepuPhysics/Trees/Tree.cs
Constraint Solver
- Solver
BepuPhysics/Solver.cs - Constraint processors
BepuPhysics/Constraints/TypeProcessor.cs - Island sleep
BepuPhysics/IslandSleeper.cs - Island wake
BepuPhysics/IslandAwakener.cs - Timestepper
BepuPhysics/DefaultTimestepper.cs
Runtime Foundations
- SIMD math
BepuUtilities/Vector3Wide.cs - Buffer pooling
BepuUtilities/Memory/BufferPool.cs - Pooled collections
BepuUtilities/Collections/QuickList.cs - Task scheduler
BepuUtilities/TaskScheduling/TaskStack.cs - Worker state
BepuUtilities/TaskScheduling/Worker.cs
Other components
- Physics client
Connections 26
- Physics client → Simulation: configures and advances
- Simulation → Bodies: updates
BepuPhysics/Simulation.cs - Simulation → Static geometry: manages
BepuPhysics/Simulation.cs - Simulation → Solver: steps
BepuPhysics/Simulation.cs - Bodies → Shape registry: computes bounds
BepuPhysics/Bodies.cs - Bodies → Broad phase: adds active bounds
BepuPhysics/Bodies.cs - Shape registry → Shape types: dispatches by type
BepuPhysics/Collidables/Shapes.cs - Broad phase → Narrow phase: selects candidate pairs
- Narrow phase → Collision tasks: dispatches tests
- Narrow phase → Solver: produces contact constraints
- Simulation → Continuous collision: supports continuous collision
BepuPhysics/Simulation.cs - Simulation → Scene queries: offers ray and sweep queries
- Scene queries → Spatial tree: traverses
- Solver → Constraint processors: creates processors
BepuPhysics/Solver.cs - Solver → Bodies: accesses body state
BepuPhysics/Solver.cs - Solver → Island wake: uses island awakening
BepuPhysics/Solver.cs - Timestepper → Solver: advances solve
- Simulation → Timestepper: steps through
BepuPhysics/Simulation.cs - Simulation → Island sleep: supports low-cost sleep
BepuPhysics/Simulation.cs - Constraint processors → Bodies: solves against
BepuPhysics/Constraints/TypeProcessor.cs - Solver → Buffer pooling: allocates from
BepuPhysics/Solver.cs - Constraint processors → SIMD math: uses SIMD vectors
BepuPhysics/Constraints/TypeProcessor.cs - Task scheduler → Worker state: uses worker state
BepuUtilities/TaskScheduling/TaskStack.cs - Worker state → Buffer pooling: allocates worker buffers
BepuUtilities/TaskScheduling/Worker.cs - Worker state → Pooled collections: tracks allocated jobs
BepuUtilities/TaskScheduling/Worker.cs - Pooled collections → Buffer pooling: resizes through pool
BepuUtilities/Collections/QuickList.cs