Merged master into NewAtmosphere

This commit is contained in:
Jonathas Costa
2017-12-01 17:13:04 -05:00
34 changed files with 365 additions and 93 deletions

View File

@@ -94,7 +94,10 @@ private:
void clear();
QStringList selectedScenes() const;
void handleFileFutureAddition(const std::vector<std::shared_ptr<openspace::DownloadManager::FileFuture>>& futures);
void handleFileFutureAddition(
const std::vector<std::shared_ptr<openspace::DownloadManager::FileFuture>>&
futures
);
void handleDirectFiles();
void handleFileRequest();
@@ -116,7 +119,10 @@ private:
std::set<std::string> _filesDownloading;
std::vector<std::shared_ptr<openspace::DownloadManager::FileFuture>> _futures;
std::map<std::shared_ptr<openspace::DownloadManager::FileFuture>, InfoWidget*> _futureInfoWidgetMap;
std::map<
std::shared_ptr<openspace::DownloadManager::FileFuture>,
InfoWidget*
> _futureInfoWidgetMap;
std::vector<std::shared_ptr<openspace::DownloadManager::FileFuture>> _futuresToAdd;
std::atomic_flag _mutex;

View File

@@ -41,7 +41,7 @@ namespace ghoul::fontrendering {
namespace ghoul::opengl {
class ProgramObject;
class Texture;
class Texture;
} // namespace ghoul::opengl
namespace openspace {

View File

@@ -110,9 +110,9 @@ public:
float globalBlackOutFactor();
void setGlobalBlackOutFactor(float factor);
void registerScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s);
void unregisterScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s);
void unregisterScreenSpaceRenderable(const std::string& name);
void addScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s);
void removeScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s);
void removeScreenSpaceRenderable(const std::string& name);
std::shared_ptr<ScreenSpaceRenderable> screenSpaceRenderable(const std::string& name);
std::vector<ScreenSpaceRenderable*> screenSpaceRenderables() const;

View File

@@ -73,7 +73,7 @@ public:
* Initalizes the SceneGraph
*/
void initialize();
/**
* Initializes the OpenGL part of the SceneGraph
*/

View File

