Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix begin paused behaviour #120

Merged
merged 1 commit into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/flamegpu/visualiser/FLAMEGPU_Visualisation.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class FLAMEGPU_Visualisation {
/**
* Set true when the vis has resized the first agent's buffers
*/
bool buffersReady() const;
/**
* Set true when the vis has had a chance to pause if beginPaused is enabled
*/
bool isReady() const;

private:
Expand Down
3 changes: 3 additions & 0 deletions src/flamegpu/visualiser/FLAMEGPU_Visualisation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ void FLAMEGPU_Visualisation::stop() {
bool FLAMEGPU_Visualisation::isRunning() const {
return vis->isRunning();
}
bool FLAMEGPU_Visualisation::buffersReady() const {
return vis->buffersReady();
}
bool FLAMEGPU_Visualisation::isReady() const {
return vis->isReady();
}
Expand Down
8 changes: 7 additions & 1 deletion src/flamegpu/visualiser/Visualiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Visualiser::Visualiser(const ModelConfig& modelcfg)
, isInitialised(false)
, continueRender(false)
, buffersAllocated(false)
, visualisationLoaded(false)
, msaaState(true)
, windowTitle(modelcfg.windowTitle)
, windowDims(modelcfg.windowDimensions[0], modelcfg.windowDimensions[1])
Expand Down Expand Up @@ -468,9 +469,12 @@ void Visualiser::render() {
bool Visualiser::isRunning() const {
return continueRender;
}
bool Visualiser::isReady() const {
bool Visualiser::buffersReady() const {
return buffersAllocated;
}
bool Visualiser::isReady() const {
return visualisationLoaded;
}
void Visualiser::addAgentState(const std::string &agent_name, const std::string &state_name, const AgentStateConfig &vc,
const std::map<TexBufferConfig::Function, TexBufferConfig>& core_tex_buffers, const std::multimap<TexBufferConfig::Function, CustomTexBufferConfig>& tex_buffers) {
std::pair<std::string, std::string> namepair = { agent_name, state_name };
Expand Down Expand Up @@ -583,6 +587,8 @@ void Visualiser::renderAgentStates() {
this->pause_guard = guard;
guard = nullptr;
}
// Notify the sim that we're ready and it can continue
visualisationLoaded = true;
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/flamegpu/visualiser/Visualiser.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class Visualiser : public ViewportExt {
/**
* Returns true if the first agent buffer resize has been requested and applied
*/
bool buffersReady() const;
/**
* Returns true if the beginPaused has had a chance to be activated
*/
bool isReady() const;
/**
* Adds the render details for a specific agent state
Expand Down Expand Up @@ -272,6 +276,10 @@ class Visualiser : public ViewportExt {
*/
std::atomic<bool> continueRender;
std::atomic<bool> buffersAllocated;
/**
* Flag which notifies the simulation it can continue past step 0
*/
std::atomic<bool> visualisationLoaded;
/**
* Flag representing whether MSAA is currently enabled
* MSAA can be toggled at runtime with F10
Expand Down