TerraSync: set scenery path suffixes explicitly

This commit is contained in:
James Turner
2021-06-11 10:00:54 +01:00
parent 1a6bf3c284
commit 9ec9d8e423
2 changed files with 15 additions and 25 deletions
+11 -23
View File
@@ -1124,12 +1124,10 @@ void SGTerraSync::setRoot(SGPropertyNode_ptr root)
{ {
if (!root) { if (!root) {
_terraRoot.clear(); _terraRoot.clear();
_renderingRoot.clear();
return; return;
} }
_terraRoot = root->getNode("/sim/terrasync",true); _terraRoot = root->getNode("/sim/terrasync",true);
_renderingRoot = root->getNode("/sim/rendering", true);
} }
void SGTerraSync::init() void SGTerraSync::init()
@@ -1249,7 +1247,6 @@ void SGTerraSync::unbind()
_stalledNode.clear(); _stalledNode.clear();
_activeNode.clear(); _activeNode.clear();
_cacheHits.clear(); _cacheHits.clear();
_renderingRoot.clear();
_busyNode.clear(); _busyNode.clear();
_updateCountNode.clear(); _updateCountNode.clear();
_errorCountNode.clear(); _errorCountNode.clear();
@@ -1327,24 +1324,6 @@ void SGTerraSync::syncAirportsModels()
_workerThread->request(a); _workerThread->request(a);
} }
string_list SGTerraSync::getSceneryPathSuffixes() const
{
string_list scenerySuffixes;
for (auto node : _renderingRoot->getChildren("scenery-path-suffix")) {
if (node->getBoolValue("enabled", true) && node->hasValue("name")) {
scenerySuffixes.push_back(node->getStringValue("name"));
}
}
if (scenerySuffixes.empty()) {
// if preferences didn't load, use some default
scenerySuffixes = {"Objects", "Terrain"}; // default values
}
return scenerySuffixes;
}
bool isOSMSuffix(const std::string& suffix) bool isOSMSuffix(const std::string& suffix)
{ {
return (suffix == "Buildings") || (suffix == "Roads") || (suffix == "Pylons") || (suffix == "Details"); return (suffix == "Buildings") || (suffix == "Roads") || (suffix == "Pylons") || (suffix == "Details");
@@ -1356,7 +1335,11 @@ void SGTerraSync::syncAreaByPath(const std::string& aPath)
return; return;
} }
for (const auto& suffix : getSceneryPathSuffixes()) { if (_sceneryPathSuffixes.empty()) {
throw sg_exception("SGTerraSync::syncAreaByPath called before scenery suffixes were defined.");
}
for (const auto& suffix : _sceneryPathSuffixes) {
const auto dir = suffix + "/" + aPath; const auto dir = suffix + "/" + aPath;
if (_workerThread->isDirActive(dir)) { if (_workerThread->isDirActive(dir)) {
continue; continue;
@@ -1373,13 +1356,18 @@ bool SGTerraSync::scheduleTile(const SGBucket& bucket)
return true; return true;
} }
void SGTerraSync::setSceneryPathSuffixes(const string_list& suffixes)
{
_sceneryPathSuffixes = suffixes;
}
bool SGTerraSync::isTileDirPending(const std::string& sceneryDir) const bool SGTerraSync::isTileDirPending(const std::string& sceneryDir) const
{ {
if (!_workerThread->isRunning()) { if (!_workerThread->isRunning()) {
return false; return false;
} }
for (const auto& suffix : getSceneryPathSuffixes()) { for (const auto& suffix : _sceneryPathSuffixes) {
// don't wait on OSM dirs, even if enabled // don't wait on OSM dirs, even if enabled
if (isOSMSuffix(suffix)) { if (isOSMSuffix(suffix)) {
continue; continue;
+4 -2
View File
@@ -66,6 +66,8 @@ public:
void setRoot(SGPropertyNode_ptr root); void setRoot(SGPropertyNode_ptr root);
void setSceneryPathSuffixes(const string_list& suffixes);
/// retrive the associated log object, for displaying log /// retrive the associated log object, for displaying log
/// output somewhere (a UI, presumably) /// output somewhere (a UI, presumably)
BufferedLogCallback* log() const BufferedLogCallback* log() const
@@ -86,7 +88,6 @@ public:
protected: protected:
void syncAirportsModels(); void syncAirportsModels();
string_list getSceneryPathSuffixes() const;
class WorkerThread; class WorkerThread;
@@ -96,7 +97,6 @@ private:
private: private:
WorkerThread* _workerThread; WorkerThread* _workerThread;
SGPropertyNode_ptr _terraRoot; SGPropertyNode_ptr _terraRoot;
SGPropertyNode_ptr _renderingRoot;
SGPropertyNode_ptr _stalledNode; SGPropertyNode_ptr _stalledNode;
SGPropertyNode_ptr _cacheHits; SGPropertyNode_ptr _cacheHits;
SGPropertyNode_ptr _busyNode; SGPropertyNode_ptr _busyNode;
@@ -113,6 +113,8 @@ private:
SGPropertyNode_ptr _extractPendingKbytesNode; SGPropertyNode_ptr _extractPendingKbytesNode;
SGPropertyNode_ptr _maxErrorsNode; SGPropertyNode_ptr _maxErrorsNode;
string_list _sceneryPathSuffixes;
// we manually bind+init TerraSync during early startup // we manually bind+init TerraSync during early startup
// to get better overlap of slow operations (Shared Models sync // to get better overlap of slow operations (Shared Models sync
// and nav-cache rebuild). As a result we need to track the bind/init // and nav-cache rebuild). As a result we need to track the bind/init