Board index FlightGear Development Weather

rand() Function in Nasal code  Topic is solved

Everything related to weather simulation, visuals should be discussed in the shader subforum.

rand() Function in Nasal code

Postby gierschi@flightgear » Wed Mar 09, 2016 11:22 am

Hey guys,

I often find a function called rand() (e.g. in local_weather.nas). Where is it defined and what is the function doing? Maybe making something randomly?

Sebastian
gierschi@flightgear
 
Posts: 58
Joined: Tue Nov 03, 2015 9:40 pm

Re: rand() Function in Nasal code  

Postby sanhozay » Wed Mar 09, 2016 11:48 am

It is a Nasal function defined in NasalSys.cxx: https://sourceforge.net/p/flightgear/fl ... salSys.cxx

This calls sg_random, which is defined in: https://sourceforge.net/p/flightgear/si ... g_random.c

As you can see from the comment on line 110, each call to it generates a random number between 0.0 and 1.0. So things like local weather will use it to randomly create clouds. Aircraft might use it to trigger things like failures, differences in fuel consumption between engines, slight differences in refuelling between tanks, etc.
sanhozay
 
Posts: 1207
Joined: Thu Dec 26, 2013 11:57 am
Location: EGNM
Callsign: G-SHOZ
Version: Git
OS: Ubuntu 16.04

Re: rand() Function in Nasal code

Postby gierschi@flightgear » Wed Mar 09, 2016 1:08 pm

Great, thanks for the quick and helpful reply.
gierschi@flightgear
 
Posts: 58
Joined: Tue Nov 03, 2015 9:40 pm

Re: rand() Function in Nasal code

Postby Hooray » Wed Mar 09, 2016 7:21 pm

note that, at some point, there's been talk about another RNG for cloud placement to keep coud placement in sync between different instances, see Stuart's and Mathias' comments in the archives.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11292
Joined: Tue Mar 25, 2008 8:40 am


Return to Weather

Who is online

Users browsing this forum: No registered users and 2 guests

cron