wip: wait until data is ready and has been consumed (couples physics and rendering thread again)
This commit is contained in:
@ -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
|
||||
|
||||
@ -61,10 +61,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
auto AllocateGraphInstancing(const std::vector<Mass> &masses) -> void;
|
||||
auto AllocateGraphInstancing(std::size_t size) -> void;
|
||||
|
||||
auto ReallocateGraphInstancingIfNecessary(const std::vector<Mass> &masses)
|
||||
-> void;
|
||||
auto ReallocateGraphInstancingIfNecessary(std::size_t size) -> void;
|
||||
|
||||
public:
|
||||
auto UpdateTextureSizes() -> void;
|
||||
|
||||
Reference in New Issue
Block a user