From 9593059258f391b50bb2417b819e14257d64b592 Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 23 Jan 2003 21:59:07 +0000 Subject: [PATCH] Misc. tweaks that have been laying around. --- configure.ac | 2 +- simgear/scene/sky/cloud.cxx | 79 +++++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/configure.ac b/configure.ac index 7846a9b4..0d4131cf 100644 --- a/configure.ac +++ b/configure.ac @@ -379,7 +379,7 @@ dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS( \ fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \ - sys/stat.h sys/time.h sys/timeb.h unistd.h winbase.h values.h ) + sys/stat.h sys/time.h sys/timeb.h unistd.h values.h ) if test "x$ac_cv_header_stdint_h" = "xyes"; then AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists]) diff --git a/simgear/scene/sky/cloud.cxx b/simgear/scene/sky/cloud.cxx index 74fd99e6..5cb994f0 100644 --- a/simgear/scene/sky/cloud.cxx +++ b/simgear/scene/sky/cloud.cxx @@ -37,17 +37,26 @@ SGCloudLayer::layer_states[SGCloudLayer::SG_MAX_CLOUD_TYPES]; // Constructor -SGCloudLayer::SGCloudLayer( const string &tex_path ) - : layer_root(new ssgRoot), +SGCloudLayer::SGCloudLayer( const string &tex_path ) : + layer_root(new ssgRoot), layer_transform(new ssgTransform), - layer(0), + layer(NULL), + cl(NULL), + vl(NULL), + tl(NULL), texture_path(tex_path), - layer_span(0), - layer_asl(0), - layer_thickness(0), - layer_transition(0), - layer_type(SG_CLOUD_CLEAR) + layer_span(0.0), + layer_asl(0.0), + layer_thickness(0.0), + layer_transition(0.0), + layer_type(SG_CLOUD_CLEAR), + scale(4000.0), + last_lon(0.0), + last_lat(0.0) { + for ( int i = 0; i < SG_MAX_CLOUD_TYPES; ++i ) { + layer_states[i] = NULL; + } layer_root->addKid(layer_transform); rebuild(); } @@ -130,33 +139,38 @@ void SGCloudLayer::rebuild() { // Initialize states and sizes if necessary. - if (layer_states[0] == 0) { - SGPath cloud_path; + if ( layer_states[0] == NULL ) { + SGPath cloud_path; - cloud_path.set(texture_path.str()); - cloud_path.append("overcast.rgb"); - layer_states[SG_CLOUD_OVERCAST] = SGCloudMakeState(cloud_path.str()); + cloud_path.set(texture_path.str()); + cloud_path.append("overcast.rgb"); + layer_states[SG_CLOUD_OVERCAST] = SGCloudMakeState(cloud_path.str()); - cloud_path.set(texture_path.str()); - cloud_path.append("mostlycloudy.rgba"); - layer_states[SG_CLOUD_MOSTLY_CLOUDY] = - SGCloudMakeState(cloud_path.str()); + cloud_path.set(texture_path.str()); + cloud_path.append("mostlycloudy.rgba"); + layer_states[SG_CLOUD_MOSTLY_CLOUDY] + = SGCloudMakeState(cloud_path.str()); - cloud_path.set(texture_path.str()); - cloud_path.append("mostlysunny.rgba"); - layer_states[SG_CLOUD_MOSTLY_SUNNY] = SGCloudMakeState(cloud_path.str()); + cloud_path.set(texture_path.str()); + cloud_path.append("mostlysunny.rgba"); + layer_states[SG_CLOUD_MOSTLY_SUNNY] + = SGCloudMakeState(cloud_path.str()); - cloud_path.set(texture_path.str()); - cloud_path.append("cirrus.rgba"); - layer_states[SG_CLOUD_CIRRUS] = SGCloudMakeState(cloud_path.str()); + cloud_path.set(texture_path.str()); + cloud_path.append("cirrus.rgba"); + layer_states[SG_CLOUD_CIRRUS] = SGCloudMakeState(cloud_path.str()); - layer_states[SG_CLOUD_CLEAR] = 0; + layer_states[SG_CLOUD_CLEAR] = 0; } scale = 4000.0; last_lon = last_lat = -999.0f; + if ( layer != NULL ) { + layer_transform->removeKid(layer); // automatic delete + } + cl = new ssgColourArray( 4 ); vl = new ssgVertexArray( 4 ); tl = new ssgTexCoordArray( 4 ); @@ -193,17 +207,15 @@ SGCloudLayer::rebuild() vl->add( vertex ); tl->add( tc ); - if (layer != 0) - layer_transform->removeKid(layer); // automatic delete layer = new ssgVtxTable ( GL_TRIANGLE_STRIP, vl, NULL, tl, cl ); - if (layer_states[layer_type] != 0) - layer->setState( layer_states[layer_type] ); + layer_transform->addKid( layer ); + if ( layer_states[layer_type] != NULL ) { + layer->setState( layer_states[layer_type] ); + } - // force a repaint of the moon colors with arbitrary defaults + // force a repaint of the sky colors with arbitrary defaults repaint( color ); - // moon_transform->addKid( halo ); - layer_transform->addKid( layer ); } @@ -346,8 +358,9 @@ bool SGCloudLayer::reposition( sgVec3 p, sgVec3 up, double lon, double lat, void SGCloudLayer::draw() { - if (layer_type != SG_CLOUD_CLEAR) - ssgCullAndDraw( layer_root ); + if ( layer_type != SG_CLOUD_CLEAR ) { + ssgCullAndDraw( layer_root ); + } } -- 2.39.5