diff --git a/pc/src/pathfinding/astar/arcs/ArcManager.java b/pc/src/pathfinding/astar/arcs/ArcManager.java index 2710aa21..f3dd63b2 100644 --- a/pc/src/pathfinding/astar/arcs/ArcManager.java +++ b/pc/src/pathfinding/astar/arcs/ArcManager.java @@ -383,10 +383,12 @@ public double heuristicDirect(Cinematique cinematique) public void disableObstaclesFixes(boolean symetrie, CinematiqueObs obs) { disabledObstaclesFixes.clear(); + ObstaclesFixes depart; if(symetrie) - disabledObstaclesFixes.add(ObstaclesFixes.ZONE_DEPART_GAUCHE_CENTRE); + depart = ObstaclesFixes.ZONE_DEPART_GAUCHE_CENTRE; else - disabledObstaclesFixes.add(ObstaclesFixes.ZONE_DEPART_DROITE_CENTRE); + depart = ObstaclesFixes.ZONE_DEPART_DROITE_CENTRE; + disabledObstaclesFixes.add(depart); for(ObstaclesFixes o : ObstaclesFixes.values()) if(!o.bordure && o.getObstacle().isColliding(obs.obstacle)) { @@ -394,9 +396,9 @@ public void disableObstaclesFixes(boolean symetrie, CinematiqueObs obs) disabledObstaclesFixes.add(o); } if(!disabledObstaclesFixes.isEmpty()) - dstarlite.disableObstaclesFixes(obs.getPosition()); + dstarlite.disableObstaclesFixes(obs.getPosition(), depart.getObstacle()); else - dstarlite.disableObstaclesFixes(null); + dstarlite.disableObstaclesFixes(null, depart.getObstacle()); } public boolean isToCircle() diff --git a/pc/src/pathfinding/dstarlite/DStarLite.java b/pc/src/pathfinding/dstarlite/DStarLite.java index f50981ea..7c42d155 100644 --- a/pc/src/pathfinding/dstarlite/DStarLite.java +++ b/pc/src/pathfinding/dstarlite/DStarLite.java @@ -34,6 +34,7 @@ import container.dependances.LowPFClass; import graphic.PrintBufferInterface; import graphic.printable.Couleur; +import obstacles.types.Obstacle; /** * Recherche de chemin avec replanification rapide. @@ -676,9 +677,9 @@ public synchronized void stopContinuousSearch() rechercheEnCours = false; } - public void disableObstaclesFixes(Vec2RO position) + public void disableObstaclesFixes(Vec2RO position, Obstacle obstacle) { - gridspace.disableObstaclesFixes(position); + gridspace.disableObstaclesFixes(position, obstacle); } } diff --git a/pc/src/pathfinding/dstarlite/gridspace/GridSpace.java b/pc/src/pathfinding/dstarlite/gridspace/GridSpace.java index b0dea603..5ab735d6 100644 --- a/pc/src/pathfinding/dstarlite/gridspace/GridSpace.java +++ b/pc/src/pathfinding/dstarlite/gridspace/GridSpace.java @@ -292,15 +292,14 @@ public Layer getLayer() return Layer.MIDDLE; } - public void disableObstaclesFixes(Vec2RO position) + public void disableObstaclesFixes(Vec2RO position, Obstacle obstacle) { // on initialise comme la grille statique classique grilleStatiqueModif.clear(); grilleStatiqueModif.or(grilleStatique); - if(position != null) - for(int i = 0; i < PointGridSpace.NB_POINTS; i++) - if(grilleStatiqueModif.get(i) && pointManager.get(i).computeVec2().distanceFast(position) < rayonRobotObstaclesFixes) - grilleStatiqueModif.clear(i); + for(int i = 0; i < PointGridSpace.NB_POINTS; i++) + if(grilleStatiqueModif.get(i) && ((position != null && pointManager.get(i).computeVec2().distanceFast(position) < rayonRobotObstaclesFixes) || obstacle.squaredDistance(pointManager.get(i).computeVec2()) == 0)) + grilleStatiqueModif.clear(i); } }