Updated Ghoul version

Started cleaning up OpenSpace
This commit is contained in:
Alexander Bock
2015-12-13 22:01:42 -08:00
parent 8260f5701d
commit e26f1d41a4
34 changed files with 304 additions and 351 deletions

View File

@@ -25,21 +25,35 @@
#ifndef __LOGFACTORY_H__
#define __LOGFACTORY_H__
#include <ghoul/misc/dictionary.h>
#include <memory>
namespace ghoul {
namespace logging {
class Log;
} // logging
} // ghoul
class Dictionary;
namespace logging {
class Log;
}
}
namespace openspace {
class LogFactory {
public:
static std::unique_ptr<ghoul::logging::Log> createLog(const ghoul::Dictionary& dictionary);
};
/**
* This function provides the capabilities to create a new ghoul::logging::Log from the
* provided ghoul::Dictionary%. The Dictionary must at least contain a <code>Type</code>
* value that determines the type of the created Log. Currently the types
* <code>HTML</code> and <code>Text</code> are supported which create a
* ghoul::logging::TextLog%, and ghoul::logging::HTMLLog respectively with both also
* require the <code>FileName</code> value for the location at which the logfile should be
* created . Both logs can be customized using the <code>Append</code>,
* <code>TimeStamping</code>, <code>DateStamping</code>, <code>CategoryStamping</code>,
* and <code>LogLevelStamping</code> values.
* \param dictionary The dictionary from which the ghoul::logging::Log should be created
* \return The created ghoul::logging::Log
* \post The return value will not be <code>nullptr</code>
* \throw ghoul::RuntimeError If there was an error creating the ghoul::logging::Log
* \sa ghoul::logging::TextLeg
* \sa ghoul::logging::HTMLLog
*/
std::unique_ptr<ghoul::logging::Log> createLog(const ghoul::Dictionary& dictionary);
} // namespace openspace

View File

@@ -25,27 +25,19 @@
#ifndef __OPENSPACEENGINE_H__
#define __OPENSPACEENGINE_H__
#include <ghoul/glm.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/util/keys.h>
#include <openspace/util/mouse.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/glm.h>
#include <ghoul/misc/dictionary.h>
#include <memory>
#include <string>
#include <vector>
namespace ghoul {
namespace cmdparser {
class CommandlineParser;
}
namespace fontrendering {
class FontManager;
}
namespace cmdparser { class CommandlineParser; }
namespace fontrendering { class FontManager; }
}
namespace openspace {
@@ -57,28 +49,17 @@ class GUI;
class RenderEngine;
class SyncBuffer;
class ModuleEngine;
class WindowWrapper;
namespace interaction {
class InteractionHandler;
}
namespace gui {
class GUI;
}
namespace scripting {
class ScriptEngine;
}
namespace network {
class ParallelConnection;
}
namespace properties {
class PropertyOwner;
}
namespace interaction { class InteractionHandler; }
namespace gui { class GUI; }
namespace scripting { class ScriptEngine; }
namespace network { class ParallelConnection; }
namespace properties { class PropertyOwner; }
class OpenSpaceEngine {
public:
static bool create(int argc, char** argv, WindowWrapper* windowWrapper, std::vector<std::string>& sgctArguments);
static bool create(int argc, char** argv, std::unique_ptr<WindowWrapper> windowWrapper, std::vector<std::string>& sgctArguments);
static void destroy();
static OpenSpaceEngine& ref();
@@ -91,27 +72,25 @@ public:
static bool findConfiguration(std::string& filename);
// Guaranteed to return a valid pointer
ConfigurationManager* configurationManager();
interaction::InteractionHandler* interactionHandler();
RenderEngine* renderEngine();
scripting::ScriptEngine* scriptEngine();
NetworkEngine* networkEngine();
LuaConsole* console();
ModuleEngine* moduleEngine();
network::ParallelConnection* parallelConnection();
properties::PropertyOwner* globalPropertyOwner();
ConfigurationManager& configurationManager();
interaction::InteractionHandler& interactionHandler();
RenderEngine& renderEngine();
scripting::ScriptEngine& scriptEngine();
NetworkEngine& networkEngine();
LuaConsole& console();
ModuleEngine& moduleEngine();
network::ParallelConnection& parallelConnection();
properties::PropertyOwner& globalPropertyOwner();
WindowWrapper& windowWrapper();
ghoul::fontrendering::FontManager& fontManager();
gui::GUI* gui();
gui::GUI& gui();
// SGCT callbacks
bool initializeGL();
void preSynchronization();
void postSynchronizationPreDraw();
void render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix);
void render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix);
void postDraw();
// void keyboardCallback(int key, int action);
void keyboardCallback(Key key, KeyModifier mod, KeyAction action);
void charCallback(unsigned int codepoint, KeyModifier mod);
void mouseButtonCallback(MouseButton button, MouseAction action);
@@ -127,40 +106,39 @@ public:
void runSettingsScripts();
private:
OpenSpaceEngine(std::string programName, WindowWrapper* windowWrapper);
OpenSpaceEngine(std::string programName, std::unique_ptr<WindowWrapper> windowWrapper);
~OpenSpaceEngine();
OpenSpaceEngine(const OpenSpaceEngine& rhs) = delete;
void clearAllWindows();
bool gatherCommandlineArguments();
bool loadSpiceKernels();
void loadFonts();
void loadFonts2();
void loadFonts();
void runScripts(const ghoul::Dictionary& scripts);
void runStartupScripts();
void configureLogging();
static OpenSpaceEngine* _engine;
ConfigurationManager* _configurationManager;
interaction::InteractionHandler* _interactionHandler;
RenderEngine* _renderEngine;
scripting::ScriptEngine* _scriptEngine;
NetworkEngine* _networkEngine;
ghoul::cmdparser::CommandlineParser* _commandlineParser;
LuaConsole* _console;
ModuleEngine* _moduleEngine;
gui::GUI* _gui;
network::ParallelConnection* _parallelConnection;
WindowWrapper* _windowWrapper;
ghoul::fontrendering::FontManager*_fontManager;
std::unique_ptr<ConfigurationManager> _configurationManager;
std::unique_ptr<interaction::InteractionHandler> _interactionHandler;
std::unique_ptr<RenderEngine> _renderEngine;
std::unique_ptr<scripting::ScriptEngine> _scriptEngine;
std::unique_ptr<NetworkEngine> _networkEngine;
std::unique_ptr<ghoul::cmdparser::CommandlineParser> _commandlineParser;
std::unique_ptr<LuaConsole> _console;
std::unique_ptr<ModuleEngine> _moduleEngine;
std::unique_ptr<gui::GUI> _gui;
std::unique_ptr<network::ParallelConnection> _parallelConnection;
std::unique_ptr<WindowWrapper> _windowWrapper;
std::unique_ptr<ghoul::fontrendering::FontManager> _fontManager;
properties::PropertyOwner* _globalPropertyNamespace;
std::unique_ptr<properties::PropertyOwner> _globalPropertyNamespace;
bool _isMaster;
double _runTime;
SyncBuffer* _syncBuffer;
std::unique_ptr<SyncBuffer> _syncBuffer;
static OpenSpaceEngine* _engine;
};
#define OsEng (openspace::OpenSpaceEngine::ref())

View File

