White space tweaks.
This commit is contained in:
parent
464f036f35
commit
586d7f127a
2 changed files with 97 additions and 97 deletions
|
@ -499,61 +499,61 @@ static void ssgGetCurrentBSphere( ssgEntity *entity, sgVec3 center, float *radiu
|
||||||
// Determine scenery altitude via ssg.
|
// Determine scenery altitude via ssg.
|
||||||
// returned results are in meters
|
// returned results are in meters
|
||||||
bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
|
bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
|
||||||
FGHitList *hit_list,
|
FGHitList *hit_list,
|
||||||
double *terrain_elev, double *radius, double *normal)
|
double *terrain_elev, double *radius, double *normal)
|
||||||
{
|
{
|
||||||
sgdVec3 view_pos;
|
sgdVec3 view_pos;
|
||||||
sgdSubVec3( view_pos, abs_view_pos, scenery_center );
|
sgdSubVec3( view_pos, abs_view_pos, scenery_center );
|
||||||
|
|
||||||
sgdVec3 orig, dir;
|
sgdVec3 orig, dir;
|
||||||
sgdCopyVec3(orig, view_pos );
|
sgdCopyVec3(orig, view_pos );
|
||||||
sgdCopyVec3(dir, abs_view_pos );
|
sgdCopyVec3(dir, abs_view_pos );
|
||||||
|
|
||||||
// !! why is terrain not globals->get_terrain()
|
// !! why is terrain not globals->get_terrain()
|
||||||
hit_list->Intersect( terrain_branch, orig, dir );
|
hit_list->Intersect( terrain_branch, orig, dir );
|
||||||
|
|
||||||
int this_hit=0;
|
int this_hit=0;
|
||||||
Point3D geoc;
|
Point3D geoc;
|
||||||
double result = -9999;
|
double result = -9999;
|
||||||
Point3D sc(scenery_center[0], scenery_center[1], scenery_center[2]) ;
|
Point3D sc(scenery_center[0], scenery_center[1], scenery_center[2]) ;
|
||||||
|
|
||||||
// cout << "hits = ";
|
// cout << "hits = ";
|
||||||
int hitcount = hit_list->num_hits();
|
int hitcount = hit_list->num_hits();
|
||||||
for ( int i = 0; i < hitcount; ++i ) {
|
for ( int i = 0; i < hitcount; ++i ) {
|
||||||
geoc = sgCartToPolar3d( sc + hit_list->get_point(i) );
|
geoc = sgCartToPolar3d( sc + hit_list->get_point(i) );
|
||||||
double lat_geod, alt, sea_level_r;
|
double lat_geod, alt, sea_level_r;
|
||||||
sgGeocToGeod(geoc.lat(), geoc.radius(), &lat_geod,
|
sgGeocToGeod(geoc.lat(), geoc.radius(), &lat_geod,
|
||||||
&alt, &sea_level_r);
|
&alt, &sea_level_r);
|
||||||
// cout << alt << " ";
|
// cout << alt << " ";
|
||||||
if ( alt > result && alt < 10000 ) {
|
if ( alt > result && alt < 10000 ) {
|
||||||
result = alt;
|
result = alt;
|
||||||
this_hit = i;
|
this_hit = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// cout << endl;
|
// cout << endl;
|
||||||
|
|
||||||
if ( result > -9000 ) {
|
if ( result > -9000 ) {
|
||||||
*terrain_elev = result;
|
*terrain_elev = result;
|
||||||
*radius = geoc.radius();
|
*radius = geoc.radius();
|
||||||
sgVec3 tmp;
|
sgVec3 tmp;
|
||||||
sgMat4 TMP;
|
sgMat4 TMP;
|
||||||
sgSetVec3(tmp, hit_list->get_normal(this_hit));
|
sgSetVec3(tmp, hit_list->get_normal(this_hit));
|
||||||
// cout << "cur_normal: " << tmp[0] << " " << tmp[1] << " "
|
// cout << "cur_normal: " << tmp[0] << " " << tmp[1] << " "
|
||||||
// << tmp[2] << endl;
|
// << tmp[2] << endl;
|
||||||
sgTransposeNegateMat4 ( TMP, globals->get_current_view()->get_UP() ) ;
|
sgTransposeNegateMat4 ( TMP, globals->get_current_view()->get_UP() ) ;
|
||||||
sgXformVec3(tmp, tmp, TMP);
|
sgXformVec3(tmp, tmp, TMP);
|
||||||
// cout << "NED: " << tmp[0] << " " << tmp[1] << " " << tmp[2] << endl;
|
// cout << "NED: " << tmp[0] << " " << tmp[1] << " " << tmp[2] << endl;
|
||||||
sgdSetVec3( normal, tmp[2], tmp[1], tmp[0] );
|
sgdSetVec3( normal, tmp[2], tmp[1], tmp[0] );
|
||||||
/* ssgState *IntersectedLeafState =
|
/* ssgState *IntersectedLeafState =
|
||||||
((ssgLeaf*)hit_list->get_entity(this_hit))->getState(); */
|
((ssgLeaf*)hit_list->get_entity(this_hit))->getState(); */
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
SG_LOG( SG_TERRAIN, SG_INFO, "no terrain intersection" );
|
SG_LOG( SG_TERRAIN, SG_INFO, "no terrain intersection" );
|
||||||
*terrain_elev = 0.0;
|
*terrain_elev = 0.0;
|
||||||
float *up = globals->get_current_view()->get_world_up();
|
float *up = globals->get_current_view()->get_world_up();
|
||||||
sgdSetVec3(normal, up[0], up[1], up[2]);
|
sgdSetVec3(normal, up[0], up[1], up[2]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -561,60 +561,60 @@ bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
|
||||||
// Determine scenery altitude via ssg.
|
// Determine scenery altitude via ssg.
|
||||||
// returned results are in meters
|
// returned results are in meters
|
||||||
bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
|
bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
|
||||||
ssgTransform *terra_transform,
|
ssgTransform *terra_transform,
|
||||||
FGHitList *hit_list,
|
FGHitList *hit_list,
|
||||||
double *terrain_elev, double *radius, double *normal)
|
double *terrain_elev, double *radius, double *normal)
|
||||||
{
|
{
|
||||||
sgdVec3 view_pos;
|
sgdVec3 view_pos;
|
||||||
sgdSubVec3( view_pos, abs_view_pos, scenery_center );
|
sgdSubVec3( view_pos, abs_view_pos, scenery_center );
|
||||||
|
|
||||||
sgdVec3 orig, dir;
|
sgdVec3 orig, dir;
|
||||||
sgdCopyVec3(orig, view_pos );
|
sgdCopyVec3(orig, view_pos );
|
||||||
|
|
||||||
sgdCopyVec3(dir, abs_view_pos );
|
sgdCopyVec3(dir, abs_view_pos );
|
||||||
sgdNormalizeVec3(dir);
|
sgdNormalizeVec3(dir);
|
||||||
|
|
||||||
sgMat4 fxform;
|
sgMat4 fxform;
|
||||||
sgMakeIdentMat4 ( fxform ) ;
|
sgMakeIdentMat4 ( fxform ) ;
|
||||||
ssgGetEntityTransform( terra_transform, fxform );
|
ssgGetEntityTransform( terra_transform, fxform );
|
||||||
|
|
||||||
sgdMat4 xform;
|
sgdMat4 xform;
|
||||||
sgdSetMat4(xform,fxform);
|
sgdSetMat4(xform,fxform);
|
||||||
hit_list->Intersect( terra_transform, xform, orig, dir );
|
hit_list->Intersect( terra_transform, xform, orig, dir );
|
||||||
|
|
||||||
int this_hit=0;
|
int this_hit=0;
|
||||||
Point3D geoc;
|
Point3D geoc;
|
||||||
double result = -9999;
|
double result = -9999;
|
||||||
Point3D sc(scenery_center[0], scenery_center[1], scenery_center[2]) ;
|
Point3D sc(scenery_center[0], scenery_center[1], scenery_center[2]) ;
|
||||||
|
|
||||||
int hitcount = hit_list->num_hits();
|
int hitcount = hit_list->num_hits();
|
||||||
for ( int i = 0; i < hitcount; ++i ) {
|
for ( int i = 0; i < hitcount; ++i ) {
|
||||||
geoc = sgCartToPolar3d( sc + hit_list->get_point(i) );
|
geoc = sgCartToPolar3d( sc + hit_list->get_point(i) );
|
||||||
double lat_geod, alt, sea_level_r;
|
double lat_geod, alt, sea_level_r;
|
||||||
sgGeocToGeod(geoc.lat(), geoc.radius(), &lat_geod,
|
sgGeocToGeod(geoc.lat(), geoc.radius(), &lat_geod,
|
||||||
&alt, &sea_level_r);
|
&alt, &sea_level_r);
|
||||||
if ( alt > result && alt < 20000 ) {
|
if ( alt > result && alt < 20000 ) {
|
||||||
result = alt;
|
result = alt;
|
||||||
this_hit = i;
|
this_hit = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( result > -9000 ) {
|
if ( result > -9000 ) {
|
||||||
*terrain_elev = result;
|
*terrain_elev = result;
|
||||||
*radius = geoc.radius();
|
*radius = geoc.radius();
|
||||||
sgVec3 tmp;
|
sgVec3 tmp;
|
||||||
sgMat4 TMP;
|
sgMat4 TMP;
|
||||||
sgSetVec3(tmp, hit_list->get_normal(this_hit));
|
sgSetVec3(tmp, hit_list->get_normal(this_hit));
|
||||||
sgTransposeNegateMat4 ( TMP, globals->get_current_view()->get_UP() ) ;
|
sgTransposeNegateMat4 ( TMP, globals->get_current_view()->get_UP() ) ;
|
||||||
sgXformVec3(tmp, tmp, TMP);
|
sgXformVec3(tmp, tmp, TMP);
|
||||||
sgdSetVec3( normal, tmp[2], tmp[1], tmp[0] );
|
sgdSetVec3( normal, tmp[2], tmp[1], tmp[0] );
|
||||||
/* ssgState *IntersectedLeafState =
|
/* ssgState *IntersectedLeafState =
|
||||||
((ssgLeaf*)hit_list->get_entity(this_hit))->getState(); */
|
((ssgLeaf*)hit_list->get_entity(this_hit))->getState(); */
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
SG_LOG( SG_TERRAIN, SG_DEBUG, "DOING FULL TERRAIN INTERSECTION" );
|
SG_LOG( SG_TERRAIN, SG_DEBUG, "DOING FULL TERRAIN INTERSECTION" );
|
||||||
return fgCurrentElev( abs_view_pos, scenery_center, hit_list,
|
return fgCurrentElev( abs_view_pos, scenery_center, hit_list,
|
||||||
terrain_elev,radius,normal);
|
terrain_elev,radius,normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
|
|
||||||
FGHitList();
|
FGHitList();
|
||||||
~FGHitList();
|
~FGHitList();
|
||||||
|
|
||||||
void init(void) { list.clear(); test_dist=DBL_MAX; }
|
void init(void) { list.clear(); test_dist=DBL_MAX; }
|
||||||
void clear(void) { init(); last = NULL; }
|
void clear(void) { init(); last = NULL; }
|
||||||
void add( ssgEntity *ent, int idx, sgdVec3 point, sgdVec3 normal ) {
|
void add( ssgEntity *ent, int idx, sgdVec3 point, sgdVec3 normal ) {
|
||||||
|
|
Loading…
Reference in a new issue