Remove gen_runway_marking(). Trying to minimize the number of functions needed to generate a runway,
which should make it easier to understand the code. If there are parts that can be generalized, I'll pull these out. gen_runway_marking was only called from one place however...
This commit is contained in:
parent
051e73da6a
commit
f5e1084eb8
2 changed files with 136 additions and 172 deletions
|
@ -141,16 +141,6 @@ private:
|
||||||
ClipPolyType* accum,
|
ClipPolyType* accum,
|
||||||
poly_list& slivers );
|
poly_list& slivers );
|
||||||
|
|
||||||
void gen_rw_marking( const TGPolygon& runway,
|
|
||||||
double &start1_pct, double &end1_pct,
|
|
||||||
double heading,
|
|
||||||
const string& material,
|
|
||||||
superpoly_list* rwy_polys,
|
|
||||||
texparams_list* texparams,
|
|
||||||
ClipPolyType* accum,
|
|
||||||
poly_list& slivers,
|
|
||||||
int marking );
|
|
||||||
|
|
||||||
void gen_runway_lights( superpoly_list* lights );
|
void gen_runway_lights( superpoly_list* lights );
|
||||||
|
|
||||||
Point3D gen_runway_light_vector( double angle, bool recip );
|
Point3D gen_runway_light_vector( double angle, bool recip );
|
||||||
|
|
|
@ -30,26 +30,12 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
struct sections
|
struct sections
|
||||||
{
|
{
|
||||||
const char* tex;
|
const char* tex;
|
||||||
int size;
|
int size;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Runway::gen_rw_marking( const TGPolygon& runway,
|
|
||||||
double &start1_pct, double &end1_pct,
|
|
||||||
double heading,
|
|
||||||
const string& material,
|
|
||||||
superpoly_list *rwy_polys,
|
|
||||||
texparams_list *texparams,
|
|
||||||
ClipPolyType *accum,
|
|
||||||
poly_list& slivers,
|
|
||||||
int marking) {
|
|
||||||
|
|
||||||
std::vector<sections> rw_marking_list;
|
|
||||||
|
|
||||||
if (marking == 5){
|
|
||||||
// UK Precision runway sections from after the designation number
|
// UK Precision runway sections from after the designation number
|
||||||
// onwards to the middle (one half).
|
// onwards to the middle (one half).
|
||||||
// Set order of sections and their corresponding size
|
// Set order of sections and their corresponding size
|
||||||
|
@ -65,11 +51,7 @@ void Runway::gen_rw_marking( const TGPolygon& runway,
|
||||||
{ "rest", 200 * SG_FEET_TO_METER },
|
{ "rest", 200 * SG_FEET_TO_METER },
|
||||||
{ "tz_one_b", 200 * SG_FEET_TO_METER }
|
{ "tz_one_b", 200 * SG_FEET_TO_METER }
|
||||||
};
|
};
|
||||||
rw_marking_list.clear();
|
|
||||||
rw_marking_list.insert( rw_marking_list.begin(), uk_prec, uk_prec + sizeof(uk_prec) / sizeof(uk_prec[0]) );
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (marking == 4){
|
|
||||||
// UK non-precision runway sections from after the designation number
|
// UK non-precision runway sections from after the designation number
|
||||||
// onwards to the middle (one half).
|
// onwards to the middle (one half).
|
||||||
// Set order of sections and their corresponding size
|
// Set order of sections and their corresponding size
|
||||||
|
@ -77,11 +59,7 @@ void Runway::gen_rw_marking( const TGPolygon& runway,
|
||||||
{ "centerline", 200 * SG_FEET_TO_METER },
|
{ "centerline", 200 * SG_FEET_TO_METER },
|
||||||
{ "aim_uk", 400 * SG_FEET_TO_METER },
|
{ "aim_uk", 400 * SG_FEET_TO_METER },
|
||||||
};
|
};
|
||||||
rw_marking_list.clear();
|
|
||||||
rw_marking_list.insert( rw_marking_list.begin(), uk_nprec, uk_nprec + sizeof(uk_nprec) / sizeof(uk_nprec[0]) );
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (marking == 3){
|
|
||||||
// Precision runway sections from after the designation number
|
// Precision runway sections from after the designation number
|
||||||
// onwards to the middle (one half).
|
// onwards to the middle (one half).
|
||||||
// Set order of sections and their corresponding size
|
// Set order of sections and their corresponding size
|
||||||
|
@ -97,11 +75,7 @@ void Runway::gen_rw_marking( const TGPolygon& runway,
|
||||||
{ "rest", 200 * SG_FEET_TO_METER },
|
{ "rest", 200 * SG_FEET_TO_METER },
|
||||||
{ "tz_one_b", 200 * SG_FEET_TO_METER }
|
{ "tz_one_b", 200 * SG_FEET_TO_METER }
|
||||||
};
|
};
|
||||||
rw_marking_list.clear();
|
|
||||||
rw_marking_list.insert( rw_marking_list.begin(), prec, prec + sizeof(prec) / sizeof(prec[0]) );
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (marking == 2){
|
|
||||||
// Non-precision runway sections from after the designation number
|
// Non-precision runway sections from after the designation number
|
||||||
// onwards to the middle (one half).
|
// onwards to the middle (one half).
|
||||||
// Set order of sections and their corresponding size
|
// Set order of sections and their corresponding size
|
||||||
|
@ -109,31 +83,6 @@ void Runway::gen_rw_marking( const TGPolygon& runway,
|
||||||
{ "centerline", 200 * SG_FEET_TO_METER },
|
{ "centerline", 200 * SG_FEET_TO_METER },
|
||||||
{ "aim", 400 * SG_FEET_TO_METER }
|
{ "aim", 400 * SG_FEET_TO_METER }
|
||||||
};
|
};
|
||||||
rw_marking_list.clear();
|
|
||||||
rw_marking_list.insert( rw_marking_list.begin(), nprec, nprec + sizeof(nprec) / sizeof(nprec[0]) );
|
|
||||||
}
|
|
||||||
|
|
||||||
//Now create the sections of the runway type
|
|
||||||
double length = rwy.length / 2.0;
|
|
||||||
|
|
||||||
for ( unsigned int i=0; i < rw_marking_list.size(); ++i) {
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway section texture = " << rw_marking_list[i].tex << " lenght: " << rw_marking_list[i].size);
|
|
||||||
|
|
||||||
if ( end1_pct < 1.0 ) {
|
|
||||||
start1_pct = end1_pct;
|
|
||||||
end1_pct = start1_pct + ( rw_marking_list[i].size / length );
|
|
||||||
gen_runway_section( runway,
|
|
||||||
start1_pct, end1_pct,
|
|
||||||
0.0, 1.0,
|
|
||||||
0.0, 1.0, 0.0, 1.0,
|
|
||||||
heading,
|
|
||||||
material, rw_marking_list[i].tex,
|
|
||||||
rwy_polys, texparams, accum, slivers );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// generate a runway. The routine modifies
|
// generate a runway. The routine modifies
|
||||||
// rwy_polys, texparams, and accum. For specific details and
|
// rwy_polys, texparams, and accum. For specific details and
|
||||||
|
@ -151,9 +100,6 @@ void Runway::gen_rwy( const string& material,
|
||||||
//
|
//
|
||||||
// Generate the basic runway outlines
|
// Generate the basic runway outlines
|
||||||
//
|
//
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
TGPolygon runway = gen_runway_w_mid( 0, 0 );
|
TGPolygon runway = gen_runway_w_mid( 0, 0 );
|
||||||
|
|
||||||
TGPolygon runway_half;
|
TGPolygon runway_half;
|
||||||
|
@ -181,7 +127,7 @@ void Runway::gen_rwy( const string& material,
|
||||||
|
|
||||||
Point3D p;
|
Point3D p;
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway half pts (run " << rwhalf << ")");
|
SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway half pts (run " << rwhalf << ")");
|
||||||
for ( i = 0; i < runway_half.contour_size( 0 ); ++i ) {
|
for ( int i = 0; i < runway_half.contour_size( 0 ); ++i ) {
|
||||||
p = runway_half.get_pt( 0, i );
|
p = runway_half.get_pt( 0, i );
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
|
SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
|
||||||
}
|
}
|
||||||
|
@ -201,7 +147,6 @@ void Runway::gen_rwy( const string& material,
|
||||||
//
|
//
|
||||||
// Displaced threshold if it exists
|
// Displaced threshold if it exists
|
||||||
//
|
//
|
||||||
|
|
||||||
if (rwhalf == 0) {
|
if (rwhalf == 0) {
|
||||||
heading = rwy.heading + 180.0;
|
heading = rwy.heading + 180.0;
|
||||||
rwname = rwy.rwnum[0];
|
rwname = rwy.rwnum[0];
|
||||||
|
@ -210,10 +155,10 @@ void Runway::gen_rwy( const string& material,
|
||||||
heading = rwy.heading;
|
heading = rwy.heading;
|
||||||
rwname = rwy.rwnum[1];
|
rwname = rwy.rwnum[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
SG_LOG( SG_GENERAL, SG_DEBUG, "runway marking = " << rwy.marking[rwhalf] );
|
SG_LOG( SG_GENERAL, SG_DEBUG, "runway marking = " << rwy.marking[rwhalf] );
|
||||||
if ( rwy.threshold[rwhalf] > 0.0 ) {
|
if ( rwy.threshold[rwhalf] > 0.0 ) {
|
||||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Displaced threshold for RW side " << rwhalf << " is "
|
SG_LOG( SG_GENERAL, SG_DEBUG, "Displaced threshold for RW side " << rwhalf << " is " << rwy.threshold[rwhalf] );
|
||||||
<< rwy.threshold[rwhalf] );
|
|
||||||
|
|
||||||
// reserve 90' for final arrows
|
// reserve 90' for final arrows
|
||||||
double thresh = rwy.threshold[rwhalf] - 90.0 * SG_FEET_TO_METER;
|
double thresh = rwy.threshold[rwhalf] - 90.0 * SG_FEET_TO_METER;
|
||||||
|
@ -237,7 +182,7 @@ void Runway::gen_rwy( const string& material,
|
||||||
rwy_polys, texparams, accum, slivers );
|
rwy_polys, texparams, accum, slivers );
|
||||||
|
|
||||||
// main chunks
|
// main chunks
|
||||||
for ( i = 0; i < count; ++i ) {
|
for ( int i = 0; i < count; ++i ) {
|
||||||
start1_pct = end1_pct;
|
start1_pct = end1_pct;
|
||||||
end1_pct = start1_pct + ( 200.0 * SG_FEET_TO_METER / length );
|
end1_pct = start1_pct + ( 200.0 * SG_FEET_TO_METER / length );
|
||||||
gen_runway_section( runway_half,
|
gen_runway_section( runway_half,
|
||||||
|
@ -261,11 +206,8 @@ void Runway::gen_rwy( const string& material,
|
||||||
rwy_polys, texparams, accum, slivers );
|
rwy_polys, texparams, accum, slivers );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (rwy.marking[rwhalf] == 0) {
|
if (rwy.marking[rwhalf] == 0) {
|
||||||
|
// No marking
|
||||||
// No threshold
|
|
||||||
|
|
||||||
start1_pct = end1_pct;
|
start1_pct = end1_pct;
|
||||||
end1_pct = start1_pct + ( 10 / length );
|
end1_pct = start1_pct + ( 10 / length );
|
||||||
gen_runway_section( runway_half,
|
gen_runway_section( runway_half,
|
||||||
|
@ -276,9 +218,7 @@ void Runway::gen_rwy( const string& material,
|
||||||
material, "no_threshold",
|
material, "no_threshold",
|
||||||
rwy_polys, texparams, accum, slivers );
|
rwy_polys, texparams, accum, slivers );
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Thresholds for all others
|
// Thresholds for all others
|
||||||
|
|
||||||
start1_pct = end1_pct;
|
start1_pct = end1_pct;
|
||||||
end1_pct = start1_pct + ( 202.0 * SG_FEET_TO_METER / length );
|
end1_pct = start1_pct + ( 202.0 * SG_FEET_TO_METER / length );
|
||||||
gen_runway_section( runway_half,
|
gen_runway_section( runway_half,
|
||||||
|
@ -292,14 +232,48 @@ void Runway::gen_rwy( const string& material,
|
||||||
|
|
||||||
// Runway designation block
|
// Runway designation block
|
||||||
gen_rw_designation( material, runway_half, heading,
|
gen_rw_designation( material, runway_half, heading,
|
||||||
rwname, start1_pct, end1_pct, rwy_polys, texparams, accum, slivers );
|
rwname, start1_pct, end1_pct,
|
||||||
|
rwy_polys, texparams, accum, slivers );
|
||||||
|
|
||||||
if (rwy.marking[rwhalf] > 1){
|
|
||||||
// Generate remaining markings depending on type of runway
|
// Generate remaining markings depending on type of runway
|
||||||
gen_rw_marking( runway_half,
|
if (rwy.marking[rwhalf] > 1) {
|
||||||
|
std::vector<sections> rw_marking_list;
|
||||||
|
rw_marking_list.clear();
|
||||||
|
|
||||||
|
switch ( rwy.marking[rwhalf] ) {
|
||||||
|
case 2:
|
||||||
|
rw_marking_list.insert( rw_marking_list.begin(), nprec, nprec + sizeof(nprec) / sizeof(nprec[0]) );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
rw_marking_list.insert( rw_marking_list.begin(), prec, prec + sizeof(prec) / sizeof(prec[0]) );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
rw_marking_list.insert( rw_marking_list.begin(), uk_nprec, uk_nprec + sizeof(uk_nprec) / sizeof(uk_nprec[0]) );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
rw_marking_list.insert( rw_marking_list.begin(), uk_prec, uk_prec + sizeof(uk_prec) / sizeof(uk_prec[0]) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now create the marking sections of the runway type
|
||||||
|
for ( unsigned int i=0; i < rw_marking_list.size(); ++i) {
|
||||||
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway section texture = " << rw_marking_list[i].tex << " start_pct: " << start1_pct << " end_pct: " << end1_pct << " length: " << rw_marking_list[i].size);
|
||||||
|
|
||||||
|
if ( end1_pct < 1.0 ) {
|
||||||
|
start1_pct = end1_pct;
|
||||||
|
end1_pct = start1_pct + ( rw_marking_list[i].size / length );
|
||||||
|
gen_runway_section( runway_half,
|
||||||
start1_pct, end1_pct,
|
start1_pct, end1_pct,
|
||||||
heading, material,
|
0.0, 1.0,
|
||||||
rwy_polys, texparams, accum, slivers, rwy.marking[rwhalf] );
|
0.0, 1.0, 0.0, 1.0,
|
||||||
|
heading,
|
||||||
|
material, rw_marking_list[i].tex,
|
||||||
|
rwy_polys, texparams, accum, slivers );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue