Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
711cc512c5 | ||
|
|
d0dee701a9 | ||
|
|
e87a671942 | ||
|
|
234abdf85c | ||
|
|
e5bef3f97f | ||
|
|
af0f7676c4 | ||
|
|
a3bdfab17b | ||
|
|
44bae773a0 | ||
|
|
5fe527a2d1 | ||
|
|
b79f03c96c | ||
|
|
631fa62495 | ||
|
|
a157e50302 | ||
|
|
70e6b6b13f | ||
|
|
c457561472 | ||
|
|
2b5ac6350d | ||
|
|
1c30b29168 | ||
|
|
ce9f476ddb | ||
|
|
2621418d3a | ||
|
|
174b341bef | ||
|
|
df33713069 | ||
|
|
cde75530fe |
+1
-1
@@ -1 +1 @@
|
|||||||
2020.3.10
|
2020.3.13
|
||||||
|
|||||||
@@ -298,8 +298,8 @@ namespace canvas
|
|||||||
{
|
{
|
||||||
if( camera.valid() && Canvas::getSystemAdapter() )
|
if( camera.valid() && Canvas::getSystemAdapter() )
|
||||||
Canvas::getSystemAdapter()->removeCamera(camera.get());
|
Canvas::getSystemAdapter()->removeCamera(camera.get());
|
||||||
camera.release();
|
camera = nullptr;
|
||||||
texture.release();
|
texture = nullptr;
|
||||||
|
|
||||||
_flags &= ~AVAILABLE;
|
_flags &= ~AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <simgear_config.h>
|
#include <simgear_config.h>
|
||||||
|
|
||||||
#include "ErrorReportingCallback.hxx"
|
#include "ErrorReportingCallback.hxx"
|
||||||
|
#include "logstream.hxx"
|
||||||
|
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
|
||||||
@@ -27,6 +28,31 @@ static ErrorReportCallback static_callback;
|
|||||||
static ContextCallback static_contextCallback;
|
static ContextCallback static_contextCallback;
|
||||||
|
|
||||||
|
|
||||||
|
string_list static_errorNames = {
|
||||||
|
"shader/effect",
|
||||||
|
"loading texture",
|
||||||
|
"XML/animation load",
|
||||||
|
"3D model load",
|
||||||
|
"loading BTG",
|
||||||
|
"sceanrio load",
|
||||||
|
"UI dialog load",
|
||||||
|
"loading Audio/FX",
|
||||||
|
"Nasal/commnad load of XML",
|
||||||
|
"aircraft-systems",
|
||||||
|
"loading input/joystick config",
|
||||||
|
"load AI/traffic",
|
||||||
|
"from TerraSync"};
|
||||||
|
|
||||||
|
string_list static_errorTypeNames = {
|
||||||
|
"unknown",
|
||||||
|
"not found",
|
||||||
|
"out of memory",
|
||||||
|
"bad header",
|
||||||
|
"bad data",
|
||||||
|
"misconfigured",
|
||||||
|
"disk IO/permissions",
|
||||||
|
"network IO"};
|
||||||
|
|
||||||
void setErrorReportCallback(ErrorReportCallback cb)
|
void setErrorReportCallback(ErrorReportCallback cb)
|
||||||
{
|
{
|
||||||
static_callback = cb;
|
static_callback = cb;
|
||||||
@@ -53,6 +79,7 @@ static FailureCallback static_failureCallback;
|
|||||||
void reportFailure(LoadFailure type, ErrorCode code, const std::string& details, sg_location loc)
|
void reportFailure(LoadFailure type, ErrorCode code, const std::string& details, sg_location loc)
|
||||||
{
|
{
|
||||||
if (!static_failureCallback) {
|
if (!static_failureCallback) {
|
||||||
|
SG_LOG(SG_GENERAL, SG_WARN, "Error:" << static_errorTypeNames.at(static_cast<int>(type)) << " from " << static_errorNames.at(static_cast<int>(code)) << "::" << details << "\n\t" << loc.asString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +89,9 @@ void reportFailure(LoadFailure type, ErrorCode code, const std::string& details,
|
|||||||
void reportFailure(LoadFailure type, ErrorCode code, const std::string& details, const SGPath& path)
|
void reportFailure(LoadFailure type, ErrorCode code, const std::string& details, const SGPath& path)
|
||||||
{
|
{
|
||||||
if (!static_failureCallback) {
|
if (!static_failureCallback) {
|
||||||
|
// if no callback is registered, log here instead
|
||||||
|
SG_LOG(SG_GENERAL, SG_WARN, "Error:" << static_errorTypeNames.at(static_cast<int>(type)) << " from " << static_errorNames.at(static_cast<int>(code)) << "::" << details << "\n\t" << path);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -774,7 +774,7 @@ private:
|
|||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
SG_LOG(SG_TERRASYNC, SG_WARN, "removal failed for:" << path);
|
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,
|
SG_LOG(SG_TERRASYNC, SG_WARN,
|
||||||
"failed to update entry:" << relativePath << " status/code: "
|
"failed to update entry:" << relativePath << " status/code: "
|
||||||
<< innerResultCodeAsString(fileStatus)
|
<< innerResultCodeAsString(fileStatus)
|
||||||
<< "/" << fileStatus);
|
<< "/" << fileStatus
|
||||||
|
<< "\nrepo:" << baseUrl);
|
||||||
|
|
||||||
simgear::reportFailure(simgear::LoadFailure::NetworkError, simgear::ErrorCode::TerraSync,
|
simgear::reportFailure(simgear::LoadFailure::NetworkError, simgear::ErrorCode::TerraSync,
|
||||||
"failed to update entry:" + innerResultCodeAsString(fileStatus),
|
"failed to update entry:" + innerResultCodeAsString(fileStatus),
|
||||||
|
|||||||
@@ -48,9 +48,11 @@ static std::string gzErrorMessage(gzFile fd)
|
|||||||
|
|
||||||
if (errNum == Z_ERRNO) {
|
if (errNum == Z_ERRNO) {
|
||||||
return simgear::strutils::error_string(errno);
|
return simgear::strutils::error_string(errno);
|
||||||
} else {
|
} else if (gzMsg) {
|
||||||
return {gzMsg};
|
return {gzMsg};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return {"GZError: no string code for code:" + std::to_string(errNum)};
|
||||||
}
|
}
|
||||||
|
|
||||||
void sgReadChar ( gzFile fd, char *var )
|
void sgReadChar ( gzFile fd, char *var )
|
||||||
|
|||||||
@@ -74,6 +74,22 @@ public:
|
|||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const T& value_or(const T& defaultValue) const
|
||||||
|
{
|
||||||
|
if (!_haveValue) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
T& value_or(T& defaultValue) const
|
||||||
|
{
|
||||||
|
if (!_haveValue) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
T& value()
|
T& value()
|
||||||
{
|
{
|
||||||
if (!_haveValue) {
|
if (!_haveValue) {
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ setFlag( int& mode,
|
|||||||
string message = "Unrecognized flag value '";
|
string message = "Unrecognized flag value '";
|
||||||
message += flag;
|
message += flag;
|
||||||
message += '\'';
|
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 ";
|
string message = "Root element name is ";
|
||||||
message += name;
|
message += name;
|
||||||
message += "; expected PropertyList";
|
message += "; expected PropertyList";
|
||||||
throw sg_io_exception(message, location, SG_ORIGIN);
|
throw sg_io_exception(message, location, SG_ORIGIN, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for an include.
|
// Check for an include.
|
||||||
@@ -188,7 +188,7 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
|
|||||||
{
|
{
|
||||||
string message ="Cannot open file ";
|
string message ="Cannot open file ";
|
||||||
message += attval;
|
message += attval;
|
||||||
throw sg_io_exception(message, location, SG_ORIGIN);
|
throw sg_io_exception(message, location, SG_ORIGIN, false);
|
||||||
}
|
}
|
||||||
readProperties(path, _root, 0, _extended);
|
readProperties(path, _root, 0, _extended);
|
||||||
} catch (sg_io_exception &e) {
|
} catch (sg_io_exception &e) {
|
||||||
@@ -278,7 +278,7 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
|
|||||||
{
|
{
|
||||||
string message ="Cannot open file ";
|
string message ="Cannot open file ";
|
||||||
message += val;
|
message += val;
|
||||||
throw sg_io_exception(message, location, SG_ORIGIN);
|
throw sg_io_exception(message, location, SG_ORIGIN, false);
|
||||||
}
|
}
|
||||||
readProperties(path, node, 0, _extended);
|
readProperties(path, node, 0, _extended);
|
||||||
}
|
}
|
||||||
@@ -353,7 +353,7 @@ PropsVisitor::endElement (const char * name)
|
|||||||
string message = "Unrecognized data type '";
|
string message = "Unrecognized data type '";
|
||||||
message += st.type;
|
message += st.type;
|
||||||
message += '\'';
|
message += '\'';
|
||||||
throw sg_io_exception(message, location, SG_ORIGIN);
|
throw sg_io_exception(message, location, SG_ORIGIN, false);
|
||||||
}
|
}
|
||||||
if( !ret )
|
if( !ret )
|
||||||
SG_LOG
|
SG_LOG
|
||||||
@@ -701,7 +701,7 @@ writeProperties (const SGPath &path, const SGPropertyNode * start_node,
|
|||||||
if (output.good()) {
|
if (output.good()) {
|
||||||
writeProperties(output, start_node, write_all, archive_flag);
|
writeProperties(output, start_node, write_all, archive_flag);
|
||||||
} else {
|
} 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;
|
break;
|
||||||
string message = "Unknown internal SGPropertyNode type";
|
string message = "Unknown internal SGPropertyNode type";
|
||||||
message += in->getType();
|
message += in->getType();
|
||||||
throw sg_error(message, SG_ORIGIN);
|
throw sg_error(message, SG_ORIGIN, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
|||||||
@@ -160,7 +160,8 @@ size_t hash_value(const Effect::Key&);
|
|||||||
|
|
||||||
Effect* makeEffect(const std::string& name,
|
Effect* makeEffect(const std::string& name,
|
||||||
bool realizeTechniques,
|
bool realizeTechniques,
|
||||||
const SGReaderWriterOptions* options);
|
const SGReaderWriterOptions* options,
|
||||||
|
const SGPath& modelPath = SGPath{});
|
||||||
|
|
||||||
Effect* makeEffect(SGPropertyNode* prop,
|
Effect* makeEffect(SGPropertyNode* prop,
|
||||||
bool realizeTechniques,
|
bool realizeTechniques,
|
||||||
|
|||||||
@@ -114,7 +114,8 @@ void mergePropertyTrees(SGPropertyNode* resultNode,
|
|||||||
|
|
||||||
Effect* makeEffect(const string& name,
|
Effect* makeEffect(const string& name,
|
||||||
bool realizeTechniques,
|
bool realizeTechniques,
|
||||||
const SGReaderWriterOptions* options)
|
const SGReaderWriterOptions* options,
|
||||||
|
const SGPath& modelPath)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(effectMutex);
|
OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(effectMutex);
|
||||||
@@ -125,8 +126,7 @@ Effect* makeEffect(const string& name,
|
|||||||
}
|
}
|
||||||
string effectFileName(name);
|
string effectFileName(name);
|
||||||
effectFileName += ".eff";
|
effectFileName += ".eff";
|
||||||
string absFileName
|
string absFileName = SGModelLib::findDataFile(effectFileName, options, modelPath);
|
||||||
= SGModelLib::findDataFile(effectFileName, options);
|
|
||||||
if (absFileName.empty()) {
|
if (absFileName.empty()) {
|
||||||
simgear::reportFailure(simgear::LoadFailure::NotFound, simgear::ErrorCode::LoadEffectsShaders, "Couldn't find Effect:" + effectFileName);
|
simgear::reportFailure(simgear::LoadFailure::NotFound, simgear::ErrorCode::LoadEffectsShaders, "Couldn't find Effect:" + effectFileName);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -197,7 +197,7 @@ Effect* makeEffect(SGPropertyNode* prop,
|
|||||||
Effect* parent = 0;
|
Effect* parent = 0;
|
||||||
if (inheritProp) {
|
if (inheritProp) {
|
||||||
//prop->removeChild("inherits-from");
|
//prop->removeChild("inherits-from");
|
||||||
parent = makeEffect(inheritProp->getStringValue(), false, options);
|
parent = makeEffect(inheritProp->getStringValue(), false, options, filePath);
|
||||||
if (parent) {
|
if (parent) {
|
||||||
Effect::Key key;
|
Effect::Key key;
|
||||||
key.unmerged = prop;
|
key.unmerged = prop;
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ bool SGMaterialLib::load( const SGPath &fg_root, const SGPath& mpath,
|
|||||||
options->setObjectCacheHint(osgDB::Options::CACHE_ALL);
|
options->setObjectCacheHint(osgDB::Options::CACHE_ALL);
|
||||||
options->setDatabasePath(fg_root.utf8Str());
|
options->setDatabasePath(fg_root.utf8Str());
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> g(d->mutex);
|
||||||
|
|
||||||
simgear::PropertyList blocks = materialblocks.getChildren("region");
|
simgear::PropertyList blocks = materialblocks.getChildren("region");
|
||||||
simgear::PropertyList::const_iterator block_iter = blocks.begin();
|
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
|
// find a material record by material name and tile center
|
||||||
SGMaterial *SGMaterialLib::find( const string& material, const SGVec2f center ) const
|
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;
|
SGMaterial *result = NULL;
|
||||||
const_material_map_iterator it = matlib.find( material );
|
const_material_map_iterator it = matlib.find( material );
|
||||||
if ( it != end() ) {
|
if (it != end()) {
|
||||||
// We now have a list of materials that match this
|
// We now have a list of materials that match this
|
||||||
// name. Find the first one that matches.
|
// name. Find the first one that matches.
|
||||||
// We start at the end of the list, as the materials
|
// We start at the end of the list, as the materials
|
||||||
// list is ordered with the smallest regions at the end.
|
// list is ordered with the smallest regions at the end.
|
||||||
material_list::const_reverse_iterator iter = it->second.rbegin();
|
material_list::const_reverse_iterator iter = it->second.rbegin();
|
||||||
while (iter != it->second.rend()) {
|
while (iter != it->second.rend()) {
|
||||||
result = *iter;
|
result = *iter;
|
||||||
@@ -184,11 +192,12 @@ SGMaterial *SGMaterialLib::find( const string& material, const SGGeod& center )
|
|||||||
SGMaterialCache *SGMaterialLib::generateMatCache(SGVec2f center)
|
SGMaterialCache *SGMaterialLib::generateMatCache(SGVec2f center)
|
||||||
{
|
{
|
||||||
SGMaterialCache* newCache = new SGMaterialCache();
|
SGMaterialCache* newCache = new SGMaterialCache();
|
||||||
|
std::lock_guard<std::mutex> g(d->mutex);
|
||||||
|
|
||||||
material_map::const_reverse_iterator it = matlib.rbegin();
|
material_map::const_reverse_iterator it = matlib.rbegin();
|
||||||
for (; it != matlib.rend(); ++it) {
|
for (; it != matlib.rend(); ++it) {
|
||||||
newCache->insert(it->first, find(it->first, center));
|
newCache->insert(it->first, internalFind(it->first, center));
|
||||||
}
|
}
|
||||||
|
|
||||||
return newCache;
|
return newCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ private:
|
|||||||
|
|
||||||
material_map matlib;
|
material_map matlib;
|
||||||
|
|
||||||
|
|
||||||
|
SGMaterial* internalFind(const std::string& material, const SGVec2f center) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|||||||
@@ -559,8 +559,8 @@ sgLoad3DModel_internal(const SGPath& path,
|
|||||||
// Some material animations (eventually all) are actually effects.
|
// Some material animations (eventually all) are actually effects.
|
||||||
makeEffectAnimations(animation_nodes, effect_nodes);
|
makeEffectAnimations(animation_nodes, effect_nodes);
|
||||||
{
|
{
|
||||||
ref_ptr<Node> modelWithEffects
|
ref_ptr<Node> modelWithEffects = instantiateEffects(group.get(), effect_nodes, options.get(),
|
||||||
= instantiateEffects(group.get(), effect_nodes, options.get());
|
path.dirPath());
|
||||||
group = static_cast<Group*>(modelWithEffects.get());
|
group = static_cast<Group*>(modelWithEffects.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,23 +16,27 @@
|
|||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#include <simgear_config.h>
|
||||||
# include <simgear_config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "SGText.hxx"
|
#include "SGText.hxx"
|
||||||
|
|
||||||
#include <simgear/math/SGMath.hxx>
|
|
||||||
#include <simgear/misc/sg_path.hxx>
|
|
||||||
#include <simgear/misc/strutils.hxx>
|
|
||||||
|
|
||||||
#include <osg/Geode>
|
#include <osg/Geode>
|
||||||
#include <osg/MatrixTransform>
|
#include <osg/MatrixTransform>
|
||||||
#include <osgText/Text>
|
#include <osgText/Text>
|
||||||
#include <osgText/Font>
|
#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;
|
using std::string;
|
||||||
|
|
||||||
class SGText::UpdateCallback : public osg::NodeCallback {
|
class SGText::UpdateCallback : public osg::NodeCallback {
|
||||||
@@ -95,9 +99,15 @@ osg::Node * SGText::appendText(const SGPropertyNode* configNode,
|
|||||||
osg::Geode * g = new osg::Geode;
|
osg::Geode * g = new osg::Geode;
|
||||||
g->addDrawable( text );
|
g->addDrawable( text );
|
||||||
|
|
||||||
SGPath path("Fonts" );
|
const std::string requestedFont = configNode->getStringValue("font","Helvetica");
|
||||||
path.append( configNode->getStringValue( "font", "Helvetica" ));
|
const SGPath fontPath = simgear::ResourceManager::instance()->findPath("Fonts/" + requestedFont);
|
||||||
text->setFont( path.utf8Str() );
|
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 ),
|
text->setCharacterSize(configNode->getDoubleValue("character-size", 1.0 ),
|
||||||
configNode->getDoubleValue("character-aspect-ratio", 1.0 ));
|
configNode->getDoubleValue("character-aspect-ratio", 1.0 ));
|
||||||
|
|||||||
@@ -457,9 +457,6 @@ SGAnimation::~SGAnimation()
|
|||||||
}
|
}
|
||||||
if (!info.empty())
|
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"
|
SG_LOG(SG_IO, SG_DEV_ALERT, "Could not find at least one of the following"
|
||||||
" objects for animation: " << info << " in file: " << _modelData.getPath());
|
" objects for animation: " << info << " in file: " << _modelData.getPath());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ public:
|
|||||||
typedef std::map<string, SGPropertyNode_ptr> EffectMap;
|
typedef std::map<string, SGPropertyNode_ptr> EffectMap;
|
||||||
using SplicingVisitor::apply;
|
using SplicingVisitor::apply;
|
||||||
MakeEffectVisitor(const SGReaderWriterOptions* options = 0)
|
MakeEffectVisitor(const SGReaderWriterOptions* options = 0)
|
||||||
: _options(options)
|
: _options(options), _modelPath(SGPath{})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual void apply(osg::Group& node);
|
virtual void apply(osg::Group& node);
|
||||||
@@ -246,10 +246,17 @@ public:
|
|||||||
_currentEffectParent = effect;
|
_currentEffectParent = effect;
|
||||||
}
|
}
|
||||||
SGPropertyNode* getDefaultEffect() { return _currentEffectParent; }
|
SGPropertyNode* getDefaultEffect() { return _currentEffectParent; }
|
||||||
|
|
||||||
|
void setModelPath(const SGPath& p)
|
||||||
|
{
|
||||||
|
_modelPath = p;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EffectMap _effectMap;
|
EffectMap _effectMap;
|
||||||
SGPropertyNode_ptr _currentEffectParent;
|
SGPropertyNode_ptr _currentEffectParent;
|
||||||
osg::ref_ptr<const SGReaderWriterOptions> _options;
|
osg::ref_ptr<const SGReaderWriterOptions> _options;
|
||||||
|
SGPath _modelPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
void MakeEffectVisitor::apply(osg::Group& node)
|
void MakeEffectVisitor::apply(osg::Group& node)
|
||||||
@@ -287,7 +294,7 @@ void MakeEffectVisitor::apply(osg::Geode& geode)
|
|||||||
makeParametersFromStateSet(ssRoot, ss);
|
makeParametersFromStateSet(ssRoot, ss);
|
||||||
SGPropertyNode_ptr effectRoot = new SGPropertyNode;
|
SGPropertyNode_ptr effectRoot = new SGPropertyNode;
|
||||||
effect::mergePropertyTrees(effectRoot, ssRoot, _currentEffectParent);
|
effect::mergePropertyTrees(effectRoot, ssRoot, _currentEffectParent);
|
||||||
Effect* effect = makeEffect(effectRoot, true, _options.get());
|
Effect* effect = makeEffect(effectRoot, true, _options.get(), _modelPath);
|
||||||
EffectGeode* eg = dynamic_cast<EffectGeode*>(&geode);
|
EffectGeode* eg = dynamic_cast<EffectGeode*>(&geode);
|
||||||
if (eg) {
|
if (eg) {
|
||||||
eg->setEffect(effect);
|
eg->setEffect(effect);
|
||||||
@@ -332,7 +339,8 @@ protected:
|
|||||||
|
|
||||||
ref_ptr<Node> instantiateEffects(osg::Node* modelGroup,
|
ref_ptr<Node> instantiateEffects(osg::Node* modelGroup,
|
||||||
PropertyList& effectProps,
|
PropertyList& effectProps,
|
||||||
const SGReaderWriterOptions* options)
|
const SGReaderWriterOptions* options,
|
||||||
|
const SGPath& modelPath)
|
||||||
{
|
{
|
||||||
SGPropertyNode_ptr defaultEffectPropRoot;
|
SGPropertyNode_ptr defaultEffectPropRoot;
|
||||||
MakeEffectVisitor visitor(options);
|
MakeEffectVisitor visitor(options);
|
||||||
@@ -357,13 +365,15 @@ ref_ptr<Node> instantiateEffects(osg::Node* modelGroup,
|
|||||||
if (!defaultEffectPropRoot)
|
if (!defaultEffectPropRoot)
|
||||||
defaultEffectPropRoot = DefaultEffect::instance()->getEffect();
|
defaultEffectPropRoot = DefaultEffect::instance()->getEffect();
|
||||||
visitor.setDefaultEffect(defaultEffectPropRoot.ptr());
|
visitor.setDefaultEffect(defaultEffectPropRoot.ptr());
|
||||||
|
visitor.setModelPath(modelPath);
|
||||||
modelGroup->accept(visitor);
|
modelGroup->accept(visitor);
|
||||||
osg::NodeList& result = visitor.getResults();
|
osg::NodeList& result = visitor.getResults();
|
||||||
return ref_ptr<Node>(result[0].get());
|
return ref_ptr<Node>(result[0].get());
|
||||||
}
|
}
|
||||||
|
|
||||||
ref_ptr<Node> instantiateMaterialEffects(osg::Node* modelGroup,
|
ref_ptr<Node> instantiateMaterialEffects(osg::Node* modelGroup,
|
||||||
const SGReaderWriterOptions* options)
|
const SGReaderWriterOptions* options,
|
||||||
|
const SGPath& modelPath)
|
||||||
{
|
{
|
||||||
|
|
||||||
SGPropertyNode_ptr effect;
|
SGPropertyNode_ptr effect;
|
||||||
@@ -390,7 +400,7 @@ ref_ptr<Node> instantiateMaterialEffects(osg::Node* modelGroup,
|
|||||||
|
|
||||||
effect->addChild("default")->setBoolValue(true);
|
effect->addChild("default")->setBoolValue(true);
|
||||||
effectProps.push_back(effect);
|
effectProps.push_back(effect);
|
||||||
return instantiateEffects(modelGroup, effectProps, options);
|
return instantiateEffects(modelGroup, effectProps, options, modelPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,8 @@ public:
|
|||||||
osg::ref_ptr<osg::Node>
|
osg::ref_ptr<osg::Node>
|
||||||
instantiateEffects(osg::Node* model,
|
instantiateEffects(osg::Node* model,
|
||||||
PropertyList& effectProps,
|
PropertyList& effectProps,
|
||||||
const SGReaderWriterOptions* options);
|
const SGReaderWriterOptions* options,
|
||||||
|
const SGPath& currentDir = SGPath{});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a set of material-defined effects to a model
|
* Apply a set of material-defined effects to a model
|
||||||
@@ -112,9 +113,10 @@ instantiateEffects(osg::Node* model,
|
|||||||
*
|
*
|
||||||
* returns a copy if any nodes are changed
|
* returns a copy if any nodes are changed
|
||||||
*/
|
*/
|
||||||
osg::ref_ptr<osg::Node>
|
osg::ref_ptr<osg::Node>
|
||||||
instantiateMaterialEffects(osg::Node* model,
|
instantiateMaterialEffects(osg::Node* model,
|
||||||
const SGReaderWriterOptions* options);
|
const SGReaderWriterOptions* options,
|
||||||
|
const SGPath& modelPath = SGPath{});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform an OSG subgraph by substituting the Effects and
|
* Transform an OSG subgraph by substituting the Effects and
|
||||||
@@ -127,10 +129,11 @@ instantiateEffects(osg::Node* model,
|
|||||||
|
|
||||||
inline osg::ref_ptr<osg::Node>
|
inline osg::ref_ptr<osg::Node>
|
||||||
instantiateEffects(osg::Node* model,
|
instantiateEffects(osg::Node* model,
|
||||||
const SGReaderWriterOptions* options)
|
const SGReaderWriterOptions* options,
|
||||||
|
const SGPath& currentDir = SGPath{})
|
||||||
{
|
{
|
||||||
PropertyList effectProps;
|
PropertyList effectProps;
|
||||||
return instantiateEffects(model, effectProps, options);
|
return instantiateEffects(model, effectProps, options, currentDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // __MODEL_HXX
|
#endif // __MODEL_HXX
|
||||||
|
|||||||
@@ -512,6 +512,14 @@ void Particles::setupStaticColorComponent(float r1, float g1, float b1, float a1
|
|||||||
staticColorComponents[7] = a2;
|
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)
|
void ParticlesGlobalManager::setWindVector(const osg::Vec3& wind)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> g(d->_lock);
|
std::lock_guard<std::mutex> g(d->_lock);
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ protected:
|
|||||||
class ParticlesGlobalManager
|
class ParticlesGlobalManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~ParticlesGlobalManager() = default;
|
~ParticlesGlobalManager();
|
||||||
|
|
||||||
static ParticlesGlobalManager* instance();
|
static ParticlesGlobalManager* instance();
|
||||||
static void clear();
|
static void clear();
|
||||||
|
|||||||
@@ -267,12 +267,12 @@ public:
|
|||||||
SGVec2f texCoord = a*t0 + b*t1 + c*t2;
|
SGVec2f texCoord = a*t0 + b*t1 + c*t2;
|
||||||
|
|
||||||
// Check this random point against the object mask
|
// Check this random point against the object mask
|
||||||
// red channel.
|
// blue channel.
|
||||||
osg::Image* img = object_mask->getImage();
|
osg::Image* img = object_mask->getImage();
|
||||||
unsigned int x = (int) (img->s() * texCoord.x()) % img->s();
|
unsigned int x = (int) (img->s() * texCoord.x()) % img->s();
|
||||||
unsigned int y = (int) (img->t() * texCoord.y()) % img->t();
|
unsigned int y = (int) (img->t() * texCoord.y()) % img->t();
|
||||||
|
|
||||||
if (mt_rand(&seed) < img->getColor(x, y).r()) {
|
if (mt_rand(&seed) < img->getColor(x, y).b()) {
|
||||||
points.push_back(randomPoint);
|
points.push_back(randomPoint);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -192,12 +192,12 @@ public:
|
|||||||
SGVec2f texCoord = a*t0 + b*t1 + c*t2;
|
SGVec2f texCoord = a*t0 + b*t1 + c*t2;
|
||||||
|
|
||||||
// Check this random point against the object mask
|
// Check this random point against the object mask
|
||||||
// red channel.
|
// blue channel.
|
||||||
osg::Image* img = object_mask->getImage();
|
osg::Image* img = object_mask->getImage();
|
||||||
unsigned int x = (int) (img->s() * texCoord.x()) % img->s();
|
unsigned int x = (int) (img->s() * texCoord.x()) % img->s();
|
||||||
unsigned int y = (int) (img->t() * texCoord.y()) % img->t();
|
unsigned int y = (int) (img->t() * texCoord.y()) % img->t();
|
||||||
|
|
||||||
if (mt_rand(&seed) < img->getColor(x, y).r()) {
|
if (mt_rand(&seed) < img->getColor(x, y).b()) {
|
||||||
points.push_back(randomPoint);
|
points.push_back(randomPoint);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/scene/util/OptionsReadFileCallback.hxx>
|
#include <simgear/scene/util/OptionsReadFileCallback.hxx>
|
||||||
#include <simgear/scene/util/SGNodeMasks.hxx>
|
#include <simgear/scene/util/SGNodeMasks.hxx>
|
||||||
|
#include <simgear/debug/ErrorReportingCallback.hxx>
|
||||||
|
|
||||||
#include "SGNodeTriangles.hxx"
|
#include "SGNodeTriangles.hxx"
|
||||||
#include "GroundLightManager.hxx"
|
#include "GroundLightManager.hxx"
|
||||||
@@ -55,9 +56,11 @@ typedef std::list<SGDirectionalLightBin> SGDirectionalLightListBin;
|
|||||||
#define SG_SIMPLIFIER_RATIO (0.001)
|
#define SG_SIMPLIFIER_RATIO (0.001)
|
||||||
#define SG_SIMPLIFIER_MAX_LENGTH (1000.0)
|
#define SG_SIMPLIFIER_MAX_LENGTH (1000.0)
|
||||||
#define SG_SIMPLIFIER_MAX_ERROR (2000.0)
|
#define SG_SIMPLIFIER_MAX_ERROR (2000.0)
|
||||||
#define SG_TILE_MIN_EXPIRY (180.0)
|
|
||||||
using namespace simgear;
|
using namespace simgear;
|
||||||
|
|
||||||
|
using ReadResult = osgDB::ReaderWriter::ReadResult;
|
||||||
|
|
||||||
// QuadTreeBuilder is used by Random Objects Generator
|
// QuadTreeBuilder is used by Random Objects Generator
|
||||||
typedef std::pair<osg::Node*, int> ModelLOD;
|
typedef std::pair<osg::Node*, int> ModelLOD;
|
||||||
struct MakeQuadLeaf {
|
struct MakeQuadLeaf {
|
||||||
@@ -97,47 +100,59 @@ public:
|
|||||||
SG_LOG( SG_TERRAIN, SG_DEBUG, "SGTileDetailsCallback::~SGTileDetailsCallback() num cbs left " << num_tdcb );
|
SG_LOG( SG_TERRAIN, SG_DEBUG, "SGTileDetailsCallback::~SGTileDetailsCallback() num cbs left " << num_tdcb );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual osgDB::ReaderWriter::ReadResult readNode(
|
ReadResult readNode(const std::string&, const osgDB::Options*) override
|
||||||
const std::string&, const osgDB::Options*)
|
|
||||||
{
|
{
|
||||||
SGMaterialLibPtr matlib;
|
osg::ref_ptr<osg::Group> group;
|
||||||
osg::ref_ptr<SGMaterialCache> matcache;
|
simgear::ErrorReportContext ec{"btg", _path};
|
||||||
|
|
||||||
osg::ref_ptr<osg::Group> group = new osg::Group;
|
try {
|
||||||
group->setDataVariance(osg::Object::STATIC);
|
group = new osg::Group;
|
||||||
|
SGMaterialLibPtr matlib;
|
||||||
|
osg::ref_ptr<SGMaterialCache> matcache;
|
||||||
|
group->setDataVariance(osg::Object::STATIC);
|
||||||
|
|
||||||
// generate textured triangle list
|
// generate textured triangle list
|
||||||
std::vector<SGTriangleInfo> matTris;
|
std::vector<SGTriangleInfo> matTris;
|
||||||
GetNodeTriangles nodeTris(_gbs_center, &matTris);
|
GetNodeTriangles nodeTris(_gbs_center, &matTris);
|
||||||
_rootNode->accept( nodeTris );
|
_rootNode->accept( nodeTris );
|
||||||
|
|
||||||
// build matcache
|
// build matcache
|
||||||
matlib = _options->getMaterialLib();
|
matlib = _options->getMaterialLib();
|
||||||
if (matlib) {
|
if (matlib) {
|
||||||
SGGeod geodPos = SGGeod::fromCart(_gbs_center);
|
SGGeod geodPos = SGGeod::fromCart(_gbs_center);
|
||||||
matcache = matlib->generateMatCache(geodPos);
|
matcache = matlib->generateMatCache(geodPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// TEST : See if we can regenerate landclass shapes from node
|
// TEST : See if we can regenerate landclass shapes from node
|
||||||
for ( unsigned int i=0; i<matTris.size(); i++ ) {
|
for ( unsigned int i=0; i<matTris.size(); i++ ) {
|
||||||
matTris[i].dumpBorder(_gbs_center);
|
matTris[i].dumpBorder(_gbs_center);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
osg::Node* node = loadTerrain();
|
osg::Node* node = loadTerrain();
|
||||||
if (node) {
|
if (node) {
|
||||||
group->addChild(node);
|
group->addChild(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::LOD* lightLOD = generateLightingTileObjects(matTris, matcache);
|
osg::LOD* lightLOD = generateLightingTileObjects(matTris, matcache);
|
||||||
if (lightLOD) {
|
if (lightLOD) {
|
||||||
group->addChild(lightLOD);
|
group->addChild(lightLOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::LOD* objectLOD = generateRandomTileObjects(matTris, matcache);
|
osg::LOD* objectLOD = generateRandomTileObjects(matTris, matcache);
|
||||||
if (objectLOD) {
|
if (objectLOD) {
|
||||||
group->addChild(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();
|
return group.release();
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ public:
|
|||||||
* Schedule this audio sample to stop (or start) playing.
|
* Schedule this audio sample to stop (or start) playing.
|
||||||
*/
|
*/
|
||||||
inline void set_out_of_range(bool oor = true) {
|
inline void set_out_of_range(bool oor = true) {
|
||||||
_out_of_range = oor; _playing = (!oor && _loop); _changed = true;
|
_out_of_range = oor; _changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -347,7 +347,9 @@ SGXmlSound::update (double dt)
|
|||||||
// else
|
// else
|
||||||
// if a property is defined then test if it's value is FALSE
|
// if a property is defined then test if it's value is FALSE
|
||||||
// or if the mode is IN_TRANSIT then
|
// 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?
|
if ( // Lisp, anyone?
|
||||||
(_condition && !_condition->test()) ||
|
(_condition && !_condition->test()) ||
|
||||||
(!_condition && _property &&
|
(!_condition && _property &&
|
||||||
@@ -355,7 +357,8 @@ SGXmlSound::update (double dt)
|
|||||||
!curr_value ||
|
!curr_value ||
|
||||||
( (_mode == SGXmlSound::IN_TRANSIT) && (curr_value == _prev_value) )
|
( (_mode == SGXmlSound::IN_TRANSIT) && (curr_value == _prev_value) )
|
||||||
)
|
)
|
||||||
)
|
) ||
|
||||||
|
_sample->test_out_of_range()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ((_mode != SGXmlSound::IN_TRANSIT) || (_stopping > MAX_TRANSIT_TIME))
|
if ((_mode != SGXmlSound::IN_TRANSIT) || (_stopping > MAX_TRANSIT_TIME))
|
||||||
|
|||||||
Reference in New Issue
Block a user