|
From: PlayeRom R. L. <rom...@pl...> - 2023-07-25 12:23:47
|
I finally ran the debugger, and it works differently than I assumed.
The FGEnvironment constructor is run with some cyclicity in the
`FGClimate::update` function, after which the setters are run manually:
FGEnvironment dummy;
...
dummy.set_temperature_degc(_gl.temperature);
Here's why FGEnvironment won't know how the `is_isa` flag should be set,
because we have to pass it to it manually as well, so it can be done in
the FGEnvironment constructor (as I've done now), or for example in
`FGClimate::update`:
FGEnvironment dummy;
dummy.set_is_isa(fgGetBool("/environment/atmosphere/is-isa", false));
...
dummy.set_temperature_degc(_gl.temperature);
If we want to get rid of `fgGetBool` when creating `FGEnvironment
dummy;`, I see the following solution:
1. set the `is-isa` flag in the `/environament/climate/is-isa` property.
2. In the function `FGClimate::bind()` bind the flag
`_tiedProperties.Tie( "is-isa", &_is_isa);`.
3. In the `FGClimate::update` function, call `set_is_isa`:
FGEnvironment dummy;
dummy.set_is_isa(_is_isa);
...
This means that `_tiedProperties.Tie` for `is_isa` in
`FGEnvironment::Tie` is redundant and should be removed.
If this is a more appropriate solution, I can implement it.
There is another call of `FGEnvironment dummy;` in
`MetarProperties::setMetar`, but I wouldn't change anything there,
because as far as I can see it is only run for the `Live data` weather
scenario, where `is_isa` must be `false` anyway.
W dniu 24.07.2023 o 18:33, PlayeRom Roman Ludwicki pisze:
>
> I'm not sure if that's possible, but it looks to me like
> _recalc_sl_temperature() is being called between _init() and copy()
> methods in the copy constructor. So when in _init() I set is_isa =
> false, then is _recalc_sl_temperature called with is_isa = false, then
> is called copy(env) method where is_isa is set to true, but it's too
> late. The reason for this is that when I remove is_isa = false; from
> the _init() method, and I only set it in a regular constructor, then
> _recalc_sl_temperature keeps the is_isa flag set correctly.
>
>
> W dniu 24.07.2023 o 15:15, James Turner pisze:
>>
>>
>>> On 22 Jul 2023, at 00:14, PlayeRom Roman Ludwicki
>>> <rom...@pl...> wrote:
>>>
>>> At first I thought it was enough to set is_isa = false; in the
>>> FGEnvironment::_init() method. But then, even though the setter set
>>> the is_isa flag to true, it was returned to false by the
>>> FGEnvironment copy constructor.From what I checked, the
>>> FGEnvironmentcopy constructor is run every frame of the
>>> animation.The normal FGEnvironment constructor only runs once, so I
>>> hope it won't be a big deal?Unless there is a better solution to
>>> initialize the is_isa flag?
>>>
>>>
>>
>> Initialising to false is correct, the copy constructor calls copy()
>> which you did implement correctly (copy the value of is_isa from
>> source object). There must be something else going wrong, since the
>> copied-in FGEnvironment should have the correct values, otherwise we
>> would always get a blank/default FGEnvironment every frame.
>>
>> I’ll apply the patch and do some debugging, unless you can find
>> anything yourself.
>>
>> Kind regards,
>> James
>>
>>
>>
>> _______________________________________________
>> Flightgear-devel mailing list
>> Fli...@li...
>> https://lists.sourceforge.net/lists/listinfo/flightgear-devel
> --
> Pozdrawiam
> Roman Ludwicki
>
>
> _______________________________________________
> Flightgear-devel mailing list
> Fli...@li...
> https://lists.sourceforge.net/lists/listinfo/flightgear-devel
--
Pozdrawiam
Roman Ludwicki
|