Skip to content

Commit

Permalink
Fix begin paused behaviour
Browse files Browse the repository at this point in the history
Adds an additional block, after buffers have been resized, until begin paused has had a chance to take effect.

Closes #53
  • Loading branch information
Robadob committed Mar 12, 2023
1 parent 4019b87 commit 02097b5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
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 @@ -110,6 +110,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 @@ -465,9 +466,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 @@ -580,6 +584,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

0 comments on commit 02097b5

Please sign in to comment.