Code in AudioIdent::setIdent() expects that SGSampleGroup::remove() does
remove the corresponding item from _samples, however SG commit 47aae88ab
broke this assumption, which caused the bug reported at [1].
Restore the immediate removal from _samples by default. For the special
case where we do need delayed removal (i.e., while
SGSampleGroup::update() is iterating over _samples), the new optional
parameter is passed the value true. For a longer explanation, see [2].
This fixes a crash when swapping the selected and standby frequencies
for the NAV1 or NAV2 instrument (more precise description at [1]).
[1] https://forum.flightgear.org/viewtopic.php?f=25&t=40890
[2] https://sourceforge.net/p/flightgear/mailman/message/37721699/
Previously the Bounding Box of a group of building was calculated
purely based on the position of each building. Depending on the
geometry of the various buildings, this could result in a zero-volume
box, which would be culled away.
This change ensures that the BB is at least a 20x20x20 volume, by
increasing the convex hull size.
Fixes https://sourceforge.net/p/flightgear/codetickets/2542/
Update my work-around for this from last year, and handle another
case (where models are loaded directly rather using the delayed
callback via the osgDB::Pager)
Where we replaced the XMl-wrapper with an AC model in FGData or
TerraSync, accept the old path ending in .xml, to avoid many errors
loading custom scenery.
The changes to the sorting rules caused a breaking change that was incompatible.
The solution to this is to revert to being compatible with <=2020.3 but also to allow modellers to choose the new sorting rules.
I've added a new tag <defaults> which can contain either <axis-animation-vertex-order-xyz/> or <axis-animation-vertex-order-x/>. The defaults will affect all animations in the .xml and also any included models unless the included model also has a <defaults> section.
So for modelers that want to use the new definitive vertex sorting rules adding the following to the main model is sufficient.
<defaults>
<axis-animation-vertex-order-xyz/>
</defaults>
There are also a couple of new tags that can be used in the <axis> section.
1. <order-by-xyz/> - use the new sorting rules
2. <order-by-x/> - use the 2020.3 sorting rules
3. <swap-axis-direction/> - when the animation goes the wrong way this is an elegant way to fix it.
See https://sourceforge.net/p/flightgear/codetickets/2706/
- Remove the SGPath::validate() call added in commit
22779ee2c4 (first part of findPath():
when it is called with a non-null second argument).
- Remove the warning printed when the assembled path is absolute and
fails the SGPath::validate() read permission test (this caused too
much noise and confusion).
- Keep the behavior or accepting absolute, existing paths that pass the
SGPath::validate() read permission test.
This way, the 'play-audio-sample' FGCommand will continue to work with
absolute paths. If/when the built-in launcher is updated to set up the
read-allowed paths early enough, maybe we can revert FG commits
3ee54cbd72bd8f and 896be707ae558 and re-add the SGPath::validate()
call in the first part of findPath()---assuming it is deemed useful.
- Perform the SGPath::validate() test for read access before returning a
path obtained with a non-null second argument ("aContext").
- If SGPath(aContext, aResource) is an absolute path for which read
access is authorized by SGPath::validate(), return it. This restores
the possibility of using the 'play-audio-sample' FGCommand with an
absolute, read-allowed path (was lost in FG commit 8853fded2953959).
- Because a fair number of the existing uses of
ResourceManager::findPath() are not quite correct IMO, we execute the
final part where all providers are tried in turn even if
SGPath(aContext, aResource) is an absolute path (otherwise, the sim
wouldn't start because it couldn't load materials.xml---see [1]).
- The SG_LOG call will spot a few errors in calling code/data, such as
access tried for
'/Aircraft/Generic/flightrecorder/generic-piston-propeller-4.xml' and
'/Textures/Sky/cl_cumulus2.png'; since the function does not return at
this point, these incorrect absolute paths which should be relative
will still be given a chance with the BasePathProvider that has its
base path set to $FG_ROOT; thus, they will be found as before this
commit despite the new "access refused" warning (but please fix
them!).
This commit requires FlightGear commit e7594f46876fc6b0b.
[1] https://sourceforge.net/p/flightgear/mailman/message/37697516/
This will allow us to perform access control validation in SimGear. The
current implementation of SGPath::validate() is 99% Rebecca Palmer's
work (see fgValidatePath() in FlightGear commit
6a30e7086ea2f1a060dd77dab6e7e8a15b43e82d); only the coding style has
been slightly modernized here since we can now use, for instance,
C++11's range-based for loop.
This is to avoid confusion because the following commit will make
SGPath::validate(bool) replace the fgValidatePath() function from the
FlightGear repository.
- Add an explicit constructor SGSoundSample(const SGPath& file) that
directly uses the specified path instead of going through
ResourceManager::findPath().
- Reimplement the existing constructor as
SGSoundSample(const std::string& file, const SGPath& dir),
delegating to the new one.
- The first argument of the delegating constructor is now a
const std::string& instead of a const char*.
Among others, this will allow a better implementation of
FGSoundManager::playAudioSampleCommand(). More explanations can be found
here:
https://sourceforge.net/p/flightgear/mailman/message/37695786/
Build a high resolution texture containing coastline
data that will be mixed with the landclass texture
in the ws30 shader.
Replaces the previous approach of creating a separate
coastline mesh.
Until we have a way to mark techqniues as permanently disabled,
remove this check, since it generates false positives. Especially,
see model-combined technnique n=9.
Pass the full path to the XML file, not is containg directory, through
effects, so that it's available for error reporting. Convert to an
actual directory when using the path to lookup other resources.
simgear/screen/video-encoder-internal.hxx:
Fixed initialisation of AVRational instance to work on Windows.
simgear/screen/video-encoder.cxx:
av_log(): vasprintf() is not available on Windows so use fixed buffer on
Windows.
The assumption is that all images coming from Canvas should be excluded from inclusion into the DDS texture cache.
Previously there was special logic that only excluded transparent images of Canvas origin but this was probably wrong.
Due to an error I made in 7ac90850 all AxisObject-based translate animations were inverted.
I think this correctly fixes the animations so that a value of zero is the 'start' vertex of the axis and a value of 1.0 is the 'end' value of the axis.
Start and end are now defined on the lowest x,y,z that aren't equivalent (within 0.01mm)
see: https://sourceforge.net/p/flightgear/codetickets/2706/
refs: https://sourceforge.net/p/flightgear/codetickets/2674/
Because disabling threaded GC wouldn't result in exactly the same allocation and GC due to changes I made to the GC as part of the threaded GC work the only safe thing to do is to remove it all.
Once we have figured out if it is the threaded GC causing the problem or not then we will at least know what needs fixing.
We had a manual change in ShivaVG, to include the shConfig.h file
explicitly, since the sources do not include it themselves. Replicate
this change in our copy of ShaderVG.
Necessary to fix compilation on macOS and likely FreeBSD as well.
Consider non-empty containers and non-nil objects (eg, ghosts) to be
true-like, in boolify(). This makes for more natural testing of return
values.
Since these types previously caused a runtime error, should be backwards
compatible, unless code was relying on the error. This seems improbable,
if it happens in practice, we can revert and find a different solution.
getrandom() is only in GLibC >= 2.2.5, and CentOS 7 uses an older
GCC version, so add CMake logic to fallback to /dev/urandom as the
Expat entroy source.
Need a grid layout in addition to the existing vbox/hbox layouts,
add a basic one. Still work in progress, minimal test cases pass.
No height-for-width support yet, but row/column spanning and stretch
factors are supported.
Move some functionality from Layout.cxx into BoxLayout.cxx, which
is specific to the one-dimensions layout types.
Previously the vertices directly underneath an airport were
displaced downwards. In general this worked OK, but for airports
surrounded by higher terrain, this could cause "ridges" from
edges from vertices just outside the airport boundary.
This commit modifies the algorithm to also reduce the elevation
of vertices immediately outside the airport boundary as well.
All FlighGear specific patches applied to ShivaVG are also applied to
ShaderVG, if appropriate.
For testing only for now, it is not yet fully functional.
Required to address reported in-the-wild CVEs in older Expats.
This may need a tweak for Linux / BSDs to set appropriate values in
our custom expat_config.h : only macOS and Windows tested so far.
Previously 3D cloud re-position code did not re-orientate
the sprites, leading to the sprites being at an angle for
long flights.
Fix from Michael DANILOV to address this.
This gives knowledge of how to resolve relative paths, to makeEffects
invocation of findDataFile, and hence gives a more familiar lookup
ordering, for Aircraft-supplied effects.
SF-ID: https://sourceforge.net/p/flightgear/codetickets/2678/
Throwing an exception causes normal error-collecting to trigger for
the XML model load, so this is sufficient to avoid the crash and
also report back to the aircraft developer & user.
Thanks to Michael Danilov for catching this.
SF-ID: https://sourceforge.net/p/flightgear/codetickets/2702/
Previously a separate mesh was created for parts of the
terrain identified as being water.
This adds a property (/scenery/elevation-mesh/separate-water-mesh)
which controls whether this separate mesh is generated.
From Chris RINGEVAL
Squashed commit of the following:
commit ee2ec625ef10ab372a99397a82d1272670d767ec
Author: Chris Ringeval <eatdirt@protonmail.com>
Date: Mon Jan 31 00:01:39 2022 +0100
Replace galaxy texture by our own and update galactic coordinates
commit 26f3d80df6385913668635013912f1c4fef50e60
Author: Chris Ringeval <eatdirt@protonmail.com>
Date: Tue Dec 7 22:02:10 2021 +0100
Cleanup white lines and comments
commit 55e9f9b4bcbe21a34be7be874b120bda73c49cb8
Author: Chris Ringeval <eatdirt@protonmail.com>
Date: Sun Dec 5 15:53:15 2021 +0100
Cleanup cxx parts to the minimal required, moving all rendering to the shaders
commit 0cff2827bb3c18f85780cce5c0178ee37c590fe5
Author: Chris Ringeval <eatdirt@protonmail.com>
Date: Wed Dec 1 22:55:41 2021 +0100
Adding moon direction uniform vector used in the Milky Way shader
commit 24485079673c299bad95fc1f800542a6d73e8e95
Author: Chris Ringeval <eatdirt@protonmail.com>
Date: Wed Dec 1 22:54:54 2021 +0100
Adding Milky Way texturing and dark sky brightness effects
The random lights placement algorithm was using the incorrect channel
from the object mask image, (red instead of blue as mentioned in
Docs/README.materials). This commit rectifies the mismatch.
Random objects like lights and trees are not placed on airport terrain
anymore. This commit also refactors some of the existing code for clarity.
Discussion can be found here [1] and detailed history here [2].
[1] https://sourceforge.net/p/flightgear/simgear/merge-requests/102/
[2] https://sourceforge.net/u/fahimdalvi/simgear/ci/bugfix/ws30_random_objects_avoid_airports/~/tree/
Squashed commit of the following:
commit 643198f8d52da8d65a674b052c508f03d7f83ac0
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date: Tue Jan 4 09:57:34 2022 +0300
Implemented corrected airport intersection logic
We now convert the point into the correct coordinate system before
checking for intersections with the airport geometry.
commit 7e0819e4f88992658301a2c15d890fc489cfe3b6
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date: Wed Nov 10 19:59:04 2021 +0300
Added airport terrain check code for random objects
This commit does not work as expected. The light-coverage check is disabled
to amplify the bug.
commit eb21e8fd256dcf124857ac51afc0d7c3c90ae1c6
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date: Wed Nov 10 19:53:44 2021 +0300
Refactored elevation constraint checking code
This commit provides a separate elevation constraint function that does not
displace the given point. The current function has been renamed to indicate
the displacement side effect.
The Random objects check now happens in the scanline read in VPBTechnique,
rather in the VBPMaterialHandler objects. These checks are not specific
to any handler, and are thus better suited to be outside of specific
material handling logic.
The texture cache interacts badly with the code creating the WS30
texture atlas, resulting in a bad atlas. This change adds a new
SGReaderWriterOptions::LoadOriginHint::ORIGIN_MATERIAL_ATLAS
which causes the material cache not to cache the texture.
Add defaultValue arg to get*Value() methods that previously took no args. We
do this for getBoolValue(), getIntValue(), getLongValue(), getFloatValue() and
getDoubleValue(). The default value is returned if the node's string is not
convertible to the requested type.
This can enable some calling code to be optimised where it previously checked
for getStringValue() (which is slow now that it returns a std::string)
returning an empty string, before calling getDoubleValue().
This is by Lars Toenning <dev@ltoenning.de>, Roman Ludwicki <romek21@op.pl> and
SDeAstis <salvatore.deastis@gmail.com>, in 2021 Hackathon.
SGPropertyNode::getStringValue() now returns std::string by value instead of
const char* pointer into SGPropertyNode's internal data.
Patched up various call sites to use new API.
Remove SGPropertyNode::getName() and use SGPropertyNode::getNameString()
everywhere.
Uses ffmpeg libraries to provide video encoding of an osg::GraphicsContext
(which could be for Flightgear's main window) to file.
The video codec is specified as a string at runtime. Success depends on what is
supported by the system's ffmpeg installation.
Handling of resize doesn't always work. We finish current stream and create a
new encoder and continue. Works ok with mpeg2, but with more modern codecs vlc
usually fails to handle the change.
We call the encoder on a separate thread to avoid latency.
If SG_FFMPEG is not defined, we don't make calls to ffmpeg libraries and
VideoEncoder class's constructor always throws an exception.
- Prefix all WS30 Uniforms with "fg_"
- fix modelOffset (needs to be passed in as a float)
- Create a true atlas with indexes for relevant material textures
MCST E2K (Elbrus 2000) - this is VLIW/EPIC architecture, like Intel Itanium (IA-64) architecture.
e2k architecture has half native / half software support of most Intel/AMD SIMD
e.g. MMX/SSE/SSE2/SSE3/SSSE3/SSE4.1/SSE4.2/AES/AVX/AVX2 & 3DNow!/SSE4a/XOP/FMA4
Ref: https://en.wikipedia.org/wiki/Elbrus_2000
To simplify various rounding / truncation operations, especially when
dealing with frequency values, give floor() the same precision control
already present in math.round(), and add math.trunc() which always
truncates towards zero.
Earlier calculations assumed degrees instead of radians for the
granularity of random lights, resulting to the wrong density. This
is now fixed. The scanline for random lights is also more efficient
now, taking the lower limit of light-coverage into account.
Previously we were taking the nearest pixel from the nearest
mipmap. Which was braindead. Now just use the OSG defaults,
which are NEAREST_MIPMAP_LINEAR for MIN and LINEAR for MAX.
Thanks to Julian and Henning for helping diagnose this on
the weekly hangout.
Previously VPB tiles were loaded by the STG file handler.
Now they are loaded directly by the tile manager, allowing
better management of tile loading.
This will allow an object to be moved using a line (with 2d points).
Use the factor to switch direction (direction will depend on the order of definition of the end points of the vertex and) together with a (usually normalised property to define how much of the translation to apply).
<animation>
<type>translate</type>
<object-name>mm_radios-display</object-name>
<property>/sim/model/f-14/radio-position-norm</property>
<factor>-1</factor>
<axis>
<object-name>mm_radios-display-alt-position-axis</object-name>
</axis>
</animation>
On VR with visibility masking the depth buffer is first set to the
nearest possible value in parts of the frame that won't be visible
through the VR headset's lenses. This is meant to reduce GPU fragment
load.
The sky dome however is rendered with depth testing disabled which
bypasses the visibility masking. To allow invisible parts of the sky
dome to be culled, enable depth testing but set the depth mask to false
to prevent modification of the depth buffer.
Previously the STG Loader had a class member keeping track
of each WS30 tile that had been loaded, to ensure the terrain
was only loaded once.
However, this was a class member on a loader, and we have multiple
OSG loading threads. So the WS30 terrain was loaded ~6 times.
Change to a static, protected with a mutex so we only load the tile
once.
50% improvement in fps from the reduction in vertices, and an
improvement in loading.
simgear/scene/model/animation.*: added TransformExpression() - returns SGExpressiond
if given a SGRotAnimTransform or SGTranslateTransform.
simgear/scene/model/SGTranslateTransform.hxx:SGTranslateTransform: added copy
of SGExpressiond for use by TransformExpression().
Add LEFT_BIT and RIGHT_BIT node masks, which are only shown on the left
or right viewports. These will be used for eye specific visibility masks
with VR.
To allow for custom compositors and passes created by C++ code alongside
those created by Compositor::create(), add a resetOrderOffset() function
which resets _order_offset back to zero. This will allow FlightGear to
prevent repeated compositor reloads from increasing _order_offset
indefinitely, which soon results in render orders beyond those set
statically for the GUI and upcoming VR mirror compositors.
The Canvas camera and texture get recreated in several circumstances.
Calling .release() on a ref_ptr will just return the raw pointer and
'delete' won't be called. The proper way to explicitly delete an object
managed by a ref_ptr is to set the ref_ptr to NULL. This will delete it
as long as it's not referenced by any other ref_ptr.
If we have an uncallable object error, also show the type and value of the
uncallable object.
To make this work, have upgraded simgear/nasal/lib.c:dosprintf() to be globally
available. Could perhaps rename it and declare in a different header. But it's
C so we don't want to make it part of simgear's general utility functions.
These formats are not defined by OSG, so we manually define them. Some GPUs might not support them as we are using a GL compatibility context, but it shouldn't matter for now as they are only being used by the HDR pipeline.
Previously on my system, generating vegetation for a given tile
took 0.15-0.2s (for ~ 56k positions), of ~0.4s. While this is done in a
separate loading thread, the sheer number of tiles being loaded
caused noticeable delays and popping of higher LoD tiles.
As a tile at the highest LoD is typically 6x6km, and vegetation
is generated on a scanline of individual triangles, there is a _lot_
of temporal locality on the landclass of a series of points.
By caching the material information required from the landclass lookup
we can avoid a whole much of material lookups for each successive
vegetation point.
On my system this reduced the time to generate vegetation down to
0.02s per tile, and total tile generation time down to ~0.2s.
Added support for seeking (forwards only) - in ZlibAbstractIStreambuf, added
seekoff().
Also disabled assert that checked that we reach EOF compressed data at same
time as EOF uncompressed data; was breaking things when using embedded
compressed streams within fgtape recording.
Added ZLibCompressionFormat::ZLIB_RAW, uses windowBits=-15, for zlib compressed
streams without header or trailer.
Fixed clang build error with std::min().
- Add an Effect to stars and planets so they don't disappear when not using the fixed-pipeline.
- Allow usage of the shadow mapping related uniforms in 'quad' passes as well.
- Add extra buffer formats (some of them only work under the core profile).
- Better handling of mipmapping in the Compositor.
Attempt to narrow down the source of some fatal exceptions we see
on Senty, which occur during init/startup. All these blocks re-throw
so user behaviour is unchanged, but we’ll log the name of the subsytem.
Previously, by observation comparing actual vegetation density
on Medium, WS30 had many more trees than WS20.
This adjusts the base vegetation density down to match WS20.
Note that at High and Very High densities, there is still a disparity
that needs to be addressed.
Previously, reading LINE_FEATURE_LIST/AREA_FEATURE_LIST/COASTLINE_LIST
files were not read with the .stg file, but deferred into the
DelayLoadReadFileCallback. When the the Callback was executed, the
files were read and appropriate terrain tiles dirtied for regeneration.
However, re-generating dirtied tiles caused significant frame pauses
and was disabled in commit
deb802f74a
This meant that the Line/Area/Coastline features would only be rendered
when the next LoD tile was generated. Which created a race condition
on startup for the tile the user starts on, between the
DelayLoadReadFileCallback and the tile itself.
This commit reads these files at the same time as the initial terrain
so that the VPB has all the data required when the tile is initially
rendered. The downside is that line data is read for every tile,
even if it is far away. As the line data is stored as a series of
lat/lon floats, this is assumed to be OK.
An alternative would be to re-instate the Visitor, and instead
of dirtying existing terrain, generate the roads, and flag them to
the UpdateVisitor to add to the terrain node.
We now default to not calling parent nodes' listeners when a node's value
changes.
This avoid overheads introduced by recent addition of locking - walking up the
parent nodes needs to lock/unlock at each step, and was previously happening
whenever any node in the entire tree had its value changed, causing noticable
slowdown.
Node creation/removal still calls parent nodes' listeners as before.
If a node has new attribute VALUE_CHANGED_UP set, we do call its parent node's
listeners.
New SGPropertyNode::Attribute's VALUE_CHANGED_UP and VALUE_CHANGED_DOWN:
VALUE_CHANGED_UP: if set, when fireValueChanged() is called we also call
our parent node's fireValueChanged().
VALUE_CHANGED_DOWN: if set, new and existing child nodes have their
VALUE_CHANGED_UP and VALUE_CHANGED_DOWN attributes set.
Once set, these attributes cannot be cleared (because to correctly handle
this would require reference counting).
SGPropertyLockControl(): added parent_listeners arg. If true, we always call
parent node's fireValueChanged() when a node value changes; this restores
previous property system behaviour. Default is false.
Extra overall timing diagnostics.
Don't set node->_parent to null before calling
SGPropertyNodeImpl::fireChildRemoved().
This fixes problem with Jaguar-GR1 HUD.
[Should probably set node->_parent to null before returning, but previous
(non-locked) code didn't do this, and it would require acquiring mutex.
Previously blank lines in the various .txt LIST files
created spurious error logging. This commit does some
simple length checking and ignore blank lines rather than
complaining (and then ignoring).
Added runtime control of property locking active, and lock contention
diagnostics; new SGPropertyLockControl() allows associated property nodes to be
registered.
Added code to measure time spent locking/unlocking; disabled via preprocesor by
default because gives small decrease in fps even when disabled at runtime.
If SG_PROPS_UNTHREADSAFE is defined we defer to the old property code at build
time (requires old files to be available as props-unsafe.{hxx,cxx}). This
facility will hopefully be be removed at some point, but for now makes it
easier to compare before/after speed.
Added a std::shared_mutex to SGPropertyNode and changed all props code to use
shared or exclusive locks as necessary whenever reading/writing data.
SG_PROPERTY_LOCKING=0 or 1 can be used to control whether locking is
active. Default is 1.
SG_PROPERTY_LOCKING_VERBOSE=0 or 1 can be used to cause diagnostics to be
generated if we get lock contention. Default is 0.
Removed most of the inline implementation code in props.hxx - now that we use
locking, nearly all calls eventually end up in props.cxx in order to take out
a lock so there's no point inlining. For template code this also means that we
now explicitly instantiate / specialise in props.cxx.
Reformateed props.hxx to use consistent indentation. Also condensed identical
comments for related methods such as getBoolValue(), getIntValue() etc, which
results in more readable visual grouping.
Much of the internal implementation code for SGPropertyNode is now in the form
of static methods in a new SGPropertyNodeImpl class in props.cxx. This class is
marked as a friend of SGPropertyNode in props.hxx so these methods can access
all SGPropertyNode internal data without being declared in props.hxx. So one
can change implementation code without recompiling everything.
Removed TEST_READ and TEST_WRITE macros.
Removed SGPropertyNode::MAX_STRING_LEN - was only used in compare_strings() and
it is unnecessary.
It looks like assigning an Effect to the geode containing the osgText is
enough and there aren't any conflicts with OSG own shaders. This might
change in the future if the switch to the core profile happens.
The text shaders also rely on fixed pipeline features like
gl_FrontColor. This is because aircraft developers are used to using
material animations to change the text color.
Previously landclass textures were compressed by
out internal optimizer. This caused bad artifacts
on landclass boundaries, e.g. where landclass 1 met
landclass 10 there would be compression/interpolation
artifact with a value of (say) 5.
This disables compression for such landclass textures.
Use an exception rather than polling a flag, for checking errors
during BTG reading. This should allow us to give a correctly
identified error, at exactly the point the read fails.
When an effect defines no shader sources, special case this error to
avoid confusing result from SGProgram.
Add error-context for readNode STG loading, so failures inside an
STG can be attributed
The use of SGShared for IReceiver derived conflicted with other uses of SGShared / SGReferenced - and after consideration transmitters should probably remain static for the lifetime of the application.
Any dynamic transmitters will need careful consideration if working in a threaded environment to ensure that a transmitter doesn't go out of scope before any notifications that it has issued have finished being processed by other threads.
After testing with multithreading there were still problems related to
scope and transmitters - because a transmitter that was on the stack
as an object could go out of scope before a notify all had finished
and lead to invalid data and a crash
The solution is to always have Recipients allocated via new() and to
use a shared pointer to manage the scope and garbage collect when the
last reference goes out of scope.
To achieve the threadsafe minimal locking the rules are as follows;
* All recipients must be allocated via new()
* Register and DeRegister will only happen when on the outermost
level of NotifyAll.
- all other add or delete will be put into the pending queue and
added at the start of the next outer notify all
- at outer level notify all a lock will be taken to process pending
items
* during the main notify processing there will be no locks - however
it is also assumed that the recipient list will not be changed
- Add and AREA_FEATURE_LIST STG verb.
- /sim/rendering/static-lod/area-features-lod-level to control point at
which such feature are rendered
- /sim/rendering/static-lod/lod-leve[n]/area-features-min-width sets
the minimum width for feature rendering at that LoD level.
STG Format:
AREA_FEATURE_LIST <file> <material>
File format:
Area Attrib A B C D lon0 lat0 lon1 lat1 lon2 lat2 lon3 lat4....
where:
Area is the area of the feature in m^2
Attrib is an integer attribute (currently unused)
A, B, C, D are generic float attributes. Their interpretation may vary by feature type
lon[n], lat[n] are pairs of lon/lat defining straight road segments
- Generate vegetation based on underlying landclass material mapping
- Reduce frame pauses by removing terrain init from update visitor
- Fix a couple of small timing windows causing crashes.
- Rip out various pieces of irrelevant code, simplifying VPBTechnique.
Largely dealing with multiple textures per terrain tile, which we
don't need.
- Use a lookup of the landclass of mesh vertices to identify sections of
the mesh that are entirely in water, and split those out into a
separate water mesh, using it's own Effect.
Report errors from readWAV, and improve attribution for the
format error (include the file path). As a result, mark the individual
exceptions as dont-report, since we will report higher up.
Fixes an error case where a manual TerraSync server is specified; we
would attempt to use an empty string as the OSM2City server, with
hilarious consequences.
Sentry-Id: FLIGHTGEAR-NCZ
- Fix a bug causing roads to be displaced from their
true position (caused by incorrect assumption in ElevationSlicer).
- Add control of the minimum width of roads that are rendered at
each LoD level. Control properties under /sim/rendering/static-lod
- Improve marking tiles for re-rendering.
Ensure the STG absolute path can be propagated to all files triggered
by STG loading, including the delayed files and proxied files. This
allows us to attribute errors to the correct scenery path.
Allow us to pass the current error-context from the main thread
into the osgDB loader thread. This is necessary so we can attribute
AIModel (etc) load problems to the correct source.
Adds a LINE_FEATURES STG Verb of the form
LINE_FEATURES <file.txt> <Material>
Where <file.txt> is a text file consisting of line features to be
rendered with the appropriate <Material> definition.
Each line of <file.txt> has the form
<w> <attr> <a> <b> <c> <d> <lon1> <lat1> <lon2> <lat2> ...
Where
<w> is the line feature width in m
<attr> is an integer for attributes - likely a bitmask*
<a> <b> <c> <d> are floats*
<lonN> <latN> are the lon/lat of point N on the line feature
* denotes values that may be feature-dependent. For example to indicate
street lighting, kerbing etc.
There must be at least two points on the line feature.
Move sg_location member up to the base clase, since it’s potentially
useful in more types.
Allow suppression of the report callback when the exception is thrown
Previous code sometimes gave a SEGV in _callback's destructor when
setCallback() was called; this is on Linux with g++-8.3.0. Have tried various
alternative ways to initialise _callback but the problem persistend.
So have switched to an old-style function-pointer plus void* approach.
simgear/io/HTTPClient.cxx
Support range in HTTPRequest's. Set CURLOPT_MAX_RECV_SPEED_LARGE if request's
getMaxBytesPerSec() is non-zero.
simgear/io/HTTPFileRequest.cxx
simgear/io/HTTPFileRequest.hxx
Added 'bool append' to constructor args; if specified we assume that, if
the output file already exists, it is from an interrupted download, and we
use an http Range header to append any remaining data.
Support a std::function callback when new data is available.
Added setMaxBytesPerSec() to limit download bandwidth; useful for testing.
simgear/io/HTTPRequest.cxx
simgear/io/HTTPRequest.hxx
Added support for setting Range header.
In both simgear/io/HTTPClient.cxx and simgear/io/HTTPRequest.cxx, if
a range is specified, we treat http results 206 'Partial Content' and
416 'Range Not Satisfiable' as success.
Generate random vegetation of VPB tiles. Currently
prototype that generates same vegetation for all landclass types.
Needs additional work to
a) make the scenegraph more efficient
b) support different material definitions of vegetation.
Fix the cull callback to continue with normal culling. Also move
where the particle frame is added to the scene graph, to be sure
we don’t modify the scene during OSG traversals.
Ensure all data members are correctly re-initialzied when doing a reset.
This shoed up as negative ‘bytes downloaded’ counts after a TerraSync
abandon and retry.
Extend our own particle manager to replace the OSG particle system
updater. This fixes thread-safety and also timing (better match to
simulation dt values). We also use weak pointers (observer_ptr in
OSG terminology) to ensure particle systems are released once their
frame is gone.
Increased some diagnostics to SG_ALERT if terrasync checksums fail.
Show failed URLs; show SyncItem::Type enum names; show SyncItem::Status enum
names.
Configure the VPB elevation mesh via properties:
/scenery/elevation-mesh/sample-ratio controls the elevation
mesh sampling, allowing reduction in mesh size
/scenery/elevation-mesh/vertical-scale is just for fun and
scales the mesh vertically making mountains taller.
/scenery/elevation-mesh/constraint-gap-m controls how much below
airports etc. elevation vertices are forced to be.
Previously if the elevation of the terrain vertices was higher
than the airport, the terrain pushed through the airport, looking
ugly.
This adds the concept of elevation constraint models, which the
VPBTechnique applies when generating terrain vertices.
Simply add a scenery model to the contraints on the technique,
and terrain won't poke through it.
The 'spin' animation has a strange behaviour:
it pushes a temporary rotation matrix on the transformation stack during
cull traversal, and removes it thereafter.
Thus, the rotation matrix is missing outside of cull traversal, e.g.
when the position of Compositor lights is computed.
The same issue was fixed for the 'rotate' animation by commit
e202d4e4a5
(this mentions broken 'picking' animations as a different manifestation
of the same issue).
Fix this by setting the angle of the persistent SGRotateTransform,
instead of creating a temporary rotation matrix.
Avoid hard-coding the archive extension, and ensure the extracted
archive directory is not orphaned on update. Finally, use the
literal filename in the .dirindex when computing the hash, rather
than adding a .tgz extension.
Traversing a container which is modified causes crashes, take a copy
during traversal for firePackageStatus.
Sentry-Id: FLIGHTGEAR-CJF
Sentry-Id: FLIGHTGEAR-CJ5
Previously attempting to start on an ocean tile with static
models present cause FG to spin on "Loading Scenery".
This was caused by not creating a BVH for an ocean tile in
the specific case where there was STG models, due to a PagedLOD
node being inserted in the scene graph. So
FG never thought the scenery was loaded sufficient to place
the aircraft.
By explicitly creating a BVH for ocean tiles the problem is
fixed.
Candidate for 2020.X
Metar sky condition without base layer height (e.g. FEW///) is the cause of this issue.
Randomize the base layer height when the actual height is unknown.
This time it tries to be as compatible as possible with older hardware setups.
The only feature that might not be supported by some really old hardware
(or picky drivers) is floating point textures. There is no way around that
though, so this is as compatible as we can be with GL 2.1 level hardware.
- Create a Texture2DArray for a MaterialCache
- Adjust the landclass image to index into the above array
- Add the array to as a Uniform for rendering.
Change logic so we create an empty file for such cases, i.e exactly
matching the repository. This simplifies logic in downstream code,
compared with not creating a local file.
Add a test-case to cover this
Modify TerraSync to detect a failure of Airports_archive downloading,
and fall back to file-by-file updating.
This is to permit an <overlay> section in <model> to be present whilst the rest of the model is loaded - otherwise the overlay is only present after the model is loaded;
e.g. to allow a model specific registration to be applied to a shared model;
<model>
<overlay>
<texture-file>island_68.png</texture-file>
<carrier-name>Nimitz</carrier-name>
<carrier-registration>CVN-68</carrier-registration>
</overlay>
<path>nimitz-class.xml</path>
</model>
Add a TREE_LIST STG analogous to the existing BUILDING_LIST verb
TREE_LIST <filename> <material name> <lon> <lat> <elev>
where <filename> is a file containing a set of trees to generate
using the defined <material name> at the given location.
The referenced <filename> contains lines of the form
X Y Z A B C
Where:
- X,Y,Z are the cartesian coordinates of the tree. +X is East, +Y is North
- A,B,C is optional and represents the normal of the underlying terrain. Used for shadows. Defaults to (0,0,1)
Previously the PagedLoD range for OBJECT_STATIC etc. was purely
measured from the object reference point. For large meshes from
osm2city this was problematic, particular at DETAILED LOD ranges,
where the range of (say) 1500m would result in the mesh being
rendered at 500m distance from the edge. We fudged this by adding
1400m to the DETAILED LOD range.
Now, such meshes can specify their radius in the STG file, ensuring
they are loaded at the correct distance.
- scoped locks using lock_guard are better
- because of this the exception handler can also be removed;
although this was originally intended to manage the locks
it never did work properly with C++ exceptions.
- Remove prepending shader filenames with Compositor/.
- Always check for fallback effects in Effects/schemes.xml.
- Shadow mapping can now be disabled at night.
- New clustered shading implementation for older systems (GLSL 120 compatible).
- Miscellaneous bug fixes.
Create Uniforms for the tile_level, tile_width and tile_height.
These can be used by the fragment shader to determine the level
of detail to render and also to perform samples for borders of
landclasses.
Fixes crashes where a request times-out, but then is completed by
UDN sometime afterwards, with a free-d object. Have the DNS::Client own
requests, and be able to retrieve the udns_query to cancel them, in
the timeout case.
Fixes a couple of Sentry reports.
As of 2020-08-01, OpenBSD's system zlib is 1.2.3 which doesn't
have gzoffset(). However we can get away with this by making
gzfilebuf::approxOffset() always return zero.
Avoid a central hash cache becoming enormous, now we use the selective
download scheme for the tile dirs.
Hash name is changed to co-exist with older versions.
Use the top-level dirIndex files to determine if a 1x1 tile dir
exists, instead of proving the server via a 404. This reduces the
number of requests we make considerably, which is … important.
Add a process() method to HTTPRepository, and use this to
incrementally validate subdirs after the .dirIndex is received. This
avoids large pauses of the TerraSync thread, when all of Airports/
is validated at once.
When doing a catalog migration to a new ID (eg, 2018 -> 2020), also
mark the installed packages for installation, on the new catalog.
Related to this, when manually removing a catalog, record this fact,
so we don’t re-add it automatically due to migration.
Add unit-tests covering both of these cases.
Trying to fix a reported crash, in this code. malloc() returning null
seems unlikely but worth checking for. ALso use a unique_ptr with
a custom deleter to avoid a leak if we throw.
Sentry-Id: FLIGHTGEAR-3Y
If TerraSync/Airports is missing, download Airport_archive.tgz instead.
In all other cases update as normal. This has the effect, that fresh
installs make many fewer requests to TerraSync servers.
Re-add (with some tweaks) the persistent tile-cache code, so that
TerraSync checks the server at most once per 24 hour period, for a
given repository path.
(Disbale the cache by setting /sim/terrasync/enable-persistent-cache=0)
Avoids need to specify the 3rd-party dir, in the standard/fgmeta
layout of source directories, and accept more combinations of path,
when the user specifies a value.
Previous additional checks for a value BUILDING_LIST entry
used an enum incorrectly, resulting in all BUILDING_LIST entries
failing. Now fixed to check bad() / fail() which are bool.
New log-level to avoid using ‘ALERT’ for expected mandatory messages,
since I want to do error collection on real alerts in a future commit.
As part of this, split logstream.hxx into separate header files, and
add a new virtual hook to LogCallback which takes the complete log-entry
Ensure that if we copy file-names of log entries while startup
logging is active, we free them, but only once startup logging is
disabled, or on shutdown. This is needed to avoid crashes when
we use file-name copying for the Qt message handler.
Caching it complicates add/remove command logic, so making a simple
fix for now, which can be back-ported to 2020.2; ideally we would
cache the pointer but have an invalidation scheme, but that’s
considerably more work and risk.
Relates to Sentry crash:
https://sentry.io/organizations/flightgear/issues/1858764364
Since we probe for AeonWave first, we set AAX_LIBRARY to NOT_FOUND,
which then upsets CMake if we try to use it. So add some temporary
ugly logic, until I have time to define a proper ALIAS target for the
audio backend.
2,028 (1,976 direct, 52 indirect) bytes in 13 blocks are definitely lost
1,963 bytes in 47 blocks are indirectly lost
1,544 bytes in 193 blocks are indirectly lost
662 bytes in 32 blocks are indirectly lost
152 bytes in 1 blocks are definitely lost
32 bytes in 1 blocks are indirectly lost
8 bytes in 1 blocks are indirectly lost
3,572 (136 direct, 3,436 indirect) bytes in 1 blocks are definitely lost
3,572 (8 direct, 3,564 indirect) bytes in 1 blocks are definitely lost
2,712 bytes in 3 blocks are indirectly lost
384 bytes in 3 blocks are indirectly lost
168 bytes in 3 blocks are indirectly lost
Spotted by valgrind, w00t. If you used a numerical formatter, such
as f,d or g, with. a nil value, we would read uninitialised data, and
generally get confused.
We had some confusion between two error codes, meaning we would log an
error (and treat as a failure) a pure ocean 1x1 area, even though this
was entirely correct and expected behaviour.
Terrasync.cxx expected REPO_ERROR_NOT_FOUND, we need to convert the
file-level error to that, and avoid logging a warning.
Fix various cases where re-init could get things blocked. Remove the
duplicate storage of the active paths; now we always check the primary
data, and hence it can’t be out of sync.
Also remove the obsolete persistent cache code.
Fixes some of the issues discussed in:
https://sourceforge.net/p/flightgear/codetickets/2308/
Further improvements still to come, especially to retry on a better
schedule for intermittent connections.
The previous catch policy breaks unit-testing, since CppUnit relies
on a special Exception type.
This could be made conditional based on testing or not, but trying the
simple way initially.
It seems that clang++ headers #include <version>, which found simgear/version
because we need to put singear/ in include path for some code to compile.
This allows one to see what properties are being used to control moving objects
such as needles and dials in the cockpit, or external moving objects such as
bomb doors.
The system works by optionally creating new animations with type=pick for all
animated objects. A side affect of this is that yellow highlighting of controls
from Ctrl-C will also highlight instrument needles in the cockpit and external
animations such as flaps, rudder, gear etc.
src/Model/acmodel.cxx:simgear::SGModelLib::loadModel() takes new param bool
autoTooltipsMaster and int autoTooltipsMasterMax, which is added into the
SGReaderWriterOptions that is passed to loadFile(). autoTooltipsMasterMax
limits the maximum number of tooltips, which appears to be necessary on 777 -
more than 45 can cause fg to fail to make progress.
The auto-generated tooltips show the name of the object and also the names and
values of the properties that control the animation. For example the tooltip
for a fuel gauge might say 'consumables/fuel/tank[1]/level-gal_imp=0.23456789'.
simgear/props/props_test.cxx: test for self-unregister.
SGPropertyNode::removeChangeListener() used to modify the _listeners vector or
even delete it and set _listeners to NULL, if a listener was removed.
This could cause a SEGV if removeChangeListener() was called from
a listener, because listeners are called from methods such as
SGPropertyNode::fireValueChanged() which iterate through _listeners and don't
expect it to be changed to NULL.
The fix here is to keep a track of whether we are iterating through the
_listeners vector; if we are, SGPropertyNode::removeChangeListener() sets the
entry to NULL, instead of removing it.
We have a new internal function forEachListener() which takes
care of the iterating details - incrementing/decrementing the new
_listeners->_num_iterators count and skipping NULL entries. Before returning,
if _num_iterators is now zero it removes any NULL entries in the vector of
listeners.
The nListeners() member is no longer inline, because it needs to ignore NULL
entries in the vector. And _listeners now points to an internally-defined
struct which contains a new _num_iterators as well as the vector of listeners.
Added self-unregister test to simgear/props/props_test.cxx.
It is possible to have a property tree with
/sim/rendering/scenery-path-suffix[n]/enabled=true
/sim/rendering/scenery-path-suffix[n]/name=<blank>
Previously this would be downloaded as scenery//[tile]
Now we just ignore such invalid paths.
Previously we required 6 shader attributes to pass
in all the required information for the building shader.
By using packing techniques this has been reduced to 4.
This should improve support for integrated graphics cards.
making the build between Simgear and Flightgear consistent.
- Fix an issue with lib/lib64 path between CentOS/RedHat distributions
and Debian derived distributions.
Some AMD drivers do not like triangles for point sprites, which
breaks directional lights. This works around this by allowing
users to set /rendering/triangle-directional-lights=false which
falls back to the non-directional implementation of a point.
logstream::LogStreamPrivate::log() sets line=-1 to turn off both filename and
line numbers in log output, if m_fileLine is false.
StderrLogCallback::operator() already omits both file and line if line == -1;
this commit does the same thing for FileLogCallback::operator().
E.g. this fixes output e.g. to ~/.fgfs/fgfs.log.
The deadlock is possibly caused by the thread not being joined, or because of an implementation difference with phtreads.
So this fix adds a call to release the background thread when terminating it and then also joins the thread to await for the completion of the background thread.
As before this works fine under Win32 (x64)
Previously the front and side faces of random/OSM buildings
had identical texture coordinates. This resulted in the sides
of buildings texture mapping being squeezed or stretched.
This change generates a separate texture mapping for the sides
of the buildings.
Plantations are regularly spaced vegetation. This effect is switched
on by the is_plantation material property. Vegetation is laid out
at integer spacings in x and y, with the spacing determined by the
usual coverage properties.
remove special characters from output. We used to include 0xb0 characters -
small 'o' degree symbol, but this isn't reliable and looks bad in flightgear's
weather window.
Consistently use space between number and its unit.
remove 'METAR Report' header.
Fix a bug in the roof transformation that meant the
roof ridges were not sized correctly. Also change
the texture "unit" width for small buildings from 6m
to 5m following discussions with Rick Gruber-Riemer.
Now we no longer list OpenAL a s apublic dependency of SimGear, we
need to explicitly link the tests against OpenAL, since they use it
directly, in all cases.
Previously the width was set as the x-axis and
depth for the y-axis when passed through to the
shader. This was incorrect, as the x-axis is actually
the depth of the building.
Previously there was very limited texture variations
as a given texture index was used for both the wall
and ceiling. Now these can be specified separately,
allowing for more variation in both STG defined and
random buildings.
Replace existing random buildings implementation with one using
proper instancing. This allows better control of the buildings
themselves and allows BUILDING_LIST STG verb to specify
individual building dimensions. See README.scenery for details.
The updateInterval argument is used a lot less than the dependency list, so
these have been swapped. That simplifies the registration code in the subsystem
implementations as the updateInterval default of 0.0 no longer need to be
supplied.
This is a partial reversion of c1dd8faa29 and a
complete reversion of caea68007e and
846f024e91. These changes are incompatible with
the subsystem class IDs.
This is a clean up commit prior to the subsystem API standardisation to simplify
the diffs. It includes all SGSubsystem and SGSubsystemGroup derived classes.
This uses an SGThreadExclusive controlled by Emesary notifications that are received from the main loop.
When active at the end of a frame the garbage collection thread will be released; if it is already running this will do nothing. Optionally at the start of the mainloop we can wait for the previous GC to finish.
The actions of the background GC is controlled by notifications - again received from the main loop which in turn uses properties.
I initially thought that the wait at the start of the frame would be necessary; however in 100 or so hours of flight without the await for completion at the start of frame no threading problems (or any other problems) were shown; so nasal-gc-threaded-wait is defaulted to false which gives a slight boost in performance.
So what this does is to it removes the GC pause of 10-20ms every 4 seconds (test using the F-15). This change doesn't really give much extra performance per frame because normally GC is only performed when needed.
An exclusive thread is one that is suited to being used where the thread needs to be activated at a certain point, and also that the code activating the thread may also need to wait for thread completion.
Example of this is the new background garbage collection for Nasal. The thread will be activated at the end of the frame processing and at the start of the next frame the thread can be awaited - thus allowing the thread to work in parallel with the rendering.
rework to measure the required length (vsnsprintf does this with a size of zero and a nullptr as the first parameters) - and then just alloc the required space. Should be more efficient than the looping version.
- Added light definitions to the model XML files. This is not compatible with Rembrandt.
- Added depth slicing.
- Added threading support. For now it's faster to run everything on the main thread since there aren't many lights.
derived from: https://github.com/Zaretto/Emesary/tree/master/src/Emesary/EmesaryC++
This is a similar implementation to that in Nasal; currently this is only for use in C++ modules as there is no Nasal interface - however this is something that may be added later.
The basic premise of the Emesary messaging system is to allow the decoupled operation of the various components that comprise any system - usually within the same process.
The basic unit of communication is a Notification, which is passed around to any and or all objects that implement the IReceive interface (pure virtual class). Using Interfaces and ihneritance
it is possible to pass around Notifications that have special meanings to certain objects and allow them to perform the appropriate function.
Notifications are created and sent via a call to NotifyAll. Any object within the system can inherit from IReceive and register itself with a Transmitter to receive all notifications that are sent out.
The underlying concept is that one part of a system knows that something needs to be done without needing to know how to do it. The part of the system that needs something done simply creates a notification and sends it out. Once received by the part of the system that is capable of performing the requested Notification the relevant actions will be carried out and a status of OK or Finished returned.
The return code from the Receive method must follow the guidlines as follows:
If a notification is not recognised in the recipient must return ReceiptStatusNotProcessed. Normally a recipient will return ReceiptStatusOK, sometimes ReceiptStatusFail to indicate that the recipient could not properly process the notification.
The overall result of a call to NotifyAll is a composite of the results of each individual recipient's return value; and generally OK or Fail. It is acceptable to use the return code to ascertain success or failure and take appropriate action.
It is generally recommended that more detail specific to the particular purpose be included within the Notification to allow more control.
Notifications can be modified during processing to permit a multistage process; however this needs to be designed correctly.
* ReceiptStatusOK : Notification processed fine by Receive, transmitter continues with next recipient
* ReceiptStatusFail : Notification processed but failed, transmitter continues with next recipient
* ReceiptStatusAbort : Notification processed and the receive method declares a fatal error; the transmitter will stop notifying recipients
* ReceiptStatusFinished : Notification processed and the recipient declares that the processing is completed, the transmitter will stop notifying recipients
* ReceiptStatusNotProcessed : receive method does not recognise the notification
These status are for later implmentation.
* ReceiptStatusPending : (future ues); notification been sent but the return status cannot be determined as it has been queued for later processing, transmitter continues with next recipient
* ReceiptStatusPendingFinished : Message has been definitively handled but the return value cannot be determined. the transmitter will stop notifying recipients
- change to always use the SG create mipmap function as it works better (no purple clouds)
- when enabled always generate a mipmap even if the file couldn't be compressed
- adjust level of log messages
- move lru_cache into its own header file.
The following changes fixes a case for me where I hear the sound change levels up and down for each pause un-pause cycle.
Patch provided by daniel.c.wickstrom@gmail.com.
Effect schemes are a way of rendering an object in different ways depending on the Compositor pipeline. A new <scheme> tag in the Compositor pipeline definition allows the user to choose which Effect scheme is going to be used for that pass. Every Effect will then be rendered using the technique that has a matching scheme name. If no valid technique is found, it won't be rendered. Since it would be a pain to define a valid technique for every scheme and for every Effect, the file '$FG_ROOT/Effects/schemes.xml' is introduced:
<scheme>
<name>test</name>
<fallback>Effects/test</fallback>
</scheme>
If an Effect doesn't have a valid technique for the 'test' scheme, the 'Effects/test.eff' Effect will be merged with it. This process is done at initialization when techniques are being realized.
Previously, these two files were only added when SG was built with
-DUSE_AEONWAVE:BOOL=OFF, because the SG code in use when USE_AEONWAVE is
set to ON doesn't need readwav.hxx nor readwav.cxx. However, readwav.hxx
and readwav.cxx are not only used in SG, but also in FG (at least by
flightgear/src/Sound/VoiceSynthesizer.cxx), and this was causing a build
failure when SG's USE_AEONWAVE and FG's ENABLE_FLITE flags were both set
to ON:
https://forum.flightgear.org/viewtopic.php?f=45&t=35672#p346633
and
https://sourceforge.net/p/flightgear/mailman/message/36645567/
This commit should fix this build failure.
- remove the old svn properties; a scan of FGAddon and FGdata showed these are not in use except for the dialog
- new property "active" - which is true when the worker thread is running.
- changes to enabled now take effect immediately; whereas before a reinit had to be issued. This could lead to confusing GUI state as the enabled property would be true but without closing the dialog (e.g. cancelling it) terrasync could be in a different state.
- use property nodes (performance optimisation)
Extend the command API to allow posting commands from arbitrary threads,
for deferred execution on the main thread. Additional pieces on the FG
side to follow shortly.
changed to use const char* rather than const std::string & as this doesn't work on GCC; and besides std::string converts nicely to const char* and most of the times this is used it is actually a string literal.
Set the filename back to what it was after loading - seems sensible and as yet no side effects.
Also the previous commit that included the handling of sgio_exceptions also broke the DDS-TC pretty much completely.
State machines will now throw exceptions if errors are encountered
when loading the XML file.
This includes:
- Unknown <source> or <target> states referenced by transitions
- States and transitions without <name> elements
- Transitions without <target> or <condition> elements
- State machines with fewer than two states
Previously the state machine would load and then crash when hitting
such malformed states or transitions. Now it will refuse to load,
while providing useful error messages as to the problem.
This is to help diagnose where performance is being used and augments the current performance monitor.
The easiest way to active this is to open the performance monitor; however setting the enable property will enable less intrusive logging and overrun detection.
Using the GUI performance monitor itself affects the performance when it updates.
Properties
/sim/performance-monitor/enabled - need to be true to be active (unchanged)
/sim/performance-monitor/dump-stats - hierarchical dump to console of all current timing stats for all subsysems
/sim/performance-monitor/interval-s - reporting interval (unchanged)
/sim/performance-monitor/max-time-per-frame-ms - any subsystem that takes more than this amount of will be logged to the console
This will use the inherently unsafe versions of the load methods which can result in deleting an object (from the cache) that has just been loaded in the database thread.
Symptom OSG WARN deleting still referenced object.
- use a file contents hash instead of filepath.
- add a local lru cache for filepath->hash (for performance improvements)
- calculate and resize to nearest power of two
- handle normal maps and images from effects differently.
- when cache is active any image that can't be converted to a dds will have a mipmap generated (which still helps the loading process); although this may be responsible for introducing purple into transparent images..
This should have been in the previous commit - However I managed to mess up the merging of this module due to other changes related to the DDS texture cache.
Possibly this could be fixed better by using the plugin string data - but there is nothing that currently set this; and it seems easier to use the particle callback enabled flag.
Remove would_log() : callbacks receive all log messages so they can
do custom filtering individually.
Also move popup message handling into the private (d-ptr) of sglog(),
to keep the header as minimal impossible (no include of <vector>)
1. Anything that comes in from OSG will always be logged; it seems
somewhat redundant to have to set the FG log level to be identical to
the OSG log level to see these messages.
2. Console output will now have delta time (since start), priority and class.
3. Log file output wil also have delta time (since start), priority and class.
Times are displayed as delta decimal seconds since the logger was created
e.g.
1294.06 [INFO]:terrain Some log message
This is a performance improvement that reduces the amount of frame pauses which are related to mipmap creation when the geometry (osg::Texture) is added to the scene graph within osg::Texture::applyTexImage2D_load
The texture cache is configured from FG as follows
- /sim/rendering/texture-cache/cache-enabled
- /sim/rendering/texture-cache/compress-transparent
- /sim/rendering/texture-cache/compress-solid
- /sim/rendering/texture-cache/compress
These properties are set via the SGSceneFeatures singleton.
When the texture cache is enabled it will auto convert files from any supported osg::Image format that can be read and store the resulting (compressed or raw) file in the texture cache.
The texture cache uses osg_nvtt to perform texture compression (and mipmap generation) if available. When not available simgear::effect::computeMipmap is used to make mimaps but compression isn't available.
The texture cache filename ends with .TIME.cache.dds where TIME is the hex modtime of the original file. As yet there isn't a clean way to maintain the texture cache to ensure that stale files are removed; and in fact this is quite difficult to do because of the dynamic nature of the cache.
The texture cache will be stored in download_dir/texture-cache unless --texture-cache is passed on the command line.
The UI has a single checkbox to turn the texture cache on or off.
This was something that happened when random vegetation was off, but tree shadows was on.
Adding random vegetation would then reliably cause an exception.
Under Basic Weather, the cloudfield is finite size and clouds
are shifted as the viewpoint changes. Previously each cloud
was checked every frame to determine if it should be shifted.
Not this only occurs if the viewpoint has moved a non-trivial
distance.
Note that this is separate from the clouds moving due to the wind.
This is fixing an issue identified in the launcher in a secondary way,
to ensure if another user of the API tries to schedule an already
scheduled package, we ignore the second request.
When adding/remove subsystems to a group which is already bound or
inited, transition the subsystem automatically. This removes the
need to manually transition the subsystem in various places in
Flightgear.
The vector is now a static function variable that is returned by reference by
the new getGlobalRegistrations() function, which remains in the anonymous
namespace.
This solves the issue of the global_registrations vector being populated during
static init, but then been subsequently allocated and hence reset at the end of
static init.
Migrate and update these commands from FlightGear’s subsystem factory.
Currently disabled until subsystem-factory is removed, to avoid
duplicate registration.
Groups track their state, which will enable them to correctly transition
added and removed children in the future. Only stubbed for now, to avoid
breakage on the FG side.
- track more meta-data and a factory function for each subsystem,
registered either explicitly or via a helper static class.
- add a delegate to receive notifications of subsystem changes
- make sub-grouped subsystems work more naturally, especially for
child lookups
- add some test coverage for all of this
When CMAKE_BUILD_TYPE is Debug and we are compiling with GCC, add the
following options to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS:
-O0 -fno-omit-frame-pointer -fno-inline
Ditto for Clang, except that -fno-inline-functions is used instead of
-fno-inline.
cf. thread starting at
https://sourceforge.net/p/flightgear/mailman/message/36295412/
The new function logstream::setTestingMode() has been created to allow for a
testing mode to be set. This stores a boolean in the private logstream thread
which modifies the behaviour of the would_log() function, allowing for
everything to be logged. The removeCallbacks() function has also been added,
allowing for the default fgfs output to STDOUT and STDERR to be silenced when
calling setTestingMode().
Add test coverage for disabling a catalog due to version, and also
for auto-migrating to a new version. Expose disabled catalogs on the
Root, so they can be checked for.
Since the dawn of times (FG commit
1bcaf4bfdd38f18ac7c375dd9319935ff3df56ac, where SGBinding was called
FGBinding), SGBinding's destructor has had a strange behavior:
SGBinding::~SGBinding()
{
if(_arg && _arg->getParent())
_arg->getParent()->removeChild(_arg->getName(), _arg->getIndex());
}
In other words, it used to remove the passed-in <binding> node from its
parent node (if any) once the SGBinding instance got destroyed. This
behavior is very unintuitive to several people and has resulted in a few
workarounds in the FG code base just to cope with this strangeness.
This commit gives SGBinding the implictly-generated destructor,
therefore SGBinding::~SGBinding() does not attempt to remove the
property node anymore.
See disussion at:
https://sourceforge.net/p/flightgear/mailman/flightgear-devel/thread/87d12b1h0h.fsf%40frougon.crabdance.com/#msg36190666
this is to use some kind of utc time for timestamps in mp protocol,
to improve the lag correction system for mp planes, using a
"real time" mode when possible.
Remove an apparently bogus portability workaround (which was presumably
targetting one of the bugs fixed in the previous commit [1]) and further
simplify the code using std::find().
[1] da099d4312/
Explicitly enable the CMP0067 policy to have try_compile use the correct
C/C++ standard flags; otherwise, CMake will default to not honoring those,
causing the C/C++ checks to be compiled with no standard flags and SimGear
to be compiled with them. This causes errors if we try to detect a new
prototype which is only present in C++14 and above).
Indent the test code in a nicer way and shorten it, taking advantage of
this guarantee from the C++ standard:
If control reaches the end of main without encountering a return
statement, the effect is that of executing return 0.
-> no need for "#include <cstdlib>" nor for "return EXIT_SUCCESS".
Define HAVE_WORKING_STD_REGEX if, and only if <regex> is usable.
Normally, <regex> should be available and working in any compliant C++11
implementation, however at least g++ 4.8[1] lies about its C++11
compliance: its <regex> is utterly unusable, see [2] and [3] for
details.
[1] Which appears to be (precisely 4.8.5) the version shipped in
CentOS 7, and used on FlightGear's current Jenkins installation.
[2] https://stackoverflow.com/a/12665408/4756009
[3] https://sourceforge.net/p/flightgear/mailman/message/36170781/
Calling a virtual method in a destructor has undefined behaviour.
Furthermore passing 'this' to nasal from within the destructor
is not safe. 'onRemove' is called for widgets within layouts
on destruction anyhow, so no need to call it here again. If widgets
are arranged manually without any layout 'onRemoved' should be
called upon removing them from a dialog.
This allows one to use SGPath in containers such as std::map,
std::unordered_map and std::unordered_set.
Like the existing == and !=, all these operators rely solely on the
UTF-8 internal representation of the path.
We'll use this to cleanly declare std::hash<SGPath> as 'noexcept' in the
next commit, which appears to be desirable for std::hash template
specializations, according to:
http://en.cppreference.com/w/cpp/utility/hash
This is done by simply not user-defining the copy constructor,
copy-assignment operator and destructor. See [1] for more info.
[1] http://accu.org/content/conf2014/Howard_Hinnant_Accu_2014.pdf
For the benchmark below (compiled with the next commit to allow sorting
SGPath instances), on Linux amd64 with g++ 6.3.0, I observe that
enabling SGPath move operations with this commit increases the
performance by 31% or 28% respectively, depending on whether I use this:
// Typical code that creates a data structure in several steps and
// benefits from move operations (the std::move() does nothing when
// running the test with move operations disabled: a copy is made).
auto p = SGPath::fromUtf8(randomString(0, 30));
v.emplace_back(std::move(p));
or that:
v.emplace_back(randomString(0, 30))
for the initialization code. Now the benchmark code:
using std::string;
static std::default_random_engine randomNumbersGenerator;
// Utility function: generate a random string whose length is in the
// [minLen, maxLen] range.
string randomString(string::size_type minLen, string::size_type maxLen)
{
std::uniform_int_distribution<string::size_type> sLenDist(minLen, maxLen);
std::uniform_int_distribution<int> byteDist(0, 255);
auto randomByte = std::bind(byteDist, randomNumbersGenerator);
string::size_type len = sLenDist(randomNumbersGenerator);
string str;
while (str.size() < len) {
str += std::char_traits<char>::to_char_type(randomByte());
}
return str;
}
// The test function, run with nbIterations = 500000, minSize = 0 and
// maxSize = 200 to obtain the figures given above.
void SGPath_perfTest(std::size_t nbIterations,
std::size_t minSize, std::size_t maxSize)
{
std::uniform_int_distribution<std::size_t> sizeDist(minSize, maxSize);
auto randomSize = std::bind(sizeDist, randomNumbersGenerator);
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
vector<SGPath> v;
for (std::size_t i=0; i < nbIterations; i++) {
v = vector<SGPath>{}; // start anew
for (std::size_t j=0; j < randomSize(); j++) {
v.emplace_back(randomString(0, 30));
}
std::shuffle(v.begin(), v.end(), randomNumbersGenerator);
std::sort(v.begin(), v.end());
}
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsedSecs = end - start;
std::cout << elapsedSecs.count() << "\n"; // duration in seconds
}
With this simple change, the speedup as compared to commit 18f048424 is
now 37 % for the benchmark given in the previous commit. This is because
optimized swap() only needs to swap the raw pointers, which is certainly
less work than the three move assignments on SGSharedPtr (not raw
pointers) done by std::swap().
To benefit from this, write code like:
using std::swap; // now useless for SGSharedPtr, but idiomatic
swap(ptr1, ptr2); // *not* std::swap()!
This automatically makes SGSharedPtr more efficient when used in
standard containers (among others). See below for the benchmark details.
Mark as 'noexcept' (after checking it's legitimate!) the SGSharedPtr and
SGReferenced methods required for SGSharedPtr's move constructor and
move assignment operator to be guaranteed 'noexcept'.
Benchmark
---------
I measured a 25 % speedup with g++ 6.3.0 on Linux amd64, CFLAGS=-Wall -O2
as compared to commit 18f0484249 (which is
just before my changes to SGSharedPtr.hxx) on the following test code,
called with:
nbIterations = 3000000
minSize = 0
maxSize = 200
------------------------------------------------------------------------
static std::default_random_engine randomNumbersGenerator;
class SGReferencedTestClass : public SGReferenced
{ int i; };
void SGSharedPtr_perfTest(std::size_t nbIterations,
std::size_t minSize, std::size_t maxSize)
{
using Ref = SGSharedPtr<SGReferencedTestClass>;
std::uniform_int_distribution<std::size_t> sizeDist(minSize, maxSize);
auto randomSize = std::bind(sizeDist, randomNumbersGenerator);
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
std::vector<Ref> v;
for (std::size_t i=0; i < nbIterations; i++) {
v = std::vector<Ref>{}; // start anew
for (std::size_t j=0; j < randomSize(); j++) {
auto p = Ref(new SGReferencedTestClass());
v.emplace_back(std::move(p));
}
std::shuffle(v.begin(), v.end(), randomNumbersGenerator);
std::sort(v.begin(), v.end());
}
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsedSecs = end - start;
std::cout << elapsedSecs.count() << "\n"; // duration in seconds
}
------------------------------------------------------------------------
Basically, these gains can be explained by the fact that copying an
SGSharedPtr requires to test SGReferenced::ref, increase the refcount,
and then when the object is destroyed, test again SGReferenced::ref,
decrease the refcount and test it in order to maybe delete. With the
move constructor and move assignment operator, copying the argument is
never necessary: its raw pointer can be swapped with the one contained
in *this, which is very fast. For the move constructor, this is all that
is needed; move assignment just needs one reset() call after that in
order to release the resource from the moved-from shared pointer.
The copy-and-swap idiom is certainly very cute, but often causes
unnecessary copies. My commit fedafb9352
did exactly that, unfortunately.
Restore the exact same code for the copy-assignment operator as before
commit fedafb935, and add a more efficient implementation for the
move-assignment operator.
As explained by Howard Hinnant in [1] and [2], if some particular piece
of code really needs a strong exception safety guarantee, one can easily
add a specific method for that; this is not a valid reason to make the
code slower for all other places that have no use for such a guarantee!
[1] http://www.slideshare.net/ripplelabs/howard-hinnant-accu2014
[2] https://stackoverflow.com/a/9322542/4756009
In C++11, destructors are 'noexcept' by default -> remove useless
throw() specifiers. There was one case that wasn't about a destructor: I
replaced the 'throw()' with 'noexcept' because this use of 'throw()' is
deprecated and 'noexcept' offers the intended meaning as far as I can
guess (in C++17, 'throw()' will be equivalent to 'noexcept' anyway). For
more info, see:
http://en.cppreference.com/w/cpp/language/noexcept_spechttps://akrzemi1.wordpress.com/2013/08/20/noexcept-destructors/
Avoids codecvt dependency on Unix where it might not be present, eg
with GCC 4.8; on Windows we use <codecvt> since it’s present in VS2015
to avoid writing a seperate UTF-16 <-> UTF-8 conversion.
Designed for 2d objects, such as a canvas placements, this permits the receipt of touch (mouse click) events to enable the simulation of avionics with a touchscreen.
The coordinates are passed in as arguments to the action; these can be accessed with Nasal via the cmdarg() method.
example:
<animation>
<type>touch</type>
<visible>true</visible>
<object-name>VSDImage</object-name>
<action>
<touch>0</touch>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>print("touch input
(",cmdarg().getNode("x").getValue(),",",cmdarg().getNode("y").getValue())</script>
</binding>
</action>
</animation>
simgear::Dir::isEmpty() used to make up to 5 calls to readdir(), while 3
are enough to say whether the directory has entries other than '.' and
'..'.
Also add an automated test for this method.
This is done so as to avoid confusion with the unrelated classes
ResourceProvider and ResourceManager already present in SimGear.
Despite this new name, EmbeddedResourceProxy is a proxy not only for
embedded resources, but also for real files (hence the initial name
choice): its purpose is precisely to allow zero-work switching from one
data source to the other.
The ResourceProxy class allows one to access real files or embedded
resources in a unified way. When using it, one can switch from one data
source to the other with minimal code changes, possibly even at runtime
(in which case there is obviously no code change at all).
Sample usage (from FlightGear for the globals->get_fg_root() bit):
simgear::ResourceProxy proxy(globals->get_fg_root(), "/FGData");
std::string s = proxy.getString("/some/path");
std::unique_ptr<std::istream> streamp = proxy.getIStream("/some/path");
The methods ResourceProxy::getString(const std::string& path) and
ResourceProxy::getIStream(const std::string& path) decide whether to use
embedded resources or real files depending on the boolean value passed
to ResourceProxy::setUseEmbeddedResources() (also available as an
optional parameter to the ResourceProxy constructor, defaulting to
true). It is often most convenient to set this boolean once and don't
worry about it anymore---it's stored inside the ResourceProxy object.
Otherwise, if you want to fetch resources some times from real files,
other times from embedded resources, you may use the following methods:
// Retrieve contents using embedded resources
std:string s = proxy.getString("/some/path", true);
std:string s = proxy.getStringDecideOnPrefix(":/some/path");
// Retrieve contents using real files
std:string s = proxy.getString("/some/path", false);
std:string s = proxy.getStringDecideOnPrefix("/some/path");
(alternatively, you could use several ResourceProxy objects with
different values for the constructor's third parameter)
By default you can either do
1. axis -> object-name ...
2. axis -> x-m ...
3. omit axis. This will now try to find an 'object-name' with -axis appended. If this can't be found then no message will be output; and the default behaviour of just using (0,0,0) will appyl.
Add a rehash() method to EmbeddedResourceManager::Impl to update
'poolSearchList'. Introduce a 'dirty' flag so that
EmbeddedResourceManager::Impl::rehash() is automatically called whenever
needed. It is not necessary anymore to call
EmbeddedResourceManager::selectLocale() after adding resources: changing
the EmbeddedResourceManager's locale or adding resources are both
operations that set the dirty flag. Whenever someone tries to fetch a
resource for the selected locale and the dirty flag is set, a rehash is
triggered before the actual fetching so as to ensure it is correct.
This should reduce the load on Ibiblio when browsing aircraft, the
package system caches thumbnails for seven days. Also we detect for
certain failure conditions and retry, to deal with Ibiblio’s rate-
limiting mechanism.
MSVC really needs these methods to be out of line, to avoid generating code for the shared pointers
in each translation unit which includes the header.
This fixes the animation bindings to use the defined property tree root - to support multiplayer (or other) model that can bind to the correct part of the property tree.
Requires a corresponding fix in fg to allow the command methods to take an optional root parameter.
What this means is that when inside someone else's multiplayer model (e.g. backseat, or co-pilot), the multipalyer (AI) model will correctly modify properties inside the correct part of the property tree inside (/ai), rather than modifying the properties inside the same part of the tree as the non-ai model.
This means that a properly setup model will operate within it's own space in the property tree; and permit more generic multiplayer code to be written.
This is probably responsible for some of the pollution of the /sim property tree with MP aircraft properties.
The previous fix was successful, but a priori doesn't need to be applied
to *all* compilers that define _WIN32. Apply it only when _MSC_VER is
defined, and only to the template instantiations that MSVC doesn't
recognize (i.e., those that use a parameter from the variadic template).
The MS compiler doesn't seem to recognize our templates here:
g:\jenkins\workspace\simgear-win\source\simgear\embedded_resources\EmbeddedResourceManager.hxx(169): error C3190: 'std::shared_ptr<const simgear::AbstractEmbeddedResource> simgear::EmbeddedResourceManager::getResource(const std::string &,const std::string &) const' with the provided template arguments is not the explicit instantiation of any member function of 'simgear::EmbeddedResourceManager' (compiling source file G:\Jenkins\workspace\SimGear-Win\source\simgear\embedded_resources\EmbeddedResourceManager.cxx) [G:\Jenkins\workspace\SimGear-Win\build32\simgear\SimGearCore.vcxproj]
g:\jenkins\workspace\simgear-win\source\simgear\embedded_resources\EmbeddedResourceManager.hxx(169): error C2945: explicit instantiation does not refer to a template-class specialization (compiling source file G:\Jenkins\workspace\SimGear-Win\source\simgear\embedded_resources\EmbeddedResourceManager.cxx) [G:\Jenkins\workspace\SimGear-Win\build32\simgear\SimGearCore.vcxproj]
-> try without the explicit instantiations on Windows.
Add the EmbeddedResourceManager class as well as
AbstractEmbeddedResource and two derived concrete classes:
RawEmbeddedResource and ZlibEmbeddedResource.
The purpose of this is to provide a way for FlightGear to use data from
files without relying on FG_ROOT to be set. The whole system (SimGear
and FlightGear parts) was described in detail at [1]. I'll probably
include a copy in $FG_ROOT/Docs too for fear of the link becoming dead
one day.
Basically, classes derived from AbstractEmbeddedResource provide access
to some data---the source of which is a priori of static storage
class---and handle the conversion from whatever format it is stored in
to allow convenient use of said data. At the very least, they allow
obtaining ready-to-use data as an std::string, as well as reading it
incrementally via an std::streambuf or an std::istream interface.
ZlibEmbeddedResource instances also provide access to the compressed
size of the data (i.e., as stored in static memory) as well as its
uncompressed size, without requiring any prior decompression.
EmbeddedResourceManager is a class which FlightGear will normally
instantiate exactly once---it has createInstance() and instance() static
methods for this. It maintains a map between resource paths and
instances of concrete classes derived from AbstractEmbeddedResource. It
also provides convenience methods allowing to access a resource data in
one step (not requiring to manually fetch the
AbstractEmbeddedResource-derived object corresponding to the given
resource path before calling the appropriate method of this object).
From the EmbeddedResourceManager's point of view, resource paths (keys
of the map) are just plain std::string instances in the current
implementation. However, unless there is a good reason not to, I think
it's a good idea to only use values obtained with SGPath::utf8Str()[2].
This is precisely what fgrcc, the resource compiler in the FlightGear
repository, does; so, unless you register resources manually, your
resource paths will automatically comply with this suggestion.
[1] https://sourceforge.net/p/flightgear/mailman/message/35870025/
[2] This allows later addition of methods listing all resources under a
given virtual path, as well as optimized resource lookup using a
tree-like data structure instead of an std::unordered_map (not
justified now IMO).
Add the following classes in the 'simgear' namespace:
- CharArrayStreambuf subclass of std::streambuf stream buffer
- ROCharArrayStreambuf subclass of CharArrayStreambuf stream buffer
- CharArrayIStream subclass of std::istream input stream
- CharArrayOStream subclass of std::ostream output stream
- CharArrayIOStream subclass of std::iostream input/output stream
CharArrayStreambuf is a stream buffer class allowing to read from, and
write to char arrays (std::strstream has been deprecated since C++98).
Contrary to std::strstream, this class does no dynamic allocation: it is
very simple, strictly staying for both reads and writes within the
limits of the buffer specified in the constructor. Contrary to
std::stringstream, CharArrayStreambuf allows one to work on an array of
char (that could be static data or on the stack) without having to make
a whole copy of it.
CharArrayStreambuf supports reading and writing (including efficient
implementations of xsgetn() and xsputn()), seeking (with independent
read and write stream pointers, as for std::stringstream) and putting
back chars up to the beginning of the char array. The internal buffer
for both reads and writes is defined to be the whole buffer specified in
the constructor call. As a consequence, flushing the stream buffer with
pubsync() is useless: data is always written directly to the buffer
passed to the constructor, never to an intermediate buffer.
Of course, this buffer must remain available as long as the stream
buffer object is used.
ROCharArrayStreambuf is a read-only subclass of CharArrayStreambuf.
CharArrayIStream, CharArrayOStream and CharArrayIOStream are very simple
convenience stream classes using either CharArrayStreambuf or
ROCharArrayStreambuf as their stream buffer class.
Applicable to / works with rotate, translate and knob. Once the axis object-name has been used it will be hidden, however it still can be used for object-name animations. The hiding of the axis object is a useful guide as to what is left to be wired up to animations.
This allows the follow to work (on a combined ASI / Mach instrument).
<animation>
<type>rotate</type>
<object-name>asi-needle</object-name>
...
<axis>
<object-name>airspeed-asi-axis</object-name>
</axis>
</animation>
<animation>
<type>rotate</type>
<object-name>asi-mach-scale</object-name>
...
<axis>
<object-name>airspeed-asi-axis</object-name>
</axis>
</animation>
This function is similar to simgear::strutils::to_int(), except it is:
- generic: the return type, selected with the first template
parameter, can be an arbitrary integral type. This type also defines
the set of accepted input strings ("values").
- stricter regarding the input: it must be non-empty and contain only
valid digits for the specified base (second template parameter). If
the input doesn't conform to these constraints or is too large to
fit into the specified type, an exception with a suitable error
message is raised.
- faster (12 to 17 times as fast as simgear::strutils::to_int() on my
system, depending on compilation flags): this is probably a
consequence of not using std::stringstream to do the conversion.
The function template is only instantiated for <int, 10> and
<unsigned int, 10> in order to be sure not to waste memory (see comments
in strutils.cxx). If you need it for other combinations of type and
base, just enable them by adjusting the corresponding '#if 0 / #endif'
pairs in strutils.cxx and strutils_test.cxx.
The existance of a dns entry with a protocol defined caused the
naptr callback being terminated early and the request never completed.
This patch also adds a unit test for this particular case.
test_dns now also accepts up to two command line parameters:
first: dns DN to query for NAPTR records (default: terrasync.flightgear.org)
second: service to query (default: empty)
Since the virtuality of a method is inherited by derived classes, this
makes the virtual status of such methods clearly visible in the
declarations of derived classes.
The Windows and Mac builders on jenkins complain that '\U12345678' is
an invalid universal character; let's try with '\U000000E9' instead,
which should be LATIN SMALL LETTER E WITH ACUTE.
Also replace '\uab42' with '\u00e0' to remove a warning on the Windows
builder, due to the fact that '\uab42' cannot be represented in the
current code page (1252). This doesn't mean '\uab42' was incorrect,
though; I'm only changing this to make the warning disappear.
This function complements the existing strutils::unescape(). It
backslash-escapes a string for C/C++ string literal syntax.
For every std::string s, the following holds:
unescape(escape(s)) == s
(not the other way around, because there are many ways to escape a given
character in a string literal)
An octal escape sequence in a string literal can't have more than 3
octal digits after the backslash. The previous code was using up to 4
digits per octal escape sequence.
Such an argument is /a priori/ perfectly valid, and not an option.
Typical use in a command line:
-o -
equivalent to:
-o-
The former way wasn't accepted before this commit; now it is (also
'--output -', equivalent to '--output=-').
If the last option is followed by an argument consisting of a single
'-', this argument marks the end of options and is the first non-option
argument (contrary to '--' which, given its special status, would mark
the end of options but would *not* count as a non-option argument).
This commit also adds an std::string length check in
ArgumentParser::parseArgs() that was missing before using operator[]()
(important difference between operator[]() for std::string and std::map
or std::unordered_map!).
Previously, SGPath::pathListSep was a char in static memory, that could
be followed by anything (often '\0', as it seems... but not always).
This is (was) dangerous, because it is then tempting to take its address
and pass it to functions expecting a char * corresponding to a
null-terminated string (C-style).
SGPath::pathListSep is now a static array of two const chars: the path
list separator followed by a '\0'. This implies that
&SGPath::pathListSep can now be reliably interpreted as a C-style string
of length 1 (not counting the null terminator), containing only the path
list separator.
See simgear/misc/argparse.hxx for API and documentation
(simgear/misc/argparse_test.cxx also has examples, although argparse.hxx
features a very simple one at the top).
These classes were also presented in
<https://sourceforge.net/p/flightgear/mailman/message/35785019/>.
The popup/no popup logic in SG_LOG() could be wrong before this commit,
because of missing parentheses around uses of the second macro argument.
For instance, this:
SG_LOG(SG_NAVCACHE, t == 0 ? SG_WARN : SG_ALERT, "Message");
could cause a popup window to be displayed even though neither SG_WARN
nor SG_ALERT should do that in the current state of the logging system.
Thanks to Szymon Acedański for finding this.
Add an alternate constructor to each of the following classes:
ZlibAbstractIStreambuf, ZlibCompressorIStreambuf,
ZlibDecompressorIStreambuf, ZlibCompressorIStream and
ZlibDecompressorIStream. These new constructors are passed the source
std::istream wrapped inside an std::unique_ptr instead of by reference,
and store the unique_ptr object as an instance member. This ensures that
the source std::istream object is available as long as the
ZlibDecompressorIStreambuf, etc. instance is alive (which is necessary
for its getInputData() method) without any additional work for callers,
and that it is automatically destroyed afterwards.
This is particularly useful when writing functions that create and
return an object 'zobj' whose type is a subclass of
ZlibAbstractIStreambuf, when the source std::istream is only of interest
for its role of feeding data to 'zobj'. For instance:
std::unique_ptr<simgear::ZlibCompressorIStream>
myZlibCompressorIStreamProducer(std::string str)
{
std::unique_ptr<std::istringstream> iss(new std::istringstream(str));
return std::unique_ptr<simgear::ZlibCompressorIStream>(
new simgear::ZlibCompressorIStream(std::move(iss))); // new ctor here
}
Callers of such a function get access to a new ZlibCompressorIStream
instance fed by an std::istringstream object ('iss'), but they don't
even have to know this detail, nor to take any measure to ensure that
'iss' lives at least as long as the ZlibCompressorIStream object. The
std::unique_ptr<std::istream> pointing to 'iss' and stored as a member
of the ZlibCompressorIStream object by its constructor automatically
takes care of this lifetime problem.
New automated test for ZlibDecompressorIStreambuf::xsgetn(). xsgetn() is
called by sgetn() from the base class std::streambuf. In our case,
xsgetn() is actually defined in the base class ZlibAbstractIStreambuf
(subclass of std::streambuf), therefore this new test also applies to
ZlibCompressorIStreambuf and the two other related classes,
ZlibCompressorIStream and ZlibDecompressorIStream.
This test asks [x]sgetn() the largest possible amount of chars every
time it is called, i.e., the largest value that can be represented by
std::streamsize. This exercises the code in interesting ways due to the
various types involved (zlib's uInt, std::size_t and std::streamsize,
which have various sizes depending on the platform).
Compilation of these files was disabled in commit
e21ad4b5c1.
Fix build errors and warnings:
- Ambiguous template parameters for std::min();
- No appropriate default constructor available for
std::basic_istream<char,std::char_traits<char>> (the std::istream
subclasses didn't explicitly call the std::istream constructor,
which requires an argument). This is presumably exactly the reason
why sg_gzifstream is declared like this:
class sg_gzifstream : private gzifstream_base, public std::istream
where gzifstream_base is an empty shell for a stream buffer object:
struct gzifstream_base
{
gzifstream_base() {}
gzfilebuf gzbuf;
};
This ensures that the stream buffer object (gzbuf) is initialized
before std::istream's constructor is called. I solved this problem
in a different way, hopefully easier to understand, and requiring
neither an additional class nor multiple inheritance: first, we
initialize the std::istream base with a nullptr as the
std::streambuf * argument (this is valid C++11), then in the
constructor bodies for ZlibCompressorIStream and
ZlibDecompressorIStream, we call std::istream::rdbuf() to attach the
std::istream instance to the now-initialized stream buffer object.
- Possible truncation of constant value on 32 bits systems (this was
in zlibMaxChunkSize() which is now removed, see below).
Type-related improvements:
- Remove zlibMaxChunkSize() and zlibMaxChunk: in C++, one can simply
use std::numeric_limits<uInt>::max()---most of the code in
zlibMaxChunkSize() was there only to find this value via a zlib
function call.
- Add helper function templates zlibChunk() and clipCast().
- Split preparation of the putback area out of
ZlibAbstractIStreambuf::xsgetn() to a new utility method:
xsgetn_preparePutbackArea().
- More rigorous type handling in zlibstream_test.cxx.
Some precautions are necessary because the IOStreams API uses
std::streamsize in many places (e.g., the return value of
std::istream::gcount()), but functions such as the following
std::string constructor:
std::string(const char* s, std::size_t n);
work with std::size_t instead. Since these types are different and
opaque, this requires some care!
Add:
- two stream buffer classes (ZlibCompressorIStreambuf and
ZlibDecompressorIStreambuf), both based on the same abstract class:
ZlibAbstractIStreambuf;
- two std::istream subclasses (ZlibCompressorIStream and
ZlibDecompressorIStream), each creating and using the corresponding
stream buffer class from the previous item.
All these allow one to work with RFC 1950 and RFC 1952 compression
formats, respectively known as the zlib and gzip formats.
These classes are *input* streaming classes, which means they can
efficiently handle arbitrary amounts of data without using any disk
space nor increasing amounts of memory, and allow "client code" to pull
exactly as much data as it wants at any given time, resuming later when
it is ready to handle the next chunk.
See comments in simgear/io/iostreams/zlibstream.hxx for more details.
- Rename zfstream.cxx (resp. zfstream.hxx) to gzfstream.cxx (resp.
gzfstream.hxx)
This is because these files only deal with the gzip format (RFC 1952),
while zlib can actually read and write two slightly different formats:
this one and the "ZLIB Compressed Data Format" (RFC 1950). Since I am
going to add std::streambuf and std::istream subclasses able to deal
with both formats (and supporting data sources that are general
std::istream instances, not just files), this renaming will make
things a bit clearer, I hope.
- Add new folder simgear/io/iostreams and move the following files to
this folder:
simgear/misc/gzcontainerfile.cxx
simgear/misc/gzcontainerfile.hxx
simgear/misc/gzfstream.cxx
simgear/misc/gzfstream.hxx
simgear/misc/sgstream.cxx
simgear/misc/sgstream.hxx
simgear/misc/sgstream_test.cxx
- Adapt other files accordingly (mainly #includes and CMakeLists.txt
files).
HTTP/1.0 and HTTP/1.1 allow the reason string to be empty.
Some servers produce empty reason strings on success,
e.g. "HTTP/1.1 200 ", which throws a "bad HTTP response"
exception.
From the specification:
"Reason-Phrase = *<TEXT, excluding CR, LF>"
From notational conventions:
"*(element) allows any number, including zero"
References:
www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2
www.w3.org/Protocols/HTTP/1.0/spec.html
www.w3.org/Protocols/rfc2616/rfc2616-sec6.html
- Create "testfile" in a temporary directory (and make sure the temp dir
and the file it contains are both removed when the test program exits).
- Use test macros such as SG_CHECK_EQUAL() instead of by-hand checks and
"return EXIT_FAILURE" statements.
- Use sg_ofstream instead of plain std::ostream. This simplifies things
a tiny bit, because one SGPath instance is enough to create both the
sg_ofstream instance and the sg_gzifstream instance used afterwards to
reread the created file.
- Don't call (sg_)ofstream::close() at the end of the block the instance
is declared in: this is entirely unnecessary, since sg_ofstream
derives from std::ofstream, which is automatically close()d when
destroyed (RAII behavior).
- Add method simgear::Dir::isNull(), analogous to SGPath::isNull().
- Make sure that simgear::Dir::tempDir() returns a null simgear::Dir
instance when creation of the directory failed (so far, this was only
the case on systems where HAVE_MKDTEMP is defined).
- Use simgear::strutils::error_string() instead of strerror() (the
latter is not guaranteed to be thread-safe).
- Make sure <cerrno> is #included, regardless of the platform.
- Add automated tests for isNull(), setRemoveOnDestroy() and tempDir().
This was triggered by the TU154B; probably related to the console error
* "Image loading failed:Warning: reading "fgdata\AI\Aircraft\tu154b\Model" not supported.
This avoids an XML naming clash, and allows both systems to exist in
parallel peacefully. Update the tests to check both the thumbnails
and preview system in parallel with each other.
In pt_lights.cxx in SGLightFactory::getOdal, at segment "centerline lights",
the decrement loop index i is initialized with lights.getNumLights(), then is used at lights.getLight. (ERROR)
The function getNumLights is set to the size of the vector which is one more than the max index refernce.
This restores the behavior that was in place before commit 8ddb99f62f
BoostTestTargets.cmake requires the CMake-configurable form of the Boost
test framework to be used (i.e. "#include <BoostTestTargetConfig.h>"), and
checks each test source code file for this, outputting a warning in case
this requirement is not met.
Unfortunately, a conditional in the check is badly specified (the CMake
variable syntax is not followed), so the warning is emitted even when it
should not be.
This patch fixes this bug and restores the correct behavior.
Submitted upstream at https://github.com/rpavlik/cmake-modules/pull/44
Want to verify this is the cause of crashes inside the property code,
since if it's not we have a much bigger problem.
This means all listeners are recursive, with a parent-chain walk on each
setValue call, as has been the case since 'forever'.
- osg::Vec4 objects can't be output to a stream -> use the _NOSTREAM
variant of the test macro.
- ditto for the NULL... thing -> use SG_CHECK_IS_NULL().
- Add an _NOSTREAM variant for each macro (except for SG_TEST_FAIL, that
doesn't take any argument, and for SG_VERIFY, which doesn't attempt to
print its argument to a stream---doesn't sound very useful). So, if a
and b can be output to a stream (without any undesirable side effect,
of course), use for instance SG_CHECK_EQUAL(a, b); otherwise, use
SG_CHECK_EQUAL_NOSTREAM(a, b).
- Add test macros SG_CHECK_IS_NULL, SG_CHECK_IS_NULL_NOSTREAM,
SG_CHECK_IS_NOT_NULL and SG_CHECK_IS_NOT_NULL_NOSTREAM.
- Add a few comments.
- Because of possible operator overloading, make SG_CHECK_EQUAL(a, b)
fail if, and only if (a) == (b) is false (testing if (a) != (b) for
this macro is not correct in general).
- For clarity and consistency, change the messages printed when some
tests fail: SG_VERIFY(some_test) prints 'failed: some_test' (okay),
but SG_CHECK_EQUAL(a, b) used to print 'failed: a != b', which is
inconsistent. Instead, print: 'failed: a == b' because this is what we
know that failed (again, because of possible operator overloading,
pretending we know the the logical value of (a != b) after testing
(a == b) is not correct in general.
Similarly, the "approximate equality tests" SG_CHECK_EQUAL_EP() and
SG_CHECK_EQUAL_EP2() now print something like 'failed: a ~= b' when
they fail, instead of 'failed with epsilon: a != b'.
- The header is needed for std::cerr.
- Also improve the messages when tests fail (spacing, and in some cases
an argument was missing).
- Reorder the macros a tiny bit.
Some of the modules where I previously removed duplicate private
definitions of these macros had these features, and since they seem wise
to me, I'm applying them to the canonical SG_CHECK_EQUAL_EP() and
SG_CHECK_EQUAL_EP2() macros defined in simgear/misc/test_macros.hxx.
COMPARE -> SG_CHECK_EQUAL
COMPARE_EP -> SG_CHECK_EQUAL_EP
COMPARE_EP2 -> SG_CHECK_EQUAL_EP2
VERIFY -> SG_VERIFY
Also remove duplicate private definitions of these macros in test
modules, using instead those defined in simgear/misc/test_macros.hxx.
Only handle PackageRef by reference in the header file, so we don’t
create calls to the copy constructor and/or destructor. If this doesn’t
work will need to create a stub implementation file.
This is a number ranging between 0 and 1 based on the log of the illuminance of
the moon outside the atmosphere. It is calculated as
factor = (log(I) - max_loglux) / (max_loglux - min_loglux) + 1.0,
where I is the illuminance of the moon outside the atmosphere and min_loglux and
max_loglux are hardcoded to -0.504030345621 and -4.39964634562 respectively.
Although the value should never be outside of [0, 1], for safety it is clipped
to be between these values. For more background, see
http://forum.flightgear.org/viewtopic.php?f=47&t=28201&start=60#p270516 .
This is the base 10 log of equation 20, converted from foot-candles to lux,
from:
Krisciunas K. and Schaefer B.E. (1991). A model of the brightness of
moonlight, Publ. Astron. Soc. Pacif. 103(667), 1033-1039 (DOI:
http://dx.doi.org/10.1086/132921).
To obtain the sun's true longitude, the Star::getlonEcl() function has been
created. The moon's age is then calculated as the difference between the moon's
and sun's true longitudes. The phase is then simply half of one minus the
cosine of the age. Hence these calculations are very cheap compared to the rest
of the moon position calculations. The algorithm is from:
Duffett-Smith, Peter. Practical Astronomy With Your Calculator. 3rd ed.
Cambridge: Cambridge University Press, 1981. ISBN 0-521-28411-2.
The code can replicate the example in the book of Feb 26, 1979 at 16h UT, with
an age of -0.4767 degrees a phase of 0.0:
$ fgfs --aircraft=UFO --start-date-gmt=1979:02:26:16:00:00 --airport=EGLL \
--altitude=50000 --enable-hud
The calculated phase is 1.459e-5 and the age is -6.2908 (which is -0.43628
degrees). For a recent full moon:
$ fgfs --aircraft=UFO --start-date-gmt=2015:11:25:22:44:00 --airport=EGLL \
--altitude=50000 --enable-hud
The calculated age is -3.1413 and the phase is 0.9999999778.
By storing repetitive intermediate calculations, the number of mathematical
operations for a single call to CelestialBody::updatePosition() has decreased by
12. This matches the changes to MoonPos::updatePosition().
The following functions have been added: MoonPos::getM(), MoonPos::getw(),
MoonPos::getxg(), MoonPos::getyg(), MoonPos::getye(), MoonPos::getze(),
MoonPos::getDistance(). These are copied from and match the Star class
functions (but with xs and ys replaced by xg and yg).
By storing repetitive intermediate calculations, the number of mathematical
operations for a single call to MoonPos::updatePosition() has decreased by 32.
Commit 8277857827 relies on zlib's
gzoffset() function (not just offset(): that was a typo in the commit
message, sorry). This function appeared in zlib 1.2.4 (which dates from
2010). Enforce this requirement with CMake.
This way, one can easily use the OS-dependent separarator for path lists in
other places to build and split path lists in an optimal way (e.g., not
sacrificing ';' on Unix, since the path list separator is ':' on this
platform).
- When started from the console use the console (when no --console)
- When started from the GUI (with --console) open a new console window
- When started from the GUI (without --console) don't open a new console window; stdout/stderr will not appear (except in logfiles as they do now). This opens stderr/stdout on the NUL device to alleviate any potential issues
- When started from the Console (with --console) open a new console window
- Ensure that IO redirection still works when started from the console. When redirecting stdout stderr will also be redirected (providing it wasn't already via 2>&1) - otherwise output from stderr will be lost.
- When using redirection from the command prompt --console will produce an error message box.
Notes:
- fgfs needs to be a linked as Win32 GUI subsystem app - which it already is
- What can't be done is to make the cmd prompt run fgfs synchronously; this is only something that can be done via "start /wait fgfs"
Basically the way that Win32 works is quite sensible, but slightly at odds with the unix nature of the C-RTL; so the standard streams sort of get lost for GUI apps. AttachConsole and AllocConsole are provided to address this - but they do slightly different things. AttachConsole will attach to the cmd.exe (or any console related to the parent process), whereas AllocConsole will open a new one. Depending on where the application was launched from it makes sense to use AttachConsole for a cmd.exe launch and do nothing (unless --console is given) for a GUI launch.
Redirection is not available from the GUI (unless set in the Process Create block) - so really only available when launched from the command line. If any stream is redirected then all must be otherwise it appears that AttachConsole will undo the redirection by changing the standard handles.
SG_LOG(SG_GENERAL,SG_DEBUG,"CanvasImageCallback "<<instanceid<<": image available for "<<_subscribers.size()<<" subscribers. camera is "<<renderInfo.getCurrentCamera());
SG_LOG(SG_GENERAL,SG_INFO,"CanvasImage: attached image and draw callback to camera "<<camera<<" for canvas "<<canvasname<<". Ready for subscriber now.");
}
}
// TODO Allow custom render order? For now just keep in order with
// Heavily modified to be usable for the 2d Canvas by Thomas Geymayer - April 2012
// Supports now multisampling/mipmapping, usage of the stencil buffer and placing
// the texture in the scene by certain filter criteria
// Heavily modified to be usable for the 2d Canvas by Thomas Geymayer - April
// 2012 Supports now multisampling/mipmapping, usage of the stencil buffer and
// placing the texture in the scene by certain filter criteria.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@@ -108,6 +109,8 @@ namespace canvas
intcoverage_samples=0,
intcolor_samples=0);
voidsetMaxAnisotropy(floatanis);
/**
* Enable/Disable updating the texture (If disabled the contents of the
* texture remains with the outcome of the last rendering pass)
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.