Skip to content

Commit

Permalink
Fix AGL altitude calculation for fixed landing gears and reorganize t…
Browse files Browse the repository at this point in the history
…his code a little bit.
  • Loading branch information
jmbau committed Nov 6, 2022
1 parent 67129af commit 86c7640
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions src/sardraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -3791,31 +3791,23 @@ static void SARDrawOutsideAttitude(
y += 18;

/* Altitude AGL */
if(aircraft->landed)
v1 = 0.0f;
else
v1 = (float)MAX(
-(((((gear_state == 1) || (gear_state == 2)) ? aircraft->gear_height : 0.0f) +
aircraft->belly_height) +
aircraft->center_to_ground_height), 0.0f
);
switch(opt->units)
{
case SAR_UNITS_METRIC:
if(aircraft->landed)
v1 = 0.0f;
else
v1 = (float)MAX(
-((((gear_state == 1) ? aircraft->gear_height : 0.0f) +
aircraft->belly_height) +
aircraft->center_to_ground_height), 0.0f
);
units_str1 = "M";
break;

case SAR_UNITS_METRIC_ALT_FEET:
default:
if(aircraft->landed)
v1 = 0.0f;
else
v1 = (float)SFMMetersToFeet(
MAX(
-((((gear_state == 1) ? aircraft->gear_height : 0.0f) +
aircraft->belly_height) +
aircraft->center_to_ground_height), 0.0f
)
);
v1 = (float)SFMMetersToFeet(v1);
units_str1 = "FT";
break;
}
Expand Down

0 comments on commit 86c7640

Please sign in to comment.