Commit 2369669d authored by hm-mgoedel's avatar hm-mgoedel

Issue #138 : Update only if there are still pedestrians in the scenario and...

Issue #138 : Update only if there are still pedestrians in the scenario and /or still pedestrians to be spawned.
parent d67d3808
Pipeline #99358 passed with stages
in 120 minutes and 40 seconds
......@@ -24,6 +24,7 @@ import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
public class Simulation {
......@@ -319,10 +320,17 @@ public class Simulation {
cognitionLayer.prioritizeEventsForPedestrians(events, pedestrians);
for (Model m : models) {
m.update(simTimeInSec);
if (topography.isRecomputeCells()){
// rebuild CellGrid if model does not manage the CellGrid state while updating
topographyController.update(simTimeInSec); //rebuild CellGrid
List<SourceController> stillSpawningSource = this.sourceControllers.stream().filter(s -> !s.isSourceFinished(simTimeInSec)).collect(Collectors.toList());
int pedestriansInSimulation = this.simulationState.getTopography().getPedestrianDynamicElements().getElements().size();
// Only update until there are pedestrians in the scenario or pedestrian to spawn
if (!stillSpawningSource.isEmpty() || pedestriansInSimulation > 0 ) {
m.update(simTimeInSec);
if (topography.isRecomputeCells()) {
// rebuild CellGrid if model does not manage the CellGrid state while updating
topographyController.update(simTimeInSec); //rebuild CellGrid
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment