Optimized key property node accesses.
This commit is contained in:
parent
70cfe7e606
commit
083ba99657
1 changed files with 27 additions and 26 deletions
|
@ -38,6 +38,7 @@
|
||||||
#include <simgear/constants.h>
|
#include <simgear/constants.h>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/math/polar3d.hxx>
|
#include <simgear/math/polar3d.hxx>
|
||||||
|
#include <simgear/misc/props.hxx>
|
||||||
|
|
||||||
#include <Aircraft/aircraft.hxx>
|
#include <Aircraft/aircraft.hxx>
|
||||||
#include <Include/general.hxx>
|
#include <Include/general.hxx>
|
||||||
|
@ -152,10 +153,12 @@ float get_rudderval( void )
|
||||||
|
|
||||||
float get_speed( void )
|
float get_speed( void )
|
||||||
{
|
{
|
||||||
// Make an explicit function call.
|
static const SGPropertyNode * speedup_node = fgGetNode("/sim/speed-up");
|
||||||
|
|
||||||
float speed = current_aircraft.fdm_state->get_V_calibrated_kts()
|
float speed = current_aircraft.fdm_state->get_V_calibrated_kts()
|
||||||
* fgGetInt("/sim/speed-up"); // FIXME: inefficient
|
* speedup_node->getIntValue();
|
||||||
return( speed );
|
|
||||||
|
return speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
float get_mach(void)
|
float get_mach(void)
|
||||||
|
@ -190,19 +193,18 @@ float get_heading( void )
|
||||||
|
|
||||||
float get_altitude( void )
|
float get_altitude( void )
|
||||||
{
|
{
|
||||||
// FGState *f;
|
static const SGPropertyNode *startup_units_node
|
||||||
// double rough_elev;
|
= fgGetNode("/sim/startup/units");
|
||||||
|
|
||||||
// current_aircraft.fdm_state
|
|
||||||
// rough_elev = mesh_altitude(f->get_Longitude() * SG_RAD_TO_ARCSEC,
|
|
||||||
// f->get_Latitude() * SG_RAD_TO_ARCSEC);
|
|
||||||
float altitude;
|
float altitude;
|
||||||
|
|
||||||
if ( fgGetString("/sim/startup/units") == "feet" ) {
|
if ( startup_units_node->getStringValue() == "feet" ) {
|
||||||
altitude = current_aircraft.fdm_state->get_Altitude();
|
altitude = current_aircraft.fdm_state->get_Altitude();
|
||||||
} else {
|
} else {
|
||||||
altitude = (current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER);
|
altitude = (current_aircraft.fdm_state->get_Altitude()
|
||||||
|
* SG_FEET_TO_METER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return altitude;
|
return altitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,18 +703,21 @@ bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
|
||||||
void fgCockpitUpdate( void ) {
|
void fgCockpitUpdate( void ) {
|
||||||
|
|
||||||
SG_LOG( SG_COCKPIT, SG_DEBUG,
|
SG_LOG( SG_COCKPIT, SG_DEBUG,
|
||||||
"Cockpit: code " << ac_cockpit->code() << " status "
|
"Cockpit: code " << ac_cockpit->code() << " status "
|
||||||
<< ac_cockpit->status() );
|
<< ac_cockpit->status() );
|
||||||
|
|
||||||
|
static const SGPropertyNode * xsize_node = fgGetNode("/sim/startup/xsize");
|
||||||
|
static const SGPropertyNode * ysize_node = fgGetNode("/sim/startup/ysize");
|
||||||
|
static const SGPropertyNode * hud_visibility_node
|
||||||
|
= fgGetNode("/sim/hud/visibility");
|
||||||
|
|
||||||
|
int iwidth = xsize_node->getIntValue();
|
||||||
|
int iheight = ysize_node->getIntValue();
|
||||||
|
float width = iwidth;
|
||||||
|
float height = iheight;
|
||||||
|
|
||||||
// FIXME: inefficient
|
// FIXME: inefficient
|
||||||
int iwidth = fgGetInt("/sim/startup/xsize");
|
if ( hud_visibility_node->getBoolValue() ) {
|
||||||
// FIXME: inefficient
|
|
||||||
int iheight = fgGetInt("/sim/startup/ysize");
|
|
||||||
float width = iwidth;
|
|
||||||
float height = iheight;
|
|
||||||
|
|
||||||
// FIXME: inefficient
|
|
||||||
if ( fgGetBool("/sim/hud/visibility") ) {
|
|
||||||
// This will check the global hud linked list pointer.
|
// This will check the global hud linked list pointer.
|
||||||
// If these is anything to draw it will.
|
// If these is anything to draw it will.
|
||||||
fgUpdateHUD();
|
fgUpdateHUD();
|
||||||
|
@ -731,8 +736,7 @@ void fgCockpitUpdate( void ) {
|
||||||
glMatrixMode( GL_PROJECTION );
|
glMatrixMode( GL_PROJECTION );
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluOrtho2D( 0, fgGetInt("/sim/startup/xsize"),
|
gluOrtho2D( 0, iwidth, 0, iheight );
|
||||||
0, fgGetInt("/sim/startup/ysize") );
|
|
||||||
glMatrixMode( GL_MODELVIEW );
|
glMatrixMode( GL_MODELVIEW );
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -754,8 +758,5 @@ void fgCockpitUpdate( void ) {
|
||||||
}
|
}
|
||||||
#endif // #ifdef DISPLAY_COUNTER
|
#endif // #ifdef DISPLAY_COUNTER
|
||||||
|
|
||||||
glViewport( 0, 0,
|
glViewport( 0, 0, iwidth, iheight );
|
||||||
fgGetInt("/sim/startup/xsize"),
|
|
||||||
fgGetInt("/sim/startup/ysize") );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue