Merge pull request #408 from OpenSpace/feature/various-fixes

Feature/various fixes
  * Remove runTime from OpenSpaceEngine and place in WindowWrapper instead
  * Add the ability to remove Tags
  * Add display for current time and ability to return to today to the sp…  …
  * Clean up RenderEngine
  * Remove unused shaders
  * Add Lua method to check whether a scenegraphnode is present in the scene  …
  * Make use of the function to guard mark_interesting_nodes against a nonexisting scenegraph node
This commit is contained in:
Alexander Bock
2017-10-24 10:33:39 -07:00
committed by GitHub
33 changed files with 529 additions and 795 deletions
-1
View File
@@ -313,7 +313,6 @@ void mainInitFunc() {
void mainPreSyncFunc() {
LTRACE("main::mainPreSyncFunc(begin)");
OsEng.setRunTime(sgct::Engine::getTime());
OsEng.preSynchronization();
LTRACE("main::mainPreSyncFunc(end)");
}
@@ -79,9 +79,6 @@ public:
static OpenSpaceEngine& ref();
static bool isCreated();
double runTime();
void setRunTime(double t);
// callbacks
void initialize();
void initializeGL();
@@ -101,9 +98,6 @@ public:
void decode();
void scheduleLoadScene(std::string scenePath);
void enableBarrier();
void disableBarrier();
void writeDocumentation();
void toggleShutdownMode();
@@ -234,8 +228,6 @@ private:
std::vector<std::function<bool (double, double)>> mouseScrollWheel;
} _moduleCallbacks;
double _runTime;
// Structure that is responsible for the delayed shutdown of the application
struct {
// Whether the application is currently in shutdown mode (i.e. counting down the
@@ -49,6 +49,7 @@ public:
double averageDeltaTime() const override;
double deltaTime() const override;
double applicationTime() const override;
glm::vec2 mousePosition() const override;
uint32_t mouseButtons(int maxNumber) const override;
glm::ivec2 currentWindowSize() const override;
@@ -106,6 +106,13 @@ public:
*/
virtual double deltaTime() const;
/**
* Returns the time that has passed (in seconds) since application start
* \return The time that has passed (in seconds) since application start
* @return [description]
*/
virtual double applicationTime() const;
/**
* Returns the location of the mouse cursor in pixel screen coordinates. On default,
* this method returns <code>0,0</code>.
+1 -1
View File
@@ -55,6 +55,7 @@ public:
private:
void parallelConnectionChanged(const ParallelConnection::Status& status);
void addToCommand(std::string c);
std::string sanitizeInput(std::string str);
@@ -68,7 +69,6 @@ private:
properties::Vec4Property _historyTextColor;
properties::IntProperty _historyLength;
size_t _inputPosition;
std::vector<std::string> _commandsHistory;
size_t _activeCommand;
@@ -44,7 +44,9 @@ public:
static void createGlobalSharedMemory();
static void destroyGlobalSharedMemory();
PerformanceManager();
PerformanceManager(std::string loggingDirectory = "${BASE_PATH}",
std::string prefix = "PM-");
~PerformanceManager();
void resetPerformanceMeasurements();
+10 -2
View File
@@ -224,12 +224,20 @@ public:
std::vector<std::string> tags() const;
/**
* Adds a tag to the Property's list of assigned tags. Tags are useful for creating
* groups of Properties that can be used in batch operations.
* Adds a tag to the PropertyOwner's list of assigned tags. Tags are useful for
* creating oups of Properties that can be used in batch operations or to mark up
* PropertyOwners for other usages (such signalling to GUI applications).
* \param tag The string that is to be assigned to the Property
*/
void addTag(std::string tag);
/**
* Removes a tag from this PropertyOwner. No error is reported if the tag does not
* exist
* @param tag The tag is that is to be removed from this PropertyOwner
*/
void removeTag(const std::string& tag);
private:
/// The name of this PropertyOwner
std::string _name;
+6 -7
View File
@@ -65,7 +65,8 @@ public:
enum class FrametimeType {
DtTimeAvg = 0,
FPS,
FPSAvg
FPSAvg,
None
};
RenderEngine();
@@ -108,8 +109,8 @@ public:
void registerScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s);
void unregisterScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s);
void unregisterScreenSpaceRenderable(std::string name);
std::shared_ptr<ScreenSpaceRenderable> screenSpaceRenderable(std::string name);
void unregisterScreenSpaceRenderable(const std::string& name);
std::shared_ptr<ScreenSpaceRenderable> screenSpaceRenderable(const std::string& name);
std::vector<ScreenSpaceRenderable*> screenSpaceRenderables() const;
std::unique_ptr<ghoul::opengl::ProgramObject> buildRenderProgram(
@@ -168,8 +169,6 @@ public:
// Temporary fade functionality
void startFading(int direction, float fadeDuration);
void sortScreenspaceRenderables();
glm::ivec2 renderingResolution() const;
glm::ivec2 fontResolution() const;
@@ -177,7 +176,7 @@ public:
private:
void setRenderer(std::unique_ptr<Renderer> renderer);
RendererImplementation rendererFromString(const std::string& method);
RendererImplementation rendererFromString(const std::string& method) const;
void renderInformation();
@@ -185,7 +184,7 @@ private:
Scene* _scene;
std::unique_ptr<RaycasterManager> _raycasterManager;
properties::BoolProperty _performanceMeasurements;
properties::BoolProperty _doPerformanceMeasurements;
std::unique_ptr<performance::PerformanceManager> _performanceManager;
std::unique_ptr<Renderer> _renderer;
-5
View File
@@ -73,13 +73,8 @@ set(SHADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/shaders/imageplane_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/model_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/model_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/path_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/path_gs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/path_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/plane_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/plane_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/pscstandard_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/pscstandard_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/renderabletrail_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/renderabletrail_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/screenspace_fs.glsl
-1
View File
@@ -29,7 +29,6 @@ in float vs_screenSpaceDepth;
uniform sampler2D texture1;
Fragment getFragment() {
Fragment frag;
-40
View File
@@ -1,40 +0,0 @@
/*****************************************************************************************
* *
* 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 "PowerScaling/powerScaling_fs.hglsl"
#include "fragment.glsl"
in vec4 vs_positionScreenSpace;
in vec4 vs_pointColor;
Fragment getFragment() {
if (vs_pointColor.a < 0.01) {
discard;
}
Fragment frag;
frag.color = vs_pointColor;
frag.depth = vs_positionScreenSpace.w;
return frag;
}
-64
View File
@@ -1,64 +0,0 @@
/*****************************************************************************************
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
#include "PowerScaling/powerScalingMath.hglsl"
#include <${SHADERS_GENERATED}/constants.hglsl>:notrack
layout(points) in;
layout(location = 0) in vec4 vs_point_position[];
layout(location = 1) in flat int isHour[];
layout(location = 2) in vec4 vs_point_color[];
layout(points, max_vertices = 4) out;
layout(location = 0) out vec4 gs_point_position;
layout(location = 1) out vec4 gs_point_color;
uniform mat4 projection;
uniform mat4 ViewProjection;
const vec2 corners[4] = vec2[4](
vec2(0.0, 1.0),
vec2(0.0, 0.0),
vec2(1.0, 1.0),
vec2(1.0, 0.0)
);
void main() {
gs_point_color = vs_point_color[0];
gs_point_position = vs_point_position[0];
if (isHour[0] == 1) {
gl_Position = gl_in[0].gl_Position;
EmitVertex();
EndPrimitive();
}
else {
gl_Position = gl_in[0].gl_Position;
EmitVertex();
EndPrimitive();
return;
}
}
-63
View File
@@ -1,63 +0,0 @@
/*****************************************************************************************
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
#include "PowerScaling/powerScaling_vs.hglsl"
in vec4 in_point_position;
out vec4 vs_positionScreenSpace;
out vec4 vs_pointColor;
uniform vec3 color;
uniform mat4 modelViewTransform;
uniform mat4 projectionTransform;
uniform int pointSteps;
void main() {
vec4 positionCameraSpace = modelViewTransform * in_point_position;
vec4 positionClipSpace = projectionTransform * positionCameraSpace;
vs_positionScreenSpace = z_normalization(positionClipSpace);
gl_Position = vs_positionScreenSpace;
if (mod(gl_VertexID, pointSteps) == 0) {
vs_pointColor.rgb = color;
gl_PointSize = 5.0f;
}
else {
vs_pointColor.rgb = (color + vec3(0.6, 0.6, 0.6)) / 2.0;
gl_PointSize = 2.f;
}
// I don't like this random variable k defined in powerScalingMath.hglsl.
// Will ignore it and use 10 in protest of psc dependencies. /KB
// float maximumDistance = pow(k, 10);
float maximumDistance = pow(10, 10);
float distanceToCamera = length(positionCameraSpace.xyz);
vs_pointColor.a = maximumDistance / (distanceToCamera / 100.0);
}
-75
View File
@@ -1,75 +0,0 @@
/*****************************************************************************************
* *
* 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 "PowerScaling/powerScaling_fs.hglsl"
#include "fragment.glsl"
in vec2 vs_st;
in vec4 vs_normal;
in vec4 vs_position;
uniform vec4 campos;
uniform vec4 objpos;
uniform vec3 sun_pos;
uniform bool _performShading = true;
uniform float transparency;
uniform int shadows;
uniform float time;
uniform sampler2D texture1;
Fragment getFragment() {
vec4 position = vs_position;
float depth = pscDepth(position);
vec4 diffuse = texture(texture1, vs_st);
Fragment frag;
if (_performShading) {
vec3 n = normalize(vs_normal.xyz);
vec3 l_pos = vec3(sun_pos); // sun.
vec3 l_dir = normalize(l_pos - objpos.xyz);
float intensity = min(max(5 * dot(n,l_dir), 0.0), 1);
// float shine = 0.0001;
const vec4 specular = vec4(0.5);
vec4 ambient = vec4(0.0, 0.0, 0.0, transparency);
/*
if(intensity > 0.f){
// halfway vector
vec3 h = normalize(l_dir + e);
// specular factor
float intSpec = max(dot(h,n),0.0);
spec = specular * pow(intSpec, shine);
}
*/
diffuse = max(intensity * diffuse, ambient);
}
frag.color.rgb = diffuse.rgb;
frag.color.a = transparency;
frag.depth = depth;
return frag;
}
-53
View File
@@ -1,53 +0,0 @@
/*****************************************************************************************
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
#include "PowerScaling/powerScaling_vs.hglsl"
layout(location = 0) in vec4 in_position;
layout(location = 1) in vec2 in_st;
layout(location = 2) in vec3 in_normal;
out vec2 vs_st;
out vec4 vs_normal;
out vec4 vs_position;
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
void main() {
vs_st = in_st;
vs_position = in_position;
vec4 tmp = in_position;
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
vs_normal = normalize(ModelTransform * vec4(in_normal,0));
vec4 position = pscTransform(tmp, ModelTransform);
vs_position = tmp;
position = ViewProjection * position;
gl_Position = z_normalization(position);
}
+23 -3
View File
@@ -139,10 +139,12 @@ void GuiSpaceTimeComponent::render() {
CaptionText("Time Controls");
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.f);
ImGui::Text("Current Date: %s", OsEng.timeManager().time().UTC().c_str());
constexpr int BufferSize = 256;
static char Buffer[BufferSize];
bool dateChanged = ImGui::InputText(
"Date",
"Change Date",
Buffer,
BufferSize,
ImGuiInputTextFlags_EnterReturnsTrue
@@ -207,8 +209,26 @@ void GuiSpaceTimeComponent::render() {
incrementTime(-1);
}
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 55.f);
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 15.f);
bool nowDay = ImGui::Button("Now");
if (nowDay) {
std::string nowTime = Time::now().UTC();
// UTC returns a string of the type YYYY MMM DDTHH:mm:ss.xxx
// setTime doesn't like the T in it and wants a space instead
nowTime[11] = ' ';
OsEng.scriptEngine().queueScript(
"openspace.time.setTime(\"" + nowTime + "\")",
scripting::ScriptEngine::RemoteScripting::Yes
);
}
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 15.f);
bool plusDay = ImGui::Button("+Day");
if (plusDay) {
-1
View File
@@ -34,7 +34,6 @@ out vec4 vs_position;
uniform mat4 modelViewProjectionTransform;
void main() {
vs_st = in_st;
+3 -1
View File
@@ -1,5 +1,7 @@
mark_interesting_nodes = function(nodes)
for _, n in pairs(nodes) do
openspace.addTag(n, "GUI.Interesting")
if openspace.hasSceneGraphNode(n) then
openspace.addTag(n, "GUI.Interesting")
end
end
end
-1
View File
@@ -24,7 +24,6 @@
#version __CONTEXT__
#include "floatoperations.glsl"
#include <#{fragmentPath}>
-1
View File
@@ -22,7 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
void getEntry(inout vec3 entryPos, inout float entryDepth) {
entryPos = cameraPosInRaycaster;
entryDepth = 0;
+1 -1
View File
@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version __CONTEXT__
#version __CONTEXT__
in vec2 in_position;
+25 -48
View File
@@ -165,7 +165,6 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
}
, _scheduledSceneSwitch(false)
, _scenePath("")
, _runTime(0.0)
, _shutdown({false, 0.f, 0.f})
, _isFirstRenderingFirstFrame(true)
{
@@ -321,23 +320,17 @@ void OpenSpaceEngine::create(int argc, char** argv,
ConfigurationManager::KeyPerSceneCache
);
std::string cacheFolder = absPath("${CACHE}");
if (hasCacheCommandline) {
cacheFolder = commandlineArgumentPlaceholders.cacheFolder;
// @CLEANUP: Why is this commented out? ---abock
//FileSys.registerPathToken(
// "${CACHE}",
// commandlineArgumentPlaceholders.cacheFolder,
// ghoul::filesystem::FileSystem::Override::Yes
//);
}
if (hasCacheConfiguration) {
std::string scene = _engine->configurationManager().value<std::string>(
ConfigurationManager::KeyConfigScene
);
cacheFolder += "-" + ghoul::filesystem::File(scene).baseName();
}
if (hasCacheCommandline || hasCacheConfiguration) {
if (hasCacheCommandline) {
cacheFolder = commandlineArgumentPlaceholders.cacheFolder;
}
if (hasCacheConfiguration) {
std::string scene = _engine->configurationManager().value<std::string>(
ConfigurationManager::KeyConfigScene
);
cacheFolder += "-" + ghoul::filesystem::File(scene).baseName();
}
LINFO("Old cache: " << absPath("${CACHE}"));
LINFO("New cache: " << cacheFolder);
FileSys.registerPathToken(
@@ -348,8 +341,7 @@ void OpenSpaceEngine::create(int argc, char** argv,
}
// Create directories that doesn't exist
auto tokens = FileSys.tokens();
for (const std::string& token : tokens) {
for (const std::string& token : FileSys.tokens()) {
if (!FileSys.directoryExists(token)) {
std::string p = absPath(token);
FileSys.createDirectory(p, ghoul::filesystem::FileSystem::Recursive::Yes);
@@ -378,9 +370,7 @@ void OpenSpaceEngine::create(int argc, char** argv,
}
// Create the cachemanager
FileSys.createCacheManager(
absPath("${" + ConfigurationManager::KeyCache + "}"), CacheVersion
);
FileSys.createCacheManager(cacheFolder, CacheVersion);
// Register the provided shader directories
ghoul::opengl::ShaderPreprocessor::addIncludePath(absPath("${SHADERS}"));
@@ -446,7 +436,7 @@ void OpenSpaceEngine::initialize() {
glbinding::Binding::useCurrentContext();
glbinding::Binding::initialize();
// clear the screen so the user don't have to see old buffer contents from the
// clear the screen so the user doesn't have to see old buffer contents from the
// graphics card
LDEBUG("Clearing all Windows");
_windowWrapper->clearAllWindows(glm::vec4(0.f, 0.f, 0.f, 1.f));
@@ -912,10 +902,11 @@ void OpenSpaceEngine::initializeGL() {
}
LTRACE("OpenSpaceEngine::initializeGL::Console::initialize(end)");
const std::string key = ConfigurationManager::KeyOpenGLDebugContext;
if (_configurationManager->hasKey(key)) {
if (_configurationManager->hasKey(ConfigurationManager::KeyOpenGLDebugContext)) {
LTRACE("OpenSpaceEngine::initializeGL::DebugContext(begin)");
ghoul::Dictionary dict = _configurationManager->value<ghoul::Dictionary>(key);
ghoul::Dictionary dict = _configurationManager->value<ghoul::Dictionary>(
ConfigurationManager::KeyOpenGLDebugContext
);
bool debug = dict.value<bool>(ConfigurationManager::PartActivate);
// Debug output is not available before 4.3
@@ -935,7 +926,6 @@ void OpenSpaceEngine::initializeGL() {
setDebugOutput(DebugOutput(debug), SynchronousOutput(synchronous));
if (dict.hasKey(ConfigurationManager::PartFilterIdentifier)) {
ghoul::Dictionary filterDict = dict.value<ghoul::Dictionary>(
ConfigurationManager::PartFilterIdentifier
@@ -1112,20 +1102,9 @@ void OpenSpaceEngine::initializeGL() {
LINFO("Finished initializing OpenGL");
LINFO("IsUsingSwapGroups: " << _windowWrapper->isUsingSwapGroups());
LINFO("IsSwapGroupMaster: " << _windowWrapper->isSwapGroupMaster());
LTRACE("OpenSpaceEngine::initializeGL(end)");
}
double OpenSpaceEngine::runTime() {
return _runTime;
}
void OpenSpaceEngine::setRunTime(double d) {
_runTime = d;
}
void OpenSpaceEngine::preSynchronization() {
LTRACE("OpenSpaceEngine::preSynchronization(begin)");
FileSys.triggerFilesystemEvents();
@@ -1236,7 +1215,7 @@ void OpenSpaceEngine::render(const glm::mat4& sceneMatrix,
func();
}
if (_shutdown.inShutdown) {
if (isGuiWindow && _shutdown.inShutdown) {
_renderEngine->renderShutdownInformation(_shutdown.timer, _shutdown.waitTime);
}
@@ -1409,19 +1388,17 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() {
&luascriptfunctions::addTag,
"string, string",
"Adds a tag (second argument) to a scene graph node (first argument)"
},
{
"removeTag",
&luascriptfunctions::removeTag,
"string, string",
"Removes a tag (second argument) from a scene graph node (first argument)"
}
}
};
}
void OpenSpaceEngine::enableBarrier() {
_windowWrapper->setBarrier(true);
}
void OpenSpaceEngine::disableBarrier() {
_windowWrapper->setBarrier(false);
}
// Registers a callback for a specific CallbackOption
void OpenSpaceEngine::registerModuleCallback(OpenSpaceEngine::CallbackOption option,
std::function<void()> function)
@@ -1455,7 +1432,7 @@ void OpenSpaceEngine::registerModuleCallback(OpenSpaceEngine::CallbackOption opt
throw ghoul::MissingCaseException();
}
}
void OpenSpaceEngine::registerModuleKeyboardCallback(
std::function<bool (Key, KeyModifier, KeyAction)> function)
{
+25 -1
View File
@@ -176,7 +176,31 @@ int addTag(lua_State* L) {
return luaL_error(L, "Unknown scene graph node type '%s'", uri.c_str());
}
node->addTag(tag);
node->addTag(std::move(tag));
return 0;
}
/**
* \ingroup LuaScripts
* removeTag():
* Removes a tag from a SceneGraphNode
*/
int removeTag(lua_State* L) {
const int nArguments = lua_gettop(L);
if (nArguments != 2) {
return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments);
}
const std::string uri = lua_tostring(L, -2);
const std::string tag = lua_tostring(L, -1);
SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(uri);
if (!node) {
return luaL_error(L, "Unknown scene graph node type '%s'", uri.c_str());
}
node->removeTag(tag);
return 0;
}
+24 -26
View File
@@ -64,7 +64,7 @@ SGCTWindowWrapper::SGCTWindowWrapper()
setEyeSeparationDistance(_eyeSeparation);
});
}
void SGCTWindowWrapper::terminate() {
sgct::Engine::instance()->terminate();
}
@@ -72,7 +72,7 @@ void SGCTWindowWrapper::terminate() {
void SGCTWindowWrapper::setBarrier(bool enabled) {
sgct::SGCTWindow::setBarrier(enabled);
}
void SGCTWindowWrapper::setSynchronization(bool enabled) {
sgct_core::ClusterManager::instance()->setUseIgnoreSync(enabled);
}
@@ -90,7 +90,7 @@ void SGCTWindowWrapper::clearAllWindows(const glm::vec4& clearColor) {
bool SGCTWindowWrapper::windowHasResized() const {
return sgct::Engine::instance()->getCurrentWindowPtr()->isWindowResized();
}
double SGCTWindowWrapper::averageDeltaTime() const {
return sgct::Engine::instance()->getAvgDt();
}
@@ -98,7 +98,11 @@ double SGCTWindowWrapper::averageDeltaTime() const {
double SGCTWindowWrapper::deltaTime() const {
return sgct::Engine::instance()->getDt();
}
double SGCTWindowWrapper::applicationTime() const {
return sgct::Engine::getTime();
}
glm::vec2 SGCTWindowWrapper::mousePosition() const {
int id = sgct::Engine::instance()->getCurrentWindowPtr()->getId();
double posX, posY;
@@ -157,7 +161,7 @@ glm::ivec2 SGCTWindowWrapper::currentDrawBufferResolution() const {
}
throw WindowWrapperException("No viewport available");
}
glm::vec2 SGCTWindowWrapper::dpiScaling() const {
return glm::vec2(
sgct::Engine::instance()->getCurrentWindowPtr()->getXScale(),
@@ -168,7 +172,7 @@ glm::vec2 SGCTWindowWrapper::dpiScaling() const {
int SGCTWindowWrapper::currentNumberOfAaSamples() const {
return sgct::Engine::instance()->getCurrentWindowPtr()->getNumberOfAASamples();
}
bool SGCTWindowWrapper::isRegularRendering() const {
sgct::SGCTWindow* w = sgct::Engine::instance()->getCurrentWindowPtr();
std::size_t nViewports = w->getNumberOfViewports();
@@ -194,7 +198,7 @@ bool SGCTWindowWrapper::isGuiWindow() const {
GuiWindowTag
);
}
bool SGCTWindowWrapper::isMaster() const {
return sgct::Engine::instance()->isMaster();
}
@@ -206,7 +210,7 @@ bool SGCTWindowWrapper::isSwapGroupMaster() const {
bool SGCTWindowWrapper::isUsingSwapGroups() const {
return sgct::Engine::instance()->getCurrentWindowPtr()->isUsingSwapGroups();
}
glm::mat4 SGCTWindowWrapper::viewProjectionMatrix() const {
return sgct::Engine::instance()->getCurrentModelViewProjectionMatrix();
}
@@ -214,7 +218,7 @@ glm::mat4 SGCTWindowWrapper::viewProjectionMatrix() const {
glm::mat4 SGCTWindowWrapper::modelMatrix() const {
return sgct::Engine::instance()->getModelMatrix();
}
void SGCTWindowWrapper::setNearFarClippingPlane(float nearPlane, float farPlane) {
sgct::Engine::instance()->setNearAndFarClippingPlanes(nearPlane, farPlane);
}
@@ -225,39 +229,33 @@ void SGCTWindowWrapper::setEyeSeparationDistance(float distance) {
glm::ivec4 SGCTWindowWrapper::viewportPixelCoordinates() const {
int x1, xSize, y1, ySize;
sgct::Engine::instance()->getCurrentWindowPtr()->getCurrentViewportPixelCoords(x1,
y1,
xSize,
ySize);
sgct::Engine::instance()->getCurrentWindowPtr()->getCurrentViewportPixelCoords(
x1,
y1,
xSize,
ySize
);
return glm::ivec4(x1, xSize, y1, ySize);
}
bool SGCTWindowWrapper::isExternalControlConnected() const {
return sgct::Engine::instance()->isExternalControlConnected();
}
void SGCTWindowWrapper::sendMessageToExternalControl(const std::vector<char>& message) const {
sgct::Engine::instance()->sendMessageToExternalControl(
message.data(),
static_cast<int>(message.size())
);
}
bool SGCTWindowWrapper::isSimpleRendering() const {
return (sgct::Engine::instance()->getCurrentRenderTarget() != sgct::Engine::NonLinearBuffer);
}
void SGCTWindowWrapper::takeScreenshot(bool applyWarping) const {
sgct::SGCTSettings::instance()->setCaptureFromBackBuffer(applyWarping);
sgct::Engine::instance()->takeScreenshot();
}
//void forEachWindow(std::function<void (void)> function) {
// size_t n = sgct::Engine::instance()->getNumberOfWindows();
// for (size_t i = 0; i < n; ++i)
// function();
//}
} // namespace openspace
} // namespace openspace
+16 -12
View File
@@ -92,19 +92,23 @@ double WindowWrapper::averageDeltaTime() const {
double WindowWrapper::deltaTime() const {
return 0.0;
}
double WindowWrapper::applicationTime() const {
return 0.0;
}
glm::vec2 WindowWrapper::mousePosition() const {
return glm::vec2(0.f);
}
uint32_t WindowWrapper::mouseButtons(int) const {
return uint32_t(0);
}
glm::ivec2 WindowWrapper::currentWindowSize() const {
return glm::ivec2(0);
}
glm::ivec2 WindowWrapper::currentWindowResolution() const {
return currentWindowSize();
}
@@ -153,11 +157,11 @@ glm::mat4 WindowWrapper::viewProjectionMatrix() const {
glm::mat4 WindowWrapper::modelMatrix() const {
return glm::mat4(1.f);
}
void WindowWrapper::setNearFarClippingPlane(float, float) {}
void WindowWrapper::setEyeSeparationDistance(float) {}
glm::ivec4 WindowWrapper::viewportPixelCoordinates() const {
return glm::ivec4(
0,
@@ -166,19 +170,19 @@ glm::ivec4 WindowWrapper::viewportPixelCoordinates() const {
currentWindowResolution().y
);
}
bool WindowWrapper::isExternalControlConnected() const {
return false;
}
void WindowWrapper::sendMessageToExternalControl(const std::vector<char>&) const {
}
bool WindowWrapper::isSimpleRendering() const {
return true;
}
void WindowWrapper::takeScreenshot(bool) const {}
} // namespace openspace
+2 -1
View File
@@ -25,6 +25,7 @@
#include <openspace/interaction/keyframenavigator.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/scene/scene.h>
#include <openspace/util/camera.h>
@@ -37,7 +38,7 @@
namespace openspace::interaction {
void KeyframeNavigator::updateCamera(Camera& camera) {
double now = OsEng.runTime();
double now = OsEng.windowWrapper().applicationTime();
if (_cameraPoseTimeline.nKeyframes() == 0) {
return;
+4 -4
View File
@@ -587,7 +587,7 @@ void ParallelConnection::initializationMessageReceived(){
double ParallelConnection::calculateBufferedKeyframeTime(double originalTime) {
std::lock_guard<std::mutex> latencyLock(_latencyMutex);
double timeDiff = OsEng.runTime() - originalTime;
double timeDiff = OsEng.windowWrapper().applicationTime() - originalTime;
if (_latencyDiffs.size() == 0) {
_initialTimeDiff = timeDiff;
}
@@ -1084,7 +1084,7 @@ void ParallelConnection::preSynchronization() {
if (OsEng.timeManager().time().timeJumped()) {
_timeJumped = true;
}
double now = OsEng.runTime();
double now = OsEng.windowWrapper().applicationTime();
if (_lastCameraKeyframeTimestamp + _cameraKeyframeInterval < now) {
sendCameraKeyframe();
@@ -1156,7 +1156,7 @@ void ParallelConnection::sendCameraKeyframe() {
kf._focusNode = focusNode->name();
// Timestamp as current runtime of OpenSpace instance
kf._timestamp = OsEng.runTime();
kf._timestamp = OsEng.windowWrapper().applicationTime();
// Create a buffer for the keyframe
std::vector<char> buffer;
@@ -1180,7 +1180,7 @@ void ParallelConnection::sendTimeKeyframe() {
kf._time = time.j2000Seconds();
// Timestamp as current runtime of OpenSpace instance
kf._timestamp = OsEng.runTime();
kf._timestamp = OsEng.windowWrapper().applicationTime();
// Create a buffer for the keyframe
std::vector<char> buffer;
+3 -3
View File
@@ -130,10 +130,10 @@ void PerformanceManager::destroyGlobalSharedMemory() {
sharedMemory.releaseLock();
}
PerformanceManager::PerformanceManager()
PerformanceManager::PerformanceManager(std::string loggingDirectory, std::string prefix)
: _loggingEnabled(false)
, _logDir(absPath("${BASE_PATH}"))
, _prefix("PM-")
, _logDir(absPath(std::move(loggingDirectory)))
, _prefix(std::move(prefix))
, _ext("log")
, _performanceMemory(nullptr)
, _tick(0)
+7
View File
@@ -282,4 +282,11 @@ void PropertyOwner::addTag(std::string tag) {
_tags.push_back(std::move(tag));
}
void PropertyOwner::removeTag(const std::string& tag) {
_tags.erase(
std::remove(_tags.begin(), _tags.end(), tag),
_tags.end()
);
}
} // namespace openspace::properties
+346 -370
View File
@@ -196,7 +196,7 @@ RenderEngine::RenderEngine()
, _camera(nullptr)
, _scene(nullptr)
, _raycasterManager(nullptr)
, _performanceMeasurements(PerformanceInfo)
, _doPerformanceMeasurements(PerformanceInfo)
, _performanceManager(nullptr)
, _renderer(nullptr)
, _rendererImplementation(RendererImplementation::Invalid)
@@ -219,18 +219,26 @@ RenderEngine::RenderEngine()
, _nAaSamples(AaSamplesInfo, 8, 1, 16)
, _frameNumber(0)
{
_performanceMeasurements.onChange([this](){
if (_performanceMeasurements) {
_doPerformanceMeasurements.onChange([this](){
if (_doPerformanceMeasurements) {
if (!_performanceManager) {
_performanceManager = std::make_unique<performance::PerformanceManager>();
const std::string KeyLogDir = ConfigurationManager::KeyLogging + "." + ConfigurationManager::PartLogDir;
std::string loggingDir = "${BASE_PATH}";
const std::string KeyDir = ConfigurationManager::KeyLogging + "." + ConfigurationManager::PartLogDir;
if (OsEng.configurationManager().hasKey(KeyDir)) {
loggingDir = OsEng.configurationManager().value<std::string>(KeyDir);
}
std::string prefix = "PM-";
const std::string KeyPrefix = ConfigurationManager::KeyLogging + "." + ConfigurationManager::PartLogPerformancePrefix;
if (OsEng.configurationManager().hasKeyAndValue<std::string>(KeyLogDir)) {
_performanceManager->logDir(OsEng.configurationManager().value<std::string>(KeyLogDir));
}
if (OsEng.configurationManager().hasKeyAndValue<std::string>(KeyPrefix)) {
_performanceManager->prefix(OsEng.configurationManager().value<std::string>(KeyPrefix));
if (OsEng.configurationManager().hasKey(KeyPrefix)) {
prefix = OsEng.configurationManager().value<std::string>(KeyPrefix);
}
_performanceManager = std::make_unique<performance::PerformanceManager>(
loggingDir,
prefix
);
}
}
else {
@@ -238,20 +246,14 @@ RenderEngine::RenderEngine()
}
});
addProperty(_performanceMeasurements);
addProperty(_doPerformanceMeasurements);
_frametimeType.addOption(
static_cast<int>(FrametimeType::DtTimeAvg),
"Average Deltatime"
);
_frametimeType.addOption(
static_cast<int>(FrametimeType::FPS),
"Frames per second"
);
_frametimeType.addOption(
static_cast<int>(FrametimeType::FPSAvg),
"Average frames per second"
);
_frametimeType.addOptions({
{ static_cast<int>(FrametimeType::DtTimeAvg), "Average Deltatime" },
{ static_cast<int>(FrametimeType::FPS), "Frames per second" },
{ static_cast<int>(FrametimeType::FPSAvg), "Average frames per second" },
{ static_cast<int>(FrametimeType::None), "None" }
});
addProperty(_frametimeType);
addProperty(_showDate);
@@ -278,9 +280,6 @@ RenderEngine::RenderEngine()
addProperty(_disableMasterRendering);
}
/**
* Destructor
*/
RenderEngine::~RenderEngine() {}
void RenderEngine::setRendererFromString(const std::string& renderingMethod) {
@@ -307,7 +306,7 @@ void RenderEngine::initialize() {
std::string renderingMethod = DefaultRenderingMethod;
// If the user specified a rendering method that he would like to use, use that
auto& confManager = OsEng.configurationManager();
ConfigurationManager& confManager = OsEng.configurationManager();
if (confManager.hasKeyAndValue<std::string>(KeyRenderingMethod)) {
renderingMethod = confManager.value<std::string>(KeyRenderingMethod);
} else {
@@ -372,7 +371,7 @@ void RenderEngine::initializeGL() {
// set the close clip plane and the far clip plane to extreme values while in
// development
OsEng.windowWrapper().setNearFarClippingPlane(0.001f, 10000.f);
OsEng.windowWrapper().setNearFarClippingPlane(0.001f, 1000.f);
try {
const float fontSizeBig = 50.f;
@@ -398,7 +397,7 @@ void RenderEngine::initializeGL() {
}
void RenderEngine::deinitialize() {
for (std::shared_ptr<ScreenSpaceRenderable> ssr : _screenSpaceRenderables) {
for (std::shared_ptr<ScreenSpaceRenderable>& ssr : _screenSpaceRenderables) {
ssr->deinitialize();
}
@@ -525,8 +524,8 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat
}
_camera->sgctInternal.setProjectionMatrix(projectionMatrix);
if (!(wrapper.isMaster() && _disableMasterRendering) && !wrapper.isGuiWindow()) {
bool masterEnabled = wrapper.isMaster() ? !_disableMasterRendering : true;
if (masterEnabled && !wrapper.isGuiWindow() && _globalBlackOutFactor > 0.f) {
_renderer->render(_globalBlackOutFactor, _performanceManager != nullptr);
}
@@ -544,7 +543,7 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat
RenderFont(*_fontBig, penPosition, "%i", _frameNumber);
}
_frameNumber++;
++_frameNumber;
for (std::shared_ptr<ScreenSpaceRenderable>& ssr : _screenSpaceRenderables) {
if (ssr->isEnabled() && ssr->isReady()) {
@@ -568,7 +567,6 @@ void RenderEngine::renderShutdownInformation(float timer, float fullTime) {
fontResolution().x - size.boundingBox.x - 10,
fontResolution().y - size.boundingBox.y
);
// penPosition.y -= _fontDate->height();
RenderFontCr(
*_fontDate,
@@ -739,7 +737,6 @@ void RenderEngine::setRendererData(const ghoul::Dictionary& data) {
}
}
/**
* Set resolve data
* Called from the renderer, whenever it needs to update
@@ -806,7 +803,6 @@ scripting::LuaLibrary RenderEngine::luaLibrary() {
"number",
""
},
//also temporary @JK
{
"fadeOut",
&luascriptfunctions::fadeOut,
@@ -840,7 +836,7 @@ performance::PerformanceManager* RenderEngine::performanceManager() {
void RenderEngine::registerScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s)
{
s->initialize();
_screenSpaceRenderables.push_back(s);
_screenSpaceRenderables.push_back(std::move(s));
}
void RenderEngine::unregisterScreenSpaceRenderable(
@@ -858,7 +854,7 @@ void RenderEngine::unregisterScreenSpaceRenderable(
}
}
void RenderEngine::unregisterScreenSpaceRenderable(std::string name){
void RenderEngine::unregisterScreenSpaceRenderable(const std::string& name){
std::shared_ptr<ScreenSpaceRenderable> s = screenSpaceRenderable(name);
if (s) {
unregisterScreenSpaceRenderable(s);
@@ -866,14 +862,22 @@ void RenderEngine::unregisterScreenSpaceRenderable(std::string name){
}
std::shared_ptr<ScreenSpaceRenderable> RenderEngine::screenSpaceRenderable(
std::string name)
const std::string& name)
{
for (auto s : _screenSpaceRenderables) {
if (s->name() == name) {
return s;
auto it = std::find_if(
_screenSpaceRenderables.begin(),
_screenSpaceRenderables.end(),
[name](const std::shared_ptr<ScreenSpaceRenderable>& s) {
return s->name() == name;
}
);
if (it != _screenSpaceRenderables.end()) {
return *it;
}
else {
return nullptr;
}
return nullptr;
}
std::vector<ScreenSpaceRenderable*> RenderEngine::screenSpaceRenderables() const {
@@ -888,7 +892,7 @@ std::vector<ScreenSpaceRenderable*> RenderEngine::screenSpaceRenderables() const
}
RenderEngine::RendererImplementation RenderEngine::rendererFromString(
const std::string& impl)
const std::string& impl) const
{
const std::map<std::string, RenderEngine::RendererImplementation> RenderingMethods = {
{ "ABuffer", RendererImplementation::ABuffer },
@@ -919,73 +923,64 @@ std::string RenderEngine::progressToStr(int size, double t) {
}
void RenderEngine::renderInformation() {
// TODO: Adjust font_size properly when using retina screen
using ghoul::fontrendering::RenderFont;
if (_fontDate) {
glm::vec2 penPosition = glm::vec2(
10.f,
fontResolution().y
//OsEng.windowWrapper().viewportPixelCoordinates().w
glm::vec2 penPosition = glm::vec2(
10.f,
fontResolution().y
);
// If the console is opened, move all text downwards
penPosition.y -= OsEng.console().currentHeight();
if (_showDate && _fontDate) {
penPosition.y -= _fontDate->height();
RenderFontCr(
*_fontDate,
penPosition,
"Date: %s",
OsEng.timeManager().time().UTC().c_str()
);
}
else {
penPosition.y -= _fontInfo->height();
}
if (_showInfo && _fontInfo) {
RenderFontCr(
*_fontInfo,
penPosition,
"Simulation increment (s): %.3f",
OsEng.timeManager().time().deltaTime()
);
penPosition.y -= OsEng.console().currentHeight();
if (_showDate && _fontDate) {
penPosition.y -= _fontDate->height();
RenderFontCr(
*_fontDate,
penPosition,
"Date: %s",
OsEng.timeManager().time().UTC().c_str()
);
FrametimeType frametimeType = FrametimeType(_frametimeType.value());
switch (frametimeType) {
case FrametimeType::DtTimeAvg:
RenderFontCr(
*_fontInfo,
penPosition,
"Avg. Frametime: %.5f",
OsEng.windowWrapper().averageDeltaTime()
);
break;
case FrametimeType::FPS:
RenderFontCr(
*_fontInfo,
penPosition,
"FPS: %3.2f",
1.0 / OsEng.windowWrapper().deltaTime()
);
break;
case FrametimeType::FPSAvg:
RenderFontCr(
*_fontInfo,
penPosition,
"Avg. FPS: %3.2f",
1.0 / OsEng.windowWrapper().averageDeltaTime()
);
break;
}
else {
penPosition.y -= _fontInfo->height();
}
if (_showInfo && _fontInfo) {
RenderFontCr(
*_fontInfo,
penPosition,
"Simulation increment (s): %.3f",
OsEng.timeManager().time().deltaTime()
);
FrametimeType frametimeType = FrametimeType(_frametimeType.value());
switch (frametimeType) {
case FrametimeType::DtTimeAvg:
RenderFontCr(
*_fontInfo,
penPosition,
"Avg. Frametime: %.5f",
OsEng.windowWrapper().averageDeltaTime()
);
break;
case FrametimeType::FPS:
RenderFontCr(
*_fontInfo,
penPosition,
"FPS: %3.2f",
1.0 / OsEng.windowWrapper().deltaTime()
);
break;
case FrametimeType::FPSAvg:
RenderFontCr(
*_fontInfo,
penPosition,
"Avg. FPS: %3.2f",
1.0 / OsEng.windowWrapper().averageDeltaTime()
);
break;
default:
RenderFontCr(
*_fontInfo,
penPosition,
"Avg. Frametime: %.5f",
OsEng.windowWrapper().averageDeltaTime()
);
break;
}
ParallelConnection::Status status = OsEng.parallelConnection().status();
size_t nConnections = OsEng.parallelConnection().nConnections();
@@ -1022,7 +1017,7 @@ void RenderEngine::renderInformation() {
}
}
if (connectionInfo != "") {
if (!connectionInfo.empty()) {
RenderFontCr(
*_fontInfo,
penPosition,
@@ -1032,268 +1027,267 @@ void RenderEngine::renderInformation() {
#ifdef OPENSPACE_MODULE_SPACECRAFTINSTRUMENTS_ENABLED
bool hasNewHorizons = scene()->sceneGraphNode("NewHorizons");
double currentTime = OsEng.timeManager().time().j2000Seconds();
bool hasNewHorizons = scene()->sceneGraphNode("NewHorizons");
double currentTime = OsEng.timeManager().time().j2000Seconds();
//if (MissionManager::ref().hasCurrentMission()) {
//if (MissionManager::ref().hasCurrentMission()) {
// const Mission& mission = MissionManager::ref().currentMission();
// const Mission& mission = MissionManager::ref().currentMission();
// if (mission.phases().size() > 0) {
// static const glm::vec4 nextMissionColor(0.7, 0.3, 0.3, 1);
// //static const glm::vec4 missionProgressColor(0.4, 1.0, 1.0, 1);
// static const glm::vec4 currentMissionColor(0.0, 0.5, 0.5, 1);
// static const glm::vec4 missionProgressColor = currentMissionColor;// (0.4, 1.0, 1.0, 1);
// // static const glm::vec4 currentLeafMissionColor = missionProgressColor;
// static const glm::vec4 nonCurrentMissionColor(0.3, 0.3, 0.3, 1);
// if (mission.phases().size() > 0) {
// static const glm::vec4 nextMissionColor(0.7, 0.3, 0.3, 1);
// //static const glm::vec4 missionProgressColor(0.4, 1.0, 1.0, 1);
// static const glm::vec4 currentMissionColor(0.0, 0.5, 0.5, 1);
// static const glm::vec4 missionProgressColor = currentMissionColor;// (0.4, 1.0, 1.0, 1);
// // static const glm::vec4 currentLeafMissionColor = missionProgressColor;
// static const glm::vec4 nonCurrentMissionColor(0.3, 0.3, 0.3, 1);
// // Add spacing
// RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, " ");
// // Add spacing
// RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, " ");
// auto phaseTrace = mission.phaseTrace(currentTime);
// auto phaseTrace = mission.phaseTrace(currentTime);
// if (phaseTrace.size()) {
// const MissionPhase& phase = phaseTrace.back().get();
// std::string title = "Current Mission Phase: " + phase.name();
// RenderFontCr(*_fontInfo, penPosition, missionProgressColor, title.c_str());
// double remaining = phase.timeRange().end - currentTime;
// float t = static_cast<float>(1.0 - remaining / phase.timeRange().duration());
// std::string progress = progressToStr(25, t);
// //RenderFontCr(*_fontInfo, penPosition, missionProgressColor,
// // "%.0f s %s %.1f %%", remaining, progress.c_str(), t * 100);
// }
// else {
// RenderFontCr(*_fontInfo, penPosition, nextMissionColor, "Next Mission:");
// double remaining = mission.timeRange().start - currentTime;
// RenderFontCr(*_fontInfo, penPosition, nextMissionColor,
// "%.0f s", remaining);
// }
// if (phaseTrace.size()) {
// const MissionPhase& phase = phaseTrace.back().get();
// std::string title = "Current Mission Phase: " + phase.name();
// RenderFontCr(*_fontInfo, penPosition, missionProgressColor, title.c_str());
// double remaining = phase.timeRange().end - currentTime;
// float t = static_cast<float>(1.0 - remaining / phase.timeRange().duration());
// std::string progress = progressToStr(25, t);
// //RenderFontCr(*_fontInfo, penPosition, missionProgressColor,
// // "%.0f s %s %.1f %%", remaining, progress.c_str(), t * 100);
// }
// else {
// RenderFontCr(*_fontInfo, penPosition, nextMissionColor, "Next Mission:");
// double remaining = mission.timeRange().start - currentTime;
// RenderFontCr(*_fontInfo, penPosition, nextMissionColor,
// "%.0f s", remaining);
// }
// bool showAllPhases = false;
// bool showAllPhases = false;
// typedef std::pair<const MissionPhase*, int> PhaseWithDepth;
// std::stack<PhaseWithDepth> S;
// int pixelIndentation = 20;
// S.push({ &mission, 0 });
// while (!S.empty()) {
// const MissionPhase* phase = S.top().first;
// int depth = S.top().second;
// S.pop();
// typedef std::pair<const MissionPhase*, int> PhaseWithDepth;
// std::stack<PhaseWithDepth> S;
// int pixelIndentation = 20;
// S.push({ &mission, 0 });
// while (!S.empty()) {
// const MissionPhase* phase = S.top().first;
// int depth = S.top().second;
// S.pop();
// bool isCurrentPhase = phase->timeRange().includes(currentTime);
// bool isCurrentPhase = phase->timeRange().includes(currentTime);
// penPosition.x += depth * pixelIndentation;
// if (isCurrentPhase) {
// double remaining = phase->timeRange().end - currentTime;
// float t = static_cast<float>(1.0 - remaining / phase->timeRange().duration());
// std::string progress = progressToStr(25, t);
// RenderFontCr(*_fontInfo, penPosition, currentMissionColor,
// "%s %s %.1f %%",
// phase->name().c_str(),
// progress.c_str(),
// t * 100
// );
// }
// else {
// RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, phase->name().c_str());
// }
// penPosition.x -= depth * pixelIndentation;
// penPosition.x += depth * pixelIndentation;
// if (isCurrentPhase) {
// double remaining = phase->timeRange().end - currentTime;
// float t = static_cast<float>(1.0 - remaining / phase->timeRange().duration());
// std::string progress = progressToStr(25, t);
// RenderFontCr(*_fontInfo, penPosition, currentMissionColor,
// "%s %s %.1f %%",
// phase->name().c_str(),
// progress.c_str(),
// t * 100
// );
// }
// else {
// RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, phase->name().c_str());
// }
// penPosition.x -= depth * pixelIndentation;
// if (isCurrentPhase || showAllPhases) {
// // phases are sorted increasingly by start time, and will be popped
// // last-in-first-out from the stack, so add them in reversed order.
// int indexLastPhase = static_cast<int>(phase->phases().size()) - 1;
// for (int i = indexLastPhase; 0 <= i; --i) {
// S.push({ &phase->phases()[i], depth + 1 });
// }
// }
// }
// }
// }
// if (isCurrentPhase || showAllPhases) {
// // phases are sorted increasingly by start time, and will be popped
// // last-in-first-out from the stack, so add them in reversed order.
// int indexLastPhase = static_cast<int>(phase->phases().size()) - 1;
// for (int i = indexLastPhase; 0 <= i; --i) {
// S.push({ &phase->phases()[i], depth + 1 });
// }
// }
// }
// }
// }
if (openspace::ImageSequencer::ref().isReady()) {
penPosition.y -= 25.f;
if (openspace::ImageSequencer::ref().isReady()) {
penPosition.y -= 25.f;
glm::vec4 targetColor(0.00, 0.75, 1.00, 1);
glm::vec4 targetColor(0.00, 0.75, 1.00, 1);
if (hasNewHorizons) {
try {
double lt;
glm::dvec3 p =
SpiceManager::ref().targetPosition("PLUTO", "NEW HORIZONS", "GALACTIC", {}, currentTime, lt);
psc nhPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
float a, b;
glm::dvec3 radii;
SpiceManager::ref().getValue("PLUTO", "RADII", radii);
a = static_cast<float>(radii.x);
b = static_cast<float>(radii.y);
float radius = (a + b) / 2.f;
float distToSurf = glm::length(nhPos.vec3()) - radius;
if (hasNewHorizons) {
try {
double lt;
glm::dvec3 p =
SpiceManager::ref().targetPosition("PLUTO", "NEW HORIZONS", "GALACTIC", {}, currentTime, lt);
psc nhPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
float a, b;
glm::dvec3 radii;
SpiceManager::ref().getValue("PLUTO", "RADII", radii);
a = static_cast<float>(radii.x);
b = static_cast<float>(radii.y);
float radius = (a + b) / 2.f;
float distToSurf = glm::length(nhPos.vec3()) - radius;
RenderFont(*_fontInfo,
penPosition,
"Distance to Pluto: % .1f (KM)",
distToSurf
);
penPosition.y -= _fontInfo->height();
}
catch (...) {
// @CLEANUP: This is bad as it will discard all exceptions
// without telling us about it! ---abock
}
RenderFont(*_fontInfo,
penPosition,
"Distance to Pluto: % .1f (KM)",
distToSurf
);
penPosition.y -= _fontInfo->height();
}
catch (...) {
// @CLEANUP: This is bad as it will discard all exceptions
// without telling us about it! ---abock
}
}
double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - currentTime;
float t = static_cast<float>(1.0 - remaining / openspace::ImageSequencer::ref().getIntervalLength());
double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - currentTime;
float t = static_cast<float>(1.0 - remaining / openspace::ImageSequencer::ref().getIntervalLength());
std::string str = SpiceManager::ref().dateFromEphemerisTime(
ImageSequencer::ref().getNextCaptureTime(),
"YYYY MON DD HR:MN:SC"
std::string str = SpiceManager::ref().dateFromEphemerisTime(
ImageSequencer::ref().getNextCaptureTime(),
"YYYY MON DD HR:MN:SC"
);
glm::vec4 active(0.6, 1, 0.00, 1);
glm::vec4 brigther_active(0.9, 1, 0.75, 1);
if (remaining > 0) {
std::string progress = progressToStr(25, t);
brigther_active *= (1 - t);
RenderFontCr(*_fontInfo,
penPosition,
active * t + brigther_active,
"Next instrument activity:"
);
glm::vec4 active(0.6, 1, 0.00, 1);
glm::vec4 brigther_active(0.9, 1, 0.75, 1);
RenderFontCr(*_fontInfo,
penPosition,
active * t + brigther_active,
"%.0f s %s %.1f %%",
remaining, progress.c_str(), t * 100
);
if (remaining > 0) {
std::string progress = progressToStr(25, t);
brigther_active *= (1 - t);
RenderFontCr(*_fontInfo,
penPosition,
active,
"Data acquisition time: %s",
str.c_str()
);
}
std::pair<double, std::string> nextTarget = ImageSequencer::ref().getNextTarget();
std::pair<double, std::string> currentTarget = ImageSequencer::ref().getCurrentTarget();
RenderFontCr(*_fontInfo,
if (currentTarget.first > 0.0) {
int timeleft = static_cast<int>(nextTarget.first - currentTime);
int hour = timeleft / 3600;
int second = timeleft % 3600;
int minute = second / 60;
second = second % 60;
std::string hh, mm, ss;
if (hour < 10)
hh.append("0");
if (minute < 10)
mm.append("0");
if (second < 10)
ss.append("0");
hh.append(std::to_string(hour));
mm.append(std::to_string(minute));
ss.append(std::to_string(second));
RenderFontCr(*_fontInfo,
penPosition,
targetColor,
"Data acquisition adjacency: [%s:%s:%s]",
hh.c_str(), mm.c_str(), ss.c_str()
);
#if 0
// Why is it (2) in the original? ---abock
//std::pair<double, std::vector<std::string>> incidentTargets = ImageSequencer::ref().getIncidentTargetList(0);
//std::pair<double, std::vector<std::string>> incidentTargets = ImageSequencer::ref().getIncidentTargetList(2);
std::string space;
glm::vec4 color;
size_t isize = incidentTargets.second.size();
for (size_t p = 0; p < isize; p++) {
double t = static_cast<double>(p + 1) / static_cast<double>(isize + 1);
t = (p > isize / 2) ? 1 - t : t;
t += 0.3;
color = (p == isize / 2) ? targetColor : glm::vec4(t, t, t, 1);
RenderFont(*_fontInfo,
penPosition,
active * t + brigther_active,
"Next instrument activity:"
color,
"%s%s",
space.c_str(), incidentTargets.second[p].c_str()
);
RenderFontCr(*_fontInfo,
penPosition,
active * t + brigther_active,
"%.0f s %s %.1f %%",
remaining, progress.c_str(), t * 100
);
RenderFontCr(*_fontInfo,
penPosition,
active,
"Data acquisition time: %s",
str.c_str()
);
for (int k = 0; k < incidentTargets.second[p].size() + 2; k++)
space += " ";
}
std::pair<double, std::string> nextTarget = ImageSequencer::ref().getNextTarget();
std::pair<double, std::string> currentTarget = ImageSequencer::ref().getCurrentTarget();
#endif
penPosition.y -= _fontInfo->height();
if (currentTarget.first > 0.0) {
int timeleft = static_cast<int>(nextTarget.first - currentTime);
std::map<std::string, bool> activeMap = ImageSequencer::ref().getActiveInstruments();
glm::vec4 firing(0.58 - t, 1 - t, 1 - t, 1);
glm::vec4 notFiring(0.5, 0.5, 0.5, 1);
int hour = timeleft / 3600;
int second = timeleft % 3600;
int minute = second / 60;
second = second % 60;
std::string hh, mm, ss;
if (hour < 10)
hh.append("0");
if (minute < 10)
mm.append("0");
if (second < 10)
ss.append("0");
hh.append(std::to_string(hour));
mm.append(std::to_string(minute));
ss.append(std::to_string(second));
RenderFontCr(*_fontInfo,
penPosition,
targetColor,
"Data acquisition adjacency: [%s:%s:%s]",
hh.c_str(), mm.c_str(), ss.c_str()
);
#if 0
// Why is it (2) in the original? ---abock
//std::pair<double, std::vector<std::string>> incidentTargets = ImageSequencer::ref().getIncidentTargetList(0);
//std::pair<double, std::vector<std::string>> incidentTargets = ImageSequencer::ref().getIncidentTargetList(2);
std::string space;
glm::vec4 color;
size_t isize = incidentTargets.second.size();
for (size_t p = 0; p < isize; p++) {
double t = static_cast<double>(p + 1) / static_cast<double>(isize + 1);
t = (p > isize / 2) ? 1 - t : t;
t += 0.3;
color = (p == isize / 2) ? targetColor : glm::vec4(t, t, t, 1);
RenderFontCr(*_fontInfo,
penPosition,
active,
"Active Instruments:"
);
for (auto m : activeMap) {
if (m.second == false) {
RenderFont(*_fontInfo,
penPosition,
color,
"%s%s",
space.c_str(), incidentTargets.second[p].c_str()
);
for (int k = 0; k < incidentTargets.second[p].size() + 2; k++)
space += " ";
}
#endif
penPosition.y -= _fontInfo->height();
std::map<std::string, bool> activeMap = ImageSequencer::ref().getActiveInstruments();
glm::vec4 firing(0.58 - t, 1 - t, 1 - t, 1);
glm::vec4 notFiring(0.5, 0.5, 0.5, 1);
RenderFontCr(*_fontInfo,
penPosition,
active,
"Active Instruments:"
glm::vec4(0.3, 0.3, 0.3, 1),
"| |"
);
RenderFontCr(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
" %5s",
m.first.c_str()
);
for (auto m : activeMap) {
if (m.second == false) {
}
else {
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
"|"
);
if (m.first == "NH_LORRI") {
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
"| |"
);
RenderFontCr(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
" %5s",
m.first.c_str()
);
}
else {
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
"|"
);
if (m.first == "NH_LORRI") {
RenderFont(*_fontInfo,
penPosition,
firing,
" + "
);
}
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
" |"
);
RenderFontCr(*_fontInfo,
penPosition,
active,
" %5s",
m.first.c_str()
firing,
" + "
);
}
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
" |"
);
RenderFontCr(*_fontInfo,
penPosition,
active,
" %5s",
m.first.c_str()
);
}
}
}
#endif
}
#endif
}
}
@@ -1317,9 +1311,6 @@ void RenderEngine::renderVersionInformation() {
OPENSPACE_GIT_COMMIT
);
FR::defaultRenderer().render(
*_fontInfo,
glm::vec2(
@@ -1358,11 +1349,11 @@ void RenderEngine::renderScreenLog() {
_log->removeExpiredEntries();
const int max = 10;
const int category_length = 20;
const int msg_length = 140;
const int categoryLength = 20;
const int messageLength = 140;
std::chrono::seconds fade(5);
auto entries = _log->entries();
const std::vector<ScreenLog::LogEntry>& entries = _log->entries();
auto lastEntries =
entries.size() > max ?
std::make_pair(entries.rbegin(), entries.rbegin() + max) :
@@ -1382,87 +1373,72 @@ void RenderEngine::renderScreenLog() {
auto d = (diff - ttf).count();
auto t = static_cast<float>(d) / static_cast<float>(fade.count());
float p = 0.8f - t;
alpha = (p <= 0.f) ? 0.f : pow(p, 0.3f);
alpha = (p <= 0.f) ? 0.f : pow(p, 0.4f);
}
// Since all log entries are ordered, once one exceeds alpha, all have
if (alpha <= 0.0)
if (alpha <= 0.0) {
break;
}
const std::string lvl = "(" + ghoul::logging::stringFromLevel(e->level) + ")";
const std::string& message = e->message.substr(0, msg_length);
const std::string& message = e->message.substr(0, messageLength);
nr += std::count(message.begin(), message.end(), '\n');
const glm::vec4 White(0.9f, 0.9f, 0.9f, 1.0f);
const glm::vec4 white(0.9f, 0.9f, 0.9f, alpha);
RenderFont(
*_fontLog,
glm::vec2(10.f, _fontLog->pointSize() * nr * 2),
White * alpha,
"%-14s %s%s", // Format
e->timeString.c_str(), // Time string
e->category.substr(0, category_length).c_str(), // Category string
e->category.length() > 20 ? "..." : ""); // Pad category with "..."
const glm::vec4 Red(1.f, 0.f, 0.f, 1.f);
const glm::vec4 Yellow(1.f, 1.f, 0.f, 1.f);
const glm::vec4 Green(0.f, 1.f, 0.f, 1.f);
const glm::vec4 Blue(0.f, 0.f, 1.f, 1.f);
white,
"%-14s %s%s",
e->timeString.c_str(),
e->category.substr(0, categoryLength).c_str(),
e->category.length() > 20 ? "..." : "");
glm::vec4 color(glm::uninitialize);
switch (e->level) {
case ghoul::logging::LogLevel::Debug:
color = Green;
color = glm::vec4(0.f, 1.f, 0.f, alpha);
break;
case ghoul::logging::LogLevel::Warning:
color = Yellow;
color = glm::vec4(1.f, 1.f, 0.f, alpha);
break;
case ghoul::logging::LogLevel::Error:
color = Red;
color = glm::vec4(1.f, 0.f, 0.f, alpha);
break;
case ghoul::logging::LogLevel::Fatal:
color = Blue;
color = glm::vec4(0.3f, 0.3f, 0.85f, alpha);
break;
default:
color = White;
color = white;
break;
}
// const float font_with_light = 5;
RenderFont(
*_fontLog,
glm::vec2(10 + 39 * _fontLog->pointSize(), _fontLog->pointSize() * nr * 2),
color * alpha,
"%s", // Format
lvl.c_str()); // Pad category with "..." if exceeds category_length
color,
"%s",
lvl.c_str()
);
RenderFont(*_fontLog,
glm::vec2(10 + 53 * _fontLog->pointSize(), _fontLog->pointSize() * nr * 2),
White * alpha,
"%s", // Format
message.c_str()); // Pad category with "..." if exceeds category_length
white,
"%s",
message.c_str()
);
++nr;
}
}
std::vector<Syncable*> RenderEngine::getSyncables(){
std::vector<Syncable*> RenderEngine::getSyncables() {
if (_camera) {
return _camera->getSyncables();
} else {
return std::vector<Syncable*>();
return {};
}
}
void RenderEngine::sortScreenspaceRenderables() {
std::sort(
_screenSpaceRenderables.begin(),
_screenSpaceRenderables.end(),
[](const std::shared_ptr<ScreenSpaceRenderable>& j,
const std::shared_ptr<ScreenSpaceRenderable>& i)
{
return i->depth() > j->depth();
}
);
}
}// namespace openspace
+7
View File
@@ -416,6 +416,13 @@ scripting::LuaLibrary Scene::luaLibrary() {
&luascriptfunctions::removeSceneGraphNode,
"string",
"Removes the SceneGraphNode identified by name"
},
{
"hasSceneGraphNode",
&luascriptfunctions::hasSceneGraphNode,
"string",
"Checks whether the specifies SceneGraphNode is present in the current "
"scene"
}
}
};
+12
View File
@@ -390,4 +390,16 @@ int removeSceneGraphNode(lua_State* L) {
return 1;
}
int hasSceneGraphNode(lua_State* L) {
int nArguments = lua_gettop(L);
SCRIPT_CHECK_ARGUMENTS("removeSceneGraphNode", L, 1, nArguments);
std::string nodeName = luaL_checkstring(L, -1);
SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(nodeName);
lua_pushboolean(L, node != nullptr);
return 1;
}
} // namespace openspace::luascriptfunctions
+3 -1
View File
@@ -23,7 +23,9 @@
****************************************************************************************/
#include <openspace/util/timemanager.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/network/parallelconnection.h>
#include <openspace/util/timeline.h>
@@ -45,7 +47,7 @@ void TimeManager::preSynchronization(double dt) {
}
void TimeManager::consumeKeyframes(double dt) {
double now = OsEng.runTime();
double now = OsEng.windowWrapper().applicationTime();
const std::deque<Keyframe<Time>>& keyframes = _timeline.keyframes();
auto firstFutureKeyframe = std::lower_bound(keyframes.begin(), keyframes.end(), now, &compareKeyframeTimeWithTime);