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

Visualiser: Begin Paused v2 #1052

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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/ModelVis.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ struct ModelVisData {
* Only need to register env properties once
*/
bool env_registered = false;
/**
* Marked true when first agent data has been passed to vis
*/
bool has_first_agents = true;
/**
* Updates all agent renders from corresponding
* @param sc Step count, the step count value shown in visualisation HUD
Expand Down
13 changes: 9 additions & 4 deletions src/flamegpu/visualiser/ModelVis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ void ModelVisData::registerEnvProperties() {
}
void ModelVisData::updateBuffers(const unsigned int& sc) {
if (visualiser) {
bool has_agents = false;
bool _has_first_agents = false;
for (auto& a : agents) {
has_agents = a.second->requestBufferResizes(visualiser, sc == 0 || sc == UINT_MAX) || has_agents;
_has_first_agents = a.second->requestBufferResizes(visualiser, sc == 0 || sc == UINT_MAX) || _has_first_agents;
}
if (_has_first_agents) {
_has_first_agents = !this->has_first_agents;
this->has_first_agents = true;
}
// Block the sim when we first get agents, until vis has resized buffers, incase vis is being slow to init
if (has_agents && (sc == 0 || sc == UINT_MAX)) {
if (_has_first_agents) {
while (!visualiser->buffersReady()) {
// Do nothing, just spin until ready
std::this_thread::yield();
Expand All @@ -56,7 +60,7 @@ void ModelVisData::updateBuffers(const unsigned int& sc) {
}
visualiser->releaseMutex();
// Block the sim again, until vis is fully ready
if (has_agents && (sc == 0 || sc == UINT_MAX)) {
if (_has_first_agents) {
while (!visualiser->isReady()) {
// Do nothing, just spin until ready
std::this_thread::yield();
Expand Down Expand Up @@ -135,6 +139,7 @@ void ModelVis::_activate() {
agent.second->initBindings(data->visualiser);
}
data->env_registered = false;
data->has_first_agents = false;
data->registerEnvProperties();
data->visualiser->start();
}
Expand Down