Also add pressure to the mix

This commit is contained in:
Erik Hofman
2019-11-04 15:18:59 +01:00
parent 2976dc29d5
commit 82b1cca247
3 changed files with 22 additions and 10 deletions

View File

@@ -181,6 +181,12 @@ public:
*/
inline float get_humidity() { return _humidity; }
/**
* Get the pressure at the current altitude.
* @return Pressure in kPa
*/
inline float get_pressure() { return _pressure; }
/**
* Test if static data of audio sample configuration has changed.
* Calling this function will reset the flag so calling it a second
@@ -220,6 +226,7 @@ protected:
float _reference_dist = 500.0f;
float _max_dist = 3000.0f;
float _pressure = 101.325f;
float _humidity = 0.5f;
float _degC = 20.0f;
@@ -557,12 +564,15 @@ public:
/**
* Set both the temperature and relative humidity at the current altitude.
* @param temp Temperature in degrees Celsius
* @param hum Percent relative humidity (0.0 to 1.0)
* @param t Temperature in degrees Celsius
* @param h Percent relative humidity (0.0 to 1.0)
* @param p Pressure in kPa;
*/
inline void set_atmosphere(float temp, float hum) {
if (fabsf(_degC - temp) > 1.0f || fabsf(_humidity - hum) > 0.1f) {
_degC = temp, _humidity = hum; _static_changed = true;
inline void set_atmosphere(float t, float h, float p) {
if (fabsf(_degC - t) > 1.0f || fabsf(_humidity - h) > 0.1f ||
fabsf(_pressure - p) > 1.0f)
{
_degC = t, _humidity = h; _pressure = p; _static_changed = true;
}
}

View File

@@ -302,7 +302,7 @@ void SGSampleGroup::update_pos_and_orientation() {
sample->set_rotation( ec2body );
sample->set_position(base_position);
sample->set_velocity( velocity );
sample->set_atmosphere( _degC, _humidity );
sample->set_atmosphere( _degC, _humidity, _pressure );
// Test if a sample is farther away than max distance, if so
// stop the sound playback and free it's source.

View File

@@ -198,11 +198,12 @@ public:
/**
* Set both the temperature and relative humidity at the current altitude.
* @param temp Temperature in degrees Celsius
* @param hum Percent relative humidity (0.0 to 1.0)
* @param t Temperature in degrees Celsius
* @param h Percent relative humidity (0.0 to 1.0)
* @param p Pressure in kPa
*/
void set_atmosphere(float temp, float hum ) {
_degC = temp, _humidity = hum; _changed = true;
void set_atmosphere(float t, float h, float p ) {
_degC = t, _humidity = h; _pressure = p; _changed = true;
}
/**
@@ -223,6 +224,7 @@ private:
bool _changed = false;
bool _pause = false;
float _volume = 1.0f;
float _pressure = 101.325f;
float _humidity = 0.5f;
float _degC = 20.0f;