Keep the stack clean
This commit is contained in:
+29
-22
@@ -103,22 +103,24 @@ void SGSky::build( double h_radius_m, double v_radius_m,
|
|||||||
// 0 degrees = high noon
|
// 0 degrees = high noon
|
||||||
// 90 degrees = sun rise/set
|
// 90 degrees = sun rise/set
|
||||||
// 180 degrees = darkest midnight
|
// 180 degrees = darkest midnight
|
||||||
bool SGSky::repaint( sgVec4 sky_color, sgVec4 fog_color, sgVec4 cloud_color,
|
bool SGSky::repaint( const SGSkyColor &sc )
|
||||||
double sun_angle, double moon_angle,
|
|
||||||
int nplanets, sgdVec3 *planet_data,
|
|
||||||
int nstars, sgdVec3 *star_data )
|
|
||||||
{
|
{
|
||||||
if ( effective_visibility > 1000.0 ) {
|
if ( effective_visibility > 1000.0 ) {
|
||||||
enable();
|
enable();
|
||||||
dome->repaint( sky_color, fog_color, sun_angle, effective_visibility );
|
dome->repaint( sc.sky_color, sc.fog_color, sc.sun_angle,
|
||||||
oursun->repaint( sun_angle );
|
effective_visibility );
|
||||||
moon->repaint( moon_angle );
|
|
||||||
planets->repaint( sun_angle, nplanets, planet_data );
|
oursun->repaint( sc.sun_angle );
|
||||||
stars->repaint( sun_angle, nstars, star_data );
|
|
||||||
|
moon->repaint( sc.moon_angle );
|
||||||
|
|
||||||
|
planets->repaint( sc.sun_angle, sc.nplanets, sc.planet_data );
|
||||||
|
|
||||||
|
stars->repaint( sc.sun_angle, sc.nstars, sc.star_data );
|
||||||
|
|
||||||
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
|
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
|
||||||
if (cloud_layers[i]->getCoverage() != SGCloudLayer::SG_CLOUD_CLEAR){
|
if (cloud_layers[i]->getCoverage() != SGCloudLayer::SG_CLOUD_CLEAR){
|
||||||
cloud_layers[i]->repaint( cloud_color );
|
cloud_layers[i]->repaint( sc.cloud_color );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -137,22 +139,27 @@ bool SGSky::repaint( sgVec4 sky_color, sgVec4 fog_color, sgVec4 cloud_color,
|
|||||||
// spin specifies a rotation about the new Z axis (this allows
|
// spin specifies a rotation about the new Z axis (this allows
|
||||||
// additional orientation for the sunrise/set effects and is used by
|
// additional orientation for the sunrise/set effects and is used by
|
||||||
// the skydome and perhaps clouds.
|
// the skydome and perhaps clouds.
|
||||||
bool SGSky::reposition( sgVec3 view_pos, sgVec3 zero_elev, sgVec3 view_up,
|
bool SGSky::reposition( SGSkyState &st )
|
||||||
double lon, double lat, double alt, double spin,
|
|
||||||
double gst,
|
|
||||||
double sun_ra, double sun_dec, double sun_dist,
|
|
||||||
double moon_ra, double moon_dec, double moon_dist )
|
|
||||||
{
|
{
|
||||||
double angle = gst * 15; // degrees
|
|
||||||
dome->reposition( zero_elev, lon, lat, spin );
|
double angle = st.gst * 15; // degrees
|
||||||
oursun->reposition( view_pos, angle, sun_ra, sun_dec, sun_dist );
|
|
||||||
moon->reposition( view_pos, angle, moon_ra, moon_dec, moon_dist );
|
dome->reposition( st.zero_elev, st.lon, st.lat, st.spin );
|
||||||
planets->reposition( view_pos, angle );
|
|
||||||
stars->reposition( view_pos, angle );
|
oursun->reposition( st.view_pos, angle,
|
||||||
|
st.sun_ra, st.sun_dec, st.sun_dist );
|
||||||
|
|
||||||
|
moon->reposition( st.view_pos, angle,
|
||||||
|
st.moon_ra, st.moon_dec, st.moon_dist );
|
||||||
|
|
||||||
|
planets->reposition( st.view_pos, angle );
|
||||||
|
|
||||||
|
stars->reposition( st.view_pos, angle );
|
||||||
|
|
||||||
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
|
for ( int i = 0; i < (int)cloud_layers.size(); ++i ) {
|
||||||
if ( cloud_layers[i]->getCoverage() != SGCloudLayer::SG_CLOUD_CLEAR ) {
|
if ( cloud_layers[i]->getCoverage() != SGCloudLayer::SG_CLOUD_CLEAR ) {
|
||||||
cloud_layers[i]->reposition( zero_elev, view_up, lon, lat, alt );
|
cloud_layers[i]->reposition( st.zero_elev, st.view_up,
|
||||||
|
st.lon, st.lat, st.alt );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,21 @@ typedef vector < SGCloudLayer* > layer_list_type;
|
|||||||
typedef layer_list_type::iterator layer_list_iterator;
|
typedef layer_list_type::iterator layer_list_iterator;
|
||||||
typedef layer_list_type::const_iterator layer_list_const_iterator;
|
typedef layer_list_type::const_iterator layer_list_const_iterator;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float *view_pos, *zero_elev, *view_up;
|
||||||
|
double lon, lat, alt, spin;
|
||||||
|
double gst;
|
||||||
|
double sun_ra, sun_dec, sun_dist;
|
||||||
|
double moon_ra, moon_dec, moon_dist;
|
||||||
|
} SGSkyState;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float *sky_color, *fog_color, *cloud_color;
|
||||||
|
double sun_angle, moon_angle;
|
||||||
|
int nplanets, nstars;
|
||||||
|
sgdVec3 *planet_data, *star_data;
|
||||||
|
} SGSkyColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class to model a realistic (time/date/position) based sky.
|
* A class to model a realistic (time/date/position) based sky.
|
||||||
*
|
*
|
||||||
@@ -263,10 +278,7 @@ public:
|
|||||||
* @param star_data an array of star right ascensions, declinations,
|
* @param star_data an array of star right ascensions, declinations,
|
||||||
* and magnitudes
|
* and magnitudes
|
||||||
*/
|
*/
|
||||||
bool repaint( sgVec4 sky_color, sgVec4 fog_color, sgVec4 cloud_color,
|
bool repaint( const SGSkyColor &sc );
|
||||||
double sun_angle, double moon_angle,
|
|
||||||
int nplanets, sgdVec3 *planet_data,
|
|
||||||
int nstars, sgdVec3 *star_data );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reposition the sky at the specified origin and orientation
|
* Reposition the sky at the specified origin and orientation
|
||||||
@@ -296,11 +308,7 @@ public:
|
|||||||
* @param moon_dec the moon's current declination
|
* @param moon_dec the moon's current declination
|
||||||
* @param moon_dist the moon's distance from the current view point.
|
* @param moon_dist the moon's distance from the current view point.
|
||||||
*/
|
*/
|
||||||
bool reposition( sgVec3 view_pos, sgVec3 zero_elev, sgVec3 view_up,
|
bool reposition( SGSkyState &st );
|
||||||
double lon, double lat, double alt, double spin,
|
|
||||||
double gst,
|
|
||||||
double sun_ra, double sun_dec, double sun_dist,
|
|
||||||
double moon_ra, double moon_dec, double moon_dist );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modify the given visibility based on cloud layers, thickness,
|
* Modify the given visibility based on cloud layers, thickness,
|
||||||
|
|||||||
Reference in New Issue
Block a user