|
pure-cpp 1.0.0
A C++ physics simulation benchmark comparing performance with Python implementations
|
Runs the physics simulation in a separate thread to keep the UI responsive. More...
#include <physics_worker.hpp>


Public Slots | |
| void | startSimulation () |
| Starts the simulation loop. More... | |
| void | performSingleStep () |
| Performs a single step of the physics simulation and emits the results. More... | |
| void | stopSimulation () |
| Stops the simulation loop. This should be called before cleanup to prevent new steps from being scheduled. More... | |
Signals | |
| void | updatedBodyData (const Vector3dVec &positions, const QuaterniondVec &quaternions, const Vector3dVec &torques, const Vector3dVec &alphas, std::size_t iteration) |
| Emitted after each simulation step with the updated state of all bodies. More... | |
| void | simulationFinished () |
| Emitted when the simulation has completed all iterations. | |
Public Member Functions | |
| PhysicsWorker (const Configuration::SimulationConfig &config, QObject *in_parent=nullptr) | |
| Constructs the physics worker. More... | |
| ~PhysicsWorker () override | |
| Destructor. More... | |
| void | cleanup () |
| Triggers cleanup tasks before the worker is destroyed. More... | |
| std::vector< ConstBodyProxy > | getInitialBodies () const |
| Provides read-only access to the initial list of body proxies. More... | |
Private Attributes | |
| std::unique_ptr< Space > | space_ |
| The simulation space containing all bodies and physics logic. More... | |
| std::size_t | iterationCount_ |
| The current simulation iteration count. More... | |
| std::size_t | maxIterations_ |
| The maximum number of iterations to run. More... | |
| bool | isRunning_ |
| A flag to control the execution of the simulation loop. More... | |
Runs the physics simulation in a separate thread to keep the UI responsive.
This worker object owns the Space instance and communicates with the main (GUI) thread via signals and slots.
Definition at line 34 of file physics_worker.hpp.
|
explicit |
Constructs the physics worker.
| config | The simulation configuration. |
| in_parent | The parent QObject, if any. |
Definition at line 21 of file physics_worker.cpp.
|
overridedefault |
Destructor.
Destructor. The definition must be in the .cpp file where Space is fully defined.
| void Model::PhysicsWorker::cleanup | ( | ) |
Triggers cleanup tasks before the worker is destroyed.
Instructs the Space object to print its final profiling report.
This is primarily used to instruct the Space object to print its final profiling report.
Definition at line 43 of file physics_worker.cpp.
| std::vector< ConstBodyProxy > Model::PhysicsWorker::getInitialBodies | ( | ) | const |
Provides read-only access to the initial list of body proxies.
Definition at line 52 of file physics_worker.cpp.
|
slot |
Performs a single step of the physics simulation and emits the results.
Definition at line 76 of file physics_worker.cpp.

|
slot |
Starts the simulation loop.
This slot is connected to the QThread's started signal.
Definition at line 66 of file physics_worker.cpp.


|
slot |
Stops the simulation loop. This should be called before cleanup to prevent new steps from being scheduled.
Definition at line 99 of file physics_worker.cpp.
|
signal |
Emitted after each simulation step with the updated state of all bodies.
| positions | A vector of all body positions. |
| quaternions | A vector of all body orientations. |
| torques | A vector of all body torques. |
| alphas | A vector of all body angular accelerations. |
| iteration | The current simulation iteration number. |

|
private |
A flag to control the execution of the simulation loop.
Definition at line 111 of file physics_worker.hpp.
|
private |
The current simulation iteration count.
Definition at line 107 of file physics_worker.hpp.
|
private |
The maximum number of iterations to run.
Definition at line 109 of file physics_worker.hpp.
|
private |
The simulation space containing all bodies and physics logic.
Definition at line 105 of file physics_worker.hpp.