From 21e3c4d4931ce05470e3bd9a81f3f15bb2cf3008 Mon Sep 17 00:00:00 2001 From: BARANGER Emmanuel Date: Sat, 7 Jan 2012 00:09:41 +0100 Subject: [PATCH 1/4] Merge branch 'master' of git://gitorious.org/fg/fgdata From e3fabacfc57be9fe33bdcd7cd6e7366a32ad9ffe Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sat, 7 Jan 2012 09:23:26 +0100 Subject: [PATCH 2/4] #558: weather utility, performance drop on sim reset Do not install another set of listeners on _every_ sim reset. Also improve performance by removing a listener for a property which is written in _every_ loop anyway (don't waste another Nasal context). (Do we really need a _Nasal_ loop running at full speed just to convert a bunch of properties? It increases the load on the Nasal GC and is unconditionally active, even if all shaders are disabled etc). --- Nasal/weather-utility.nas | 89 +++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/Nasal/weather-utility.nas b/Nasal/weather-utility.nas index 90e735e61..6c93051b4 100644 --- a/Nasal/weather-utility.nas +++ b/Nasal/weather-utility.nas @@ -3,6 +3,9 @@ # be used with a tied property # +# TODO: Make this optional (when shaders disabled etc), or move computation +# away from Nasal. + #does what it says on the tin var clamp = func(v, min, max) { v < min ? min : v > max ? max : v } @@ -44,7 +47,44 @@ props.globals.initNode("/orientation/model/pitch-deg", 0, "DOUBLE"); props.globals.initNode("/orientation/model/roll-deg", 0, "DOUBLE"); +var update_waves = func (wind) { + var wind = 0; + var amp = 0; + var angle = 0; + var dangle = 0; + var freq = 0; + var factor = 0; + var sharp = 0; + + amp = Amp + 0.02 * wind; + amp = clamp(amp, 1.0, 2.0); + + setprop("/environment/wave/amp", amp); + + angle = Angle + 0.2 * wind; + setprop("/environment/wave/angle", angle); + + dangle = DAngle - 0.4 * wind; + setprop("/environment/wave/dangle", dangle); + + freq = Freq + 0.0008 * wind; + freq = clamp(freq, 0.01, 0.015); + setprop("/environment/wave/freq", freq); + + factor = Factor - 0.00001 * wind; + factor = clamp(factor, 0.0001, 0.0004); + setprop("/environment/wave/factor", factor); + + sharp = Sharp + 0.02 * wind; + sharp = clamp(sharp, 1.0, 2.0); + setprop("/environment/wave/sharp", sharp); +}; + +var is_initialized = 0; var initialize = func { + if (is_initialized) + return; # only install listeners once + is_initialized = 1; var wind_from_east_Node = props.globals.getNode("/environment/config/boundary/entry[0]/wind-from-east-fps", 1); wind_from_east_Node.setDoubleValue(0); @@ -72,48 +112,14 @@ var initialize = func { # ################## listeners #################### # - setlistener("/environment/sea/surface/wind-speed-kt", func (n) { - var wind = 0; - var amp = 0; - var angle = 0; - var dangle = 0; - var freq = 0; - var factor = 0; - var sharp = 0; - - wind = n.getValue(); - - amp = Amp + 0.02 * wind; - amp = clamp(amp, 1.0, 2.0); - - setprop("/environment/wave/amp", amp); - - angle = Angle + 0.2 * wind; - setprop("/environment/wave/angle", angle); - - dangle = DAngle - 0.4 * wind; - setprop("/environment/wave/dangle", dangle); - - freq = Freq + 0.0008 * wind; - freq = clamp(freq, 0.01, 0.015); - setprop("/environment/wave/freq", freq); - - factor = Factor - 0.00001 * wind; - factor = clamp(factor, 0.0001, 0.0004); - setprop("/environment/wave/factor", factor); - - sharp = Sharp + 0.02 * wind; - sharp = clamp(sharp, 1.0, 2.0); - setprop("/environment/wave/sharp", sharp); - - - }, - 1, - 0);# end listener +# installing a listener to /environment/sea/surface/wind-speed-kt does not make sense, +# since it's currently being written in _every_ update loop anyway). +# setlistener("/environment/sea/surface/wind-speed-kt", func(n) {update_waves(n.getValue())}, +# 1, +# 0);# end listener - print("weather util initialized ..."); + print("weather util initialized ..."); loop(); - }# end init var loop = func { @@ -132,6 +138,9 @@ var loop = func { value = getprop("/environment/config/boundary/entry[0]/wind-speed-kt"); setprop("/environment/sea/surface/wind-speed-kt", value); # print("wind-speed-kt ", getprop("/environment/sea/surface/wind-speed-kt")); + # Direct call to update wave settings (much more effective than using a listener, + # since it's written in every loop anyway. + update_waves(value); value = getprop("/environment/config/enabled"); setprop("/environment/sea/config/enabled", value); From fdcd319c9f1556985b47daea9a5977c47724ca99 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sat, 7 Jan 2012 09:42:36 +0100 Subject: [PATCH 3/4] Fix global weather dialog. Don't try to call "local_weather" when it isn't loaded. --- gui/dialogs/weather.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/dialogs/weather.xml b/gui/dialogs/weather.xml index e9055cfd4..5b56ade46 100644 --- a/gui/dialogs/weather.xml +++ b/gui/dialogs/weather.xml @@ -1759,7 +1759,7 @@ Fix for #567 --> nasal - + From 8c7c4bbb71daaab1166c43fd5151025d7bc60d4a Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sat, 7 Jan 2012 11:02:35 +0100 Subject: [PATCH 4/4] #568: runway shown twice on sim reset Exclude "/sim/atc/runway" from being restored (written) by the generic "restore-property-tree-on-reset" function, otherwise listeners are being called and the (old) runway is shown again. --- preferences.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/preferences.xml b/preferences.xml index 67c557594..73fc3736c 100644 --- a/preferences.xml +++ b/preferences.xml @@ -710,6 +710,7 @@ Started September 2000 by David Megginson, david@megginson.com true +