Try to improve frame rate and reduce jitter
Signed-off-by: v meazza <vivian.meazza@lineone.net> Conflicts: src/AIModel/AIGroundVehicle.cxx
This commit is contained in:
parent
08c0556dc7
commit
d59088dc1a
5 changed files with 12 additions and 8 deletions
0
src/AIModel/AIFlightPlanCreateCruise.cxx
Executable file → Normal file
0
src/AIModel/AIFlightPlanCreateCruise.cxx
Executable file → Normal file
|
@ -210,7 +210,7 @@ bool FGAIGroundVehicle::getGroundElev(SGGeod inpos) {
|
||||||
|
|
||||||
double height_m ;
|
double height_m ;
|
||||||
|
|
||||||
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(inpos, 10000), height_m, &_material,0)){
|
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(inpos, 3000), height_m, &_material,0)){
|
||||||
_ht_agl_ft = inpos.getElevationFt() - height_m * SG_METER_TO_FEET;
|
_ht_agl_ft = inpos.getElevationFt() - height_m * SG_METER_TO_FEET;
|
||||||
|
|
||||||
if (_material) {
|
if (_material) {
|
||||||
|
@ -261,14 +261,14 @@ bool FGAIGroundVehicle::getPitch() {
|
||||||
double elev_rear = 0;
|
double elev_rear = 0;
|
||||||
double max_alt = 10000;
|
double max_alt = 10000;
|
||||||
|
|
||||||
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(geodFront, 10000), elev_front,
|
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(geodFront, 3000), elev_front,
|
||||||
&_material, 0)){
|
&_material, 0)){
|
||||||
front_elev_m = elev_front;
|
front_elev_m = elev_front;
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(geodRear, 10000),
|
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(geodRear, 3000),
|
||||||
elev_rear, &_material,0)){
|
elev_rear, &_material, 0)){
|
||||||
rear_elev_m = elev_rear;
|
rear_elev_m = elev_rear;
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
@ -296,6 +296,7 @@ bool FGAIGroundVehicle::getPitch() {
|
||||||
static double prev_alt;
|
static double prev_alt;
|
||||||
|
|
||||||
if (_new_waypoint){
|
if (_new_waypoint){
|
||||||
|
cout << "new waypoint, calculating pitch " << endl;
|
||||||
curr_alt = curr->altitude * SG_METER_TO_FEET;
|
curr_alt = curr->altitude * SG_METER_TO_FEET;
|
||||||
prev_alt = prev->altitude * SG_METER_TO_FEET;
|
prev_alt = prev->altitude * SG_METER_TO_FEET;
|
||||||
d_alt = curr_alt - prev_alt;
|
d_alt = curr_alt - prev_alt;
|
||||||
|
@ -304,13 +305,15 @@ bool FGAIGroundVehicle::getPitch() {
|
||||||
SGGeod::fromDeg(curr->longitude, curr->latitude));
|
SGGeod::fromDeg(curr->longitude, curr->latitude));
|
||||||
|
|
||||||
_pitch = atan2(d_alt, distance * SG_METER_TO_FEET) * SG_RADIANS_TO_DEGREES;
|
_pitch = atan2(d_alt, distance * SG_METER_TO_FEET) * SG_RADIANS_TO_DEGREES;
|
||||||
|
// cout << "new waypoint, calculating pitch " << _pitch << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double distance_to_go = SGGeodesy::distanceM(SGGeod::fromDeg(pos.getLongitudeDeg(), pos.getLatitudeDeg()),
|
double distance_to_go = SGGeodesy::distanceM(SGGeod::fromDeg(pos.getLongitudeDeg(), pos.getLatitudeDeg()),
|
||||||
SGGeod::fromDeg(curr->longitude, curr->latitude));
|
SGGeod::fromDeg(curr->longitude, curr->latitude));
|
||||||
|
|
||||||
//cout << "distance curr & prev " << prev->name << " " << curr->name << " " << distance * SG_METER_TO_FEET
|
//cout << "tunnel " << _tunnel
|
||||||
|
// << " distance curr & prev " << prev->name << " " << curr->name << " " << distance * SG_METER_TO_FEET
|
||||||
// << " distance to go " << distance_to_go * SG_METER_TO_FEET
|
// << " distance to go " << distance_to_go * SG_METER_TO_FEET
|
||||||
// << " d_alt ft " << d_alt
|
// << " d_alt ft " << d_alt
|
||||||
// << endl;
|
// << endl;
|
||||||
|
@ -524,13 +527,14 @@ void FGAIGroundVehicle::RunGroundVehicle(double dt){
|
||||||
// Check execution time (currently once every 0.05 sec or 20 fps)
|
// Check execution time (currently once every 0.05 sec or 20 fps)
|
||||||
// Add a bit of randomization to prevent the execution of all flight plans
|
// Add a bit of randomization to prevent the execution of all flight plans
|
||||||
// in synchrony, which can add significant periodic framerate flutter.
|
// in synchrony, which can add significant periodic framerate flutter.
|
||||||
|
// Randomization removed to get better appearance
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//cout << "_start_sec " << _start_sec << " time_sec " << time_sec << endl;
|
//cout << "_start_sec " << _start_sec << " time_sec " << time_sec << endl;
|
||||||
if (_dt_count < _next_run)
|
if (_dt_count < _next_run)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_next_run = 0.055 + (0.015 * sg_random());
|
_next_run = 0.055 /*+ (0.015 * sg_random())*/;
|
||||||
|
|
||||||
if (getPitch()){
|
if (getPitch()){
|
||||||
setElevation(_elevation, _dt_count, _elevation_coeff);
|
setElevation(_elevation, _dt_count, _elevation_coeff);
|
||||||
|
|
0
src/AIModel/AIMultiplayer.cxx
Executable file → Normal file
0
src/AIModel/AIMultiplayer.cxx
Executable file → Normal file
0
src/AIModel/AIMultiplayer.hxx
Executable file → Normal file
0
src/AIModel/AIMultiplayer.hxx
Executable file → Normal file
|
@ -1045,8 +1045,8 @@ void FGAIShip::setWPPos() {
|
||||||
|
|
||||||
if (curr->on_ground){
|
if (curr->on_ground){
|
||||||
|
|
||||||
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(wppos, 10000),
|
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(wppos, 3000),
|
||||||
elevation_m, &_material)){
|
elevation_m, &_material, 0)){
|
||||||
wppos.setElevationM(elevation_m);
|
wppos.setElevationM(elevation_m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue