From efce88ff12164e34cefdc9761e692bcf5beec2cf Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 11 Jan 2005 16:02:39 +0000 Subject: [PATCH] - Fix a couple oops's in cloud.cxx - In sky.cxx blend low density cloud layers (few/scattered) into nothing (but don't touch visibility distance) as we approach them so we can fly through clean. - For high density cloud layers (broken/overcast) we do not fade the layers out, but we fade visibility to nearly nothing as we approach the layer. --- simgear/scene/sky/cloud.cxx | 18 +++++++++--------- simgear/scene/sky/sky.cxx | 37 +++++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/simgear/scene/sky/cloud.cxx b/simgear/scene/sky/cloud.cxx index d567f729..24b03e96 100644 --- a/simgear/scene/sky/cloud.cxx +++ b/simgear/scene/sky/cloud.cxx @@ -633,25 +633,25 @@ bool SGCloudLayer::repaint( sgVec3 fog_color ) { for ( int i = 0; i < 4; i++ ) { color = cl[i]->get( 0 ); sgCopyVec3( color, fog_color ); - color[3] = (i == 0) ? 0.0f : 0.15f; + color[3] = (i == 0) ? 0.0f : cloud_alpha * 0.15f; for ( int j = 0; j < 4; ++j ) { - color = cl[i]->get( (2*j) ); - sgCopyVec3( color, fog_color ); - color[3] = - ((j == 0) || (i == 3)) ? - ((j == 0) && (i == 3)) ? 0.0f : 0.15f : 1.0f; - color = cl[i]->get( (2*j) + 1 ); sgCopyVec3( color, fog_color ); + color[3] = + ((j == 0) || (i == 3)) ? + ((j == 0) && (i == 3)) ? 0.0f : cloud_alpha * 0.15f : cloud_alpha; + + color = cl[i]->get( (2*j) + 2 ); + sgCopyVec3( color, fog_color ); color[3] = ((j == 3) || (i == 0)) ? - ((j == 3) && (i == 0)) ? 0.0f : 0.15f : 1.0f; + ((j == 3) && (i == 0)) ? 0.0f : cloud_alpha * 0.15f : cloud_alpha; } color = cl[i]->get( 9 ); sgCopyVec3( color, fog_color ); - color[3] = (i == 3) ? 0.0f : 0.15f; + color[3] = (i == 3) ? 0.0f : cloud_alpha * 0.15f; } } diff --git a/simgear/scene/sky/sky.cxx b/simgear/scene/sky/sky.cxx index ae1a2c0a..53ff7314 100644 --- a/simgear/scene/sky/sky.cxx +++ b/simgear/scene/sky/sky.cxx @@ -266,10 +266,7 @@ void SGSky::modify_vis( float alt, float time_factor ) { double ratio = 1.0; - if ( cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_CLEAR || - cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_FEW || - cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_SCATTERED) - { + if ( cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_CLEAR ) { // less than 50% coverage -- assume we're in the clear for now ratio = 1.0; } else if ( alt < asl - transition ) { @@ -289,13 +286,33 @@ void SGSky::modify_vis( float alt, float time_factor ) { ratio = 1.0; } - // set the alpha fade value for the cloud layer - float temp = ratio * 2.0; - if ( temp > 1.0 ) { temp = 1.0; } - cloud_layers[i]->setAlpha( temp ); + if ( cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_CLEAR ) { + // do nothing, clear layers aren't drawn, don't affect + // visibility andn dont' need to be faded in or out. + } else if ( (cloud_layers[i]->getCoverage() == + SGCloudLayer::SG_CLOUD_FEW) + || (cloud_layers[i]->getCoverage() == + SGCloudLayer::SG_CLOUD_SCATTERED) ) + { + // set the alpha fade value for the cloud layer. For less + // dense cloud layers we fade the layer to nothing as we + // approach it because we stay clear visibility-wise as we + // pass through it. + float temp = ratio * 2.0; + if ( temp > 1.0 ) { temp = 1.0; } + cloud_layers[i]->setAlpha( temp ); - // accumulate effects from multiple cloud layers - effvis *= ratio; + // don't touch visibility + } else { + // maintain full alpha for denser cloud layer types. + // Let's set the value explicitly in case someone changed + // the layer type. + cloud_layers[i]->setAlpha( 1.0 ); + + // lower visibility as we approach the cloud layer. + // accumulate effects from multiple cloud layers + effvis *= ratio; + } #if 0 if ( ratio < 1.0 ) {