diff --git a/src/Airports/GenAirports850/linearfeature.cxx b/src/Airports/GenAirports850/linearfeature.cxx index 8fa3f216..e7f12381 100644 --- a/src/Airports/GenAirports850/linearfeature.cxx +++ b/src/Airports/GenAirports850/linearfeature.cxx @@ -569,7 +569,7 @@ int LinearFeature::Finish( bool closed, unsigned int idx ) { markStarted = false; cur_light_dist = 0.0f; - bool directional_light = lights[i]->IsDirectional(); + int light_direction = lights[i]->LightDirection(); bool alternate = false; // which material for this light @@ -647,33 +647,53 @@ int LinearFeature::Finish( bool closed, unsigned int idx ) tmp = SGGeodesy::direct( prev_outer, heading, cur_light_dist ); } - SGVec3f vec; - if ( !directional_light ) + SGVec3f vec1, vec2; + if ( light_direction == 0) { // calculate the omnidirectional normal - vec = normalize(SGVec3f::fromGeod(tmp)); - } else + vec1 = normalize(SGVec3f::fromGeod(tmp)); + } else if ( light_direction == 1) { - // calculate the directional normal + // calculate the directional normal. These lights all face to the right double heading_vec = SGMiscd::normalizePeriodic( 0, 360, heading + 90.0 ); SGVec3f cart1 = SGVec3f::fromGeod(tmp); SGVec3f cart2 = SGVec3f::fromGeod( SGGeodesy::direct( tmp, heading_vec, 10 ) ); - vec = normalize(cart2 - cart1); + vec1 = normalize(cart2 - cart1); + } else //( light_direction == 2) + { + // calculate the directional normals for bidirectional lights + SGVec3f cart1 = SGVec3f::fromGeod(tmp); + SGVec3f cart2 = SGVec3f::fromGeod( SGGeodesy::direct( tmp, heading, 10 ) ); + vec1 = normalize(cart2 - cart1); + cart2 = SGVec3f::fromGeod( SGGeodesy::direct( tmp, heading, -10 ) ); + vec2 = normalize(cart2 - cart1); } if (!alternate) { - cur_light_contour.AddLight( tmp, vec ); + cur_light_contour.AddLight( tmp, vec1 ); + if ( light_direction == 2) + { + cur_light_contour.AddLight( tmp, vec2 ); + } } else { if (switch_poly) { - cur_light_contour.AddLight( tmp, vec ); + cur_light_contour.AddLight( tmp, vec1 ); + if ( light_direction == 2) + { + cur_light_contour.AddLight( tmp, vec2 ); + } } else { - alt_light_contour.AddLight( tmp, vec ); + alt_light_contour.AddLight( tmp, vec1 ); + if ( light_direction == 2) + { + alt_light_contour.AddLight( tmp, vec2 ); + } } switch_poly = !switch_poly; } diff --git a/src/Airports/GenAirports850/linearfeature.hxx b/src/Airports/GenAirports850/linearfeature.hxx index 62ac52a7..073780da 100644 --- a/src/Airports/GenAirports850/linearfeature.hxx +++ b/src/Airports/GenAirports850/linearfeature.hxx @@ -55,9 +55,14 @@ public: unsigned int start_idx; unsigned int end_idx; - bool IsDirectional() + // 1 for unidirectional + // 2 for bidirectional + // 0 for omnidirectional + int LightDirection() { - return (type == 103 || type == 104) ? true : false; + if (type == 103 || type == 104) return 1; + else if (type == 101 || type == 105) return 2; + return 0; } }; typedef std::vector LightingList; @@ -123,4 +128,4 @@ private: typedef std::vector FeatureList; -#endif \ No newline at end of file +#endif