From eaedc47ddcc275740291eb2b47ea281d40ac84f0 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Sun, 30 Sep 2012 13:11:07 +0000 Subject: [PATCH] Fixed findOutOfRoadSector to take the height into account (previously incorrect quads were found in FortMagma, when driving slightly off track beneath a different part of the track - and while this did not affect the kart's steering in this case, it could cause problems in other places). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11637 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/tracks/quad_graph.cpp | 59 ++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 17 deletions(-) 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 ) {