@@ -186,7 +186,7 @@ void RenderablePlane::render(const RenderData& data) {
_shader->activate();
if (_projectionListener){
//get parent node-texture and set with correct dimensions
SceneGraphNode* textureNode = OsEng.renderEngine()->scene()->sceneGraphNode(_nodeName)->parent();
SceneGraphNode* textureNode = OsEng.renderEngine().scene()->sceneGraphNode(_nodeName)->parent();
if (textureNode != nullptr){
RenderablePlanetProjection* t = static_cast<RenderablePlanetProjection*>(textureNode->renderable());
_texture = std::unique_ptr<ghoul::opengl::Texture>(t->baseTexture());

View File

@@ -123,9 +123,9 @@ RenderablePlanet::~RenderablePlanet() {
bool RenderablePlanet::initialize() {
if (_programObject == nullptr && _hasNightTexture)
OsEng.ref().configurationManager()->getValue("nightTextureProgram", _programObject);
OsEng.ref().configurationManager().getValue("nightTextureProgram", _programObject);
else if (_programObject == nullptr)
OsEng.ref().configurationManager()->getValue("pscShader", _programObject);
OsEng.ref().configurationManager().getValue("pscShader", _programObject);
loadTexture();
_geometry->initialize(this);

View File

@@ -166,7 +166,7 @@ bool RenderableSphericalGrid::deinitialize(){
bool RenderableSphericalGrid::initialize(){
bool completeSuccess = true;
if (_gridProgram == nullptr)
completeSuccess &= OsEng.ref().configurationManager()->getValue("GridProgram", _gridProgram);
completeSuccess &= OsEng.ref().configurationManager().getValue("GridProgram", _gridProgram);
// Initialize and upload to graphics card
glGenVertexArrays(1, &_vaoID);

View File

@@ -259,8 +259,8 @@ void RenderablePlaneProjection::updatePlane(const Image img, double currentTime)
}
if (!_moving) {
SceneGraphNode* thisNode = OsEng.renderEngine()->scene()->sceneGraphNode(_name);
SceneGraphNode* newParent = OsEng.renderEngine()->scene()->sceneGraphNode(_target.node);
SceneGraphNode* thisNode = OsEng.renderEngine().scene()->sceneGraphNode(_name);
SceneGraphNode* newParent = OsEng.renderEngine().scene()->sceneGraphNode(_target.node);
if (thisNode != nullptr && newParent != nullptr)
thisNode->setParent(newParent);
}
@@ -294,7 +294,7 @@ void RenderablePlaneProjection::setTarget(std::string body) {
if (body == "")
return;
std::vector<SceneGraphNode*> nodes = OsEng.renderEngine()->scene()->allSceneGraphNodes();
std::vector<SceneGraphNode*> nodes = OsEng.renderEngine().scene()->allSceneGraphNodes();
Renderable* possibleTarget;
bool hasBody, found = false;
std::string targetBody;
@@ -321,7 +321,7 @@ std::string RenderablePlaneProjection::findClosestTarget(double currentTime) {
std::vector<std::string> targets;
std::vector<SceneGraphNode*> nodes = OsEng.renderEngine()->scene()->allSceneGraphNodes();
std::vector<SceneGraphNode*> nodes = OsEng.renderEngine().scene()->allSceneGraphNodes();
Renderable* possibleTarget;
std::string targetBody;
bool hasBody, found = false;

View File

@@ -77,7 +77,7 @@ void writeToBuffer<std::string>(std::vector<char>& buffer, size_t& currentWriteL
void SequenceParser::sendPlaybookInformation(const std::string& name) {
std::string fullName = PlaybookIdentifierName + "_" + name;
_messageIdentifier = OsEng.networkEngine()->identifier(fullName);
_messageIdentifier = OsEng.networkEngine().identifier(fullName);
std::vector<char> buffer(1024);
size_t currentWriteLocation = 0;
@@ -165,7 +165,7 @@ void SequenceParser::sendPlaybookInformation(const std::string& name) {
buffer.resize(currentWriteLocation);
//OsEng.networkEngine()->publishMessage(PlaybookIdentifier, buffer);
OsEng.networkEngine()->setInitialConnectionMessage(_messageIdentifier, buffer);
OsEng.networkEngine().setInitialConnectionMessage(_messageIdentifier, buffer);
}
}

View File

@@ -384,11 +384,11 @@ void GUI::renderMainWindow() {
bool toJupiter = ImGui::Button("Coordinate System to Jupiter");
if (toSun)
OsEng.scriptEngine()->queueScript("openspace.setPropertyValue('Interaction.coordinateSystem', 'Sun');");
OsEng.scriptEngine().queueScript("openspace.setPropertyValue('Interaction.coordinateSystem', 'Sun');");
if (toPluto)
OsEng.scriptEngine()->queueScript("openspace.setPropertyValue('Interaction.coordinateSystem', 'Pluto');");
OsEng.scriptEngine().queueScript("openspace.setPropertyValue('Interaction.coordinateSystem', 'Pluto');");
if (toJupiter)
OsEng.scriptEngine()->queueScript("openspace.setPropertyValue('Interaction.coordinateSystem', 'Jupiter');");
OsEng.scriptEngine().queueScript("openspace.setPropertyValue('Interaction.coordinateSystem', 'Jupiter');");
ImGui::Checkbox("Help", &_help._isEnabled);
@@ -536,7 +536,7 @@ int show(lua_State* L) {
if (nArguments != 0)
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
OsEng.gui()->setEnabled(true);
OsEng.gui().setEnabled(true);
return 0;
}
@@ -550,7 +550,7 @@ int hide(lua_State* L) {
if (nArguments != 0)
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
OsEng.gui()->setEnabled(false);
OsEng.gui().setEnabled(false);
return 0;
}
@@ -564,7 +564,7 @@ int toggle(lua_State* L) {
if (nArguments != 0)
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
OsEng.gui()->setEnabled(!OsEng.gui()->isEnabled());
OsEng.gui().setEnabled(!OsEng.gui().isEnabled());
return 0;
}

View File

@@ -39,9 +39,9 @@ namespace openspace {
namespace gui {
void GuiOriginComponent::render() {
const SceneGraphNode* currentFocus = OsEng.interactionHandler()->focusNode();
const SceneGraphNode* currentFocus = OsEng.interactionHandler().focusNode();
std::vector<SceneGraphNode*> nodes = OsEng.renderEngine()->scene()->allSceneGraphNodes();
std::vector<SceneGraphNode*> nodes = OsEng.renderEngine().scene()->allSceneGraphNodes();
std::sort(nodes.begin(), nodes.end(), [](SceneGraphNode* lhs, SceneGraphNode* rhs) { return lhs->name() < rhs->name(); });
auto it = std::find(nodes.begin(), nodes.end(), currentFocus);
ghoul_assert(it != nodes.end(), "Focus node not found");
@@ -57,7 +57,7 @@ void GuiOriginComponent::render() {
if (result) {
LINFO("openspace.setPropertyValue('Interaction.origin', '" + nodes[position]->name() + "');");
OsEng.scriptEngine()->queueScript("openspace.setPropertyValue('Interaction.origin', '" + nodes[position]->name() + "');");
OsEng.scriptEngine().queueScript("openspace.setPropertyValue('Interaction.origin', '" + nodes[position]->name() + "');");
}
}

View File

@@ -76,7 +76,7 @@ void GuiPerformanceComponent::render() {
};
ImGui::Begin("Performance", &_isEnabled);
if (OsEng.renderEngine()->doesPerformanceMeasurements() &&
if (OsEng.renderEngine().doesPerformanceMeasurements() &&
ghoul::SharedMemory::exists(RenderEngine::PerformanceMeasurementSharedData))
{
ImGui::SliderFloat2("Min values, max Value", _minMaxValues, 0.f, 10000.f);

View File

@@ -48,7 +48,7 @@ namespace {
void executeScript(const std::string& id, const std::string& value) {
std::string script =
"openspace.setPropertyValue('" + id + "', " + value + ");";
OsEng.scriptEngine()->queueScript(script);
OsEng.scriptEngine().queueScript(script);
}
void renderBoolProperty(Property* prop, const std::string& ownerName) {
@@ -432,17 +432,17 @@ void GuiPropertyComponent::render() {
ImGui::Begin("Properties", &_isEnabled, size, 0.5f);
if (ImGui::CollapsingHeader("OnScreen GUI")) {
glm::vec2& pos = OsEng.renderEngine()->_onScreenInformation._position;
glm::vec2& pos = OsEng.renderEngine()._onScreenInformation._position;
Vec2Property::ValueType value = pos;
ImGui::SliderFloat2("Position", &value.x, -1.f, 1.f);
pos = value;
unsigned int& size = OsEng.renderEngine()->_onScreenInformation._size;
unsigned int& size = OsEng.renderEngine()._onScreenInformation._size;
int sizeValue = static_cast<int>(size);
ImGui::SliderInt("Size", &sizeValue, 0, 36);
size = static_cast<unsigned int>(sizeValue);
int& node = OsEng.renderEngine()->_onScreenInformation._node;
int& node = OsEng.renderEngine()._onScreenInformation._node;
int iValue = node;
ImGui::SliderInt("Node#", &iValue, 0, 30);
node = iValue;

View File

@@ -42,7 +42,7 @@ void GuiTimeComponent::render() {
bool changed = ImGui::SliderFloat("Delta Time", &deltaTime, -100.f, 100.f);
if (changed)
OsEng.scriptEngine()->queueScript("openspace.time.setDeltaTime(" + std::to_string(deltaTime) + ")");
OsEng.scriptEngine().queueScript("openspace.time.setDeltaTime(" + std::to_string(deltaTime) + ")");
//char dateBuffer[512] = {};

View File

@@ -177,13 +177,13 @@ bool RenderableVolumeGL::initialize() {
if(_filename != "") {
_volume = loadVolume(_filename, _hintsDictionary);
_volume->uploadTexture();
OsEng.renderEngine()->aBuffer()->addVolume(_volumeName, _volume);
OsEng.renderEngine().aBuffer()->addVolume(_volumeName, _volume);
}
if(_transferFunctionPath != "") {
_transferFunction = loadTransferFunction(_transferFunctionPath);
_transferFunction->uploadTexture();
OsEng.renderEngine()->aBuffer()->addTransferFunction(_transferFunctionName, _transferFunction);
OsEng.renderEngine().aBuffer()->addTransferFunction(_transferFunctionName, _transferFunction);
auto textureCallback = [this](const ghoul::filesystem::File& file) {
_updateTransferfunction = true;
@@ -192,9 +192,9 @@ bool RenderableVolumeGL::initialize() {
}
// add the sampler and get the ID
_id = OsEng.renderEngine()->aBuffer()->addSamplerfile(_samplerFilename);
_id = OsEng.renderEngine().aBuffer()->addSamplerfile(_samplerFilename);
OsEng.configurationManager()->getValue("RaycastProgram", _boxProgram);
OsEng.configurationManager().getValue("RaycastProgram", _boxProgram);
// ============================
// GEOMETRY (box)

View File

@@ -24,6 +24,7 @@
#include <openspace/abuffer/abuffer.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/filesystem/file.h>

View File

@@ -24,13 +24,13 @@
#include <openspace/engine/logfactory.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/misc/exception.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/htmllog.h>
#include <ghoul/logging/textlog.h>
#include <ghoul/filesystem/filesystem.h>
namespace {
const std::string _loggerCat = "LogFactory";
const std::string keyType = "Type";
const std::string keyFilename = "FileName";
const std::string keyAppend = "Append";
@@ -45,20 +45,21 @@ namespace {
namespace openspace {
std::unique_ptr<ghoul::logging::Log> LogFactory::createLog(const ghoul::Dictionary& dictionary) {
std::unique_ptr<ghoul::logging::Log> createLog(const ghoul::Dictionary& dictionary) {
std::string type;
bool typeSuccess = dictionary.getValue(keyType, type);
if (!typeSuccess) {
LERROR("Requested log did not contain a key '" << keyType << "'");
return nullptr;
throw ghoul::RuntimeError(
"Requested log did not contain key '" + keyType + "'", "LogFactory"
);
}
std::string filename;
bool filenameSuccess = dictionary.getValue(keyFilename, filename);
if (!filenameSuccess) {
LERROR("Requested log of type '" << keyType << "' did not contain a key '"
<< keyFilename << "'");
return nullptr;
throw ghoul::RuntimeError(
"Requested log did not contain key '" + keyFilename + "'", "LogFactory"
);
}
filename = absPath(filename);
@@ -84,9 +85,10 @@ std::unique_ptr<ghoul::logging::Log> LogFactory::createLog(const ghoul::Dictiona
);
}
else {
LERROR("Log with type '" << type << "' did not name a valid log");
return nullptr;
throw ghoul::RuntimeError(
"Log with type '" + type + "' did not name a valid log", "LogFactory"
);
}
}
} // namespace openspace

View File

@@ -24,12 +24,13 @@
#include <openspace/engine/openspaceengine.h>
#include <ghoul/opengl/ghoul_gl.h>
#include <openspace/version.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/downloadmanager.h>
#include <openspace/engine/logfactory.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/interaction/interactionhandler.h>
#include <openspace/interaction/keyboardcontroller.h>
#include <openspace/interaction/luaconsole.h>
@@ -39,28 +40,24 @@
#include <openspace/rendering/renderengine.h>
#include <openspace/scripting/scriptengine.h>
#include <openspace/scene/scene.h>
#include <openspace/util/constants.h>
#include <openspace/util/factorymanager.h>
#include <openspace/util/time.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/factorymanager.h>
#include <openspace/util/constants.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/syncbuffer.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/engine/downloadmanager.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/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
#include <ghoul/systemcapabilities/systemcapabilities>
#include <ghoul/font/fontrenderer.h>
#include <iostream>
#include <memory>
#include <fstream>
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
@@ -100,7 +97,8 @@ namespace openspace {
OpenSpaceEngine* OpenSpaceEngine::_engine = nullptr;
OpenSpaceEngine::OpenSpaceEngine(std::string programName, WindowWrapper* windowWrapper)
OpenSpaceEngine::OpenSpaceEngine(std::string programName,
std::unique_ptr<WindowWrapper> windowWrapper)
: _configurationManager(new ConfigurationManager)
, _interactionHandler(new interaction::InteractionHandler)
, _renderEngine(new RenderEngine)
@@ -111,14 +109,14 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName, WindowWrapper* windowW
, _moduleEngine(new ModuleEngine)
, _gui(new gui::GUI)
, _parallelConnection(new network::ParallelConnection)
, _windowWrapper(windowWrapper)
, _windowWrapper(std::move(windowWrapper))
, _globalPropertyNamespace(new properties::PropertyOwner)
, _isMaster(false)
, _runTime(0.0)
, _syncBuffer(nullptr)
, _syncBuffer(new SyncBuffer(1024))
{
_interactionHandler->setPropertyOwner(_globalPropertyNamespace);
_globalPropertyNamespace->addPropertySubOwner(_interactionHandler);
_interactionHandler->setPropertyOwner(_globalPropertyNamespace.get());
_globalPropertyNamespace->addPropertySubOwner(_interactionHandler.get());
FactoryManager::initialize();
SpiceManager::initialize();
Time::initialize();
@@ -128,43 +126,18 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName, WindowWrapper* windowW
OpenSpaceEngine::~OpenSpaceEngine() {
_gui->deinitializeGL();
delete _globalPropertyNamespace;
_globalPropertyNamespace = nullptr;
delete _windowWrapper;
_windowWrapper = nullptr;
delete _parallelConnection;
_parallelConnection = nullptr;
delete _configurationManager;
_configurationManager = nullptr;
delete _interactionHandler;
_interactionHandler = nullptr;
delete _renderEngine;
_renderEngine = nullptr;
delete _scriptEngine;
_scriptEngine = nullptr;
delete _networkEngine;
_networkEngine = nullptr;
delete _commandlineParser;
_commandlineParser = nullptr;
delete _console;
_console = nullptr;
delete _moduleEngine;
_moduleEngine = nullptr;
delete _gui;
_gui = nullptr;
delete _syncBuffer;
_syncBuffer = nullptr;
}
@@ -173,15 +146,14 @@ OpenSpaceEngine& OpenSpaceEngine::ref() {
return *_engine;
}
bool OpenSpaceEngine::create(
int argc, char** argv,
WindowWrapper* windowWrapper,
std::vector<std::string>& sgctArguments)
bool OpenSpaceEngine::create(int argc, char** argv,
std::unique_ptr<WindowWrapper> windowWrapper,
std::vector<std::string>& sgctArguments)
{
ghoul::initialize();
ghoul_assert(!_engine, "OpenSpaceEngine was already created");
ghoul_assert(windowWrapper != nullptr, "No Window Wrapper was provided");
ghoul::initialize();
// Initialize the LogManager and add the console log as this will be used every time
// and we need a fall back if something goes wrong between here and when we add the
@@ -208,7 +180,7 @@ bool OpenSpaceEngine::create(
// Create other objects
LDEBUG("Creating OpenSpaceEngine");
_engine = new OpenSpaceEngine(std::string(argv[0]), windowWrapper);
_engine = new OpenSpaceEngine(std::string(argv[0]), std::move(windowWrapper));
// Query modules for commandline arguments
bool gatherSuccess = _engine->gatherCommandlineArguments();
@@ -239,7 +211,7 @@ bool OpenSpaceEngine::create(
// Loading configuration from disk
LDEBUG("Loading configuration from disk");
const bool configLoadSuccess = _engine->configurationManager()->loadFromFile(
const bool configLoadSuccess = _engine->configurationManager().loadFromFile(
configurationFilePath);
if (!configLoadSuccess) {
LFATAL("Loading of configuration file '" << configurationFilePath << "' failed");
@@ -268,18 +240,18 @@ bool OpenSpaceEngine::create(
_engine->_moduleEngine->create();
// Create the cachemanager
FileSys.createCacheManager(absPath("${" + ConfigurationManager::KeyCache + "}"), CacheVersion);
FileSys.createCacheManager(
absPath("${" + ConfigurationManager::KeyCache + "}"), CacheVersion
);
_engine->_console->initialize();
// Register the provided shader directories
ghoul::opengl::ShaderPreprocessor::addIncludePath(absPath("${SHADERS}"));
_engine->_syncBuffer = new SyncBuffer(1024);
// Determining SGCT configuration file
LDEBUG("Determining SGCT configuration file");
std::string sgctConfigurationPath = _sgctDefaultConfigFile;
_engine->configurationManager()->getValue(
_engine->configurationManager().getValue(
ConfigurationManager::KeyConfigSgct, sgctConfigurationPath);
if (!commandlineArgumentPlaceholders.sgctConfigurationName.empty()) {
@@ -331,21 +303,21 @@ bool OpenSpaceEngine::initialize() {
using Verbosity = ghoul::systemcapabilities::SystemCapabilitiesComponent::Verbosity;
Verbosity verbosity = Verbosity::Default;
if (configurationManager()->hasKeyAndValue<std::string>(ConfigurationManager::KeyCapabilitiesVerbosity)) {
if (configurationManager().hasKeyAndValue<std::string>(ConfigurationManager::KeyCapabilitiesVerbosity)) {
std::map<std::string, Verbosity> verbosityMap = {
{ "Minimal", Verbosity::Minimal },
{ "Default", Verbosity::Default },
{ "Full", Verbosity::Full }
};
std::string v = configurationManager()->value<std::string>(ConfigurationManager::KeyCapabilitiesVerbosity);
std::string v = configurationManager().value<std::string>(ConfigurationManager::KeyCapabilitiesVerbosity);
if (verbosityMap.find(v) != verbosityMap.end())
verbosity = verbosityMap[v];
}
SysCap.logCapabilities(verbosity);
std::string requestURL = "";
bool success = configurationManager()->getValue(ConfigurationManager::KeyDownloadRequestURL, requestURL);
bool success = configurationManager().getValue(ConfigurationManager::KeyDownloadRequestURL, requestURL);
if (success)
DownloadManager::initialize(requestURL, DownloadVersion);
@@ -365,23 +337,23 @@ bool OpenSpaceEngine::initialize() {
_scriptEngine->addLibrary(network::ParallelConnection::luaLibrary());
// TODO: Maybe move all scenegraph and renderengine stuff to initializeGL
scriptEngine()->initialize();
scriptEngine().initialize();
// If a LuaDocumentationFile was specified, generate it now
const bool hasType = configurationManager()->hasKey(ConfigurationManager::KeyLuaDocumentationType);
const bool hasFile = configurationManager()->hasKey(ConfigurationManager::KeyLuaDocumentationFile);
const bool hasType = configurationManager().hasKey(ConfigurationManager::KeyLuaDocumentationType);
const bool hasFile = configurationManager().hasKey(ConfigurationManager::KeyLuaDocumentationFile);
if (hasType && hasFile) {
std::string luaDocumentationType;
configurationManager()->getValue(ConfigurationManager::KeyLuaDocumentationType, luaDocumentationType);
configurationManager().getValue(ConfigurationManager::KeyLuaDocumentationType, luaDocumentationType);
std::string luaDocumentationFile;
configurationManager()->getValue(ConfigurationManager::KeyLuaDocumentationFile, luaDocumentationFile);
configurationManager().getValue(ConfigurationManager::KeyLuaDocumentationFile, luaDocumentationFile);
luaDocumentationFile = absPath(luaDocumentationFile);
_scriptEngine->writeDocumentation(luaDocumentationFile, luaDocumentationType);
}
bool disableMasterRendering = false;
configurationManager()->getValue(
configurationManager().getValue(
ConfigurationManager::KeyDisableMasterRendering, disableMasterRendering);
_renderEngine->setDisableRenderingOnMaster(disableMasterRendering);
@@ -396,7 +368,7 @@ bool OpenSpaceEngine::initialize() {
std::string sceneDescriptionPath = "";
if (commandlineArgumentPlaceholders.sceneName.empty()) {
success = configurationManager()->getValue(
success = configurationManager().getValue(
ConfigurationManager::KeyConfigScene, sceneDescriptionPath);
}
else
@@ -410,8 +382,7 @@ bool OpenSpaceEngine::initialize() {
runStartupScripts();
// Load a light and a monospaced font
loadFonts();
loadFonts2();
loadFonts();
LINFO("Initializing GUI");
_gui->initialize();
@@ -483,7 +454,7 @@ bool OpenSpaceEngine::findConfiguration(std::string& filename) {
bool OpenSpaceEngine::loadSpiceKernels() {
// Load time kernel
std::string timeKernel;
bool success = configurationManager()->getValue(ConfigurationManager::KeySpiceTimeKernel, timeKernel);
bool success = configurationManager().getValue(ConfigurationManager::KeySpiceTimeKernel, timeKernel);
// Move this to configurationmanager::completenesscheck ---abock
if (!success) {
LERROR("Configuration file does not contain a '" << ConfigurationManager::KeySpiceTimeKernel << "'");
@@ -494,7 +465,7 @@ bool OpenSpaceEngine::loadSpiceKernels() {
// Load SPICE leap second kernel
std::string leapSecondKernel;
success = configurationManager()->getValue(ConfigurationManager::KeySpiceLeapsecondKernel, leapSecondKernel);
success = configurationManager().getValue(ConfigurationManager::KeySpiceLeapsecondKernel, leapSecondKernel);
if (!success) {
// Move this to configurationmanager::completenesscheck ---abock
LERROR("Configuration file does not have a '" << ConfigurationManager::KeySpiceLeapsecondKernel << "'");
@@ -519,7 +490,7 @@ void OpenSpaceEngine::runScripts(const ghoul::Dictionary& scripts) {
std::string scriptPath;
scripts.getValue(key, scriptPath);
std::string&& absoluteScriptPath = absPath(scriptPath);
_engine->scriptEngine()->runScriptFile(absoluteScriptPath);
_engine->scriptEngine().runScriptFile(absoluteScriptPath);
//@JK
//temporary solution to ensure that startup scripts may be syncrhonized over parallel connection
@@ -531,9 +502,9 @@ void OpenSpaceEngine::runScripts(const ghoul::Dictionary& scripts) {
//valid line and not a comment
if(line.size() > 0 && line.at(0) != '-'){
std::string lib, func;
if(_engine->scriptEngine()->parseLibraryAndFunctionNames(lib, func, line) &&
_engine->scriptEngine()->shouldScriptBeSent(lib, func)){
_engine->scriptEngine()->cacheScript(lib, func, line);
if(_engine->scriptEngine().parseLibraryAndFunctionNames(lib, func, line) &&
_engine->scriptEngine().shouldScriptBeSent(lib, func)){
_engine->scriptEngine().cacheScript(lib, func, line);
}
}
}
@@ -543,51 +514,31 @@ void OpenSpaceEngine::runScripts(const ghoul::Dictionary& scripts) {
void OpenSpaceEngine::runStartupScripts() {
ghoul::Dictionary scripts;
configurationManager()->getValue(
configurationManager().getValue(
ConfigurationManager::KeyStartupScript, scripts);
runScripts(scripts);
}
void OpenSpaceEngine::runSettingsScripts() {
ghoul::Dictionary scripts;
configurationManager()->getValue(
configurationManager().getValue(
ConfigurationManager::KeySettingsScript, scripts);
runScripts(scripts);
}
void OpenSpaceEngine::loadFonts() {
sgct_text::FontManager::FontPath local = sgct_text::FontManager::FontPath::FontPath_Local;
ghoul::Dictionary fonts;
configurationManager()->getValue(ConfigurationManager::KeyFonts, fonts);
for (const std::string& key : fonts.keys()) {
std::string font;
fonts.getValue(key, font);
font = absPath(font);
if(!FileSys.fileExists(font)) {
LERROR("Could not find font '" << font << "'");
continue;
}
LINFO("Registering font '" << font << "' with key '" << key << "'");
sgct_text::FontManager::instance()->addFont(key, font, local);
}
}
void OpenSpaceEngine::loadFonts2() {
ghoul::Dictionary fonts;
configurationManager()->getValue(ConfigurationManager::KeyFonts, fonts);
configurationManager().getValue(ConfigurationManager::KeyFonts, fonts);
const glm::ivec3 fontAtlasSize{1024, 1024, 1};
_fontManager = new ghoul::fontrendering::FontManager(fontAtlasSize);
_fontManager = std::make_unique<ghoul::fontrendering::FontManager>(fontAtlasSize);
for (const std::string& key : fonts.keys()) {
std::string font;
fonts.getValue(key, font);
font = absPath(font);
if(!FileSys.fileExists(font)) {
if (!FileSys.fileExists(font)) {
LERROR("Could not find font '" << font << "'");
continue;
}
@@ -608,12 +559,12 @@ void OpenSpaceEngine::loadFonts2() {
}
void OpenSpaceEngine::configureLogging() {
if (configurationManager()->hasKeyAndValue<std::string>(ConfigurationManager::KeyLogLevel)) {
if (configurationManager().hasKeyAndValue<std::string>(ConfigurationManager::KeyLogLevel)) {
std::string logLevel;
configurationManager()->getValue(ConfigurationManager::KeyLogLevel, logLevel);
configurationManager().getValue(ConfigurationManager::KeyLogLevel, logLevel);
bool immediateFlush = false;
configurationManager()->getValue(ConfigurationManager::KeyLogImmediateFlush, immediateFlush);
configurationManager().getValue(ConfigurationManager::KeyLogImmediateFlush, immediateFlush);
LogManager::LogLevel level = LogManager::levelFromString(logLevel);
LogManager::deinitialize();
@@ -621,52 +572,24 @@ void OpenSpaceEngine::configureLogging() {
LogMgr.addLog(std::make_unique<ConsoleLog>());
}
if (configurationManager()->hasKeyAndValue<ghoul::Dictionary>(ConfigurationManager::KeyLogs)) {
if (configurationManager().hasKeyAndValue<ghoul::Dictionary>(ConfigurationManager::KeyLogs)) {
ghoul::Dictionary logs;
configurationManager()->getValue(ConfigurationManager::KeyLogs, logs);
configurationManager().getValue(ConfigurationManager::KeyLogs, logs);
for (size_t i = 1; i <= logs.size(); ++i) {
ghoul::Dictionary logInfo;
logs.getValue(std::to_string(i), logInfo);
std::unique_ptr<Log> log = LogFactory::createLog(logInfo);
if (log)
LogMgr.addLog(std::move(log));
try {
LogMgr.addLog(createLog(logInfo));
}
catch (const ghoul::RuntimeError& e) {
LERRORC(e.component, e.message);
}
}
}
}
ConfigurationManager* OpenSpaceEngine::configurationManager() {
ghoul_assert(_configurationManager != nullptr, "ConfigurationManager is nullptr");
return _configurationManager;
}
interaction::InteractionHandler* OpenSpaceEngine::interactionHandler() {
ghoul_assert(_interactionHandler != nullptr, "InteractionHandler is nullptr");
return _interactionHandler;
}
RenderEngine* OpenSpaceEngine::renderEngine() {
ghoul_assert(_renderEngine != nullptr, "RenderEngine is nullptr");
return _renderEngine;
}
ScriptEngine* OpenSpaceEngine::scriptEngine() {
ghoul_assert(_scriptEngine != nullptr, "ScriptEngine is nullptr");
return _scriptEngine;
}
LuaConsole* OpenSpaceEngine::console() {
ghoul_assert(_console != nullptr, "LuaConsole is nullptr");
return _console;
}
gui::GUI* OpenSpaceEngine::gui() {
ghoul_assert(_gui != nullptr, "GUI is nullptr");
return _gui;
}
bool OpenSpaceEngine::initializeGL() {
LINFO("Initializing Rendering Engine");
bool success = _renderEngine->initializeGL();
@@ -701,11 +624,8 @@ void OpenSpaceEngine::preSynchronization() {
Time::ref().preSynchronization();
_interactionHandler->update(dt);
_scriptEngine->preSynchronization();
_scriptEngine->preSynchronization();
_renderEngine->preSynchronization();
_parallelConnection->preSynchronization();
}
}
@@ -765,7 +685,7 @@ void OpenSpaceEngine::keyboardCallback(Key key, KeyModifier mod, KeyAction actio
void OpenSpaceEngine::charCallback(unsigned int codepoint, KeyModifier modifier) {
if (_isMaster) {
if (_gui->isEnabled()) {
bool isConsumed = _gui->charCallback(codepoint, modifier);
const bool isConsumed = _gui->charCallback(codepoint, modifier);
if (isConsumed)
return;
}
@@ -779,7 +699,7 @@ void OpenSpaceEngine::charCallback(unsigned int codepoint, KeyModifier modifier)
void OpenSpaceEngine::mouseButtonCallback(MouseButton button, MouseAction action) {
if (_isMaster) {
if (_gui->isEnabled()) {
bool isConsumed = _gui->mouseButtonCallback(button, action);
const bool isConsumed = _gui->mouseButtonCallback(button, action);
if (isConsumed && action != MouseAction::Release)
return;
}
@@ -797,7 +717,7 @@ void OpenSpaceEngine::mousePositionCallback(double x, double y) {
void OpenSpaceEngine::mouseScrollWheelCallback(double pos) {
if (_isMaster) {
if (_gui->isEnabled()) {
bool isConsumed = _gui->mouseWheelCallback(pos);
const bool isConsumed = _gui->mouseWheelCallback(pos);
if (isConsumed)
return;
}
@@ -808,9 +728,9 @@ void OpenSpaceEngine::mouseScrollWheelCallback(double pos) {
void OpenSpaceEngine::encode() {
if (_syncBuffer) {
Time::ref().serialize(_syncBuffer);
_scriptEngine->serialize(_syncBuffer);
_renderEngine->serialize(_syncBuffer);
Time::ref().serialize(_syncBuffer.get());
_scriptEngine->serialize(_syncBuffer.get());
_renderEngine->serialize(_syncBuffer.get());
_syncBuffer->write();
}
@@ -822,14 +742,14 @@ void OpenSpaceEngine::decode() {
if (_syncBuffer) {
_syncBuffer->read();
Time::ref().deserialize(_syncBuffer);
_scriptEngine->deserialize(_syncBuffer);
_renderEngine->deserialize(_syncBuffer);
Time::ref().deserialize(_syncBuffer.get());
_scriptEngine->deserialize(_syncBuffer.get());
_renderEngine->deserialize(_syncBuffer.get());
}
}
void OpenSpaceEngine::externalControlCallback(const char* receivedChars,
int size, int clientId)
void OpenSpaceEngine::externalControlCallback(const char* receivedChars, int size,
int clientId)
{
if (size == 0)
return;
@@ -845,31 +765,66 @@ void OpenSpaceEngine::disableBarrier() {
_windowWrapper->setBarrier(false);
}
NetworkEngine* OpenSpaceEngine::networkEngine() {
return _networkEngine;
NetworkEngine& OpenSpaceEngine::networkEngine() {
ghoul_assert(_networkEngine, "NetworkEngine must not be nullptr");
return *_networkEngine;
}
ModuleEngine* OpenSpaceEngine::moduleEngine() {
return _moduleEngine;
ModuleEngine& OpenSpaceEngine::moduleEngine() {
ghoul_assert(_moduleEngine, "ModuleEngine must not be nullptr");
return *_moduleEngine;
}
ConfigurationManager& OpenSpaceEngine::configurationManager() {
ghoul_assert(_configurationManager, "ConfigurationManager must not be nullptr");
return *_configurationManager;
}
interaction::InteractionHandler& OpenSpaceEngine::interactionHandler() {
ghoul_assert(_interactionHandler, "InteractionHandler must not be nullptr");
return *_interactionHandler;
}
RenderEngine& OpenSpaceEngine::renderEngine() {
ghoul_assert(_renderEngine, "RenderEngine must not be nullptr");
return *_renderEngine;
}
ScriptEngine& OpenSpaceEngine::scriptEngine() {
ghoul_assert(_scriptEngine, "ScriptEngine must not be nullptr");
return *_scriptEngine;
}
LuaConsole& OpenSpaceEngine::console() {
ghoul_assert(_console, "LuaConsole must not be nullptr");
return *_console;
}
gui::GUI& OpenSpaceEngine::gui() {
ghoul_assert(_gui, "GUI must not be nullptr");
return *_gui;
}
network::ParallelConnection& OpenSpaceEngine::parallelConnection() {
ghoul_assert(_parallelConnection, "ParallelConnection must not be nullptr");
return *_parallelConnection;
}
network::ParallelConnection* OpenSpaceEngine::parallelConnection() {
ghoul_assert(_parallelConnection != nullptr, "ParallelConnection is nullptr");
return _parallelConnection;
}
properties::PropertyOwner* OpenSpaceEngine::globalPropertyOwner() {
ghoul_assert(_globalPropertyNamespace, "Global Property Namespace");
return _globalPropertyNamespace;
properties::PropertyOwner& OpenSpaceEngine::globalPropertyOwner() {
ghoul_assert(
_globalPropertyNamespace,
"Global Property Namespace must not be nullptr"
);
return *_globalPropertyNamespace;
}
WindowWrapper& OpenSpaceEngine::windowWrapper() {
ghoul_assert(_windowWrapper, "Window Wrapper");
ghoul_assert(_windowWrapper, "Window Wrapper must not be nullptr");
return *_windowWrapper;
}
ghoul::fontrendering::FontManager& OpenSpaceEngine::fontManager() {
ghoul_assert(_fontManager, "Font Manager");
ghoul_assert(_fontManager, "Font Manager must not be nullptr");
return *_fontManager;
}

View File

@@ -139,7 +139,7 @@ InteractionHandler::InteractionHandler()
addProperty(_origin);
_coordinateSystem.onChange([this](){
OsEng.renderEngine()->changeViewPoint(_coordinateSystem.value());
OsEng.renderEngine().changeViewPoint(_coordinateSystem.value());
});
addProperty(_coordinateSystem);
}
@@ -552,14 +552,14 @@ void InteractionHandler::keyboardCallback(Key key, KeyModifier modifier, KeyActi
rotateDelta(rot);
}
if ((key == Key::KeypadSubtract) && (modifier == KeyModifier::NoModifier)) {
glm::vec2 s = OsEng.renderEngine()->camera()->scaling();
glm::vec2 s = OsEng.renderEngine().camera()->scaling();
s[1] -= 0.5f;
OsEng.renderEngine()->camera()->setScaling(s);
OsEng.renderEngine().camera()->setScaling(s);
}
if ((key == Key::KeypadAdd) && (modifier == KeyModifier::NoModifier)) {
glm::vec2 s = OsEng.renderEngine()->camera()->scaling();
glm::vec2 s = OsEng.renderEngine().camera()->scaling();
s[1] += 0.5f;
OsEng.renderEngine()->camera()->setScaling(s);
OsEng.renderEngine().camera()->setScaling(s);
}
// iterate over key bindings
@@ -567,7 +567,7 @@ void InteractionHandler::keyboardCallback(Key key, KeyModifier modifier, KeyActi
auto ret = _keyLua.equal_range(key);
for (auto it = ret.first; it != ret.second; ++it) {
//OsEng.scriptEngine()->runScript(it->second);
OsEng.scriptEngine()->queueScript(it->second);
OsEng.scriptEngine().queueScript(it->second);
if (!_validKeyLua) {
break;
}

View File

@@ -51,7 +51,7 @@ int setOrigin(lua_State* L) {
return 0;
}
OsEng.interactionHandler()->setFocusNode(node);
OsEng.interactionHandler().setFocusNode(node);
return 0;
}
@@ -84,7 +84,7 @@ int bindKey(lua_State* L) {
}
OsEng.interactionHandler()->bindKey(iKey, command);
OsEng.interactionHandler().bindKey(iKey, command);
return 0;
}
@@ -102,7 +102,7 @@ int clearKeys(lua_State* L) {
if (nArguments != 0)
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
OsEng.interactionHandler()->resetKeyBindings();
OsEng.interactionHandler().resetKeyBindings();
return 0;
}
@@ -117,7 +117,7 @@ int dt(lua_State* L) {
if (nArguments != 0)
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
lua_pushnumber(L,OsEng.interactionHandler()->deltaTime());
lua_pushnumber(L,OsEng.interactionHandler().deltaTime());
return 1;
}
@@ -134,7 +134,7 @@ int distance(lua_State* L) {
double d1 = luaL_checknumber(L, -2);
double d2 = luaL_checknumber(L, -1);
PowerScaledScalar dist(static_cast<float>(d1), static_cast<float>(d2));
OsEng.interactionHandler()->distanceDelta(dist);
OsEng.interactionHandler().distanceDelta(dist);
return 0;
}
@@ -149,7 +149,7 @@ int setInteractionSensitivity(lua_State* L) {
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
float sensitivity = static_cast<float>(luaL_checknumber(L, -1));
OsEng.interactionHandler()->setInteractionSensitivity(sensitivity);
OsEng.interactionHandler().setInteractionSensitivity(sensitivity);
return 0;
}
@@ -159,7 +159,7 @@ int setInteractionSensitivity(lua_State* L) {
* Returns the current, global interaction sensitivity
*/
int interactionSensitivity(lua_State* L) {
float sensitivity = OsEng.interactionHandler()->interactionSensitivity();
float sensitivity = OsEng.interactionHandler().interactionSensitivity();
lua_pushnumber(L, sensitivity);
return 1;
}
@@ -175,7 +175,7 @@ int setInvertRoll(lua_State* L) {
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
bool invert = lua_toboolean(L, -1) == 1;
OsEng.interactionHandler()->setInvertRoll(invert);
OsEng.interactionHandler().setInvertRoll(invert);
return 0;
}
@@ -185,7 +185,7 @@ int setInvertRoll(lua_State* L) {
* Returns the current setting for inversion of roll movement
*/
int invertRoll(lua_State* L) {
bool invert = OsEng.interactionHandler()->invertRoll();
bool invert = OsEng.interactionHandler().invertRoll();
lua_pushboolean(L, invert);
return 1;
}
@@ -201,7 +201,7 @@ int setInvertRotation(lua_State* L) {
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
bool invert = lua_toboolean(L, -1) == 1;
OsEng.interactionHandler()->setInvertRotation(invert);
OsEng.interactionHandler().setInvertRotation(invert);
return 0;
}
@@ -211,7 +211,7 @@ int setInvertRotation(lua_State* L) {
* Returns the current setting for inversion of rotation movement
*/
int invertRotation(lua_State* L) {
bool invert = OsEng.interactionHandler()->invertRotation();
bool invert = OsEng.interactionHandler().invertRotation();
lua_pushboolean(L, invert);
return 1;
}

View File

@@ -117,14 +117,14 @@ void KeyboardControllerFixed::keyPressed(KeyAction action, Key key, KeyModifier
}
if (key == Key::KeypadSubtract) {
glm::vec2 s = OsEng.renderEngine()->camera()->scaling();
glm::vec2 s = OsEng.renderEngine().camera()->scaling();
s[1] -= 0.5;
OsEng.renderEngine()->camera()->setScaling(s);
OsEng.renderEngine().camera()->setScaling(s);
}
if (key == Key::KeypadAdd) {
glm::vec2 s = OsEng.renderEngine()->camera()->scaling();
glm::vec2 s = OsEng.renderEngine().camera()->scaling();
s[1] += 0.5;
OsEng.renderEngine()->camera()->setScaling(s);
OsEng.renderEngine().camera()->setScaling(s);
}
}
/*

View File

@@ -171,7 +171,7 @@ void LuaConsole::keyboardCallback(Key key, KeyModifier modifier, KeyAction actio
else {
if (_commands.at(_activeCommand) != "") {
//OsEng.scriptEngine()->runScript(_commands.at(_activeCommand));
OsEng.scriptEngine()->queueScript(_commands.at(_activeCommand));
OsEng.scriptEngine().queueScript(_commands.at(_activeCommand));
if (!_commandsHistory.empty() &&
_commands.at(_activeCommand) != _commandsHistory.at(_commandsHistory.size() - 1))
_commandsHistory.push_back(_commands.at(_activeCommand));
@@ -197,7 +197,7 @@ void LuaConsole::keyboardCallback(Key key, KeyModifier modifier, KeyAction actio
// find the value before the one that was previously found
if (_autoCompleteInfo.lastIndex != NoAutoComplete && modifierShift)
_autoCompleteInfo.lastIndex -= 2;
std::vector<std::string> allCommands = OsEng.scriptEngine()->allLuaFunctions();
std::vector<std::string> allCommands = OsEng.scriptEngine().allLuaFunctions();
std::sort(allCommands.begin(), allCommands.end());
std::string currentCommand = _commands.at(_activeCommand);

View File

@@ -36,7 +36,7 @@ int show(lua_State* L) {
if (nArguments != 0)
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
OsEng.console()->setVisible(true);
OsEng.console().setVisible(true);
return 0;
}
@@ -50,7 +50,7 @@ int hide(lua_State* L) {
if (nArguments != 0)
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
OsEng.console()->setVisible(false);
OsEng.console().setVisible(false);
return 0;
}
@@ -64,7 +64,7 @@ int toggle(lua_State* L) {
if (nArguments != 0)
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
OsEng.console()->toggleVisibility();
OsEng.console().toggleVisibility();
return 0;
}

View File

@@ -25,6 +25,7 @@
#include <openspace/interaction/mousecontroller.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/interaction/interactionhandler.h>
@@ -218,9 +219,9 @@ void OrbitalMouseController::scrollWheel(int pos) {
}
void OrbitalMouseController::update(const double& dt){
const float interactionSpeed = OsEng.interactionHandler()->interactionSensitivity();
const bool rotationInvert = OsEng.interactionHandler()->invertRotation();
const bool rollInvert = OsEng.interactionHandler()->invertRoll();
const float interactionSpeed = OsEng.interactionHandler().interactionSensitivity();
const bool rotationInvert = OsEng.interactionHandler().invertRotation();
const bool rollInvert = OsEng.interactionHandler().invertRoll();
//if (_leftMouseButtonDown || _rightMouseButtonDown || _middleMouseButtonDown){
_handler->orbit(

View File

@@ -23,9 +23,9 @@
****************************************************************************************/
#include <openspace/network/networkengine.h>
#include <openspace/util/time.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <array>
#include <chrono>
@@ -67,7 +67,7 @@ bool NetworkEngine::handleMessage(const std::string& message) {
{
std::string script = message.substr(1);
//LINFO("Received Lua Script: '" << script << "'");
OsEng.scriptEngine()->queueScript(script);
OsEng.scriptEngine().queueScript(script);
return true;
}
case MessageTypeExternalControlConnected:

View File

@@ -470,7 +470,7 @@ void ParallelConnection::initializationMessageReceived(){
script.assign(buffer.begin(), buffer.end());
//queue received script
OsEng.scriptEngine()->queueScript(script);
OsEng.scriptEngine().queueScript(script);
}
//we've gone through all scripts, initialization is done
@@ -540,7 +540,7 @@ void ParallelConnection::dataMessageReceived(){
kf.deserialize(buffer);
//add the keyframe to the interaction handler
OsEng.interactionHandler()->addKeyframe(kf);
OsEng.interactionHandler().addKeyframe(kf);
break;
}
case network::datamessagestructures::TimeData:{
@@ -587,7 +587,7 @@ void ParallelConnection::dataMessageReceived(){
sm.deserialize(buffer);
//Que script to be executed by script engine
OsEng.scriptEngine()->queueScript(sm._script);
OsEng.scriptEngine().queueScript(sm._script);
break;
}
default:{
@@ -682,7 +682,7 @@ void ParallelConnection::hostInfoMessageReceived(){
}
//clear buffered any keyframes
OsEng.interactionHandler()->clearKeyframes();
OsEng.interactionHandler().clearKeyframes();
//request init package from the host
int size = headerSize();
@@ -1037,8 +1037,8 @@ void ParallelConnection::broadcast(){
//create a keyframe with current position and orientation of camera
network::datamessagestructures::PositionKeyframe kf;
kf._position = OsEng.interactionHandler()->camera()->position();
kf._viewRotationQuat = glm::quat_cast(OsEng.interactionHandler()->camera()->viewRotationMatrix());
kf._position = OsEng.interactionHandler().camera()->position();
kf._viewRotationQuat = glm::quat_cast(OsEng.interactionHandler().camera()->viewRotationMatrix());
//timestamp as current runtime of OpenSpace instance
kf._timeStamp = OsEng.runTime();

View File

@@ -45,7 +45,7 @@ int setPort(lua_State* L) {
int value = lua_tonumber(L, -1);
std::string port = std::to_string(value);
if(OsEng.isMaster()){
OsEng.parallelConnection()->setPort(port);
OsEng.parallelConnection().setPort(port);
}
return 0;
}
@@ -71,7 +71,7 @@ int setAddress(lua_State* L) {
if (type == LUA_TSTRING) {
std::string address = luaL_checkstring(L, -1);
if(OsEng.isMaster()){
OsEng.parallelConnection()->setAddress(address);
OsEng.parallelConnection().setAddress(address);
}
return 0;
}
@@ -97,7 +97,7 @@ int setPassword(lua_State* L) {
if (type == LUA_TSTRING) {
std::string pwd = luaL_checkstring(L, -1);
if(OsEng.isMaster()){
OsEng.parallelConnection()->setPassword(pwd);
OsEng.parallelConnection().setPassword(pwd);
}
return 0;
}
@@ -123,7 +123,7 @@ int setDisplayName(lua_State* L) {
if (type == LUA_TSTRING) {
std::string name = luaL_checkstring(L, -1);
if(OsEng.isMaster()){
OsEng.parallelConnection()->setName(name);
OsEng.parallelConnection().setName(name);
}
return 0;
}
@@ -142,7 +142,7 @@ int connect(lua_State* L) {
if (nArguments != 0)
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
if(OsEng.isMaster()){
OsEng.parallelConnection()->clientConnect();
OsEng.parallelConnection().clientConnect();
}
return 0;
}
@@ -153,7 +153,7 @@ int disconnect(lua_State* L) {
if (nArguments != 0)
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
if(OsEng.isMaster()){
OsEng.parallelConnection()->signalDisconnect();
OsEng.parallelConnection().signalDisconnect();
}
return 0;
}
@@ -171,7 +171,7 @@ int requestHostship(lua_State* L) {
if (type == LUA_TSTRING) {
std::string pwd = luaL_checkstring(L, -1);
if(OsEng.isMaster()){
OsEng.parallelConnection()->requestHostship(pwd);
OsEng.parallelConnection().requestHostship(pwd);
}
return 0;
}

View File

@@ -38,7 +38,7 @@ namespace {
}
Scene* sceneGraph() {
return OsEng.renderEngine()->scene();
return OsEng.renderEngine().scene();
}
SceneGraphNode* sceneGraphNode(const std::string& name) {
@@ -52,7 +52,7 @@ Renderable* renderable(const std::string& name) {
}
properties::Property* property(const std::string& uri) {
properties::Property* globalProp = OsEng.globalPropertyOwner()->property(uri);
properties::Property* globalProp = OsEng.globalPropertyOwner().property(uri);
if (globalProp) {
return globalProp;
}

View File

@@ -53,6 +53,7 @@
#include <ghoul/font/fontrenderer.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/glm.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <ghoul/io/texture/texturereader.h>
#ifdef GHOUL_USE_DEVIL
@@ -136,8 +137,8 @@ bool RenderEngine::initialize() {
std::string renderingMethod = DefaultRenderingMethod;
// If the user specified a rendering method that he would like to use, use that
if (OsEng.configurationManager()->hasKeyAndValue<std::string>(KeyRenderingMethod))
renderingMethod = OsEng.configurationManager()->value<std::string>(KeyRenderingMethod);
if (OsEng.configurationManager().hasKeyAndValue<std::string>(KeyRenderingMethod))
renderingMethod = OsEng.configurationManager().value<std::string>(KeyRenderingMethod);
else {
using Version = ghoul::systemcapabilities::OpenGLCapabilitiesComponent::Version;
@@ -179,7 +180,7 @@ bool RenderEngine::initialize() {
_mainCamera = new Camera();
_mainCamera->setScaling(glm::vec2(1.0, -8.0));
_mainCamera->setPosition(psc(0.f, 0.f, 1.499823f, 11.f));
OsEng.interactionHandler()->setCamera(_mainCamera);
OsEng.interactionHandler().setCamera(_mainCamera);
#ifdef GHOUL_USE_DEVIL
ghoul::io::TextureReader::ref().addReader(std::make_shared<ghoul::io::TextureReaderDevIL>());

View File

@@ -47,7 +47,7 @@ int takeScreenshot(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments != 0)
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
OsEng.renderEngine()->takeScreenshot();
OsEng.renderEngine().takeScreenshot();
return 0;
}
@@ -65,7 +65,7 @@ int visualizeABuffer(lua_State* L) {
if (type != LUA_TBOOLEAN)
return luaL_error(L, "Expected argument of type 'bool'");
bool b = lua_toboolean(L, -1) != 0;
OsEng.renderEngine()->toggleVisualizeABuffer(b);
OsEng.renderEngine().toggleVisualizeABuffer(b);
return 0;
}
@@ -83,7 +83,7 @@ int showRenderInformation(lua_State* L) {
if (type != LUA_TBOOLEAN)
return luaL_error(L, "Expected argument of type 'bool'");
bool b = lua_toboolean(L, -1) != 0;
OsEng.renderEngine()->toggleInfoText(b);
OsEng.renderEngine().toggleInfoText(b);
return 0;
}
@@ -98,7 +98,7 @@ int setPerformanceMeasurement(lua_State* L) {
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
bool b = lua_toboolean(L, -1) != 0;
OsEng.renderEngine()->setPerformanceMeasurements(b);
OsEng.renderEngine().setPerformanceMeasurements(b);
return 0;
}
@@ -114,7 +114,7 @@ int fadeIn(lua_State* L) {
double t = luaL_checknumber(L, -1);
OsEng.renderEngine()->startFading(1, static_cast<float>(t));
OsEng.renderEngine().startFading(1, static_cast<float>(t));
return 0;
}
/**
@@ -129,7 +129,7 @@ int fadeOut(lua_State* L) {
double t = luaL_checknumber(L, -1);
OsEng.renderEngine()->startFading(-1, static_cast<float>(t));
OsEng.renderEngine().startFading(-1, static_cast<float>(t));
return 0;
}

View File

@@ -96,7 +96,7 @@ bool Scene::initialize() {
"${SHADERS}/fboPass_fs.glsl");
if (!prg) return false;
prg->setProgramObjectCallback(cb);
OsEng.ref().configurationManager()->setValue("fboPassProgram", prg.get());
OsEng.ref().configurationManager().setValue("fboPassProgram", prg.get());
_programs.push_back(std::move(prg));
// pscstandard
@@ -105,7 +105,7 @@ bool Scene::initialize() {
"${SHADERS}/pscstandard_fs.glsl");
if (! prg) return false;
prg->setProgramObjectCallback(cb);
OsEng.ref().configurationManager()->setValue("pscShader", prg.get());
OsEng.ref().configurationManager().setValue("pscShader", prg.get());
_programs.push_back(std::move(prg));
// Night texture program
@@ -114,7 +114,7 @@ bool Scene::initialize() {
"${SHADERS}/nighttexture_fs.glsl");
if (!prg) return false;
prg->setProgramObjectCallback(cb);
OsEng.ref().configurationManager()->setValue("nightTextureProgram", prg.get());
OsEng.ref().configurationManager().setValue("nightTextureProgram", prg.get());
_programs.push_back(std::move(prg));
// RaycastProgram
@@ -123,7 +123,7 @@ bool Scene::initialize() {
"${SHADERS}/exitpoints.frag");
if (!prg) return false;
prg->setProgramObjectCallback(cb);
OsEng.ref().configurationManager()->setValue("RaycastProgram", prg.get());
OsEng.ref().configurationManager().setValue("RaycastProgram", prg.get());
_programs.push_back(std::move(prg));
return true;
@@ -140,12 +140,12 @@ bool Scene::deinitialize() {
void Scene::update(const UpdateData& data) {
if (!_sceneGraphToLoad.empty()) {
OsEng.renderEngine()->scene()->clearSceneGraph();
OsEng.renderEngine().scene()->clearSceneGraph();
bool success = loadSceneInternal(_sceneGraphToLoad);
_sceneGraphToLoad = "";
if (!success)
return;
OsEng.renderEngine()->aBuffer()->invalidateABuffer();
OsEng.renderEngine().aBuffer()->invalidateABuffer();
}
for (SceneGraphNode* node : _graph.nodes())
node->update(data);
@@ -257,7 +257,7 @@ bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) {
//_root->calculateBoundingSphere();
// set the camera position
Camera* c = OsEng.ref().renderEngine()->camera();
Camera* c = OsEng.ref().renderEngine().camera();
//auto focusIterator = _allNodes.find(_focus);
auto focusIterator = std::find_if(
_graph.nodes().begin(),
@@ -304,10 +304,10 @@ bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) {
// c->setScaling(scaling);
// Set the focus node for the interactionhandler
OsEng.interactionHandler()->setFocusNode(focusNode);
OsEng.interactionHandler().setFocusNode(focusNode);
}
else
OsEng.interactionHandler()->setFocusNode(_graph.rootNode());
OsEng.interactionHandler().setFocusNode(_graph.rootNode());
glm::vec4 position;
if (cameraDictionary.hasKey(KeyPositionObject)
@@ -324,7 +324,7 @@ bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) {
}
// the camera position
const SceneGraphNode* fn = OsEng.interactionHandler()->focusNode();
const SceneGraphNode* fn = OsEng.interactionHandler().focusNode();
// Check crash for when fn == nullptr
glm::mat4 la = glm::lookAt(cameraPosition.vec3(), fn->worldPosition().vec3(), c->lookUpVector());
@@ -344,18 +344,18 @@ bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) {
for (SceneGraphNode* node : _graph.nodes()) {
std::vector<properties::Property*> properties = node->propertiesRecursive();
for (properties::Property* p : properties) {
OsEng.gui()->_property.registerProperty(p);
OsEng.gui()._property.registerProperty(p);
}
}
// If a LuaDocumentationFile was specified, generate it now
const bool hasType = OsEng.configurationManager()->hasKey(ConfigurationManager::KeyPropertyDocumentationType);
const bool hasFile = OsEng.configurationManager()->hasKey(ConfigurationManager::KeyPropertyDocumentationFile);
const bool hasType = OsEng.configurationManager().hasKey(ConfigurationManager::KeyPropertyDocumentationType);
const bool hasFile = OsEng.configurationManager().hasKey(ConfigurationManager::KeyPropertyDocumentationFile);
if (hasType && hasFile) {
std::string propertyDocumentationType;
OsEng.configurationManager()->getValue(ConfigurationManager::KeyPropertyDocumentationType, propertyDocumentationType);
OsEng.configurationManager().getValue(ConfigurationManager::KeyPropertyDocumentationType, propertyDocumentationType);
std::string propertyDocumentationFile;
OsEng.configurationManager()->getValue(ConfigurationManager::KeyPropertyDocumentationFile, propertyDocumentationFile);
OsEng.configurationManager().getValue(ConfigurationManager::KeyPropertyDocumentationFile, propertyDocumentationFile);
propertyDocumentationFile = absPath(propertyDocumentationFile);
writePropertyDocumentation(propertyDocumentationFile, propertyDocumentationType);

View File

@@ -62,7 +62,7 @@ int property_setValue(lua_State* L) {
//ensure properties are synced over parallel connection
std::string value;
prop->getStringValue(value);
OsEng.parallelConnection()->scriptMessage(prop->fullyQualifiedIdentifier(), value);
OsEng.parallelConnection().scriptMessage(prop->fullyQualifiedIdentifier(), value);
}
return 0;
@@ -107,7 +107,7 @@ int loadScene(lua_State* L) {
std::string sceneFile = luaL_checkstring(L, -1);
OsEng.renderEngine()->scene()->scheduleLoadSceneFile(sceneFile);
OsEng.renderEngine().scene()->scheduleLoadSceneFile(sceneFile);
return 0;
}

View File

@@ -125,7 +125,7 @@ bool SceneGraph::loadFromFile(const std::string& sceneDescription) {
return true;
lua_State* state = ghoul::lua::createNewLuaState();
OsEng.scriptEngine()->initializeLuaState(state);
OsEng.scriptEngine().initializeLuaState(state);
// Get the common directory
bool commonFolderSpecified = sceneDictionary.hasKey(KeyCommonFolder);
@@ -343,7 +343,7 @@ bool SceneGraph::sortTopologically() {
}
RenderEngine::ABufferImplementation i = OsEng.renderEngine()->aBufferImplementation();
RenderEngine::ABufferImplementation i = OsEng.renderEngine().aBufferImplementation();
if (i == RenderEngine::ABufferImplementation::FrameBuffer) {
auto it = std::find_if(
_topologicalSortedNodes.begin(),

View File

@@ -156,7 +156,7 @@ bool ScriptEngine::runScript(const std::string& script) {
}
//if we're currently hosting the parallel session, find out if script should be synchronized.
if (OsEng.parallelConnection()->isHost()){
if (OsEng.parallelConnection().isHost()){
std::string lib, func;
if (parseLibraryAndFunctionNames(lib, func, script) && shouldScriptBeSent(lib, func)){

View File

@@ -25,6 +25,7 @@
#include <openspace/util/screenlog.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <ghoul/opengl/ghoul_gl.h>