Compare commits

..

16 Commits

Author SHA1 Message Date
Jonathan Redpath
af0f7676c4 osgText: improve code to search aircraft directory for font 2022-01-12 11:16:05 +00:00
Automatic Release Builder
a3bdfab17b new version: 2020.3.12 2021-12-20 16:19:27 +00:00
Fernando García Liñán
44bae773a0 Canvas: Set pointers to NULL instead of calling .release()
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.
2021-12-20 16:12:06 +00:00
James Turner
5fe527a2d1 MaterialLib: make it thread-safe 2021-12-20 16:10:31 +00:00
James Turner
b79f03c96c Fix a ref-count loop in Paticles manager 2021-12-20 16:10:31 +00:00
Erik Hofman
631fa62495 Michael Danilov: Fix issue #2169 Sound with condition=false will play when moving into its max-dist (patch available) 2021-09-25 11:17:15 +02:00
Automatic Release Builder
a157e50302 Ooops, use correct variable name. 2021-07-29 10:21:20 +01:00
Automatic Release Builder
70e6b6b13f new version: 2020.3.11 2021-07-29 09:08:37 +01:00
James Turner
c457561472 HTTPRepo: Add detail to an error
This is showing up in the wild, but not clear how, so extend the
logging.
2021-07-29 08:47:12 +01:00
James Turner
2b5ac6350d remove an error on stable, too common. 2021-07-28 15:14:41 +01:00
James Turner
1c30b29168 Report errors on TileDetails callback failures
This callback can do out of memory and other failures, so catch
those and report them.
2021-07-28 15:14:41 +01:00
James Turner
ce9f476ddb Don't report PropsIO exceptions 2021-07-28 14:23:38 +01:00
James Turner
2621418d3a Fix a dumb back-port issue. 2021-07-22 10:11:04 +01:00
James Turner
174b341bef Don’t report HTTPRepo removeChild failures
Sentry-Id: FLIGHTGEAR-E5T
2021-07-15 10:31:28 +01:00
James Turner
df33713069 Remove incorrectly added ‘version’ file 2021-07-15 08:44:08 +01:00
James Turner
cde75530fe BTG reading: don’t crash on empty error message
Sentry-Id:FLIGHTGEAR-WA8
2021-07-15 08:43:31 +01:00
15 changed files with 119 additions and 72 deletions

View File

@@ -1 +1 @@
2020.3.10
2020.3.12

View File

@@ -298,8 +298,8 @@ namespace canvas
{
if( camera.valid() && Canvas::getSystemAdapter() )
Canvas::getSystemAdapter()->removeCamera(camera.get());
camera.release();
texture.release();
camera = nullptr;
texture = nullptr;
_flags &= ~AVAILABLE;
}

View File

@@ -774,7 +774,7 @@ private:
if (!ok) {
SG_LOG(SG_TERRASYNC, SG_WARN, "removal failed for:" << path);
throw sg_io_exception("Failed to remove existing file/dir:", path);
throw sg_io_exception("Failed to remove existing file/dir:", path, "", false);
}
}
@@ -1424,7 +1424,8 @@ HTTPRepository::failure() const
SG_LOG(SG_TERRASYNC, SG_WARN,
"failed to update entry:" << relativePath << " status/code: "
<< innerResultCodeAsString(fileStatus)
<< "/" << fileStatus);
<< "/" << fileStatus
<< "\nrepo:" << baseUrl);
simgear::reportFailure(simgear::LoadFailure::NetworkError, simgear::ErrorCode::TerraSync,
"failed to update entry:" + innerResultCodeAsString(fileStatus),

View File

@@ -48,9 +48,11 @@ static std::string gzErrorMessage(gzFile fd)
if (errNum == Z_ERRNO) {
return simgear::strutils::error_string(errno);
} else {
} else if (gzMsg) {
return {gzMsg};
}
return {"GZError: no string code for code:" + std::to_string(errNum)};
}
void sgReadChar ( gzFile fd, char *var )

View File