@@ -35,7 +35,8 @@ namespace openspace {
class BlockPlaneIntersectionGeometry {
public:
// initializers
BlockPlaneIntersectionGeometry(glm::vec3 blockSize, glm::vec3 planeNormal, float planeDistance);
BlockPlaneIntersectionGeometry(glm::vec3 blockSize, glm::vec3 planeNormal,
float planeDistance);
~BlockPlaneIntersectionGeometry();
bool initialize();

View File

@@ -48,10 +48,11 @@ public:
// Sets the power scaled coordinates with w = 0
PowerScaledCoordinate(glm::vec3 v);
static PowerScaledCoordinate CreatePowerScaledCoordinate(double d1, double d2, double d3);
static PowerScaledCoordinate CreatePowerScaledCoordinate(double d1, double d2,
double d3);
// get functions
// return the full, unmodified PSC
// return the full, unmodified PSC
const glm::vec4& vec4() const;
// returns the rescaled, "normal" coordinates

View File

@@ -35,7 +35,7 @@ namespace openspace {
class PowerScaledSphere {
public:
// initializers
PowerScaledSphere(const PowerScaledScalar& radius,
PowerScaledSphere(const PowerScaledScalar& radius,
int segments = 8);
PowerScaledSphere(glm::vec3 radius, int segments);

View File

@@ -34,6 +34,7 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrail.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrailorbit.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrailtrajectory.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspacedashboard.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimagelocal.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimageonline.h
@@ -57,6 +58,7 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrail.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrailorbit.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrailtrajectory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspacedashboard.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimagelocal.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimageonline.cpp

View File

@@ -39,6 +39,7 @@
#include <modules/base/rendering/renderableplane.h>
#include <modules/base/rendering/modelgeometry.h>
#include <modules/base/rendering/multimodelgeometry.h>
#include <modules/base/rendering/screenspacedashboard.h>
#include <modules/base/rendering/screenspaceimagelocal.h>
#include <modules/base/rendering/screenspaceimageonline.h>
#include <modules/base/rendering/screenspaceframebuffer.h>
@@ -72,6 +73,7 @@ void BaseModule::internalInitialize() {
auto fSsRenderable = FactoryManager::ref().factory<ScreenSpaceRenderable>();
ghoul_assert(fSsRenderable, "ScreenSpaceRenderable factory was not created");
fSsRenderable->registerClass<ScreenSpaceDashboard>("ScreenSpaceDashboard");
fSsRenderable->registerClass<ScreenSpaceImageLocal>("ScreenSpaceImageLocal");
fSsRenderable->registerClass<ScreenSpaceImageOnline>("ScreenSpaceImageOnline");
fSsRenderable->registerClass<ScreenSpaceFramebuffer>("ScreenSpaceFramebuffer");
@@ -117,6 +119,7 @@ std::vector<documentation::Documentation> BaseModule::documentations() const {
RenderableSphere::Documentation(),
RenderableTrailOrbit::Documentation(),
RenderableTrailTrajectory::Documentation(),
ScreenSpaceDashboard::Documentation(),
ScreenSpaceFramebuffer::Documentation(),
ScreenSpaceImageLocal::Documentation(),
ScreenSpaceImageOnline::Documentation(),

View File

@@ -47,12 +47,12 @@ namespace documentation { struct Documentation; }
class RenderableTrailOrbit : public RenderableTrail {
public:
explicit RenderableTrailOrbit(const ghoul::Dictionary& dictionary);
void initializeGL() override;
void deinitializeGL() override;
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
private:

View File

@@ -0,0 +1,182 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/base/rendering/screenspacedashboard.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/interaction/navigationhandler.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/util/distanceconversion.h>>
#include <openspace/util/timeconversion.h>
#include <openspace/util/timemanager.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
namespace {
const char* KeyName = "Name";
const char* KeyFontMono = "Mono";
} // namespace
namespace openspace {
documentation::Documentation ScreenSpaceDashboard::Documentation() {
using namespace openspace::documentation;
return {
"ScreenSpace Dashboard",
"base_screenspace_dashboard",
{
{
KeyName,
new StringVerifier,
Optional::Yes,
"Specifies the GUI name of the ScreenSpaceDashboard"
}
}
};
}
ScreenSpaceDashboard::ScreenSpaceDashboard(const ghoul::Dictionary& dictionary)
: ScreenSpaceFramebuffer(dictionary)
, _fontRenderer(nullptr)
, _fontDate(nullptr)
, _fontInfo(nullptr)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"ScreenSpaceDashboard"
);
if (dictionary.hasKey(KeyName)) {
setName(dictionary.value<std::string>(KeyName));
}
else {
static int id = 0;
if (id == 0) {
setName("ScreenSpaceDashboard");
}
else {
setName("ScreenSpaceDashboard" + std::to_string(id));
}
++id;
}
_scale = 1.f;
_scale.setMaxValue(15.f);
_size.onChange([this]() {
_fontRenderer->setFramebufferSize({ _size.value().z, _size.value().w });
});
}
ScreenSpaceDashboard::~ScreenSpaceDashboard() {}
bool ScreenSpaceDashboard::initializeGL() {
ScreenSpaceFramebuffer::initializeGL();
_fontRenderer = ghoul::fontrendering::FontRenderer::createDefault();
_fontRenderer->setFramebufferSize({ _size.value().z, _size.value().w });
_fontDate = OsEng.fontManager().font(
KeyFontMono,
48
);
_fontInfo = OsEng.fontManager().font(
KeyFontMono,
32
);
addRenderFunction([this]() {
glm::vec2 penPosition = glm::vec2(
10.f,
_size.value().w
);
penPosition.y -= _fontDate->height();
RenderFontCr(
*_fontDate,
penPosition,
"Date: %s",
OsEng.timeManager().time().UTC().c_str()
);
std::pair<double, std::string> deltaTime = simplifyTime(
OsEng.timeManager().time().deltaTime()
);
RenderFontCr(
*_fontInfo,
penPosition,
"Simulation increment: %.1f %s / second",
deltaTime.first,
deltaTime.second.c_str()
);
double distance = glm::length(
OsEng.renderEngine().camera()->positionVec3() -
OsEng.navigationHandler().focusNode()->worldPosition()
);
std::pair<double, std::string> dist = simplifyDistance(distance);
RenderFontCr(
*_fontInfo,
penPosition,
"Distance from focus: %f %s",
dist.first,
dist.second.c_str()
);
});
return true;
}
bool ScreenSpaceDashboard::deinitializeGL() {
_fontRenderer = nullptr;
return ScreenSpaceFramebuffer::deinitializeGL();
}
bool ScreenSpaceDashboard::isReady() const {
return (_fontRenderer != nullptr) &&
(_fontDate != nullptr) &&
(_fontInfo != nullptr) &&
ScreenSpaceFramebuffer::isReady();
}
void ScreenSpaceDashboard::update() {
if (OsEng.windowWrapper().windowHasResized()) {
glm::ivec2 size = OsEng.windowWrapper().currentWindowResolution();
_size = { 0.f, 0.f, size.x, size.y };
_originalViewportSize = size;
createFramebuffer();
}
}
} // namespace openspace

View File

@@ -0,0 +1,61 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_MODULE_BASE___SCREENSPACEDASHBOARD___H__
#define __OPENSPACE_MODULE_BASE___SCREENSPACEDASHBOARD___H__
#include <modules/base/rendering/screenspaceframebuffer.h>
namespace ghoul::fontrendering {
class Font;
class FontRenderer;
}
namespace openspace {
namespace documentation { struct Documentation; }
class ScreenSpaceDashboard: public ScreenSpaceFramebuffer {
public:
ScreenSpaceDashboard(const ghoul::Dictionary& dictionary);
~ScreenSpaceDashboard();
bool initializeGL() override;
bool deinitializeGL() override;
bool isReady() const override;
void update() override;
static documentation::Documentation Documentation();
private:
std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
std::shared_ptr<ghoul::fontrendering::Font> _fontDate;
std::shared_ptr<ghoul::fontrendering::Font> _fontInfo;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___SCREENSPACEDASHBOARD___H__

View File

@@ -82,7 +82,7 @@ ScreenSpaceFramebuffer::~ScreenSpaceFramebuffer() {}
bool ScreenSpaceFramebuffer::initializeGL() {
ScreenSpaceRenderable::initializeGL();
createFragmentbuffer();
createFramebuffer();
return isReady();
}
@@ -90,7 +90,9 @@ bool ScreenSpaceFramebuffer::initializeGL() {
bool ScreenSpaceFramebuffer::deinitializeGL() {
ScreenSpaceRenderable::deinitializeGL();
_framebuffer->activate();
_framebuffer->detachAll();
_framebuffer->deactivate();
removeAllRenderFunctions();
return true;
@@ -103,7 +105,7 @@ void ScreenSpaceFramebuffer::render() {
float xratio = _originalViewportSize.x / (size.z-size.x);
float yratio = _originalViewportSize.y / (size.w-size.y);;
if (!_renderFunctions.empty()) {
if (!_renderFunctions.empty() || !_renderFunctionsShared.empty()) {
glViewport(
static_cast<GLint>(-size.x * xratio),
static_cast<GLint>(-size.y * yratio),
@@ -113,10 +115,12 @@ void ScreenSpaceFramebuffer::render() {
GLint defaultFBO = _framebuffer->getActiveObject();
_framebuffer->activate();
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClearColor(0.f, 0.f, 0.f, 0.f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_ALPHA_TEST);
for (const auto& renderFunction : _renderFunctions) {
renderFunction();
}
for (const auto& renderFunction : _renderFunctionsShared) {
(*renderFunction)();
}
_framebuffer->deactivate();
@@ -131,15 +135,15 @@ void ScreenSpaceFramebuffer::render() {
glm::mat4 rotation = rotationMatrix();
glm::mat4 translation = translationMatrix();
glm::mat4 scale = scaleMatrix();
scale = glm::scale(scale, glm::vec3((1.0/xratio), -(1.0/yratio), 1.0f));
glm::mat4 scale = glm::scale(
scaleMatrix(),
glm::vec3((1.f / xratio), (1.f / yratio), 1.f)
);
glm::mat4 modelTransform = rotation*translation*scale;
draw(modelTransform);
}
}
void ScreenSpaceFramebuffer::update() {}
bool ScreenSpaceFramebuffer::isReady() const {
bool ready = true;
if (!_shader) {
@@ -155,17 +159,22 @@ void ScreenSpaceFramebuffer::setSize(glm::vec4 size) {
_size.set(size);
}
void ScreenSpaceFramebuffer::addRenderFunction(std::function<void()> renderFunction) {
_renderFunctions.push_back(std::move(renderFunction));
}
void ScreenSpaceFramebuffer::addRenderFunction(
std::shared_ptr<std::function<void()>> renderFunction)
{
_renderFunctions.push_back(renderFunction);
_renderFunctionsShared.push_back(std::move(renderFunction));
}
void ScreenSpaceFramebuffer::removeAllRenderFunctions() {
_renderFunctions.clear();
_renderFunctionsShared.clear();
}
void ScreenSpaceFramebuffer::createFragmentbuffer() {
void ScreenSpaceFramebuffer::createFramebuffer() {
_framebuffer = std::make_unique<ghoul::opengl::FramebufferObject>();
_framebuffer->activate();
_texture = std::make_unique<ghoul::opengl::Texture>(glm::uvec3(

View File

@@ -51,23 +51,25 @@ public:
bool initializeGL() override;
bool deinitializeGL() override;
void render() override;
void update() override;
bool isReady() const override;
void setSize(glm::vec4);
void addRenderFunction(std::shared_ptr<std::function<void()>> renderFunction);
void addRenderFunction(std::function<void()> renderFunction);
void removeAllRenderFunctions();
static documentation::Documentation Documentation();
private:
void createFragmentbuffer();
static int id();
protected:
void createFramebuffer();
properties::Vec4Property _size;
private:
static int id();
std::unique_ptr<ghoul::opengl::FramebufferObject> _framebuffer;
std::vector<std::shared_ptr<std::function<void()>>> _renderFunctions;
std::vector<std::shared_ptr<std::function<void()>>> _renderFunctionsShared;
std::vector<std::function<void()>> _renderFunctions;
int _id;
};

View File

@@ -355,7 +355,6 @@ FixedRotation::FixedRotation(const ghoul::Dictionary& dictionary)
break;
}
};
_xAxis.type.addOptions({
{ Axis::Type::Object, "Object" },

View File

@@ -48,7 +48,8 @@ public:
void initialize();
void deinitialize();
std::shared_ptr<Layer> addLayer(layergroupid::GroupID groupId, ghoul::Dictionary layerDict);
std::shared_ptr<Layer> addLayer(layergroupid::GroupID groupId,
ghoul::Dictionary layerDict);
void deleteLayer(layergroupid::GroupID groupId, std::string layerName);
const LayerGroup& layerGroup(size_t groupId);

View File

@@ -129,7 +129,7 @@ bool TileProviderByLevel::deinitialize() {
for (const std::shared_ptr<TileProvider>& tp : _levelTileProviders) {
success &= tp->deinitialize();
}
return TileProvider::deinitialize() && success;
}

View File

@@ -94,7 +94,6 @@ private:
properties::Property::Visibility _currentVisibility;
std::vector<ImGuiContext*> _contexts;
};

View File

@@ -227,7 +227,7 @@ void addScreenSpaceRenderableLocal(std::string texturePath) {
const std::string luaTable =
"{Type = 'ScreenSpaceImageLocal', TexturePath = openspace.absPath('" +
texturePath + "') }";
const std::string script = "openspace.registerScreenSpaceRenderable(" +
const std::string script = "openspace.addScreenSpaceRenderable(" +
luaTable + ");";
OsEng.scriptEngine().queueScript(
script,
@@ -238,7 +238,7 @@ void addScreenSpaceRenderableLocal(std::string texturePath) {
void addScreenSpaceRenderableOnline(std::string texturePath) {
const std::string luaTable =
"{Type = 'ScreenSpaceImageOnline', TexturePath = '" + texturePath + "' }";
const std::string script = "openspace.registerScreenSpaceRenderable(" +
const std::string script = "openspace.addScreenSpaceRenderable(" +
luaTable + ");";
OsEng.scriptEngine().queueScript(
script,
@@ -483,7 +483,11 @@ void GUI::initializeGL() {
//_contexts[i] = ImGui::CreateContext();
ImGui::SetCurrentContext(_contexts[i]);
ImGui::GetIO().Fonts->GetTexDataAsRGBA32(&pngData, &textureSize.x, &textureSize.y);
ImGui::GetIO().Fonts->GetTexDataAsRGBA32(
&pngData,
&textureSize.x,
&textureSize.y
);
}
_fontTexture = std::make_unique<ghoul::opengl::Texture>(
pngData,
@@ -812,6 +816,14 @@ void GUI::render() {
addScreenSpaceRenderableOnline(std::string(addImageOnlineBuffer));
}
bool addDashboard = ImGui::Button("Add Dashboard");
if (addDashboard) {
OsEng.scriptEngine().queueScript(
"openspace.addScreenSpaceRenderable({ Type = 'ScreenSpaceDashboard' });",
openspace::scripting::ScriptEngine::RemoteScripting::Yes
);
}
ImGui::Checkbox("ImGUI Internals", &_showInternals);
if (_showInternals) {
ImGui::Begin("Style Editor");

View File

@@ -38,6 +38,8 @@
#include <ghoul/filesystem/filesystem.h>
#include <glm/ext.hpp>
#include <glm/ext.hpp>
namespace openspace {
using namespace properties;
@@ -668,7 +670,7 @@ void renderDMat2Property(Property* prop, const std::string& ownerName,
isRegular
);
}
ImGui::PopID();
}

View File

@@ -93,7 +93,7 @@ int iswa_addScreenSpaceCygnet(lua_State* L) {
std::shared_ptr<ScreenSpaceRenderable> s(
ScreenSpaceRenderable::createFromDictionary(d)
);
OsEng.renderEngine().registerScreenSpaceRenderable(s);
OsEng.renderEngine().addScreenSpaceRenderable(s);
}
return 0;
}

View File

@@ -48,7 +48,7 @@ namespace documentation { struct Documentation; }
class RenderableFov : public Renderable {
public:
RenderableFov(const ghoul::Dictionary& dictionary);
void initializeGL() override;
void deinitializeGL() override;
@@ -56,7 +56,7 @@ public:
void render(const RenderData& data, RendererTasks& rendererTask) override;
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
private:
@@ -153,7 +153,7 @@ private:
properties::Vec4Property square; // Color for the orthogonal square
} _colors;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_SPACECRAFTINSTRUMENTS___RENDERABLEFOV___H__

View File

@@ -385,7 +385,7 @@ void TouchInteraction::directControl(const std::vector<TuioCursor>& list) {
{ // Orbit (global rotation)
dvec3 eulerAngles(q[1], q[0], 0);
dquat rotationDiffCamSpace = dquat(eulerAngles);
dvec3 centerToCamera = camPos - centerPos;
dquat rotationDiffWorldSpace =

View File

@@ -89,8 +89,8 @@ return {
ShowNodeNames = true,
ShowProgressbar = true
},
-- CheckOpenGLState = true,
-- LogEachOpenGLCall = true,
CheckOpenGLState = true,
LogEachOpenGLCall = true,
ShutdownCountdown = 3,
-- OnScreenTextScaling = "framebuffer",

View File

@@ -611,7 +611,6 @@ void OpenSpaceEngine::loadScene(const std::string& scenePath) {
if (configurationManager().hasKey(kProgress)) {
showProgressbar = configurationManager().value<bool>(kProgress);
}
_loadingScreen = std::make_unique<LoadingScreen>(
LoadingScreen::ShowMessage(showMessage),
@@ -679,8 +678,6 @@ void OpenSpaceEngine::loadScene(const std::string& scenePath) {
initializeFinished = true;
});
// While the SceneGraphNodes initialize themselves, we can hand over control to the
// Loading screen rendering
@@ -693,7 +690,7 @@ void OpenSpaceEngine::loadScene(const std::string& scenePath) {
t.join();
// It's okay to delete it since the last rendered image will remain on screen
_loadingScreen = nullptr;
if (errorWhileLoading) {
return;
}

View File

@@ -31,7 +31,7 @@
#include <vector>
namespace {
glm::mat4x3 fromLuaConversion(lua_State* state, bool& success) {
glm::mat4x3 result;
int number = 1;
@@ -106,7 +106,7 @@ bool toStringConversion(std::string& outValue, glm::mat4x3 inValue) {
return true;
}
} // namespace
} // namespace
namespace openspace::properties {

View File

@@ -30,7 +30,7 @@
#include <sstream>
namespace {
unsigned short fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {

View File

@@ -77,7 +77,7 @@ namespace {
{
lhsLl -= glm::vec2(ItemStandoffDistance / 2.f);
lhsUr += glm::vec2(ItemStandoffDistance / 2.f);
rhsLl -= glm::vec2(ItemStandoffDistance / 2.f);
rhsUr += glm::vec2(ItemStandoffDistance / 2.f);
@@ -149,7 +149,7 @@ LoadingScreen::LoadingScreen(ShowMessage showMessage, ShowNodeNames showNodeName
absPath("${OPENSPACE_DATA}/openspace-logo.png")
);
_logoTexture->uploadTexture();
glGenVertexArrays(1, &_logo.vao);
glBindVertexArray(_logo.vao);
glGenBuffers(1, &_logo.vbo);
@@ -216,7 +216,7 @@ LoadingScreen::LoadingScreen(ShowMessage showMessage, ShowNodeNames showNodeName
LoadingScreen::~LoadingScreen() {
_logoTexture = nullptr;
_loadingFont = nullptr;
_messageFont = nullptr;
_itemFont = nullptr;
@@ -234,7 +234,7 @@ LoadingScreen::~LoadingScreen() {
void LoadingScreen::render() {
// We have to recalculate the positions here because we will not be informed about a
// window size change
const glm::vec2 dpiScaling = OsEng.windowWrapper().dpiScaling();
const glm::ivec2 res =
glm::vec2(OsEng.windowWrapper().currentWindowResolution()) / dpiScaling;
@@ -304,16 +304,14 @@ void LoadingScreen::render() {
ProgressbarSize.x,
ProgressbarSize.y * screenAspectRatio
};
glm::vec2 progressbarLl = {
ProgressbarCenter.x - progressbarSize.x,
ProgressbarCenter.y - progressbarSize.y
};
glm::vec2 progressbarUr = {
ProgressbarCenter.x + progressbarSize.x ,
ProgressbarCenter.y + progressbarSize.y
};
if (_showProgressbar) {
@@ -321,14 +319,14 @@ void LoadingScreen::render() {
// Depending on the progress, we only want to draw the progress bar to a mixture
// of the lowerleft and upper right extent
float progress = _nItems != 0 ?
static_cast<float>(_iProgress) / static_cast<float>(_nItems) :
0.f;
glm::vec2 ur = progressbarUr;
ur.x = glm::mix(progressbarLl.x, progressbarUr.x, progress);
GLfloat dataFill[] = {
progressbarLl.x, progressbarLl.y,
ur.x, ur.y,
@@ -471,7 +469,7 @@ void LoadingScreen::render() {
for (Item& item : _items) {
if (!item.hasLocation) {
// Compute a new location
FR::BoundingBoxInformation b = renderer.boundingBox(
*_itemFont,
"%s",
@@ -500,7 +498,6 @@ void LoadingScreen::render() {
ur = ll + b.boundingBox;
// Test against logo and text
bool logoOverlap = rectOverlaps(
ndcToScreen(logoLl, res), ndcToScreen(logoUr, res),
ll, ur
@@ -528,7 +525,6 @@ void LoadingScreen::render() {
continue;
}
// Test against all other boxes
bool overlap = false;
for (const Item& j : _items) {
@@ -569,11 +565,14 @@ void LoadingScreen::render() {
return glm::vec4(1.f);
}
}();
if (item.status == ItemStatus::Finished) {
auto t = std::chrono::duration_cast<std::chrono::milliseconds>(now - item.finishedTime);
color.a = 1.f - static_cast<float>(t.count()) / static_cast<float>(TTL.count());
if (item.status == ItemStatus::Finished) {
auto t = std::chrono::duration_cast<std::chrono::milliseconds>(
now - item.finishedTime
);
color.a = 1.f - static_cast<float>(t.count()) /
static_cast<float>(TTL.count());
}
#ifdef LOADINGSCREEN_DEBUGGING

View File

@@ -886,15 +886,15 @@ scripting::LuaLibrary RenderEngine::luaLibrary() {
""
},
{
"registerScreenSpaceRenderable",
&luascriptfunctions::registerScreenSpaceRenderable,
"addScreenSpaceRenderable",
&luascriptfunctions::addScreenSpaceRenderable,
"table",
"Will create a ScreenSpaceRenderable from a lua Table and register it in "
"the RenderEngine"
"Will create a ScreenSpaceRenderable from a lua Table and add it in the "
"RenderEngine"
},
{
"unregisterScreenSpaceRenderable",
&luascriptfunctions::unregisterScreenSpaceRenderable,
"removeScreenSpaceRenderable",
&luascriptfunctions::removeScreenSpaceRenderable,
"string",
"Given a ScreenSpaceRenderable name this script will remove it from the "
"renderengine"
@@ -911,16 +911,12 @@ performance::PerformanceManager* RenderEngine::performanceManager() {
return _performanceManager.get();
}
void RenderEngine::registerScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s)
{
void RenderEngine::addScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s) {
s->initialize();
s->initializeGL();
_screenSpaceRenderables.push_back(std::move(s));
}
void RenderEngine::unregisterScreenSpaceRenderable(
std::shared_ptr<ScreenSpaceRenderable> s)
{
void RenderEngine::removeScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s) {
auto it = std::find(
_screenSpaceRenderables.begin(),
_screenSpaceRenderables.end(),
@@ -933,10 +929,10 @@ void RenderEngine::unregisterScreenSpaceRenderable(
}
}
void RenderEngine::unregisterScreenSpaceRenderable(const std::string& name){
void RenderEngine::removeScreenSpaceRenderable(const std::string& name) {
std::shared_ptr<ScreenSpaceRenderable> s = screenSpaceRenderable(name);
if (s) {
unregisterScreenSpaceRenderable(s);
removeScreenSpaceRenderable(s);
}
}
@@ -1034,7 +1030,7 @@ void RenderEngine::renderInformation() {
penPosition,
"Simulation increment: %.1f %s / second",
deltaTime.first,
deltaTime.second
deltaTime.second.c_str()
);
double distance = glm::length(
@@ -1047,7 +1043,7 @@ void RenderEngine::renderInformation() {
penPosition,
"Distance from focus: %f %s",
dist.first,
dist.second
dist.second.c_str()
);
FrametimeType frametimeType = FrametimeType(_frametimeType.value());

View File

@@ -97,7 +97,7 @@ int fadeOut(lua_State* L) {
return 0;
}
int registerScreenSpaceRenderable(lua_State* L) {
int addScreenSpaceRenderable(lua_State* L) {
using ghoul::lua::errorLocation;
int nArguments = lua_gettop(L);
@@ -110,19 +110,19 @@ int registerScreenSpaceRenderable(lua_State* L) {
ghoul::lua::luaDictionaryFromState(L, d);
}
catch (const ghoul::lua::LuaFormatException& e) {
LERRORC("registerScreenSpaceRenderable", e.what());
LERRORC("addScreenSpaceRenderable", e.what());
return 0;
}
std::shared_ptr<ScreenSpaceRenderable> s(
ScreenSpaceRenderable::createFromDictionary(d)
);
OsEng.renderEngine().registerScreenSpaceRenderable(s);
OsEng.renderEngine().addScreenSpaceRenderable(s);
return 1;
}
int unregisterScreenSpaceRenderable(lua_State* L) {
int removeScreenSpaceRenderable(lua_State* L) {
using ghoul::lua::errorLocation;
int nArguments = lua_gettop(L);
@@ -137,13 +137,13 @@ int unregisterScreenSpaceRenderable(lua_State* L) {
);
if (!s) {
LERRORC(
"unregisterScreenSpaceRenderable",
"removeScreenSpaceRenderable",
errorLocation(L) << "Could not find ScreenSpaceRenderable '" << name << "'"
);
return 0;
}
OsEng.renderEngine().unregisterScreenSpaceRenderable(s);
OsEng.renderEngine().removeScreenSpaceRenderable(s);
return 1;
}

View File

@@ -295,7 +295,7 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary
_delete.onChange([this](){
std::string script =
"openspace.unregisterScreenSpaceRenderable('" + name() + "');";
"openspace.removeScreenSpaceRenderable('" + name() + "');";
OsEng.scriptEngine().queueScript(
script,
scripting::ScriptEngine::RemoteScripting::Yes

View File

@@ -145,7 +145,7 @@ std::unique_ptr<Scene> SceneLoader::loadScene(const std::string& path) {
std::unique_ptr<SceneGraphNode> rootNode = std::make_unique<SceneGraphNode>();
rootNode->setName(SceneGraphNode::RootNodeName);
scene->setRoot(std::move(rootNode));
OsEng.loadingScreen().updateItem(
SceneGraphNode::RootNodeName,
LoadingScreen::ItemStatus::Started

View File

@@ -338,7 +338,7 @@ def check_empty_character_at_end(lines):
if not is_strict_mode:
return ''
index = [i + 1 for i, s in enumerate(lines) if len(s) > 1 and s[-2] == ' ']
index = [i + 1 for i, s in enumerate(lines) if len(s) > 1 and s[-2] == ' ' and not s.strip() == '']
if len(index) > 0:
return index
else: