From d4145ede0cc552bac9e947f2fd1f9e97872cda63 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sat, 26 Nov 2016 14:45:09 +0100 Subject: [PATCH 1/2] Enable Translation classes to signal when settings have changed substantially RenderableTrail listens to those changes and recomputes the trail if Translation settings have changed Minor GUI improvements Remove try/catch block from SpiceRotation Update Ghoul reference --- ext/ghoul | 2 +- include/openspace/scene/translation.h | 9 +++++++++ modules/base/rendering/renderableplanet.cpp | 2 +- modules/base/rendering/renderabletrail.cpp | 1 + modules/base/rendering/renderabletrailorbit.cpp | 12 +++++------- .../base/rendering/renderabletrailtrajectory.cpp | 4 ++++ modules/base/rotation/spicerotation.cpp | 16 +++++----------- modules/base/translation/spicetranslation.cpp | 10 ++++++++++ modules/onscreengui/src/guipropertycomponent.cpp | 3 ++- src/scene/translation.cpp | 9 +++++++++ 10 files changed, 47 insertions(+), 21 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 4301855146..822898275c 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 4301855146b5aaaeed7960e628839d59cd4d5f06 +Subproject commit 822898275c122f7ec3fcc480f5b1f817365e0201 diff --git a/include/openspace/scene/translation.h b/include/openspace/scene/translation.h index 2fba7f86e8..7d7809e65f 100644 --- a/include/openspace/scene/translation.h +++ b/include/openspace/scene/translation.h @@ -46,7 +46,16 @@ public: glm::dvec3 position(double time); + // Registers a callback that gets called when a significant change has been made that + // invalidates potentially stored points, for example in trails + void onParameterChange(std::function callback); + static openspace::Documentation Documentation(); + +protected: + void notifyObservers(); + + std::function _onParameterChangeCallback; }; } // namespace openspace diff --git a/modules/base/rendering/renderableplanet.cpp b/modules/base/rendering/renderableplanet.cpp index 1a4ae0d7a9..fdccd9920e 100644 --- a/modules/base/rendering/renderableplanet.cpp +++ b/modules/base/rendering/renderableplanet.cpp @@ -349,7 +349,7 @@ void RenderablePlanet::render(const RenderData& data) { glm::dmat4 rot = glm::rotate(glm::dmat4(1.0), M_PI_2, glm::dvec3(1, 0, 0)); glm::dmat4 roty = glm::rotate(glm::dmat4(1.0), M_PI_2, glm::dvec3(0, -1, 0)); //glm::dmat4 rotProp = glm::rotate(glm::dmat4(1.0), glm::radians(static_cast(_rotation)), glm::dvec3(0, 1, 0)); - modelTransform = modelTransform * rot /** roty*/ /** rotProp*/; + modelTransform = modelTransform * rot * roty /** rotProp*/; glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index b150cbb871..181a05ce9a 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -143,6 +143,7 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary) _translation = std::unique_ptr(Translation::createFromDictionary( dictionary.value(KeyTranslation) )); + addPropertySubOwner(_translation.get()); _lineColor = dictionary.value(KeyColor); addProperty(_lineColor); diff --git a/modules/base/rendering/renderabletrailorbit.cpp b/modules/base/rendering/renderabletrailorbit.cpp index ca154b3607..7215c17ab0 100644 --- a/modules/base/rendering/renderabletrailorbit.cpp +++ b/modules/base/rendering/renderabletrailorbit.cpp @@ -131,7 +131,7 @@ openspace::Documentation RenderableTrailOrbit::Documentation() { RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary) : RenderableTrail(dictionary) , _period("period", "Period in days", 0.0, 0.0, 1e9) - , _resolution("resoluion", "Number of Samples along Orbit", 10000, 1, 1e6) + , _resolution("resolution", "Number of Samples along Orbit", 10000, 1, 1e6) , _needsFullSweep(true) , _indexBufferDirty(true) { @@ -141,6 +141,10 @@ RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary) "RenderableTrailOrbit" ); + _translation->onParameterChange([this](){ + _needsFullSweep = true; + }); + // Period is in days using namespace std::chrono; int factor = duration_cast(hours(24)).count(); @@ -180,12 +184,6 @@ void RenderableTrailOrbit::update(const UpdateData& data) { // 2. Update floating position // 3. Determine which parts of the array to upload and upload the data - // Early bailout when we don't move in time - if (data.timePaused || data.delta == 0.0) { - return; - } - - // 1 // Update the trails; the report contains whether any of the other values has been // touched and if so, how many diff --git a/modules/base/rendering/renderabletrailtrajectory.cpp b/modules/base/rendering/renderabletrailtrajectory.cpp index 9aa9d1606e..1cbf3e830d 100644 --- a/modules/base/rendering/renderabletrailtrajectory.cpp +++ b/modules/base/rendering/renderabletrailtrajectory.cpp @@ -140,6 +140,10 @@ RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& di "RenderableTrailTrajectory" ); + _translation->onParameterChange([this]() { + _needsFullSweep = true; + }); + _startTime = dictionary.value(KeyStartTime); _startTime.onChange([this] { _needsFullSweep = true; }); addProperty(_startTime); diff --git a/modules/base/rotation/spicerotation.cpp b/modules/base/rotation/spicerotation.cpp index 76aaf6dbf3..e1179820d8 100644 --- a/modules/base/rotation/spicerotation.cpp +++ b/modules/base/rotation/spicerotation.cpp @@ -116,17 +116,11 @@ SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary) } void SpiceRotation::update(const UpdateData& data) { - try { - _matrix = SpiceManager::ref().positionTransformMatrix( - _sourceFrame, - _destinationFrame, - data.time - ); - } - catch (const ghoul::RuntimeError&) { - // In case of missing coverage - _matrix = glm::dmat3(1); - } + _matrix = SpiceManager::ref().positionTransformMatrix( + _sourceFrame, + _destinationFrame, + data.time + ); } } // namespace openspace diff --git a/modules/base/translation/spicetranslation.cpp b/modules/base/translation/spicetranslation.cpp index 9f3ce6b2c9..5d8a8be05b 100644 --- a/modules/base/translation/spicetranslation.cpp +++ b/modules/base/translation/spicetranslation.cpp @@ -144,8 +144,18 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary) } } + auto update = [this](){ + notifyObservers(); + }; + + _target.onChange(update); addProperty(_target); + + _origin.onChange(update); addProperty(_origin); + + _frame.onChange(update); + addProperty(_frame); } glm::dvec3 SpiceTranslation::position() const { diff --git a/modules/onscreengui/src/guipropertycomponent.cpp b/modules/onscreengui/src/guipropertycomponent.cpp index 7e247045c7..4093f87573 100644 --- a/modules/onscreengui/src/guipropertycomponent.cpp +++ b/modules/onscreengui/src/guipropertycomponent.cpp @@ -74,6 +74,7 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner) return; } + int nThisProperty = nVisibleProperties(owner->properties(), _visibility); ImGui::PushID(owner->name().c_str()); const auto& subOwners = owner->propertySubOwners(); for (properties::PropertyOwner* subOwner : subOwners) { @@ -82,7 +83,7 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner) if (count == 0) { continue; } - if (subOwners.size() == 1) { + if (subOwners.size() == 1 && (nThisProperty == 0)) { renderPropertyOwner(subOwner); } else { diff --git a/src/scene/translation.cpp b/src/scene/translation.cpp index 8fe9513bce..0f0c19fefd 100644 --- a/src/scene/translation.cpp +++ b/src/scene/translation.cpp @@ -97,5 +97,14 @@ glm::dvec3 Translation::position(double time) { return position(); } +void Translation::notifyObservers() { + if (_onParameterChangeCallback) { + _onParameterChangeCallback(); + } +} + +void Translation::onParameterChange(std::function callback) { + _onParameterChangeCallback = std::move(callback); +} } // namespace openspace From 1d79fea9699736c7aa433f52f3c15120c5319628 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 5 Dec 2016 15:51:11 +0100 Subject: [PATCH 2/2] Add potential for modules to be defines as shared libraries --- support/cmake/module_definition.cmake | 10 +++++++++- support/cmake/support_macros.cmake | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/support/cmake/module_definition.cmake b/support/cmake/module_definition.cmake index 0ce121737d..7297179580 100644 --- a/support/cmake/module_definition.cmake +++ b/support/cmake/module_definition.cmake @@ -41,8 +41,14 @@ function (create_new_module module_name output_library_name) # Add the module files to the list of sources add_module_files() + set(library_mode STATIC) + if (${library_name}_LIBRARY_MODE) + set(library_mode ${${library_name}_LIBRARY_MODE}) + message(STATUS "\t Overwritten library mode: ${library_mode}") + endif () + # Create the library - add_library(${library_name} STATIC ${sources}) + add_library(${library_name} ${library_mode} ${sources}) # Set compile settings that are common to all modules set_common_compile_settings(${library_name}) @@ -154,6 +160,7 @@ function (handle_dependencies target_name module_name) # Handle OpenSpace dependencies foreach (dep ${OPENSPACE_DEPENDENCIES}) create_library_name(${dep} dep_library) + message(STATUS "Link: ${target_name} <- ${dep_library}") target_link_libraries(${target_name} ${dep_library}) get_property( @@ -171,6 +178,7 @@ function (handle_dependencies target_name module_name) target_include_directories(${target_name} PUBLIC ${${dep_upper}_INCLUDE_DIR} ${${dep_upper}_INCLUDE_DIRS} ) + message(STATUS "Link: ${target_name} <- ${${dep_upper}_LIBRARIES}") target_link_libraries(${target_name} ${${dep_upper}_LIBRARIES}) endforeach () endif () diff --git a/support/cmake/support_macros.cmake b/support/cmake/support_macros.cmake index b997b88fa6..d547d25cca 100644 --- a/support/cmake/support_macros.cmake +++ b/support/cmake/support_macros.cmake @@ -438,7 +438,12 @@ function (handle_internal_modules) endif () endforeach() - target_link_libraries(libOpenSpace ${libraryName}) + # Only link libOpenSpace against the library if it has been set STATIC + get_target_property(libType ${libraryName} TYPE) + if (NOT ${libType} STREQUAL "SHARED_LIBRARY") + target_link_libraries(libOpenSpace ${libraryName}) + endif() + create_define_name(${module} defineName) target_compile_definitions(libOpenSpace PUBLIC "${defineName}")