From 58bd28bb0339e7e4359a9d145e846fd6dbb148a9 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 22 Nov 2002 22:00:08 +0000 Subject: [PATCH] Make centerline light generation more robust for ultra short runways. This keeps us from generation a bogus output file that could crash fgfs. --- src/Airports/GenAirports/lights.cxx | 49 ++++++++++++++++------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/Airports/GenAirports/lights.cxx b/src/Airports/GenAirports/lights.cxx index 466d20d3..0da8669a 100644 --- a/src/Airports/GenAirports/lights.cxx +++ b/src/Airports/GenAirports/lights.cxx @@ -462,30 +462,35 @@ static superpoly_list gen_runway_center_line_lights( const FGRunway& rwy_info, dist -= step; } - FGPolygon lights_poly; lights_poly.erase(); - FGPolygon normals_poly; normals_poly.erase(); - lights_poly.add_contour( w_lights, false ); - normals_poly.add_contour( w_normals, false ); - - FGSuperPoly white; - white.set_poly( lights_poly ); - white.set_normals( normals_poly ); - white.set_material( "RWY_WHITE_MEDIUM_LIGHTS" ); - - lights_poly.erase(); - normals_poly.erase(); - lights_poly.add_contour( r_lights, false ); - normals_poly.add_contour( r_normals, false ); - - FGSuperPoly red; - red.set_poly( lights_poly ); - red.set_normals( normals_poly ); - red.set_material( "RWY_RED_MEDIUM_LIGHTS" ); - superpoly_list result; result.clear(); - result.push_back( white ); - result.push_back( red ); + if ( w_lights.size() > 0 ) { + FGPolygon lights_poly; lights_poly.erase(); + FGPolygon normals_poly; normals_poly.erase(); + lights_poly.add_contour( w_lights, false ); + normals_poly.add_contour( w_normals, false ); + + FGSuperPoly white; + white.set_poly( lights_poly ); + white.set_normals( normals_poly ); + white.set_material( "RWY_WHITE_MEDIUM_LIGHTS" ); + + result.push_back( white ); + } + + if ( r_lights.size() > 0 ) { + FGPolygon lights_poly; lights_poly.erase(); + FGPolygon normals_poly; normals_poly.erase(); + lights_poly.add_contour( r_lights, false ); + normals_poly.add_contour( r_normals, false ); + + FGSuperPoly red; + red.set_poly( lights_poly ); + red.set_normals( normals_poly ); + red.set_material( "RWY_RED_MEDIUM_LIGHTS" ); + + result.push_back( red ); + } return result; }