@@ -161,7 +161,7 @@ setFlag( int& mode,
string message = "Unrecognized flag value '";
message += flag;
message += '\'';
throw sg_io_exception(message, location, SG_ORIGIN);
throw sg_io_exception(message, location, SG_ORIGIN, false);
}
}
@@ -176,7 +176,7 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
string message = "Root element name is ";
message += name;
message += "; expected PropertyList";
throw sg_io_exception(message, location, SG_ORIGIN);
throw sg_io_exception(message, location, SG_ORIGIN, false);
}
// Check for an include.
@@ -188,7 +188,7 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
{
string message ="Cannot open file ";
message += attval;
throw sg_io_exception(message, location, SG_ORIGIN);
throw sg_io_exception(message, location, SG_ORIGIN, false);
}
readProperties(path, _root, 0, _extended);
} catch (sg_io_exception &e) {
@@ -278,7 +278,7 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
{
string message ="Cannot open file ";
message += val;
throw sg_io_exception(message, location, SG_ORIGIN);
throw sg_io_exception(message, location, SG_ORIGIN, false);
}
readProperties(path, node, 0, _extended);
}
@@ -353,7 +353,7 @@ PropsVisitor::endElement (const char * name)
string message = "Unrecognized data type '";
message += st.type;
message += '\'';
throw sg_io_exception(message, location, SG_ORIGIN);
throw sg_io_exception(message, location, SG_ORIGIN, false);
}
if( !ret )
SG_LOG
@@ -701,7 +701,7 @@ writeProperties (const SGPath &path, const SGPropertyNode * start_node,
if (output.good()) {
writeProperties(output, start_node, write_all, archive_flag);
} else {
throw sg_io_exception("Cannot open file", sg_location(path.utf8Str()));
throw sg_io_exception("Cannot open file", sg_location(path.utf8Str()), "", false);
}
}
@@ -770,7 +770,7 @@ copyPropertyValue(const SGPropertyNode *in, SGPropertyNode *out)
break;
string message = "Unknown internal SGPropertyNode type";
message += in->getType();
throw sg_error(message, SG_ORIGIN);
throw sg_error(message, SG_ORIGIN, false);
}
return retval;

View File

