From 4c6abccd9686828f71c87c8adf5cb2685f69d30c Mon Sep 17 00:00:00 2001 From: PF Date: Tue, 23 May 2017 14:38:43 +0200 Subject: [PATCH] =?UTF-8?q?Sym=C3=A9trie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc/src/pathfinding/astar/arcs/ArcManager.java | 10 ++++++---- pc/src/pathfinding/dstarlite/DStarLite.java | 5 +++-- pc/src/pathfinding/dstarlite/gridspace/GridSpace.java | 9 ++++----- 3 files changed, 13 insertions(+), 11 deletions(-) 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); } }