#include <simgear/math/point3d.hxx>
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/math/vector.hxx>
+#include <simgear/timing/timestamp.hxx>
#include <Main/globals.hxx>
#include <Main/viewer.hxx>
FGHitList *hit_list,
double *terrain_elev, double *radius, double *normal)
{
- SGTimeStamp start; start.stamp();
+ // SGTimeStamp start; start.stamp();
bool result;
sgdVec3 view_pos;
hit_list->Intersect( globals->get_scenery()->get_terrain_branch(),
orig, dir );
- int this_hit=0;
+ int this_hit = -1;
+ int max_hit = -1;
Point3D geoc;
double hit_elev = -9999;
+ double max_elev = -9999;
Point3D sc(scenery_center[0], scenery_center[1], scenery_center[2]) ;
int hitcount = hit_list->num_hits();
hit_elev = alt;
this_hit = i;
}
+ if ( alt > hit_elev ) {
+ max_elev = alt;
+ max_hit = i;
+ }
+ }
+
+ if ( this_hit < 0 ) {
+ // no hits below us, take the max hit
+ this_hit = max_hit;
+ hit_elev = max_elev;
}
if ( hit_elev > -9000 ) {
result = false;
}
- SGTimeStamp finish; finish.stamp();
- hitlist1_time = ( 29.0 * hitlist1_time + (finish - start) ) / 30.0;
+ // SGTimeStamp finish; finish.stamp();
+ // hitlist1_time = ( 29.0 * hitlist1_time + (finish - start) ) / 30.0;
// cout << " time per call = " << hitlist1_time << endl;
return result;
FGHitList *hit_list,
double *terrain_elev, double *radius, double *normal)
{
- SGTimeStamp start; start.stamp();
+ // SGTimeStamp start; start.stamp();
bool result;
sgdVec3 view_pos;
sgdSetMat4(xform,fxform);
hit_list->Intersect( terra_transform, xform, orig, dir );
- int this_hit=0;
+ int this_hit = -1;
+ int max_hit = -1;
Point3D geoc;
double hit_elev = -9999;
+ double max_elev = -9999;
Point3D sc(scenery_center[0], scenery_center[1], scenery_center[2]) ;
int hitcount = hit_list->num_hits();
this_hit = i;
// cout << " it's a keeper" << endl;
}
+ if ( alt > hit_elev ) {
+ max_elev = alt;
+ max_hit = i;
+ }
+ }
+
+ if ( this_hit < 0 ) {
+ // no hits below us, take the max hit
+ this_hit = max_hit;
+ hit_elev = max_elev;
}
if ( hit_elev > -9000 ) {
hit_list, terrain_elev, radius, normal);
}
- SGTimeStamp finish; finish.stamp();
- hitlist2_time = ( 29.0 * hitlist2_time + (finish - start) ) / 30.0;
- cout << "time per call 2 = " << hitlist2_time << endl;
+ // SGTimeStamp finish; finish.stamp();
+ // hitlist2_time = ( 29.0 * hitlist2_time + (finish - start) ) / 30.0;
+ // cout << "time per call 2 = " << hitlist2_time << endl;
return result;
}