Commit 9042126f authored by Marion Goedel's avatar Marion Goedel
Browse files

Added a check if pedestrians that are generated are overlapping with obstacles.

parent be202fad
Pipeline #71957 failed with stages
in 48 seconds
......@@ -117,8 +117,9 @@ public class SingleSourceController extends SourceController {
VPoint randomPoint = new VPoint(rec.getMinX() + random.nextDouble() * rec.getWidth(), rec.getMinY() + random.nextDouble() * rec.getHeight());
VShape freeSpaceRequired = dynamicElementFactory.getDynamicElementRequiredPlace(randomPoint);
// no intersection with other free spaces.
if(blockPedestrianShapes.stream().noneMatch(shape -> shape.intersects(freeSpaceRequired))) {
// no intersection with other free spaces (obstacles & other pedestrians)
if(blockPedestrianShapes.stream().noneMatch(shape -> shape.intersects(freeSpaceRequired))
&& this.getTopography().getObstacles().stream().noneMatch(obs -> obs.getShape().intersects(freeSpaceRequired))) {
return Optional.of(randomPoint);
}
}
......
......@@ -26,10 +26,11 @@ import java.util.Random;
public abstract class SourceController {
protected final double NO_EVENT = Double.MAX_VALUE;
public static final double SPAWN_BUFFER_SIZE = 0.01;
public static final double SPAWN_BUFFER_SIZE = 0.03;
protected final Source source;
private final DynamicElementFactory dynamicElementFactory;
private final Topography topography;
protected final Random random;
......@@ -111,6 +112,10 @@ public abstract class SourceController {
abstract protected void determineNumberOfSpawnsAndNextEvent(double simTimeInSec);
protected Topography getTopography() {
return topography;
}
protected void createNextEvent() {
if (isSourceWithOneSingleSpawnEvent()) {
timeOfNextEvent = NO_EVENT;
......
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