24#include <simgear/compiler.h>
32#include <simgear/debug/logstream.hxx>
33#include <simgear/math/SGLimits.hxx>
34#include <simgear/math/SGMisc.hxx>
48 if ( timeratio < 0.0 ) {
49 if ( timeratio < -1.0 ) {
55 }
else if ( timeratio < 0.2 ) {
58 current = current * (1.0 - timeratio) + target * timeratio;
59 }
else if ( timeratio > 5.0 ) {
64 double keep = exp(-timeratio);
65 current = current * keep + target * (1.0 - keep);
72double innerLowPassPeriodic(
double current,
double target,
double timeratio)
74 auto currentSigned = SGMiscd::normalizePeriodic(-180.0, 180.0, current);
75 auto targetSigned = SGMiscd::normalizePeriodic(-180.0, 180.0, target);
76 if (fabs(currentSigned - targetSigned) > 180.0) {
81 targetSigned += copysign(360, currentSigned);
84 return fgGetLowPass(currentSigned, targetSigned, timeratio);
91 return SGMiscd::normalizePeriodic(0.0, 360.0, innerLowPassPeriodic(current, target, timeratio));
97 return SGMiscd::normalizePeriodic(-180.0, 180.0, innerLowPassPeriodic(current, target, timeratio));
103 double factor = 2.0 / (timeratio + 1.0);
104 return (target - current) * factor + current;
114 if(SGPath(
"ygjmyfvhhnvdoesnotexist").realpath().utf8Str() ==
"ygjmyfvhhnvdoesnotexist"){
119 "Nasal initialization error",
120 "Version mismatch - please update simgear");
122 SGPath::clearListOfAllowedPaths(
false);
123 SGPath::clearListOfAllowedPaths(
true);
126 read_paths.push_back(
globals->get_fg_root());
127 read_paths.push_back(
globals->get_fg_home());
129 for (
const auto& path: read_paths) {
134 "Nasal initialization error",
135 "Empty string in FG_ROOT, FG_HOME, FG_AIRCRAFT, FG_SCENERY or "
136 "--allow-nasal-read, or fgInitAllowedPaths() called too early");
138 SGPath::addAllowedPathPattern(path.realpath().utf8Str() +
"/*",
140 SGPath::addAllowedPathPattern(path.realpath().utf8Str(),
false);
143 const std::string fg_home =
globals->get_fg_home().realpath().utf8Str();
144 SGPath::addAllowedPathPattern(fg_home +
"/*.sav",
true );
145 SGPath::addAllowedPathPattern(fg_home +
"/*.log",
true);
146 SGPath::addAllowedPathPattern(fg_home +
"/cache/*",
true);
147 SGPath::addAllowedPathPattern(fg_home +
"/Export/*",
true);
148 SGPath::addAllowedPathPattern(fg_home +
"/state/*.xml",
true);
149 SGPath::addAllowedPathPattern(fg_home +
"/aircraft-data/*.xml",
true);
150 SGPath::addAllowedPathPattern(fg_home +
"/Wildfire/*.xml",
true);
151 SGPath::addAllowedPathPattern(fg_home +
"/runtime-jetways/*.xml",
true);
152 SGPath::addAllowedPathPattern(fg_home +
"/Input/Joysticks/*.xml",
true);
155 const std::string homePath =
globals->get_fg_home().utf8Str();
156 if (! SGPath(homePath +
"/../no.log").validate(
true).isNull() ||
157 ! SGPath(homePath +
"/no.logt").validate(
true).isNull() ||
158 ! SGPath(homePath +
"/nolog").validate(
true).isNull() ||
159 ! SGPath(homePath +
"no.log").validate(
true).isNull() ||
160 ! SGPath(homePath +
"\\..\\no.log").validate(
false).isNull() ||
161 SGPath(homePath +
"/aircraft-data/yes..xml").validate(
true).isNull() ||
162 SGPath(homePath +
"/.\\yes.bmp").validate(
false).isNull()) {
164 "Nasal initialization error",
165 "The FG_HOME directory must not be inside any of the FG_ROOT, "
166 "FG_AIRCRAFT, FG_SCENERY or --allow-nasal-read directories",
167 "(check that you have not accidentally included an extra ':', "
168 "as an empty part means the current directory)");
175 for (
auto a : authors->getChildren(
"author")) {
176 const std::string
name = a->getStringValue(
"name");
182 result += a->getStringValue(
"name");
189 const auto authorsNode =
fgGetNode(
"sim/authors");
std::string fgGetString(const char *name, const char *defaultValue)
Get a string value for a property.
std::vector< SGPath > PathList
std::string getAircraftAuthorsText()
getAircraftAuthorsText - get the aircraft authors as a single string value.
double lowPassPeriodicDegreesPositive(double current, double target, double timeratio)
low-pass filter for bearings, etc in degrees.
double lowPassPeriodicDegreesSigned(double current, double target, double timeratio)
low-pass filter for bearings, etc in degrees.
void fatalMessageBoxThenExit(const std::string &caption, const std::string &msg, const std::string &moreText, int exitStatus, bool reportToSentry)
double filterExponential(double current, double target, double timeratio)
exponential filter
SGPropertyNode * fgGetNode(const char *path, bool create)
Get a property node.
double fgGetLowPass(double current, double target, double timeratio)
Move a value towards a target.
void fgInitAllowedPaths()
Allowed paths here are absolute, and may contain one *, which matches any string.
std::string generateAuthorsText(SGPropertyNode *authors)