}
cout << "ERROR IN FGATCMgr - reached end of GetATCPointer\n";
+
+ return NULL;
}
#include <iomanip>
#elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
# include <iostream.h>
-#elif defined( __BORLANDC__ )
+#elif defined( __BORLANDC__ ) || (__APPLE__)
# include <iostream>
#else
# include <istream.h>
#include <iomanip>
#elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
# include <iostream.h>
-#elif defined( __BORLANDC__ )
+#elif defined( __BORLANDC__ ) || (__APPLE__)
# include <iostream>
#else
# include <istream.h>
# include <istream>
#elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
# include <iostream.h>
-#elif defined( __BORLANDC__ )
+#elif defined( __BORLANDC__ ) || defined (__APPLE__)
# include <iostream>
#else
# include <istream.h>
# include <istream>
#elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
# include <iostream.h>
-#elif defined( __BORLANDC__ )
+#elif defined( __BORLANDC__ ) || defined (__APPLE__)
# include <iostream>
#else
# include <istream.h>
if(type=="gauge") {
float x,y;
float i;
- int decimal, sign;
y=(float)(scrn_rect.top);
x=(float)(scrn_rect.left);
glEnable(GL_POINT_SMOOTH);
//type-fixed & zoom=1, behaviour to be defined
// Code for Moving Type Pointer included by suma.
float ycentre, ypoint,xpoint;
- int range,wth;
+ int range;
if(cur_value > maxValue)
cur_value = maxValue;
float r = 7.5;
- float ang,temp;
- float x1,y1,x2,y2,xcent,ycent;
+ float x1,y1,x2,y2;
// to draw a circle
raw->rudder = node->getDoubleValue( "rudder" );
raw->flaps = node->getDoubleValue( "flaps" );
for ( i = 0; i < FGRawCtrls::FG_MAX_ENGINES; ++i ) {
- raw->throttle[i] = node->getDoubleValue( "throttle", i );
- raw->mixture[i] = node->getDoubleValue( "mixture", i );
- raw->prop_advance[i] = node->getDoubleValue( "propeller-pitch", i );
- raw->magnetos[i] = node->getIntValue( "magnetos", i );
- raw->starter[i] = node->getBoolValue( "starter", i );
+ raw->throttle[i] = node->getDoubleValue( "throttle", 0.0 );
+ raw->mixture[i] = node->getDoubleValue( "mixture", 0.0 );
+ raw->prop_advance[i] = node->getDoubleValue( "propeller-pitch", 0.0 );
+ raw->magnetos[i] = node->getIntValue( "magnetos", 0 );
+ raw->starter[i] = node->getBoolValue( "starter", false );
}
for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) {
- raw->brake[i] = node->getDoubleValue( "brakes", i );
+ raw->brake[i] = node->getDoubleValue( "brakes", 0.0 );
}
raw->hground = fgGetDouble( "/environment/ground-elevation-m" );
raw->magvar = fgGetDouble("/environment/magnetic-variation-deg");
}
net->num_wheels = htonl(net->num_wheels);
- for ( i = 0; i < net->num_wheels; ++i ) {
- net->wow[i] = htonl(net->wow[i]);
- }
+
+ // I don't need to convert the Wow flags, since they are one byte in size
net->cur_time = ntohl(net->cur_time);
net->warp = ntohl(net->warp);
void FGNewEngine::Do_Prop_Calcs()
{
float Gear_Ratio = 1.0;
- float blade_length; // meters
float forward_velocity; // m/s
float prop_power_consumed_SI; // Watts
- float prop_power_consumed_HP; // HP
double J; // advance ratio - dimensionless
double Cp_20; // coefficient of power for 20 degree blade angle
double Cp_25; // coefficient of power for 25 degree blade angle
static const char *IdSrc = "$Id$";
static const char *IdHdr = ID_FCS;
+#if defined(WIN32) && !defined(__CYGWIN__)
+#define snprintf _snprintf
+#endif
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
static const char *IdSrc = "$Id$";
static const char *IdHdr = ID_GROUNDREACTIONS;
+#if defined (__APPLE__)
+/* Not all systems have the gcvt function */
+inline char* gcvt (double value, int ndigits, char *buf) {
+ /* note that this is not exactly what gcvt is supposed to do! */
+ snprintf (buf, ndigits+1, "%f", value);
+ return buf;
+}
+#endif
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
msg->messageId = messageId++;
msg->subsystem = "FDM";
msg->type = Message::eInteger;
- msg->bVal = iVal;
+ msg->bVal = (iVal != 0);
Messages.push(msg);
return msg;
}
msg->messageId = messageId++;
msg->subsystem = "FDM";
msg->type = Message::eDouble;
- msg->bVal = dVal;
+ msg->bVal = (dVal != 0.0);
Messages.push(msg);
return msg;
}
static const char *IdSrc = "$Id$";
static const char *IdHdr = ID_PROPULSION;
+extern short debug_lvl;
+
+#if defined (__APPLE__)
+/* Not all systems have the gcvt function */
+inline char* gcvt (double value, int ndigits, char *buf) {
+ /* note that this is not exactly what gcvt is supposed to do! */
+ snprintf (buf, ndigits+1, "%f", value);
+ return buf;
+}
+#endif
+
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__)
WSADATA wsaData;
- int PASCAL FAR wsaReturnCode;
+ int wsaReturnCode;
wsaReturnCode = WSAStartup(MAKEWORD(1,1), &wsaData);
if (wsaReturnCode == 0) cout << "Winsock DLL loaded ..." << endl;
else cout << "Winsock DLL not initialized ..." << endl;
// Gravity
Glue::geodUp(s->pos, out);
- Math::mul3(-9.8, out, out);
+ Math::mul3(-9.8f, out, out);
// The regular acceleration
float tmp[3];
float segWgt = len*wid/segs;
int j;
for(j=0; j<segs; j++) {
- float frac = (j+0.5) / segs;
+ float frac = (j+0.5f) / segs;
float scale = 1;
if(frac < f->mid)
{
// Figure it will compress by 20cm
float comp[3];
- float DIST = 0.2;
+ float DIST = 0.2f;
comp[0] = 0; comp[1] = 0; comp[2] = DIST;
// Give it a spring constant such that at full compression it will
// hold up 10 times the planes mass. That's about right. Yeah.
float mass = _model.getBody()->getTotalMass();
- float spring = (1/DIST) * 9.8 * 10 * mass;
+ float spring = (1/DIST) * 9.8f * 10.0f * mass;
float damp = 2 * Math::sqrt(spring * mass);
int i;
g->setBrake(1);
// I made these up
- g->setStaticFriction(0.6);
- g->setDynamicFriction(0.5);
+ g->setStaticFriction(0.6f);
+ g->setDynamicFriction(0.5f);
_model.addGear(g);
}
t->handle = body->addMass(0, t->pos);
totalFuel += t->cap;
}
- _cruiseWeight = _emptyWeight + totalFuel*0.5;
- _approachWeight = _emptyWeight + totalFuel*0.2;
+ _cruiseWeight = _emptyWeight + totalFuel*0.5f;
+ _approachWeight = _emptyWeight + totalFuel*0.2f;
body->recalc();
// Ground effect
float gepos[3];
float gespan = _wing->getGroundEffect(gepos);
- _model.setGroundEffect(gepos, gespan, .3);
+ _model.setGroundEffect(gepos, gespan, 0.3f);
solveGear();
solve();
Gear* g = gr->gear;
g->getPosition(pos);
Math::sub3(cg, pos, pos);
- gr->wgt = 1/(0.5+Math::sqrt(pos[0]*pos[0] + pos[1]*pos[1]));
+ gr->wgt = 1.0f/(0.5f+Math::sqrt(pos[0]*pos[0] + pos[1]*pos[1]));
total += gr->wgt;
}
// The force at max compression should be sufficient to stop a
// plane moving downwards at 3x the approach descent rate. Assume
// a 3 degree approach.
- float descentRate = 3*_approachSpeed/19.1;
+ float descentRate = 3.0f*_approachSpeed/19.1f;
// Spread the kinetic energy according to the gear weights. This
// will results in an equal compression fraction (not distance) of
// each gear.
- float energy = 0.5*_approachWeight*descentRate*descentRate;
+ float energy = 0.5f*_approachWeight*descentRate*descentRate;
for(i=0; i<_gears.size(); i++) {
GearRec* gr = (GearRec*)_gears.get(i);
gr->gear->setDamping(2*Math::sqrt(k*_approachWeight*gr->wgt));
// These are pretty generic
- gr->gear->setStaticFriction(0.8);
- gr->gear->setDynamicFriction(0.7);
+ gr->gear->setStaticFriction(0.8f);
+ gr->gear->setDynamicFriction(0.7f);
}
}
Math::vmul33(_approachState.orient, wind, wind);
// Approach is by convention at 20% tank capacity
- setFuelFraction(0.2);
+ setFuelFraction(0.2f);
// Run the thrusters until they get to a stable setting. FIXME:
// this is lots of wasted work.
void Airplane::solve()
{
- static const float ARCMIN = 0.0002909;
+ static const float ARCMIN = 0.0002909f;
float tmp[3];
_solutionIterations = 0;
float pitch1 = tmp[1];
// Now calculate:
- float awgt = 9.8 * _approachWeight;
+ float awgt = 9.8f * _approachWeight;
float dragFactor = thrust / (thrust-xforce);
float liftFactor = awgt / (awgt+alift);
}
// OK, now we can adjust the minor variables
- _cruiseAoA += 0.5*aoaDelta;
- _tailIncidence += 0.5*tailDelta;
+ _cruiseAoA += 0.5f*aoaDelta;
+ _tailIncidence += 0.5f*tailDelta;
- _cruiseAoA = clamp(_cruiseAoA, -.174, .174);
- _tailIncidence = clamp(_tailIncidence, -.174, .174);
+ _cruiseAoA = clamp(_cruiseAoA, -0.174f, 0.174f);
+ _tailIncidence = clamp(_tailIncidence, -0.174f, 0.174f);
if(dragFactor < 1.00001 && liftFactor < 1.00001 &&
aoaDelta < .000017 && tailDelta < .000017)
// R=287. I chose to correct the temperature to 288.20, since 79F is
// pretty hot for a "standard" atmosphere.
// meters kelvin Pa kg/m^3
-float Atmosphere::data[][4] = {{ 0, 288.20, 101325, 1.22500 },
- { 900, 282.31, 90971, 1.12260 },
- { 1800, 276.46, 81494, 1.02690 },
- { 2700, 270.62, 72835, 0.93765 },
- { 3600, 264.77, 64939, 0.85445 },
- { 4500, 258.93, 57752, 0.77704 },
- { 5400, 253.09, 51226, 0.70513 },
- { 6300, 247.25, 45311, 0.63845 },
- { 7200, 241.41, 39963, 0.57671 },
- { 8100, 235.58, 35140, 0.51967 },
- { 9000, 229.74, 30800, 0.46706 },
- { 9900, 223.91, 26906, 0.41864 },
- { 10800, 218.08, 23422, 0.37417 },
- { 11700, 216.66, 20335, 0.32699 },
- { 12600, 216.66, 17654, 0.28388 },
- { 13500, 216.66, 15327, 0.24646 },
- { 14400, 216.66, 13308, 0.21399 },
- { 15300, 216.66, 11555, 0.18580 },
- { 16200, 216.66, 10033, 0.16133 },
- { 17100, 216.66, 8712, 0.14009 },
- { 18000, 216.66, 7565, 0.12165 },
- { 18900, 216.66, 6570, 0.10564 }};
+float Atmosphere::data[][4] = {{ 0.0f, 288.20f, 101325.0f, 1.22500f },
+ { 900.0f, 282.31f, 90971.0f, 1.12260f },
+ { 1800.0f, 276.46f, 81494.0f, 1.02690f },
+ { 2700.0f, 270.62f, 72835.0f, 0.93765f },
+ { 3600.0f, 264.77f, 64939.0f, 0.85445f },
+ { 4500.0f, 258.93f, 57752.0f, 0.77704f },
+ { 5400.0f, 253.09f, 51226.0f, 0.70513f },
+ { 6300.0f, 247.25f, 45311.0f, 0.63845f },
+ { 7200.0f, 241.41f, 39963.0f, 0.57671f },
+ { 8100.0f, 235.58f, 35140.0f, 0.51967f },
+ { 9000.0f, 229.74f, 30800.0f, 0.46706f },
+ { 9900.0f, 223.91f, 26906.0f, 0.41864f },
+ { 10800.0f, 218.08f, 23422.0f, 0.37417f },
+ { 11700.0f, 216.66f, 20335.0f, 0.32699f },
+ { 12600.0f, 216.66f, 17654.0f, 0.28388f },
+ { 13500.0f, 216.66f, 15327.0f, 0.24646f },
+ { 14400.0f, 216.66f, 13308.0f, 0.21399f },
+ { 15300.0f, 216.66f, 11555.0f, 0.18580f },
+ { 16200.0f, 216.66f, 10033.0f, 0.16133f },
+ { 17100.0f, 216.66f, 8712.0f, 0.14009f },
+ { 18000.0f, 216.66f, 7565.0f, 0.12165f },
+ { 18900.0f, 216.66f, 6570.0f, 0.10564f }};
// Universal gas constant for air, in SI units. P = R * rho * T.
// P in pascals (N/m^2), rho is kg/m^3, T in kelvin.
-const float R = 287.1;
+const float R = 287.1f;
// Specific heat ratio for air, at "low" temperatures.
-const float GAMMA = 1.4;
+const float GAMMA = 1.4f;
float Atmosphere::getStdTemperature(float alt)
{
// (1+(mach^2)/5)^(gamma/(gamma-1))
cp = Math::pow(1+0.2*m2, 3.5);
} else {
- float tmp0 = ((144/25.) * m2) / (28/5.*m2 - 4/5.);
- float tmp1 = ((14/5.) * m2 - (2/5.)) * (5/12.);
+ float tmp0 = ((144.0f/25.0f) * m2) / (28.0f/5.0f*m2 - 4.0f/5.0f);
+ float tmp1 = ((14.0f/5.0f) * m2 - (2.0f/5.0f)) * (5.0f/12.0f);
cp = Math::pow(tmp0, 3.5) * tmp1;
}
pos[i] = v[i] = rot[i] = acc[i] = racc[i] = 0;
int j;
for(j=0; j<3; j++)
- orient[3*i+j] = i==j ? 1 : 0;
+ orient[3*i+j] = i==j ? 1.0f : 0.0f;
}
}
};
if(o->object == obj && o->type == type)
return i;
}
+ return 0;
}
void ControlMap::setTransitionTime(int handle, float time)
switch(o->type) {
case THROTTLE: ((Thruster*)obj)->setThrottle(lval); break;
case MIXTURE: ((Thruster*)obj)->setMixture(lval); break;
- case STARTER: ((Thruster*)obj)->setStarter((bool)lval); break;
+ case STARTER: ((Thruster*)obj)->setStarter(lval != 0.0); break;
case MAGNETOS: ((PropEngine*)obj)->setMagnetos((int)lval); break;
case ADVANCE: ((PropEngine*)obj)->setAdvance(lval); break;
case REHEAT: ((Jet*)obj)->setReheat(lval); break;
_pos[i] = _cmpr[i] = 0;
_spring = 1;
_damp = 0;
- _sfric = 0.8;
- _dfric = 0.7;
+ _sfric = 0.8f;
+ _dfric = 0.7f;
_brake = 0;
_rot = 0;
_extension = 1;
float Gear::calcFriction(float wgt, float v)
{
// How slow is stopped? 10 cm/second?
- const float STOP = 0.1;
- const float iSTOP = 1/STOP;
+ const float STOP = 0.1f;
+ const float iSTOP = 1.0f/STOP;
v = Math::abs(v);
if(v < STOP) return v*iSTOP * wgt * _sfric;
else return wgt * _dfric;
// Shorthand for our output vectors:
float *north = out, *east = out+3, *down = out+6;
- float slat = Math::sin(lat);
- float clat = Math::cos(lat);
- float slon = Math::sin(lon);
- float clon = Math::cos(lon);
+ float slat = (float) Math::sin(lat);
+ float clat = (float)Math::cos(lat);
+ float slon = (float)Math::sin(lon);
+ float clon = (float)Math::cos(lon);
north[0] = -clon * slat;
north[1] = -slon * slat;
int i, j;
for(i=0; i<3; i++)
for(j=0; j<3; j++)
- out[3*i+j] = (i==j) ? 1 : 0;
+ out[3*i+j] = (i==j) ? 1.0f : 0.0f;
// Negate Y and Z
out[4] = out[8] = -1;
double lat, lon, alt;
xyz2geod(pos, &lat, &lon, &alt);
- float slat = Math::sin(lat);
- float clat = Math::cos(lat);
- float slon = Math::sin(lon);
- float clon = Math::cos(lon);
+ float slat = (float)Math::sin(lat);
+ float clat = (float)Math::cos(lat);
+ float slon = (float)Math::sin(lon);
+ float clon = (float)Math::cos(lon);
out[0] = clon * clat;
out[1] = slon * clat;
out[2] = slat;
// tsfc.
_vMax = 800;
_epr0 = 3.0;
- _tsfc = 0.8;
+ _tsfc = 0.8f;
_egt0 = 1050;
_n1Min = 55;
_n1Max = 102;
// 2.3 = -ln(0.1), i.e. x=2.3 is the 90% point we're defining
// The extra fudge factor is there because the N1 speed (which
// determines thrust) lags the N2 speed.
- _decay = 1.5 * 2.3 / time;
+ _decay = 1.5f * 2.3f / time;
}
void Jet::setVectorAngle(float angle)
// The actual thrust produced is keyed to the N1 speed. Add the
// afterburners in at the end.
float betaN1 = (_epr0-1) * (_n1 - _n1Min) / (_n1Max - _n1Min);
- _thrust *= betaN1/(betaTarget+.00001); // blowup protection
+ _thrust *= betaN1/(betaTarget+0.00001f); // blowup protection
_thrust *= 1 + _reheat*(_abFactor-1);
// Finally, calculate the output variables. Use a 80/20 mix of
// the N2/N1 speeds as the key.
- float beta = 0.8*betaN2 + 0.2*betaN1;
+ float beta = 0.8f*betaN2 + 0.2f*betaN1;
_epr = beta + 1;
- float ff0 = _maxThrust*_tsfc*(1/(3600*9.8)); // takeoff fuel flow, kg/s
+ float ff0 = _maxThrust*_tsfc*(1/(3600.0f*9.8f)); // takeoff fuel flow, kg/s
_fuelFlow = ff0 * beta*ibeta0;
- _fuelFlow *= 1 + (3.5 * _reheat * _abFactor); // Afterburners take
+ _fuelFlow *= 1 + (3.5f * _reheat * _abFactor); // Afterburners take
// 3.5 times as much
// fuel per thrust unit
_egt = T0 + beta*ibeta0 * (_egt0 - T0);
float Math::abs(float f)
{
- return ::fabs(f);
+ return (float)::fabs(f);
}
float Math::sqrt(float f)
{
- return ::sqrt(f);
+ return (float)::sqrt(f);
}
float Math::ceil(float f)
{
- return ::ceil(f);
+ return (float)::ceil(f);
}
float Math::cos(float f)
{
- return ::cos(f);
+ return (float)::cos(f);
}
float Math::sin(float f)
{
- return ::sin(f);
+ return (float)::sin(f);
}
float Math::tan(float f)
{
- return ::tan(f);
+ return (float)::tan(f);
}
float Math::atan2(float y, float x)
{
- return ::atan2(y, x);
+ return (float)::atan2(y, x);
}
double Math::abs(double f)
float Math::pow(double base, double exp)
{
- return ::pow(base, exp);
+ return (float)::pow(base, exp);
}
double Math::ceil(double f)
_integrator.setEnvironment(this);
// Default value of 30 Hz
- _integrator.setInterval(1.0/30.0);
+ _integrator.setInterval(1.0f/30.0f);
_agl = 0;
_crashed = false;
// Gravity, convert to a force, then to local coordinates
float grav[3];
Glue::geodUp(s->pos, grav);
- Math::mul3(-9.8 * _body.getTotalMass(), grav, grav);
+ Math::mul3(-9.8f * _body.getTotalMass(), grav, grav);
Math::vmul33(s->orient, grav, grav);
_body.addForce(grav);
#include "PistonEngine.hpp"
namespace yasim {
-const static float HP2W = 745.7;
-const static float CIN2CM = 1.6387064e-5;
-const static float RPM2RADPS = 0.1047198;
+const static float HP2W = 745.7f;
+const static float CIN2CM = 1.6387064e-5f;
+const static float RPM2RADPS = 0.1047198f;
PistonEngine::PistonEngine(float power, float speed)
{
// Presume a BSFC (in lb/hour per HP) of 0.45. In SI that becomes
// (2.2 lb/kg, 745.7 W/hp, 3600 sec/hour) 7.62e-08 kg/Ws.
- _f0 = power * 7.62e-08;
+ _f0 = power * 7.62e-08f;
_power0 = power;
_omega0 = speed;
// Further presume that takeoff is (duh) full throttle and
// peak-power, that means that by our efficiency function, we are
// at 11/8 of "ideal" fuel flow.
- float realFlow = _f0 * (11.0/8.0);
- _mixCoeff = realFlow * 1.1 / _omega0;
+ float realFlow = _f0 * (11.0f/8.0f);
+ _mixCoeff = realFlow * 1.1f / _omega0;
_turbo = 1;
_maxMP = 1e6; // No waste gate on non-turbo engines.
float P = P0 * (1 + _boost * (_turbo - 1));
if(P > _maxMP) P = _maxMP;
float T = Atmosphere::getStdTemperature(0) * Math::pow(P/P0, 2./7.);
- _rho0 = P / (287.1 * T);
+ _rho0 = P / (287.1f * T);
}
void PistonEngine::setDisplacement(float d)
// thrust at that setting, so hold onto the "output" value
// separately. Ick.
_mp = pressure * (1 + _boost*(_turbo-1)); // turbocharger
- float mp = _mp * (0.1 + 0.9 * _throttle); // throttle
+ float mp = _mp * (0.1f + 0.9f * _throttle); // throttle
_mp *= _throttle;
if(mp > _maxMP) mp = _maxMP; // wastegate
// pressure change can be assumed to be adiabatic. Calculate a
// temperature change, and use that to get the density.
float T = temp * Math::pow(mp/pressure, 2.0/7.0);
- float rho = mp / (287.1 * T);
+ float rho = mp / (287.1f * T);
// The actual fuel flow is determined only by engine RPM and the
// mixture setting. Not all of this will burn with the same
else if(r < .625) burned = _fuelFlow;
else if(r > 1.375) burned = burnable;
else
- burned = _fuelFlow + (burnable-_fuelFlow)*(r-.625)*(4.0/3.0);
+ burned = _fuelFlow + (burnable-_fuelFlow)*(r-0.625f)*(4.0f/3.0f);
// Correct for engine control state
if(!_running)
burned = 0;
if(_magnetos < 3)
- burned *= 0.9;
+ burned *= 0.9f;
// And finally the power is just the reference power scaled by the
// amount of fuel burned, and torque is that divided by RPM.
// Figure that the starter motor produces 20% of the engine's
// cruise torque.
if(_cranking && !_running)
- _torque += 0.20 * _power0/_omega0;
+ _torque += 0.20f * _power0/_omega0;
// Also, add a negative torque of 10% of cruise, to represent
// internal friction. Propeller aerodynamic friction is too low
// away as we approach cruise RPMs, though, to prevent interaction
// with the power computations. Ugly.
if(speed > 0 && speed < _omega0)
- _torque -= 0.05 * (_power0/_omega0) * (1 - speed/_omega0);
+ _torque -= 0.05f * (_power0/_omega0) * (1 - speed/_omega0);
// Now EGT. This one gets a little goofy. We can calculate the
// work done by an isentropically expanding exhaust gas as the
// account for non-thermodynamic losses like internal friction;
// 10% should do it.
- float massFlow = _fuelFlow + (rho * 0.5 * _displacement * speed);
+ float massFlow = _fuelFlow + (rho * 0.5f * _displacement * speed);
float specHeat = 1300;
- float corr = 1.0/(Math::pow(_compression, 0.4) - 1);
- _egt = corr * (power * 1.1) / (massFlow * specHeat);
+ float corr = 1.0f/(Math::pow(_compression, 0.4f) - 1.0f);
+ _egt = corr * (power * 1.1f) / (massFlow * specHeat);
if(_egt < temp) _egt = temp;
}
PropEngine::PropEngine(Propeller* prop, PistonEngine* eng, float moment)
{
// Start off at 500rpm, because the start code doesn't exist yet
- _omega = 52.3;
+ _omega = 52.3f;
_dir[0] = 1; _dir[1] = 0; _dir[2] = 0;
_variable = false;
break;
if(tdiff > 0) {
- if(!goingUp) step *= 0.5;
+ if(!goingUp) step *= 0.5f;
goingUp = true;
if(!_variable) _omega += step;
- else _prop->modPitch(1+(step*0.005));
+ else _prop->modPitch(1+(step*0.005f));
} else {
- if(goingUp) step *= 0.5;
+ if(goingUp) step *= 0.5f;
goingUp = false;
if(!_variable) _omega -= step;
- else _prop->modPitch(1-(step*0.005));
+ else _prop->modPitch(1-(step*0.005f));
}
}
void PropEngine::init()
{
- _omega = 0.01;
+ _omega = 0.01f;
_eng->setStarter(false);
_eng->setMagnetos(0);
}
float ratio2 = (_omega*_omega)/(targetOmega*targetOmega);
float targetTorque = engTorque * ratio2;
- float mod = propTorque < targetTorque ? 1.04 : (1/1.04);
+ float mod = propTorque < targetTorque ? 1.04f : (1.0f/1.04f);
// Convert to an acceleration here, so that big propellers
// don't seek faster than small ones.
float diff = Math::abs((propTorque - targetTorque) / _moment);
- if(diff < 10) mod = 1 + (mod-1)*(0.1*diff);
+ if(diff < 10) mod = 1 + (mod-1)*(0.1f*diff);
_prop->modPitch(mod);
}
{
// Initialize numeric constants:
_lambdaPeak = Math::pow(5.0, -1.0/4.0);
- _beta = 1.0/(Math::pow(5.0, -1.0/4.0) - Math::pow(5.0, -5.0/4.0));
+ _beta = 1.0f/(Math::pow(5.0f, -1.0f/4.0f) - Math::pow(5.0f, -5.0f/4.0f));
_r = radius;
- _etaC = 0.85; // make this settable?
+ _etaC = 0.85f; // make this settable?
_j0 = v/(omega*_lambdaPeak);
_baseJ0 = _j0;
float gamma = _etaC * _beta / _j0;
float torque = power0 / omega0;
float density = Atmosphere::getStdDensity(0);
- _tc0 = (torque * gamma) / (0.5 * density * V2 * _f0);
+ _tc0 = (torque * gamma) / (0.5f * density * V2 * _f0);
}
void Propeller::modPitch(float mod)
{
_j0 *= mod;
- if(_j0 < 0.25*_baseJ0) _j0 = 0.25*_baseJ0;
- if(_j0 > 4*_baseJ0) _j0 = 4*_baseJ0;
+ if(_j0 < 0.25f*_baseJ0) _j0 = 0.25f*_baseJ0;
+ if(_j0 > 4*_baseJ0) _j0 = 4*_baseJ0;
}
float torque = 0;
if(lambda > 1) {
- lambda = 1.0/lambda;
+ lambda = 1.0f/lambda;
torque = (density*V2*_f0*_j0)/(4*_etaC*_beta*(1-_lambdaPeak));
}
// fix (note: the discontinuity is at EXACTLY one, this is about
// the only time in history you'll see me use == on a floating
// point number!)
- if(lambda == 1) lambda = 0.9999;
+ if(lambda == 1.0) lambda = 0.9999f;
// Calculate lambda^4
float l4 = lambda*lambda; l4 = l4*l4;
float tc = (1 - lambda) / (1 - _lambdaPeak);
if(_matchTakeoff && tc > _tc0) tc = _tc0;
- float thrust = 0.5 * density * V2 * _f0 * tc;
+ float thrust = 0.5f * density * V2 * _f0 * tc;
if(torque > 0) {
torque -= thrust/gamma;
// edge. Convert to local (i.e. airplane) coordiantes and store
// into "torque".
torque[0] = 0;
- torque[1] = 0.1667 * _chord * (flapLift - (_cz*_cz0 + stallLift));
+ torque[1] = 0.1667f * _chord * (flapLift - (_cz*_cz0 + stallLift));
torque[2] = 0;
Math::tmul33(_orient, torque, torque);
Math::tmul33(_orient, out, out);
// Add in the units to make a real force:
- float scale = 0.5*rho*vel*vel*_c0;
+ float scale = 0.5f*rho*vel*vel*_c0;
Math::mul3(scale, out, out);
Math::mul3(scale, torque, torque);
}
return 1;
// (note mask: we want to use the "positive" stall angle here)
- float scale = 0.5*_peaks[fwdBak]/_stalls[i&2];
+ float scale = 0.5f*_peaks[fwdBak]/_stalls[i&2];
// Before the stall
if(alpha <= stallAlpha)
{
_pressure = pressure;
_temp = temp;
- _rho = _pressure / (287.1 * _temp);
+ _rho = _pressure / (287.1f * _temp);
}
}; // namespace yasim
// Calculate a "nominal" segment length equal to an average chord,
// normalized to lie within 0-1 over the length of the wing.
- float segLen = _chord * (0.5*(_taper+1)) / _length;
+ float segLen = _chord * (0.5f*(_taper+1)) / _length;
// Generating a unit vector pointing out the left wing.
float left[3];
int j;
for(j=0; j<nSegs; j++) {
- float frac = start + (j+0.5) * (end-start)/nSegs;
+ float frac = start + (j+0.5f) * (end-start)/nSegs;
float pos[3];
interp(root, tip, frac, pos);
// The negative AoA stall is the same if we're using an uncambered
// airfoil, otherwise a "little badder".
if(_camber > 0) {
- s->setStall(1, stallAoA * 0.8);
- s->setStallWidth(1, _stallWidth * 0.5);
+ s->setStall(1, stallAoA * 0.8f);
+ s->setStallWidth(1, _stallWidth * 0.5f);
} else {
s->setStall(1, stallAoA);
s->setStall(1, _stallWidth);
s->setStallPeak(1, 1);
int i;
for(i=2; i<4; i++) {
- s->setStall(i, 0.2267);
+ s->setStall(i, 0.2267f);
s->setStallWidth(i, 1);
}
static float _quat[4];
static double _view_offset;
- // general purpose variables
- double offset;
-
glutModifiers = glutGetModifiers();
glut_active_shift = glutModifiers & GLUT_ACTIVE_SHIFT;
glut_active_ctrl = glutModifiers & GLUT_ACTIVE_CTRL;
return;
}
- _update_button(m.modes[m.current_mode].buttons[b], modifiers, updown, x, y);
+ _update_button(m.modes[m.current_mode].buttons[b], modifiers, 0 != updown, x, y);
}
void
if (hasStep)
value = step->getBoolValue();
else
- value = amount;
+ value = (0.0 != amount);
if (value)
return prop->setBoolValue(!prop->getBoolValue());
else
config.append( "system.fgfsrc" );
fgParseOptions(config.str());
- char name[256];
#if defined( unix ) || defined( __CYGWIN__ )
+ char name[256];
// Check for $fg_root/system.fgfsrc.hostname
gethostname( name, 256 );
config.concat( "." );
void
FGViewer::recalc ()
{
- sgVec3 minus_z, right, forward, tilt;
+ sgVec3 right, forward;
sgMat4 tmpROT; // temp rotation work matrices
sgVec3 eye_pos, at_pos;
sgVec3 position_offset; // eye position offsets (xyz)
default:
assert(false);
}
+ return 0.0;
}
double
default:
assert(false);
}
+ return 0.0;
}
void
// Update the current view
do_axes();
view->update(dt);
- double tmp;
}
void
bool
FG3DModel::getVisible () const
{
- return _selector->getSelect();
+ return (_selector->getSelect() != 0);
}
void
// Generate a directional light
ssgLeaf *gen_directional_light( sgVec3 pt, sgVec3 dir ) {
+return NULL;
}
sgdVec4 plane;
sgdMakePlane( plane, tri[0], tri[1], tri[2] );
- sgdVec3 point, test;
+ sgdVec3 point;
// find point of intersection of line from point org
// in direction dir with triangle's plane
*terrain_elev = result;
*radius = geoc.radius();
sgVec3 tmp;
- sgMat4 TMP;
sgSetVec3(tmp, hit_list->get_normal(this_hit));
// cout << "cur_normal: " << tmp[0] << " " << tmp[1] << " " << tmp[2] << endl;
sgdSetVec3( normal, tmp );
*terrain_elev = result;
*radius = geoc.radius();
sgVec3 tmp;
- sgMat4 TMP;
sgSetVec3(tmp, hit_list->get_normal(this_hit));
// cout << "cur_normal: " << tmp[0] << " " << tmp[1] << " " << tmp[2] << endl;
sgdSetVec3( normal, tmp );
{
//************** HARD CODED RUNWAY LIGHT TEXTURES BEGIN ************************
- GLuint texEdge, texTaxi, texCenter, texTouchdown;
- GLuint texThreshold, texCrossbar, texUndershoot, texApproach;
- GLuint texRabbit, texVasi, texWhite, texRed, texGreen, texYellow;
+ GLuint texEdge, texTaxi, texTouchdown;
+ GLuint texThreshold;
+ GLuint texVasi, texWhite, texRed, texGreen, texYellow;
//VASI lights
setColor(0.0,0.0,1.0,360.0, 0, 0, 0, 0);
// updated, but hopefully we can can the ascii format soon.
ssgBranch *tmp = fgAsciiObjLoad( path, this, ground_lights, is_base );
if ( tmp ) {
- return tmp;
+ return (NULL != tmp);
} else {
// default to an ocean tile
if ( fgGenTile( path, tile_bucket, &c, &br, geometry ) ) {
}
}
- return geometry;
+ return (NULL != geometry);
}