@@ -83,6 +83,8 @@ bool SGMaterialLib::load( const SGPath &fg_root, const SGPath& mpath,
options->setObjectCacheHint(osgDB::Options::CACHE_ALL);
options->setDatabasePath(fg_root.utf8Str());
std::lock_guard<std::mutex> g(d->mutex);
simgear::PropertyList blocks = materialblocks.getChildren("region");
simgear::PropertyList::const_iterator block_iter = blocks.begin();
@@ -153,14 +155,20 @@ bool SGMaterialLib::load( const SGPath &fg_root, const SGPath& mpath,
// find a material record by material name and tile center
SGMaterial *SGMaterialLib::find( const string& material, const SGVec2f center ) const
{
std::lock_guard<std::mutex> g(d->mutex);
return internalFind(material, center);
}
SGMaterial* SGMaterialLib::internalFind(const string& material, const SGVec2f center) const
{
SGMaterial *result = NULL;
const_material_map_iterator it = matlib.find( material );
if ( it != end() ) {
if (it != end()) {
// We now have a list of materials that match this
// name. Find the first one that matches.
// We start at the end of the list, as the materials
// list is ordered with the smallest regions at the end.
// We start at the end of the list, as the materials
// list is ordered with the smallest regions at the end.
material_list::const_reverse_iterator iter = it->second.rbegin();
while (iter != it->second.rend()) {
result = *iter;
@@ -184,11 +192,12 @@ SGMaterial *SGMaterialLib::find( const string& material, const SGGeod& center )
SGMaterialCache *SGMaterialLib::generateMatCache(SGVec2f center)
{
SGMaterialCache* newCache = new SGMaterialCache();
std::lock_guard<std::mutex> g(d->mutex);
material_map::const_reverse_iterator it = matlib.rbegin();
for (; it != matlib.rend(); ++it) {
newCache->insert(it->first, find(it->first, center));
newCache->insert(it->first, internalFind(it->first, center));
}
return newCache;
}

View File

@@ -81,7 +81,10 @@ private:
typedef material_map::const_iterator const_material_map_iterator;
material_map matlib;
SGMaterial* internalFind(const std::string& material, const SGVec2f center) const;
public:
// Constructor

View File

@@ -16,23 +16,27 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#ifdef HAVE_CONFIG_H
# include <simgear_config.h>
#endif
#include <simgear_config.h>
#include <cstdio>
#include "SGText.hxx"
#include <simgear/math/SGMath.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/misc/strutils.hxx>
#include <osg/Geode>
#include <osg/MatrixTransform>
#include <osgText/Text>
#include <osgText/Font>
#include <simgear/misc/ResourceManager.hxx>
#include <simgear/math/SGMath.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/misc/strutils.hxx>
#include <simgear/scene/material/Effect.hxx>
#include <simgear/scene/material/EffectGeode.hxx>
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <simgear/debug/ErrorReportingCallback.hxx>
using std::string;
class SGText::UpdateCallback : public osg::NodeCallback {
@@ -95,9 +99,15 @@ osg::Node * SGText::appendText(const SGPropertyNode* configNode,
osg::Geode * g = new osg::Geode;
g->addDrawable( text );
SGPath path("Fonts" );
path.append( configNode->getStringValue( "font", "Helvetica" ));
text->setFont( path.utf8Str() );
const std::string requestedFont = configNode->getStringValue("font","Helvetica");
const SGPath fontPath = simgear::ResourceManager::instance()->findPath("Fonts/" + requestedFont);
if ( !fontPath.isNull() ) {
text->setFont( fontPath.utf8Str() );
} else {
simgear::reportFailure(simgear::LoadFailure::NotFound,
simgear::ErrorCode::LoadingTexture,
"SGText: couldn;t find font:" + requestedFont);
}
text->setCharacterSize(configNode->getDoubleValue("character-size", 1.0 ),
configNode->getDoubleValue("character-aspect-ratio", 1.0 ));

View File

@@ -457,9 +457,6 @@ SGAnimation::~SGAnimation()
}
if (!info.empty())
{
reportFailure(LoadFailure::Misconfigured, ErrorCode::XMLModelLoad,
"Could not find at least one of the following object for animation:" + info,
SGPath::fromUtf8(_modelData.getPath()));
SG_LOG(SG_IO, SG_DEV_ALERT, "Could not find at least one of the following"
" objects for animation: " << info << " in file: " << _modelData.getPath());
}

View File

@@ -512,6 +512,14 @@ void Particles::setupStaticColorComponent(float r1, float g1, float b1, float a1
staticColorComponents[7] = a2;
}
ParticlesGlobalManager::~ParticlesGlobalManager()
{
// break a ref-counting cycle
if (d->_commonRoot) {
d->_commonRoot->removeUpdateCallback(d.get());
}
}
void ParticlesGlobalManager::setWindVector(const osg::Vec3& wind)
{
std::lock_guard<std::mutex> g(d->_lock);

View File

@@ -150,7 +150,7 @@ protected:
class ParticlesGlobalManager
{
public:
~ParticlesGlobalManager() = default;
~ParticlesGlobalManager();
static ParticlesGlobalManager* instance();
static void clear();

View File

@@ -37,6 +37,7 @@
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <simgear/scene/util/OptionsReadFileCallback.hxx>
#include <simgear/scene/util/SGNodeMasks.hxx>
#include <simgear/debug/ErrorReportingCallback.hxx>
#include "SGNodeTriangles.hxx"
#include "GroundLightManager.hxx"
@@ -55,9 +56,11 @@ typedef std::list<SGDirectionalLightBin> SGDirectionalLightListBin;
#define SG_SIMPLIFIER_RATIO (0.001)
#define SG_SIMPLIFIER_MAX_LENGTH (1000.0)
#define SG_SIMPLIFIER_MAX_ERROR (2000.0)
#define SG_TILE_MIN_EXPIRY (180.0)
using namespace simgear;
using ReadResult = osgDB::ReaderWriter::ReadResult;
// QuadTreeBuilder is used by Random Objects Generator
typedef std::pair<osg::Node*, int> ModelLOD;
struct MakeQuadLeaf {
@@ -97,47 +100,59 @@ public:
SG_LOG( SG_TERRAIN, SG_DEBUG, "SGTileDetailsCallback::~SGTileDetailsCallback() num cbs left " << num_tdcb );
}
virtual osgDB::ReaderWriter::ReadResult readNode(
const std::string&, const osgDB::Options*)
ReadResult readNode(const std::string&, const osgDB::Options*) override
{
SGMaterialLibPtr matlib;
osg::ref_ptr<SGMaterialCache> matcache;
osg::ref_ptr<osg::Group> group = new osg::Group;
group->setDataVariance(osg::Object::STATIC);
osg::ref_ptr<osg::Group> group;
simgear::ErrorReportContext ec{"btg", _path};
// generate textured triangle list
std::vector<SGTriangleInfo> matTris;
GetNodeTriangles nodeTris(_gbs_center, &matTris);
_rootNode->accept( nodeTris );
try {
group = new osg::Group;
SGMaterialLibPtr matlib;
osg::ref_ptr<SGMaterialCache> matcache;
group->setDataVariance(osg::Object::STATIC);
// build matcache
matlib = _options->getMaterialLib();
if (matlib) {
SGGeod geodPos = SGGeod::fromCart(_gbs_center);
matcache = matlib->generateMatCache(geodPos);
}
#if 0
// TEST : See if we can regenerate landclass shapes from node
for ( unsigned int i=0; i<matTris.size(); i++ ) {
matTris[i].dumpBorder(_gbs_center);
}
#endif
// generate textured triangle list
std::vector<SGTriangleInfo> matTris;
GetNodeTriangles nodeTris(_gbs_center, &matTris);
_rootNode->accept( nodeTris );
osg::Node* node = loadTerrain();
if (node) {
group->addChild(node);
}
// build matcache
matlib = _options->getMaterialLib();
if (matlib) {
SGGeod geodPos = SGGeod::fromCart(_gbs_center);
matcache = matlib->generateMatCache(geodPos);
}
#if 0
// TEST : See if we can regenerate landclass shapes from node
for ( unsigned int i=0; i<matTris.size(); i++ ) {
matTris[i].dumpBorder(_gbs_center);
}
#endif
osg::LOD* lightLOD = generateLightingTileObjects(matTris, matcache);
if (lightLOD) {
group->addChild(lightLOD);
}
osg::Node* node = loadTerrain();
if (node) {
group->addChild(node);
}
osg::LOD* objectLOD = generateRandomTileObjects(matTris, matcache);
if (objectLOD) {
group->addChild(objectLOD);
osg::LOD* lightLOD = generateLightingTileObjects(matTris, matcache);
if (lightLOD) {
group->addChild(lightLOD);
}
osg::LOD* objectLOD = generateRandomTileObjects(matTris, matcache);
if (objectLOD) {
group->addChild(objectLOD);
}
} catch (sg_exception& sge) {
simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::BTGLoad,
"Failed to load BTG file:" + sge.getFormattedMessage(),
sge.getLocation());
return ReadResult::ERROR_IN_READING_FILE;
} catch (std::bad_alloc &e) {
simgear::reportFailure(simgear::LoadFailure::OutOfMemory, simgear::ErrorCode::BTGLoad,
"Out of memory loading tile details", sg_location{_path});
return ReadResult::INSUFFICIENT_MEMORY_TO_LOAD;
}
return group.release();

View File

@@ -343,7 +343,7 @@ public:
* Schedule this audio sample to stop (or start) playing.
*/
inline void set_out_of_range(bool oor = true) {
_out_of_range = oor; _playing = (!oor && _loop); _changed = true;
_out_of_range = oor; _changed = true;
}
/**

View File

@@ -347,7 +347,9 @@ SGXmlSound::update (double dt)
// else
// if a property is defined then test if it's value is FALSE
// or if the mode is IN_TRANSIT then
// test whether the current value matches the previous value.
// test whether the current value matches the previous value,
// else
// check if out of range.
if ( // Lisp, anyone?
(_condition && !_condition->test()) ||
(!_condition && _property &&
@@ -355,7 +357,8 @@ SGXmlSound::update (double dt)
!curr_value ||
( (_mode == SGXmlSound::IN_TRANSIT) && (curr_value == _prev_value) )
)
)
) ||
_sample->test_out_of_range()
)
{
if ((_mode != SGXmlSound::IN_TRANSIT) || (_stopping > MAX_TRANSIT_TIME))

View File

@@ -1 +0,0 @@
2020.3.8