How jrouwe/joltphysics works
Main Components
• Physics Engine Core:
– Jolt/Core: Contains low-level utilities, memory management, job systems (single-threaded and thread pools), and profiler support.
– Jolt/Math: Provides vector, matrix, quaternion operations, and other mathematical utilities.
– Jolt/Geometry: Implements spatial partitioning (AABB trees, Morton codes) and geometric calculations.
– Jolt/Physics: This is the heart of the simulation. Break it down into submodules such as:
○ Body, Character, and Collision (rigid body simulation, collision detection with broadphase and narrow phase).
○ Constraints (hinge, slider, distance, fixed constraints, etc.) and Job systems to support multi-core processing.
○ Vehicles, SoftBody, Ragdoll for simulating more specialized dynamics.
– ObjectStream: Handles serialization and deserialization of physics data.
• External/Support Components:
– TestFramework: The rendering and input framework used by both the Sample applications and the JoltViewer; includes support for multiple graphics APIs (DX, Metal, Vulkan).
– JoltViewer: Provides a standalone debugging/visualization application for recorded simulation output (using the debug renderer classes).
– Samples & PerformanceTest: These are demonstration applications that show usage of the engine and measure its performance.
– Assets & Shaders: These include the fonts, shader sources (for different rendering APIs), and other resources that the test framework or viewer will load.
– Build Scripts, CMake files, and platform-specific configurations that allow building on Windows, Linux, macOS, Android, etc.
Relationships and Data Flow
• That the Physics module has direct subcomponents for Collision Detection (broad phase and narrow phase), Constraint Solvers, and Simulation update.
• Sample applications using the TestFramework for rendering and user input, while also interfacing with the core physics simulation.
Architectural Patterns & Principles
• Modularity: Emphasize that the engine is split into logically separated yet interdependent modules (Physics, Geometry, Math, etc.).
• Multi-threading and Determinism: Mark the use of job systems from the Core module which allow simulations to run concurrently with collision queries and background scene updates.
• Separation of Concerns: Illustrate how simulation, visualization, and testing are kept in independent modules (Jolt, TestFramework, Samples).
• Platform Abstraction: The existence of separate rendering directories (DX, MTL, VK) in both Assets/Shaders and TestFramework/Renderer indicates that rendering is abstracted to support multiple platforms.
Relevant Technologies, Frameworks, and Libraries
• C++ 17 is used with heavy reliance on the STL (with custom memory management, without RTTI or exceptions).
• Multi-threading, SIMD instructions (SSE2, SSE4.1 through AVX variants on x86/x64; NEON on ARM), and a custom job system.
• Rendering support for DirectX 12, Metal (MTL), Vulkan (VK), and integration with sample apps and viewer based on these APIs.
• CMake is used for build configuration across multiple platforms.
Specific Elements
• Clear boundaries for each module (e.g., “Core & Math”, “Geometry”, “Physics”, “Collision”, “Constraints”).
– Simulation update cycle from the physics engine into the debug renderer.
– Resource loading (from Assets/Shaders) into the TestFramework for rendering.
– Build system connections with different platform-specific configurations.
• Labels to indicate that modules support multi-threading (job system) and deterministic simulation.
• Notation that the physics engine supports a variety of body types and constraints with examples (rigid bodies, vehicles, soft bodies, ragdolls).