diff --git a/src/tracks/quad_graph.cpp b/src/tracks/quad_graph.cpp index 59dfd4219..57547c666 100644 --- a/src/tracks/quad_graph.cpp +++ b/src/tracks/quad_graph.cpp @@ -900,25 +900,50 @@ int QuadGraph::findOutOfRoadSector(const Vec3& xyz, int min_sector = UNKNOWN_SECTOR; float min_dist_2 = 999999.0f*999999.0f; - for(int j=0; jgetDistance2FromPoint(xyz); - if(dist_2getDistance2FromPoint(xyz); + if(dist_2-1.0f) ) + { + min_dist_2 = dist_2; + min_sector = next_sector; + } + } + current_sector = next_sector; + } // for j + // Leave in phase 0 if any sector was found. + if(min_sector!=UNKNOWN_SECTOR) + return min_sector; +#ifdef DEBUG + printf("findOutOfRoadSector: can't find sector with height for " + "%f %f %f\n", xyz.getX(), xyz.getY(), xyz.getZ()); +#endif + } // phase if(min_sector==UNKNOWN_SECTOR ) {