Merge branch 'master' into feature/animation-fixes

* Resolve conflicts in scene.cpp
This commit is contained in:
Malin E
2021-10-14 14:23:24 +02:00
103 changed files with 2822 additions and 368 deletions

View File

@@ -295,6 +295,11 @@ namespace {
// 'false'
std::optional<bool> logEachOpenGLCall;
// Determines whether events are printed as debug messages to the console each
// frame. If this value is set it determines the default value of the property of
// the OpenSpaceEngine with the same name
std::optional<bool> printEvents;
// This value determines whether the initialization of the scene graph should
// occur multithreaded, that is, whether multiple scene graph nodes should
// initialize in parallel. The only use for this value is to disable it for
@@ -391,6 +396,7 @@ void parseLuaState(Configuration& configuration) {
p.useMultithreadedInitialization.value_or(c.useMultithreadedInitialization);
c.isCheckingOpenGLState = p.checkOpenGLState.value_or(c.isCheckingOpenGLState);
c.isLoggingOpenGLCalls = p.logEachOpenGLCall.value_or(c.isLoggingOpenGLCalls);
c.isPrintingEvents = p.printEvents.value_or(c.isPrintingEvents);
c.shutdownCountdown = p.shutdownCountdown.value_or(c.shutdownCountdown);
c.shouldUseScreenshotDate = p.screenshotUseDate.value_or(c.shouldUseScreenshotDate);
if (p.onScreenTextScaling.has_value()) {

View File

@@ -173,9 +173,10 @@ std::shared_ptr<DownloadManager::FileFuture> DownloadManager::downloadFile(
CURL* curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); // NOLINT
curl_easy_setopt(curl, CURLOPT_USERAGENT, "OpenSpace"); // NOLINT
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); // NOLINT
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); // NOLINT
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeData); // NOLINT
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &writeData); // NOLINT
if (timeout_secs) {
curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout_secs); // NOLINT
}
@@ -204,7 +205,11 @@ std::shared_ptr<DownloadManager::FileFuture> DownloadManager::downloadFile(
future->isFinished = true;
}
else {
future->errorMessage = curl_easy_strerror(res);
long rescode;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &rescode);
future->errorMessage = fmt::format(
"{}. HTTP code: {}", curl_easy_strerror(res), rescode
);
}
if (finishedCb) {

View File

@@ -24,14 +24,15 @@
#include <openspace/engine/globals.h>
#include <openspace/engine/downloadmanager.h>
#include <openspace/engine/configuration.h>
#include <openspace/engine/downloadmanager.h>
#include <openspace/engine/globalscallbacks.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/syncengine.h>
#include <openspace/engine/virtualpropertymanager.h>
#include <openspace/engine/windowdelegate.h>
#include <openspace/events/eventengine.h>
#include <openspace/interaction/actionmanager.h>
#include <openspace/interaction/interactionmonitor.h>
#include <openspace/interaction/keybindingmanager.h>
@@ -71,12 +72,13 @@ namespace {
// in some random global randoms
#ifdef WIN32
constexpr const int TotalSize =
sizeof(MemoryManager) +
sizeof(EventEngine) +
sizeof(ghoul::fontrendering::FontManager) +
sizeof(Dashboard) +
sizeof(DeferredcasterManager) +
sizeof(DownloadManager) +
sizeof(LuaConsole) +
sizeof(MemoryManager) +
sizeof(MissionManager) +
sizeof(ModuleEngine) +
sizeof(OpenSpaceEngine) +
@@ -119,6 +121,22 @@ void create() {
std::byte* currentPos = DataStorage.data();
#endif // WIN32
#ifdef WIN32
memoryManager = new (currentPos) MemoryManager;
ghoul_assert(memoryManager, "No memoryManager");
currentPos += sizeof(MemoryManager);
#else // ^^^ WIN32 / !WIN32 vvv
memoryManager = new MemoryManager;
#endif // WIN32
#ifdef WIN32
eventEngine = new (currentPos) EventEngine;
ghoul_assert(eventEngine, "No eventEngine");
currentPos += sizeof(EventEngine);
#else // ^^^ WIN32 / !WIN32 vvv
downloadManager = new EventEngine;
#endif // WIN32
#ifdef WIN32
fontManager = new (currentPos) ghoul::fontrendering::FontManager({ 1536, 1536, 1 });
ghoul_assert(fontManager, "No fontManager");
@@ -159,14 +177,6 @@ void create() {
luaConsole = new LuaConsole;
#endif // WIN32
#ifdef WIN32
memoryManager = new (currentPos) MemoryManager;
ghoul_assert(memoryManager, "No memoryManager");
currentPos += sizeof(MemoryManager);
#else // ^^^ WIN32 / !WIN32 vvv
memoryManager = new MemoryManager;
#endif // WIN32
#ifdef WIN32
missionManager = new (currentPos) MissionManager;
ghoul_assert(missionManager, "No missionManager");
@@ -574,13 +584,6 @@ void destroy() {
delete missionManager;
#endif // WIN32
LDEBUGC("Globals", "Destroying 'MemoryManager'");
#ifdef WIN32
memoryManager->~MemoryManager();
#else // ^^^ WIN32 / !WIN32 vvv
delete memoryManager;
#endif // WIN32
LDEBUGC("Globals", "Destroying 'LuaConsole'");
#ifdef WIN32
luaConsole->~LuaConsole();
@@ -616,6 +619,20 @@ void destroy() {
delete fontManager;
#endif // WIN32
LDEBUGC("Globals", "Destroying 'EventEngine'");
#ifdef WIN32
eventEngine->~EventEngine();
#else // ^^^ WIN32 / !WIN32 vvv
delete eventEngine;
#endif // WIN32
LDEBUGC("Globals", "Destroying 'MemoryManager'");
#ifdef WIN32
memoryManager->~MemoryManager();
#else // ^^^ WIN32 / !WIN32 vvv
delete memoryManager;
#endif // WIN32
callback::destroy();
}

View File

@@ -36,6 +36,8 @@
#include <openspace/engine/syncengine.h>
#include <openspace/engine/virtualpropertymanager.h>
#include <openspace/engine/windowdelegate.h>
#include <openspace/events/event.h>
#include <openspace/events/eventengine.h>
#include <openspace/interaction/actionmanager.h>
#include <openspace/interaction/interactionmonitor.h>
#include <openspace/interaction/keybindingmanager.h>
@@ -53,6 +55,7 @@
#include <openspace/scene/assetloader.h>
#include <openspace/scene/profile.h>
#include <openspace/scene/scene.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/scene/rotation.h>
#include <openspace/scene/scale.h>
#include <openspace/scene/timeframe.h>
@@ -101,13 +104,22 @@ namespace {
template <class... Ts> overloaded(Ts...)->overloaded<Ts...>;
constexpr const char* _loggerCat = "OpenSpaceEngine";
openspace::properties::Property::PropertyInfo PrintEventsInfo = {
"PrintEvents",
"Print Events",
"If this is enabled, all events that are propagated through the system are "
"printed to the log."
};
} // namespace
namespace openspace {
class Scene;
OpenSpaceEngine::OpenSpaceEngine() {
OpenSpaceEngine::OpenSpaceEngine()
: _printEvents(PrintEventsInfo, false)
{
FactoryManager::initialize();
FactoryManager::ref().addFactory(
std::make_unique<ghoul::TemplateFactory<Renderable>>(),
@@ -186,6 +198,8 @@ void OpenSpaceEngine::initialize() {
global::initialize();
_printEvents = global::configuration->isPrintingEvents;
const std::string versionCheckUrl = global::configuration->versionCheckUrl;
if (!versionCheckUrl.empty()) {
global::versionChecker->requestLatestVersion(versionCheckUrl);
@@ -895,13 +909,16 @@ void OpenSpaceEngine::deinitialize() {
TransformationManager::deinitialize();
SpiceManager::deinitialize();
if (_printEvents) {
events::Event* e = global::eventEngine->firstEvent();
events::logAllEvents(e);
}
ghoul::fontrendering::FontRenderer::deinitialize();
ghoul::logging::LogManager::deinitialize();
LTRACE("deinitialize(end)");
LTRACE("OpenSpaceEngine::deinitialize(end)");
}
@@ -1101,6 +1118,7 @@ void OpenSpaceEngine::preSynchronization() {
resetPropertyChangeFlagsOfSubowners(global::rootPropertyOwner);
_hasScheduledAssetLoading = false;
_scheduledAssetPathToLoad.clear();
global::eventEngine->publishEvent<events::EventProfileLoadingFinished>();
}
else if (_isRenderingFirstFrame) {
global::profile->ignoreUpdates = true;
@@ -1185,6 +1203,9 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
if (_shutdown.inShutdown) {
if (_shutdown.timer <= 0.f) {
global::eventEngine->publishEvent<events::EventApplicationShutdown>(
events::EventApplicationShutdown::State::Finished
);
global::windowDelegate->terminate();
return;
}
@@ -1310,6 +1331,23 @@ void OpenSpaceEngine::postDraw() {
_isRenderingFirstFrame = false;
}
//
// Handle events
//
const events::Event* e = global::eventEngine->firstEvent();
if (_printEvents) {
events::logAllEvents(e);
}
global::eventEngine->triggerActions();
while (e) {
// @TODO (abock, 2021-08-25) Need to send all events to a topic to be sent out to
// others
e = e->next;
}
global::eventEngine->postFrameCleanup();
global::memoryManager->PersistentMemory.housekeeping();
LTRACE("OpenSpaceEngine::postDraw(end)");
@@ -1543,15 +1581,24 @@ void OpenSpaceEngine::toggleShutdownMode() {
if (_shutdown.inShutdown) {
// If we are already in shutdown mode, we want to disable it
_shutdown.inShutdown = false;
global::eventEngine->publishEvent<events::EventApplicationShutdown>(
events::EventApplicationShutdown::State::Aborted
);
}
else {
// Else, we have to enable it
_shutdown.timer = _shutdown.waitTime;
_shutdown.inShutdown = true;
global::eventEngine->publishEvent<events::EventApplicationShutdown>(
events::EventApplicationShutdown::State::Started
);
}
}
void setCameraFromProfile(const Profile& p) {
if (!p.camera.has_value()) {
throw ghoul::RuntimeError("No 'camera' entry exists in the startup profile");
}
std::visit(
overloaded{
[](const Profile::CameraNavState& navStateProfile) {