Commit 84f289e4 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen

bug fix: the distance computation was ignoring the automatically added boundary obstacles.

parent ea6ba18d
Pipeline #55292 passed with stage
in 45 seconds
package org.vadere.simulator.control;
import java.util.Collection;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.vadere.simulator.models.potential.fields.IPotentialField;
import org.vadere.simulator.models.potential.fields.ObstacleDistancePotential;
import org.vadere.state.attributes.models.AttributesFloorField;
import org.vadere.state.attributes.scenario.AttributesObstacle;
import org.vadere.state.scenario.Car;
import org.vadere.state.scenario.Obstacle;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VPolygon;
import org.vadere.util.geometry.shapes.VRectangle;
public class OfflineTopographyController {
......@@ -39,6 +46,14 @@ public class OfflineTopographyController {
this.topography.addBoundary(obstacle);
}
}
// calculate distance after the boundary was added!
IPotentialField distanceField = new ObstacleDistancePotential(
topography.getObstacles().stream().map(obs -> obs.getShape()).collect(Collectors.toList()),
new VRectangle(topography.getBounds()),
new AttributesFloorField());
Function<VPoint, Double> obstacleDistance = p -> distanceField.getPotential(p, null);
this.topography.setObstacleDistanceFunction(obstacleDistance);
}
/**
......
......@@ -80,14 +80,6 @@ public class Simulation {
this.sourceControllers = new LinkedList<>();
this.targetControllers = new LinkedList<>();
this.topography = scenarioStore.topography;
IPotentialField distanceField = new ObstacleDistancePotential(
topography.getObstacles().stream().map(obs -> obs.getShape()).collect(Collectors.toList()),
new VRectangle(topography.getBounds()),
new AttributesFloorField());
Function<VPoint, Double> obstacleDistance = p -> distanceField.getPotential(p, null);
this.topography.setObstacleDistanceFunction(obstacleDistance);
this.runTimeInSec = attributesSimulation.getFinishTime();
this.startTimeInSec = startTimeInSec;
this.simTimeInSec = startTimeInSec;
......@@ -107,7 +99,6 @@ public class Simulation {
pft = ((PotentialFieldModel) mainModel).getPotentialFieldTarget();
}
for (PassiveCallback pc : this.passiveCallbacks) {
pc.setTopography(topography);
if(pft != null) {
......
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