wip: wait until data is ready and has been consumed (couples physics and rendering thread again)

This commit is contained in:
2026-02-24 13:16:00 +01:00
parent 74065b7ea2
commit e7d4170b77
6 changed files with 37 additions and 22 deletions

View File

@ -2,6 +2,7 @@
#define __PHYSICS_HPP_
#include <atomic>
#include <condition_variable>
#include <mutex>
#include <queue>
#include <raylib.h>
@ -150,7 +151,11 @@ class ThreadedPhysics {
TracyLockable(std::mutex, command_mtx);
std::queue<Command> pending_commands;
TracyLockable(std::mutex, pos_mtx);
TracyLockable(std::mutex, data_mtx);
std::condition_variable_any data_ready_cnd;
std::condition_variable_any data_consumed_cnd;
bool data_ready = false;
bool data_consumed = true;
std::vector<Mass> masses; // Read by renderer
std::unordered_map<State, int> state_masses; // Read by renderer
std::vector<Spring> springs; // Read by renderer