FLAMEGPU / FLAMEGPU2-visualiser

Cross platform real-time OpenGL visualiser for FLAMEGPU2 models.
1 stars 2 forks source link

Begin Paused without Agents prior to Step 0 #122

Open ptheywood opened 1 year ago

ptheywood commented 1 year ago

The fix from #120 only fixed beginPaused when there are agents present prior to the start of simulation step 0.

I.e. if agents are created in a hostLayer function during step 0, or in a step function at the end of step 0 the simualtion will not begin paused, and will pause at some arbitrary frame later.

This might also require changes to splash screen closing logic.

Robadob commented 1 year ago

Started looking at this.

I tried stripping out has_agents from this function.

https://github.com/FLAMEGPU/FLAMEGPU2/blob/c5007d284da9d8efbf0e937bb02034f571a7b0ef/src/flamegpu/visualiser/ModelVis.cpp#L37

But that leads to the visualiser being stuck at step 0 (with the splash screen open) when the model begins with no agents, regardless of pause state or beginPaused setting.

Debugging shows it's stuck waiting for vis to confirm it's done the initial buffer allocation.

            while (!visualiser->buffersReady()) {
                // Do nothing, just spin until ready
                std::this_thread::yield();
            }

Not too sure best way to handle this. Either strip out this check (or rather replace it with something that merely check's vis init flow is complete). Or give buffers a default allocation so they are ready assuming initial agent account is <= default.

I attempted this fix by:

This now pauses with splash screen closed at step 0, but agents are not visible in the paused frame if they are created before the sim.

Robadob commented 1 year ago

I think it would be easier to change the beginPaused logic so it always pauses at the first step with agents.

Would this be acceptable?

(I think it would just require has_agents to be calculated differently, and the step count checks in the above ModelVis fn to be removed).