1#ifndef PHYSICS_WORKER_HPP
2#define PHYSICS_WORKER_HPP
19Q_DECLARE_METATYPE(Model::Vector3dVec);
20Q_DECLARE_METATYPE(Model::QuaterniondVec);
44 explicit PhysicsWorker(
const Configuration::SimulationConfig& config,
45 QObject* in_parent =
nullptr);
76 const QuaterniondVec& quaternions,
77 const Vector3dVec& torques,
78 const Vector3dVec& alphas,
79 std::size_t iteration);
SoA container for simulation bodies and proxies for AoS-like access.
Runs the physics simulation in a separate thread to keep the UI responsive.
void cleanup()
Triggers cleanup tasks before the worker is destroyed.
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.
void startSimulation()
Starts the simulation loop.
std::unique_ptr< Space > space_
The simulation space containing all bodies and physics logic.
std::size_t iterationCount_
The current simulation iteration count.
std::vector< ConstBodyProxy > getInitialBodies() const
Provides read-only access to the initial list of body proxies.
void performSingleStep()
Performs a single step of the physics simulation and emits the results.
std::size_t maxIterations_
The maximum number of iterations to run.
void simulationFinished()
Emitted when the simulation has completed all iterations.
void stopSimulation()
Stops the simulation loop. This should be called before cleanup to prevent new steps from being sched...
~PhysicsWorker() override
Destructor.
PhysicsWorker(const Configuration::SimulationConfig &config, QObject *in_parent=nullptr)
Constructs the physics worker.
bool isRunning_
A flag to control the execution of the simulation loop.