mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-25 21:48:41 -06:00
Merge branch 'develop' of github.com:OpenSpace/OpenSpace into pr/kameleonvolume
Conflicts: src/engine/openspaceengine.cpp
This commit is contained in:
@@ -113,31 +113,8 @@ documentation::Documentation ConfigurationManager::Documentation() {
|
||||
new TableVerifier({
|
||||
{
|
||||
"*",
|
||||
new TableVerifier({
|
||||
{
|
||||
ConfigurationManager::PartType,
|
||||
new StringInListVerifier({
|
||||
// List from logfactory.cpp::createLog
|
||||
"text", "html"
|
||||
}),
|
||||
"The type of the new log to be generated."
|
||||
},
|
||||
{
|
||||
ConfigurationManager::PartFile,
|
||||
new StringVerifier,
|
||||
"The filename to which the log will be written."
|
||||
},
|
||||
{
|
||||
ConfigurationManager::PartAppend,
|
||||
new BoolVerifier,
|
||||
"Determines whether the file will be cleared at "
|
||||
"startup or if the contents will be appended to "
|
||||
"previous runs.",
|
||||
Optional::Yes
|
||||
}
|
||||
}),
|
||||
"Additional log files",
|
||||
Optional::Yes
|
||||
new ReferencingVerifier("core_logfactory"),
|
||||
"Additional log files"
|
||||
}
|
||||
}),
|
||||
"Per default, log messages are written to the console, the "
|
||||
|
||||
@@ -162,7 +162,10 @@ std::shared_ptr<DownloadManager::FileFuture> DownloadManager::downloadFile(
|
||||
std::shared_ptr<FileFuture> future = std::make_shared<FileFuture>(file.filename());
|
||||
errno = 0;
|
||||
FILE* fp = fopen(file.path().c_str(), "wb"); // write binary
|
||||
ghoul_assert(fp != nullptr, "Could not open/create file:\n" << file.path().c_str() << " \nerrno: " << errno);
|
||||
ghoul_assert(
|
||||
fp != nullptr,
|
||||
"Could not open/create file:\n" + file.path() + " \nerrno: " + std::to_string(errno)
|
||||
);
|
||||
|
||||
//LDEBUG("Start downloading file: '" << url << "' into file '" << file.path() << "'");
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
|
||||
#include <openspace/engine/logfactory.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/misc/exception.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
@@ -51,37 +54,105 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation LogFactoryDocumentation() {
|
||||
using namespace documentation;
|
||||
|
||||
return {
|
||||
"LogFactory",
|
||||
"core_logfactory",
|
||||
{
|
||||
{
|
||||
keyType,
|
||||
new StringInListVerifier({
|
||||
// List from createLog
|
||||
valueTextLog, valueHtmlLog
|
||||
}),
|
||||
"The type of the new log to be generated."
|
||||
},
|
||||
{
|
||||
keyFilename,
|
||||
new StringVerifier,
|
||||
"The filename to which the log will be written."
|
||||
},
|
||||
{
|
||||
keyAppend,
|
||||
new BoolVerifier,
|
||||
"Determines whether the file will be cleared at startup or if the "
|
||||
"contents will be appended to previous runs.",
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
keyTimeStamping,
|
||||
new BoolVerifier,
|
||||
"Determines whether the log entires should be stamped with the time at "
|
||||
"which the message was logged.",
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
keyDateStamping,
|
||||
new BoolVerifier,
|
||||
"Determines whether the log entries should be stamped with the date at "
|
||||
"which the message was logged.",
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
keyCategoryStamping,
|
||||
new BoolVerifier,
|
||||
"Determines whether the log entries should be stamped with the "
|
||||
"category that creates the log message.",
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
keyLogLevelStamping,
|
||||
new BoolVerifier,
|
||||
"Determines whether the log entries should be stamped with the log level "
|
||||
"that was used to create the log message.",
|
||||
Optional::Yes
|
||||
}
|
||||
},
|
||||
Exhaustive::Yes
|
||||
};
|
||||
}
|
||||
|
||||
std::unique_ptr<ghoul::logging::Log> createLog(const ghoul::Dictionary& dictionary) {
|
||||
using namespace std::string_literals;
|
||||
std::string type;
|
||||
bool typeSuccess = dictionary.getValue(keyType, type);
|
||||
if (!typeSuccess) {
|
||||
throw ghoul::RuntimeError(
|
||||
"Requested log did not contain key '"s + keyType + "'", "LogFactory"
|
||||
);
|
||||
}
|
||||
|
||||
std::string filename;
|
||||
bool filenameSuccess = dictionary.getValue(keyFilename, filename);
|
||||
if (!filenameSuccess) {
|
||||
throw ghoul::RuntimeError(
|
||||
"Requested log did not contain key '"s + keyFilename + "'", "LogFactory"
|
||||
);
|
||||
}
|
||||
filename = absPath(filename);
|
||||
documentation::testSpecificationAndThrow(
|
||||
LogFactoryDocumentation(),
|
||||
dictionary,
|
||||
"LogFactory"
|
||||
);
|
||||
|
||||
// 'type' and 'filename' are required keys
|
||||
std::string type = dictionary.value<std::string>(keyType);
|
||||
std::string filename = absPath(dictionary.value<std::string>(keyFilename));
|
||||
|
||||
// the rest are optional
|
||||
bool append = true;
|
||||
dictionary.getValue(keyAppend, append);
|
||||
if (dictionary.hasKeyAndValue<bool>(keyAppend)) {
|
||||
dictionary.value<bool>(keyAppend);
|
||||
}
|
||||
bool timeStamp = true;
|
||||
dictionary.getValue(keyTimeStamping, timeStamp);
|
||||
if (dictionary.hasKeyAndValue<bool>(keyTimeStamping)) {
|
||||
dictionary.value<bool>(keyTimeStamping);
|
||||
}
|
||||
bool dateStamp = true;
|
||||
dictionary.getValue(keyDateStamping, dateStamp);
|
||||
if (dictionary.hasKeyAndValue<bool>(keyDateStamping)) {
|
||||
dictionary.value<bool>(keyDateStamping);
|
||||
}
|
||||
bool categoryStamp = true;
|
||||
dictionary.getValue(keyCategoryStamping, categoryStamp);
|
||||
if (dictionary.hasKeyAndValue<bool>(keyCategoryStamping)) {
|
||||
dictionary.value<bool>(keyCategoryStamping);
|
||||
}
|
||||
bool logLevelStamp = true;
|
||||
dictionary.getValue(keyLogLevelStamping, logLevelStamp);
|
||||
if (dictionary.hasKeyAndValue<bool>(keyLogLevelStamping)) {
|
||||
dictionary.value<bool>(keyLogLevelStamping);
|
||||
}
|
||||
std::string logLevel;
|
||||
dictionary.getValue(keyLogLevel, logLevel);
|
||||
if (dictionary.hasKeyAndValue<std::string>(keyLogLevel)) {
|
||||
dictionary.value<std::string>(keyLogLevel);
|
||||
}
|
||||
|
||||
|
||||
using Append = ghoul::logging::TextLog::Append;
|
||||
using TimeStamping = ghoul::logging::Log::TimeStamping;
|
||||
@@ -90,7 +161,6 @@ std::unique_ptr<ghoul::logging::Log> createLog(const ghoul::Dictionary& dictiona
|
||||
using LogLevelStamping = ghoul::logging::Log::LogLevelStamping;
|
||||
|
||||
if (type == valueHtmlLog) {
|
||||
|
||||
std::vector<std::string> cssFiles{absPath(BootstrapPath), absPath(CssPath)};
|
||||
std::vector<std::string> jsFiles{absPath(JsPath)};
|
||||
|
||||
@@ -102,7 +172,8 @@ std::unique_ptr<ghoul::logging::Log> createLog(const ghoul::Dictionary& dictiona
|
||||
dateStamp ? DateStamping::Yes : DateStamping::No,
|
||||
categoryStamp ? CategoryStamping::Yes : CategoryStamping::No,
|
||||
logLevelStamp ? LogLevelStamping::Yes : LogLevelStamping::No,
|
||||
cssFiles, jsFiles
|
||||
cssFiles,
|
||||
jsFiles
|
||||
);
|
||||
}
|
||||
else {
|
||||
@@ -141,11 +212,7 @@ std::unique_ptr<ghoul::logging::Log> createLog(const ghoul::Dictionary& dictiona
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw ghoul::RuntimeError(
|
||||
"Log with type '" + type + "' did not name a valid log", "LogFactory"
|
||||
);
|
||||
}
|
||||
ghoul_assert(false, "Missing case in the documentation for LogFactory");
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <openspace/engine/moduleengine.h>
|
||||
|
||||
#include <openspace/moduleregistration.h>
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
#include <openspace/util/openspacemodule.h>
|
||||
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
@@ -34,7 +35,7 @@
|
||||
#include "moduleengine_lua.inl"
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ModuleEngine";
|
||||
const char* _loggerCat = "ModuleEngine";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -67,7 +68,8 @@ void ModuleEngine::registerModule(std::unique_ptr<OpenSpaceModule> module) {
|
||||
);
|
||||
if (it != _modules.end()) {
|
||||
throw ghoul::RuntimeError(
|
||||
"Module name '" + module->name() + "' was registered before", "ModuleEngine"
|
||||
"Module name '" + module->name() + "' was registered before",
|
||||
"ModuleEngine"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -85,11 +87,8 @@ std::vector<OpenSpaceModule*> ModuleEngine::modules() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version
|
||||
ModuleEngine::requiredOpenGLVersion() const
|
||||
{
|
||||
using Version = ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version;
|
||||
Version version = { 0,0 };
|
||||
ghoul::systemcapabilities::Version ModuleEngine::requiredOpenGLVersion() const {
|
||||
ghoul::systemcapabilities::Version version = { 0, 0 };
|
||||
|
||||
for (const auto& m : _modules) {
|
||||
version = std::max(version, m->requiredOpenGLVersion());
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <openspace/openspace.h>
|
||||
|
||||
#include <openspace/documentation/core_registration.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/documentationengine.h>
|
||||
#include <openspace/engine/configurationmanager.h>
|
||||
#include <openspace/engine/downloadmanager.h>
|
||||
@@ -37,45 +36,32 @@
|
||||
#include <openspace/engine/syncengine.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/interaction/interactionhandler.h>
|
||||
#include <openspace/interaction/keyboardcontroller.h>
|
||||
#include <openspace/interaction/luaconsole.h>
|
||||
#include <openspace/mission/missionmanager.h>
|
||||
#include <openspace/network/networkengine.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/scripting/scriptscheduler.h>
|
||||
#include <openspace/scene/translation.h>
|
||||
#include <openspace/scene/rotation.h>
|
||||
#include <openspace/scene/scale.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/scene/translation.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <openspace/util/task.h>
|
||||
#include <openspace/util/openspacemodule.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/timemanager.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/syncbuffer.h>
|
||||
#include <openspace/util/transformationmanager.h>
|
||||
|
||||
#include <ghoul/ghoul.h>
|
||||
#include <ghoul/cmdparser/commandlineparser.h>
|
||||
#include <ghoul/cmdparser/singlecommand.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/filesystem/cachemanager.h>
|
||||
#include <ghoul/font/fontmanager.h>
|
||||
#include <ghoul/font/fontrenderer.h>
|
||||
#include <ghoul/logging/consolelog.h>
|
||||
#include <ghoul/logging/visualstudiooutputlog.h>
|
||||
#include <ghoul/lua/ghoul_lua.h>
|
||||
#include <ghoul/lua/lua_helper.h>
|
||||
#include <ghoul/lua/luastate.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/misc/exception.h>
|
||||
#include <ghoul/misc/onscopeexit.h>
|
||||
#include <ghoul/systemcapabilities/systemcapabilities>
|
||||
|
||||
#include <fstream>
|
||||
#include <queue>
|
||||
|
||||
#if defined(_MSC_VER) && defined(OPENSPACE_ENABLE_VLD)
|
||||
#include <vld.h>
|
||||
@@ -128,7 +114,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
|
||||
, _scriptEngine(new scripting::ScriptEngine)
|
||||
, _scriptScheduler(new scripting::ScriptScheduler)
|
||||
, _networkEngine(new NetworkEngine)
|
||||
, _syncEngine(std::make_unique<SyncEngine>(new SyncBuffer(4096)))
|
||||
, _syncEngine(std::make_unique<SyncEngine>(4096))
|
||||
, _commandlineParser(new ghoul::cmdparser::CommandlineParser(
|
||||
programName, ghoul::cmdparser::CommandlineParser::AllowUnknownCommands::Yes
|
||||
))
|
||||
@@ -139,7 +125,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
|
||||
, _downloadManager(nullptr)
|
||||
, _parallelConnection(new ParallelConnection)
|
||||
, _windowWrapper(std::move(windowWrapper))
|
||||
, _globalPropertyNamespace(new properties::PropertyOwner)
|
||||
, _globalPropertyNamespace(new properties::PropertyOwner(""))
|
||||
, _runTime(0.0)
|
||||
, _shutdown({false, 0.f, 0.f})
|
||||
, _isFirstRenderingFirstFrame(true)
|
||||
@@ -240,6 +226,8 @@ void OpenSpaceEngine::create(int argc, char** argv,
|
||||
LDEBUG("Creating OpenSpaceEngine");
|
||||
_engine = new OpenSpaceEngine(std::string(argv[0]), std::move(windowWrapper));
|
||||
|
||||
registerCoreClasses(DocEng);
|
||||
|
||||
// Query modules for commandline arguments
|
||||
_engine->gatherCommandlineArguments();
|
||||
|
||||
@@ -346,7 +334,6 @@ void OpenSpaceEngine::create(int argc, char** argv,
|
||||
// Register modules
|
||||
_engine->_moduleEngine->initialize();
|
||||
|
||||
registerCoreClasses(DocEng);
|
||||
// After registering the modules, the documentations for the available classes
|
||||
// can be added as well
|
||||
for (OpenSpaceModule* m : _engine->_moduleEngine->modules()) {
|
||||
@@ -451,9 +438,9 @@ void OpenSpaceEngine::initialize() {
|
||||
SysCap.logCapabilities(verbosity);
|
||||
|
||||
// Check the required OpenGL versions of the registered modules
|
||||
ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version version =
|
||||
ghoul::systemcapabilities::Version version =
|
||||
_engine->_moduleEngine->requiredOpenGLVersion();
|
||||
LINFO("Required OpenGL version: " << version.toString());
|
||||
LINFO("Required OpenGL version: " << std::to_string(version));
|
||||
|
||||
if (OpenGLCap.openGLVersion() < version) {
|
||||
throw ghoul::RuntimeError(
|
||||
@@ -848,7 +835,7 @@ void OpenSpaceEngine::preSynchronization() {
|
||||
|
||||
bool master = _windowWrapper->isMaster();
|
||||
|
||||
_syncEngine->presync(master);
|
||||
_syncEngine->preSynchronization(SyncEngine::IsMaster(master));
|
||||
if (master) {
|
||||
double dt = _windowWrapper->averageDeltaTime();
|
||||
_timeManager->preSynchronization(dt);
|
||||
@@ -880,7 +867,7 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
LTRACE("OpenSpaceEngine::postSynchronizationPreDraw(begin)");
|
||||
|
||||
bool master = _windowWrapper->isMaster();
|
||||
_syncEngine->postsync(master);
|
||||
_syncEngine->postSynchronization(SyncEngine::IsMaster(master));
|
||||
|
||||
if (_shutdown.inShutdown) {
|
||||
if (_shutdown.timer <= 0.f) {
|
||||
@@ -943,8 +930,7 @@ void OpenSpaceEngine::render(const glm::mat4& viewMatrix,
|
||||
bool showGui = _windowWrapper->hasGuiWindow() ? _windowWrapper->isGuiWindow() : true;
|
||||
if (showGui && _windowWrapper->isMaster() && _windowWrapper->isRegularRendering()) {
|
||||
_renderEngine->renderScreenLog();
|
||||
if (_console->isVisible())
|
||||
_console->render();
|
||||
_console->render();
|
||||
}
|
||||
|
||||
if (_shutdown.inShutdown) {
|
||||
@@ -973,25 +959,18 @@ void OpenSpaceEngine::postDraw() {
|
||||
|
||||
void OpenSpaceEngine::keyboardCallback(Key key, KeyModifier mod, KeyAction action) {
|
||||
for (const auto& func : _moduleCallbacks.keyboard) {
|
||||
bool consumed = func(key, mod, action);
|
||||
const bool consumed = func(key, mod, action);
|
||||
if (consumed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// @CLEANUP: Remove the commandInputButton and replace with a method just based
|
||||
// on Lua by binding a key to the Lua script toggling the console ---abock
|
||||
if (key == _console->commandInputButton()) {
|
||||
if (action == KeyAction::Press) {
|
||||
_console->toggleMode();
|
||||
}
|
||||
} else if (!_console->isVisible()) {
|
||||
// @CLEANUP: Make the interaction handler return whether a key has been consumed
|
||||
// and then pass it on to the console ---abock
|
||||
_interactionHandler->keyboardCallback(key, mod, action);
|
||||
} else {
|
||||
_console->keyboardCallback(key, mod, action);
|
||||
|
||||
const bool consoleConsumed = _console->keyboardCallback(key, mod, action);
|
||||
if (consoleConsumed) {
|
||||
return;
|
||||
}
|
||||
|
||||
_interactionHandler->keyboardCallback(key, mod, action);
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::charCallback(unsigned int codepoint, KeyModifier modifier) {
|
||||
@@ -1002,9 +981,7 @@ void OpenSpaceEngine::charCallback(unsigned int codepoint, KeyModifier modifier)
|
||||
}
|
||||
}
|
||||
|
||||
if (_console->isVisible()) {
|
||||
_console->charCallback(codepoint, modifier);
|
||||
}
|
||||
_console->charCallback(codepoint, modifier);
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::mouseButtonCallback(MouseButton button, MouseAction action) {
|
||||
|
||||
@@ -40,94 +40,40 @@
|
||||
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "SettingsEngine";
|
||||
const char* _loggerCat = "SettingsEngine";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
SettingsEngine::SettingsEngine()
|
||||
: _eyeSeparation("eyeSeparation", "Eye Separation" , 0.f, 0.f, 10.f)
|
||||
: properties::PropertyOwner("Global Properties")
|
||||
, _eyeSeparation("eyeSeparation", "Eye Separation", 0.f, 0.f, 10.f)
|
||||
, _scenes("scenes", "Scene", properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _busyWaitForDecode("busyWaitForDecode", "Busy Wait for decode", false)
|
||||
, _logSGCTOutOfOrderErrors("logSGCTOutOfOrderErrors", "Log SGCT out-of-order", false)
|
||||
, _useDoubleBuffering("useDoubleBuffering", "Use double buffering", false)
|
||||
, _spiceUseExceptions("enableSpiceExceptions", "Enable Spice Exceptions", false)
|
||||
{
|
||||
setName("Global Properties");
|
||||
|
||||
_spiceUseExceptions.onChange([this]{
|
||||
_spiceUseExceptions.onChange([this] {
|
||||
if (_spiceUseExceptions) {
|
||||
SpiceManager::ref().setExceptionHandling(SpiceManager::UseException::Yes);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
SpiceManager::ref().setExceptionHandling(SpiceManager::UseException::No);
|
||||
}
|
||||
});
|
||||
addProperty(_spiceUseExceptions);
|
||||
addProperty(_eyeSeparation);
|
||||
addProperty(_busyWaitForDecode);
|
||||
addProperty(_logSGCTOutOfOrderErrors);
|
||||
addProperty(_useDoubleBuffering);
|
||||
addProperty(_scenes);
|
||||
}
|
||||
|
||||
void SettingsEngine::initialize() {
|
||||
initEyeSeparation();
|
||||
initSceneFiles();
|
||||
initBusyWaitForDecode();
|
||||
initLogSGCTOutOfOrderErrors();
|
||||
initUseDoubleBuffering();
|
||||
}
|
||||
|
||||
void SettingsEngine::setModules(std::vector<OpenSpaceModule*> modules) {
|
||||
for (OpenSpaceModule* m : modules) {
|
||||
addPropertySubOwner(m);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsEngine::initEyeSeparation() {
|
||||
addProperty(_eyeSeparation);
|
||||
|
||||
// Set interaction to change the window's (SGCT's) eye separation
|
||||
_eyeSeparation.onChange(
|
||||
[this]() { OsEng.windowWrapper().setEyeSeparationDistance(_eyeSeparation); });
|
||||
}
|
||||
|
||||
void SettingsEngine::initBusyWaitForDecode() {
|
||||
addProperty(_busyWaitForDecode);
|
||||
_busyWaitForDecode.onChange(
|
||||
[this]() {
|
||||
LINFO((_busyWaitForDecode.value() ? "Busy wait for decode" : "Async decode"));
|
||||
});
|
||||
}
|
||||
|
||||
bool SettingsEngine::busyWaitForDecode() {
|
||||
return _busyWaitForDecode.value();
|
||||
}
|
||||
|
||||
void SettingsEngine::initLogSGCTOutOfOrderErrors() {
|
||||
addProperty(_logSGCTOutOfOrderErrors);
|
||||
_logSGCTOutOfOrderErrors.onChange(
|
||||
[this]() {
|
||||
LINFO("Turn " << (_logSGCTOutOfOrderErrors.value() ? "on" : "off") << " SGCT out of order logging");
|
||||
});
|
||||
}
|
||||
|
||||
bool SettingsEngine::logSGCTOutOfOrderErrors() {
|
||||
return _logSGCTOutOfOrderErrors.value();
|
||||
}
|
||||
|
||||
|
||||
void SettingsEngine::initUseDoubleBuffering() {
|
||||
addProperty(_useDoubleBuffering);
|
||||
_useDoubleBuffering.onChange(
|
||||
[this]() {
|
||||
LINFO("Turn " << (_useDoubleBuffering.value() ? "on" : "off") << " double buffering");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
bool SettingsEngine::useDoubleBuffering() {
|
||||
return _useDoubleBuffering.value();
|
||||
}
|
||||
|
||||
void SettingsEngine::initSceneFiles() {
|
||||
addProperty(_scenes);
|
||||
[this]() { OsEng.windowWrapper().setEyeSeparationDistance(_eyeSeparation); }
|
||||
);
|
||||
|
||||
// Load all matching files in the Scene
|
||||
// TODO: match regex with either with new ghoul readFiles or local code
|
||||
@@ -135,18 +81,36 @@ void SettingsEngine::initSceneFiles() {
|
||||
std::vector<std::string> scenes = ghoul::filesystem::Directory(sceneDir).readFiles();
|
||||
for (std::size_t i = 0; i < scenes.size(); ++i) {
|
||||
std::size_t found = scenes[i].find_last_of("/\\");
|
||||
_scenes.addOption(i, scenes[i].substr(found+1));
|
||||
_scenes.addOption(i, scenes[i].substr(found + 1));
|
||||
}
|
||||
|
||||
// Set interaction to change ConfigurationManager and schedule the load
|
||||
_scenes.onChange(
|
||||
[this]() {
|
||||
std::string sceneFile = _scenes.getDescriptionByValue(_scenes);
|
||||
OsEng.configurationManager().setValue(
|
||||
ConfigurationManager::KeyConfigScene, sceneFile);
|
||||
OsEng.renderEngine().scene()->scheduleLoadSceneFile(sceneFile);
|
||||
}
|
||||
std::string sceneFile = _scenes.getDescriptionByValue(_scenes);
|
||||
OsEng.configurationManager().setValue(
|
||||
ConfigurationManager::KeyConfigScene, sceneFile);
|
||||
OsEng.renderEngine().scene()->scheduleLoadSceneFile(sceneFile);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void SettingsEngine::setModules(const std::vector<OpenSpaceModule*>& modules) {
|
||||
for (OpenSpaceModule* m : modules) {
|
||||
addPropertySubOwner(m);
|
||||
}
|
||||
}
|
||||
|
||||
bool SettingsEngine::busyWaitForDecode() {
|
||||
return _busyWaitForDecode.value();
|
||||
}
|
||||
|
||||
bool SettingsEngine::logSGCTOutOfOrderErrors() {
|
||||
return _logSGCTOutOfOrderErrors.value();
|
||||
}
|
||||
|
||||
bool SettingsEngine::useDoubleBuffering() {
|
||||
return _useDoubleBuffering.value();
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
@@ -23,73 +23,67 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/engine/syncengine.h>
|
||||
|
||||
#include <openspace/util/syncdata.h>
|
||||
#include <openspace/util/syncbuffer.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "SyncEngine";
|
||||
}
|
||||
|
||||
|
||||
namespace openspace {
|
||||
|
||||
SyncEngine::SyncEngine(SyncBuffer* syncBuffer)
|
||||
: _syncBuffer(syncBuffer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SyncEngine::presync(bool isMaster) {
|
||||
for (const auto& syncable : _syncables) {
|
||||
syncable->presync(isMaster);
|
||||
}
|
||||
}
|
||||
|
||||
// should be called on sgct master
|
||||
void SyncEngine::encodeSyncables() {
|
||||
for (const auto& syncable : _syncables) {
|
||||
syncable->encode(_syncBuffer.get());
|
||||
}
|
||||
_syncBuffer->write();
|
||||
}
|
||||
|
||||
//should be called on sgct slaves
|
||||
void SyncEngine::decodeSyncables() {
|
||||
_syncBuffer->read();
|
||||
for (const auto& syncable : _syncables) {
|
||||
syncable->decode(_syncBuffer.get());
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::postsync(bool isMaster) {
|
||||
for (const auto& syncable : _syncables) {
|
||||
syncable->postsync(isMaster);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SyncEngine::addSyncable(Syncable* syncable) {
|
||||
_syncables.push_back(syncable);
|
||||
}
|
||||
|
||||
void SyncEngine::addSyncables(const std::vector<Syncable*>& syncables) {
|
||||
for (const auto& syncable : syncables) {
|
||||
addSyncable(syncable);
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::removeSyncable(Syncable* syncable) {
|
||||
_syncables.erase(
|
||||
std::remove(_syncables.begin(), _syncables.end(), syncable),
|
||||
_syncables.end()
|
||||
);
|
||||
}
|
||||
|
||||
SyncEngine::SyncEngine(unsigned int syncBufferSize)
|
||||
: _syncBuffer(syncBufferSize)
|
||||
{
|
||||
ghoul_assert(syncBufferSize > 0, "syncBufferSize must be bigger than 0");
|
||||
}
|
||||
|
||||
// should be called on sgct master
|
||||
void SyncEngine::encodeSyncables() {
|
||||
for (Syncable* syncable : _syncables) {
|
||||
syncable->encode(&_syncBuffer);
|
||||
}
|
||||
_syncBuffer.write();
|
||||
}
|
||||
|
||||
//should be called on sgct slaves
|
||||
void SyncEngine::decodeSyncables() {
|
||||
_syncBuffer.read();
|
||||
for (Syncable* syncable : _syncables) {
|
||||
syncable->decode(&_syncBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::preSynchronization(IsMaster isMaster) {
|
||||
for (Syncable* syncable : _syncables) {
|
||||
syncable->presync(isMaster);
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::postSynchronization(IsMaster isMaster) {
|
||||
for (Syncable* syncable : _syncables) {
|
||||
syncable->postsync(isMaster);
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::addSyncable(Syncable* syncable) {
|
||||
ghoul_assert(syncable, "synable must not be nullptr");
|
||||
|
||||
_syncables.push_back(syncable);
|
||||
}
|
||||
|
||||
void SyncEngine::addSyncables(const std::vector<Syncable*>& syncables) {
|
||||
for (Syncable* syncable : syncables) {
|
||||
ghoul_assert(syncable, "syncables must not contain any nullptr");
|
||||
addSyncable(syncable);
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::removeSyncable(Syncable* syncable) {
|
||||
_syncables.erase(
|
||||
std::remove(_syncables.begin(), _syncables.end(), syncable),
|
||||
_syncables.end()
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user