From bbc20062db7b9846050645af6099d965d5a2f2ef Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 15 Jul 2022 21:47:29 +0200 Subject: [PATCH 1/9] Remove legacy geometry specification from RenderablePlanetProjection (closes 1967) (#2181) * Remove planet geometry and simplespheregeometry * Fix RenderablePlanetProjection specification --- .../missions/newhorizons/charon.asset | 7 +- .../missions/newhorizons/pluto.asset | 6 +- modules/space/CMakeLists.txt | 4 - modules/space/rendering/planetgeometry.cpp | 64 ---------- modules/space/rendering/planetgeometry.h | 58 --------- .../space/rendering/simplespheregeometry.cpp | 116 ------------------ .../space/rendering/simplespheregeometry.h | 65 ---------- modules/space/spacemodule.cpp | 10 -- .../rendering/renderableplanetprojection.cpp | 80 +++++++----- .../rendering/renderableplanetprojection.h | 7 +- 10 files changed, 59 insertions(+), 358 deletions(-) delete mode 100644 modules/space/rendering/planetgeometry.cpp delete mode 100644 modules/space/rendering/planetgeometry.h delete mode 100644 modules/space/rendering/simplespheregeometry.cpp delete mode 100644 modules/space/rendering/simplespheregeometry.h diff --git a/data/assets/scene/solarsystem/missions/newhorizons/charon.asset b/data/assets/scene/solarsystem/missions/newhorizons/charon.asset index 52ad91c9be..d11bbc1af5 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/charon.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/charon.asset @@ -29,11 +29,8 @@ local CharonProjection = { }, Renderable = { Type = "RenderablePlanetProjection", - Geometry = { - Type = "SimpleSphere", - Radius = charonRadius, - Segments = 350 - }, + Radius = charonRadius, + Segments = 350, ColorTexturePaths = { textures .. "NH_Charon_mosaic.png", textures .. "NH_Charon_mosaic_8192.png" diff --git a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset index b6456a2a5a..2dcab6bebc 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset @@ -51,11 +51,7 @@ local PlutoProjection = { Renderable = { Type = "RenderablePlanetProjection", Radius = plutoRadius, - Geometry = { - Type = "SimpleSphere", - Radius = plutoRadius, - Segments = 400 - }, + Segments = 400, ColorTexturePaths = { textures .. "pluto.png", textures .. "NH_Pluto_mosaic_16384.png", diff --git a/modules/space/CMakeLists.txt b/modules/space/CMakeLists.txt index 35e09179ce..dc8f0ddfd2 100644 --- a/modules/space/CMakeLists.txt +++ b/modules/space/CMakeLists.txt @@ -27,7 +27,6 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) set(HEADER_FILES horizonsfile.h speckloader.h - rendering/planetgeometry.h rendering/renderableconstellationbounds.h rendering/renderablefluxnodes.h rendering/renderablehabitablezone.h @@ -37,7 +36,6 @@ set(HEADER_FILES rendering/renderablesmallbody.h rendering/renderablestars.h rendering/renderabletravelspeed.h - rendering/simplespheregeometry.h translation/keplertranslation.h translation/spicetranslation.h translation/tletranslation.h @@ -50,7 +48,6 @@ set(SOURCE_FILES horizonsfile.cpp spacemodule_lua.inl speckloader.cpp - rendering/planetgeometry.cpp rendering/renderableconstellationbounds.cpp rendering/renderablefluxnodes.cpp rendering/renderablehabitablezone.cpp @@ -60,7 +57,6 @@ set(SOURCE_FILES rendering/renderablesmallbody.cpp rendering/renderablestars.cpp rendering/renderabletravelspeed.cpp - rendering/simplespheregeometry.cpp translation/keplertranslation.cpp translation/spicetranslation.cpp translation/tletranslation.cpp diff --git a/modules/space/rendering/planetgeometry.cpp b/modules/space/rendering/planetgeometry.cpp deleted file mode 100644 index c0b3538303..0000000000 --- a/modules/space/rendering/planetgeometry.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2022 * - * * - * 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 - -#include -#include -#include -#include - -namespace { - struct [[codegen::Dictionary(PlanetGeometry)]] Parameters { - // The type of the PlanetGeometry that will can be constructed - std::string type; - }; -#include "planetgeometry_codegen.cpp" -} // namespace - -namespace openspace::planetgeometry { - -documentation::Documentation PlanetGeometry::Documentation() { - return codegen::doc("space_geometry_planet"); -} - -std::unique_ptr PlanetGeometry::createFromDictionary( - const ghoul::Dictionary& dictionary) -{ - const Parameters p = codegen::bake(dictionary); - - ghoul::TemplateFactory* factory = - FactoryManager::ref().factory(); - - PlanetGeometry* result = factory->create(p.type, dictionary); - return std::unique_ptr(result); -} - -PlanetGeometry::PlanetGeometry() : properties::PropertyOwner({ "PlanetGeometry" }) {} - -void PlanetGeometry::initialize() {} - -void PlanetGeometry::deinitialize() {} - -} // namespace openspace::planetgeometry diff --git a/modules/space/rendering/planetgeometry.h b/modules/space/rendering/planetgeometry.h deleted file mode 100644 index c5f5fcd4eb..0000000000 --- a/modules/space/rendering/planetgeometry.h +++ /dev/null @@ -1,58 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2022 * - * * - * 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_SPACE___PLANETGEOMETRY___H__ -#define __OPENSPACE_MODULE_SPACE___PLANETGEOMETRY___H__ - -#include - -#include -#include - -namespace ghoul { class Dictionary; } -namespace openspace { class Renderable; } -namespace openspace::documentation { struct Documentation; } - -namespace openspace::planetgeometry { - -class PlanetGeometry : public properties::PropertyOwner { -public: - static std::unique_ptr createFromDictionary( - const ghoul::Dictionary& dictionary - ); - - PlanetGeometry(); - ~PlanetGeometry() override = default; - virtual void initialize(); - virtual void deinitialize(); - virtual void render() = 0; - - virtual float boundingSphere() const = 0; - - static documentation::Documentation Documentation(); -}; - -} // namespace openspace::planetgeometry - -#endif // __OPENSPACE_MODULE_SPACE___PLANETGEOMETRY___H__ diff --git a/modules/space/rendering/simplespheregeometry.cpp b/modules/space/rendering/simplespheregeometry.cpp deleted file mode 100644 index 94c83b0545..0000000000 --- a/modules/space/rendering/simplespheregeometry.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2022 * - * * - * 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 - -#include -#include -#include -#include - -namespace { - constexpr openspace::properties::Property::PropertyInfo RadiusInfo = { - "Radius", - "Radius", - "This value specifies the radius of this sphere in meters." - }; - - constexpr openspace::properties::Property::PropertyInfo SegmentsInfo = { - "Segments", - "Segments", - "This value specifies the number of segments that this sphere is split into." - }; - - struct [[codegen::Dictionary(SimpleSphereGeometry)]] Parameters { - // [[codegen::verbatim(RadiusInfo.description)]] - std::variant radius; - - // [[codegen::verbatim(SegmentsInfo.description)]] - int segments; - }; -#include "simplespheregeometry_codegen.cpp" -} // namespace - -namespace openspace::planetgeometry { - -documentation::Documentation SimpleSphereGeometry::Documentation() { - return codegen::doc("space_geometry_simplesphere"); -} - -SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary) - : _radius(RadiusInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(std::pow(10.f, 20.f))) - , _segments(SegmentsInfo, 20, 1, 5000) - , _sphere(nullptr) -{ - const Parameters p = codegen::bake(dictionary); - - if (std::holds_alternative(p.radius)) { - const float radius = std::get(p.radius); - _radius = glm::dvec3(radius, radius, radius); - } - else { - _radius = std::get(p.radius); - } - - _segments = p.segments; - - // The shader need the radii values but they are not changeable runtime - // TODO: Possibly add a scaling property @AA - // Changing the radius/scaling should affect the shader but not the geometry? @AA - _radius.onChange([&]() { createSphere(); }); - addProperty(_radius); - - _segments.onChange([&]() { createSphere(); }); - addProperty(_segments); -} - -SimpleSphereGeometry::~SimpleSphereGeometry() {} // NOLINT - -void SimpleSphereGeometry::initialize() { - createSphere(); -} - -void SimpleSphereGeometry::deinitialize() { - delete _sphere; - _sphere = nullptr; -} - -void SimpleSphereGeometry::render() { - _sphere->render(); -} - -float SimpleSphereGeometry::boundingSphere() const { - const glm::vec3 radius = _radius; - return std::max(std::max(radius[0], radius[1]), radius[2]); -} - -void SimpleSphereGeometry::createSphere() { - const glm::vec3 radius = _radius.value(); - - delete _sphere; - _sphere = new Sphere(radius, _segments); - _sphere->initialize(); -} - -} // namespace openspace::planetgeometry diff --git a/modules/space/rendering/simplespheregeometry.h b/modules/space/rendering/simplespheregeometry.h deleted file mode 100644 index 7b6f9848fb..0000000000 --- a/modules/space/rendering/simplespheregeometry.h +++ /dev/null @@ -1,65 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2022 * - * * - * 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_SPACE___SIMPLESPHEREGEOMETRY___H__ -#define __OPENSPACE_MODULE_SPACE___SIMPLESPHEREGEOMETRY___H__ - -#include - -#include -#include - -namespace openspace { - class Renderable; - class Sphere; -} // namespace openspace - -namespace openspace::documentation { struct Documentation; } - -namespace openspace::planetgeometry { - -class SimpleSphereGeometry : public PlanetGeometry { -public: - SimpleSphereGeometry(const ghoul::Dictionary& dictionary); - ~SimpleSphereGeometry() override; - - void initialize() override; - void deinitialize() override; - void render() override; - - float boundingSphere() const override; - - static documentation::Documentation Documentation(); - -private: - void createSphere(); - - properties::Vec3Property _radius; - properties::IntProperty _segments; - Sphere* _sphere; -}; - -} // namespace openspace::planetgeometry - -#endif // __OPENSPACE_MODULE_SPACE___SIMPLESPHEREGEOMETRY___H__ diff --git a/modules/space/spacemodule.cpp b/modules/space/spacemodule.cpp index f73711b250..ee6b08d588 100644 --- a/modules/space/spacemodule.cpp +++ b/modules/space/spacemodule.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -74,8 +73,6 @@ SpaceModule::SpaceModule() } void SpaceModule::internalInitialize(const ghoul::Dictionary& dictionary) { - FactoryManager::ref().addFactory("PlanetGeometry"); - ghoul::TemplateFactory* fRenderable = FactoryManager::ref().factory(); ghoul_assert(fRenderable, "Renderable factory was not created"); @@ -106,11 +103,6 @@ void SpaceModule::internalInitialize(const ghoul::Dictionary& dictionary) { fRotation->registerClass("SpiceRotation"); - ghoul::TemplateFactory* fGeometry = - FactoryManager::ref().factory(); - ghoul_assert(fGeometry, "Planet geometry factory was not created"); - fGeometry->registerClass("SimpleSphere"); - if (dictionary.hasValue(SpiceExceptionInfo.identifier)) { _showSpiceExceptions = dictionary.value(SpiceExceptionInfo.identifier); } @@ -124,7 +116,6 @@ std::vector SpaceModule::documentations() const { return { HorizonsTranslation::Documentation(), KeplerTranslation::Documentation(), - planetgeometry::PlanetGeometry::Documentation(), RenderableConstellationBounds::Documentation(), RenderableFluxNodes::Documentation(), RenderableHabitableZone::Documentation(), @@ -133,7 +124,6 @@ std::vector SpaceModule::documentations() const { RenderableSmallBody::Documentation(), RenderableStars::Documentation(), RenderableTravelSpeed::Documentation(), - planetgeometry::SimpleSphereGeometry::Documentation(), SpiceRotation::Documentation(), SpiceTranslation::Documentation(), TLETranslation::Documentation() diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp index 0d152ffe98..fe6ff8c505 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp @@ -24,13 +24,13 @@ #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -130,10 +130,19 @@ namespace { "Remove all pending projections from the buffer" }; - struct [[codegen::Dictionary(RenderablePlanetProjection)]] Parameters { - // The geometry that is used for rendering this planet - ghoul::Dictionary geometry [[codegen::reference("space_geometry_planet")]]; + constexpr openspace::properties::Property::PropertyInfo RadiusInfo = { + "Radius", + "Radius", + "This value specifies the radius of this sphere in meters." + }; + constexpr openspace::properties::Property::PropertyInfo SegmentsInfo = { + "Segments", + "Segments", + "This value specifies the number of segments that this sphere is split into." + }; + + struct [[codegen::Dictionary(RenderablePlanetProjection)]] Parameters { // Contains information about projecting onto this planet ghoul::Dictionary projection [[codegen::reference("spacecraftinstruments_projectioncomponent")]]; @@ -155,6 +164,12 @@ namespace { // [[codegen::verbatim(MaxProjectionsPerFrameInfo.description)]] std::optional maxProjectionsPerFrame; + + // [[codegen::verbatim(RadiusInfo.description)]] + std::variant radius; + + // [[codegen::verbatim(SegmentsInfo.description)]] + int segments; }; #include "renderableplanetprojection_codegen.cpp" } // namespace @@ -177,10 +192,12 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& , _maxProjectionsPerFrame(MaxProjectionsPerFrameInfo, 3, 1, 64) , _projectionsInBuffer(ProjectionsInBufferInfo, 0, 1, 32) , _clearProjectionBuffer(ClearProjectionBufferInfo) + , _radius(RadiusInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(std::pow(10.f, 20.f))) + , _segments(SegmentsInfo, 20, 1, 5000) + , _sphere(nullptr) { const Parameters p = codegen::bake(dict); - _geometry = planetgeometry::PlanetGeometry::createFromDictionary(p.geometry); _projectionComponent.initialize(identifier(), p.projection); _colorTexturePaths.addOption(0, NoImageText); @@ -251,7 +268,6 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& } setBoundingSphere(radius); - addPropertySubOwner(_geometry.get()); addPropertySubOwner(_projectionComponent); _heightExaggeration.setExponent(3.f); @@ -270,6 +286,20 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& }); addProperty(_clearProjectionBuffer); + + if (std::holds_alternative(p.radius)) { + const float r = std::get(p.radius); + _radius = glm::dvec3(r, r, r); + } + else { + _radius = std::get(p.radius); + } + _radius.onChange([&]() { createSphere(); }); + addProperty(_radius); + + _segments = p.segments; + _segments.onChange([&]() { createSphere(); }); + addProperty(_segments); } RenderablePlanetProjection::~RenderablePlanetProjection() {} // NOLINT @@ -322,8 +352,9 @@ void RenderablePlanetProjection::initializeGL() { loadColorTexture(); loadHeightTexture(); _projectionComponent.initializeGL(); - _geometry->initialize(); - setBoundingSphere(_geometry->boundingSphere()); + createSphere(); + const glm::vec3 radius = _radius; + setBoundingSphere(std::max(std::max(radius[0], radius[1]), radius[2])); // SCREEN-QUAD const GLfloat vertexData[] = { @@ -346,9 +377,10 @@ void RenderablePlanetProjection::initializeGL() { } void RenderablePlanetProjection::deinitializeGL() { + _sphere = nullptr; + _projectionComponent.deinitialize(); _baseTexture = nullptr; - _geometry = nullptr; glDeleteVertexArrays(1, &_quad); glDeleteBuffers(1, &_vertexPositionBuffer); @@ -366,7 +398,7 @@ void RenderablePlanetProjection::deinitializeGL() { } bool RenderablePlanetProjection::isReady() const { - return _geometry && _programObject && _projectionComponent.isReady(); + return _programObject && _projectionComponent.isReady(); } void RenderablePlanetProjection::imageProjectGPU( @@ -385,25 +417,8 @@ void RenderablePlanetProjection::imageProjectGPU( _fboProgramObject->setUniform(_fboUniformCache.projectorMatrix, projectorMatrix); _fboProgramObject->setUniform(_fboUniformCache.modelTransform, _transform); _fboProgramObject->setUniform(_fboUniformCache.boresight, _boresight); - - if (_geometry->hasProperty("Radius")) { - std::any r = _geometry->property("Radius")->get(); - if (glm::vec3* radius = std::any_cast(&r)){ - _fboProgramObject->setUniform(_fboUniformCache.radius, *radius); - } - } - else { - LERROR("Geometry object needs to provide radius"); - } - if (_geometry->hasProperty("Segments")) { - std::any s = _geometry->property("Segments")->get(); - if (int* segments = std::any_cast(&s)) { - _fboProgramObject->setUniform(_fboUniformCache.segments, segments[0]); - } - } - else{ - LERROR("Geometry object needs to provide segment count"); - } + _fboProgramObject->setUniform(_fboUniformCache.radius, _radius); + _fboProgramObject->setUniform(_fboUniformCache.segments, _segments); glBindVertexArray(_quad); glDrawArrays(GL_TRIANGLES, 0, 6); @@ -552,7 +567,7 @@ void RenderablePlanetProjection::render(const RenderData& data, RendererTasks&) _programObject->setUniform(_mainUniformCache.heightTexture, unit[2]); } - _geometry->render(); + _sphere->render(); _programObject->deactivate(); } @@ -674,4 +689,9 @@ void RenderablePlanetProjection::loadHeightTexture() { } } +void RenderablePlanetProjection::createSphere() { + _sphere = std::make_unique(_radius, _segments); + _sphere->initialize(); +} + } // namespace openspace diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.h b/modules/spacecraftinstruments/rendering/renderableplanetprojection.h index caf194aec5..0f753e717a 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.h +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.h @@ -31,6 +31,7 @@ #include #include #include +#include #include namespace openspace { @@ -38,6 +39,7 @@ namespace openspace { namespace documentation { struct Documentation; } struct Image; +class Sphere; namespace planetgeometry { class PlanetGeometry; } @@ -59,6 +61,7 @@ public: private: void loadColorTexture(); void loadHeightTexture(); + void createSphere(); glm::mat4 attitudeParameters(double time, const glm::vec3& up); void imageProjectGPU(const ghoul::opengl::Texture& projectionTexture, @@ -94,7 +97,9 @@ private: properties::IntProperty _projectionsInBuffer; properties::TriggerProperty _clearProjectionBuffer; - std::unique_ptr _geometry; + properties::Vec3Property _radius; + properties::IntProperty _segments; + std::unique_ptr _sphere; glm::mat4 _transform = glm::mat4(1.f); glm::mat4 _projectorMatrix = glm::mat4(1.f); From 521868866c9441d3444427ec6a47411d673430f2 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 17 Jul 2022 07:51:32 +0200 Subject: [PATCH 2/9] Convert hasProperty and getProperty Lua functions to luawrap --- src/scene/scene.cpp | 17 ++--------- src/scene/scene_lua.inl | 65 +++++++++++++++-------------------------- 2 files changed, 25 insertions(+), 57 deletions(-) diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index d9a179298d..f82ad1c7bd 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -863,13 +863,6 @@ scripting::LuaLibrary Scene::luaLibrary() { "This is the same as calling the setValue method and passing 'single' as " "the fourth argument to setPropertyValue." }, - { - "hasProperty", - &luascriptfunctions::propertyHasProperty, - {}, - "", - "Returns whether a property with the given URI exists" - }, { "getPropertyValue", &luascriptfunctions::propertyGetValue, @@ -877,14 +870,8 @@ scripting::LuaLibrary Scene::luaLibrary() { "", "Returns the value the property, identified by the provided URI." }, - { - "getProperty", - &luascriptfunctions::propertyGetProperty, - {}, - "", - "Returns a list of property identifiers that match the passed regular " - "expression" - }, + codegen::lua::HasProperty, + codegen::lua::GetProperty, codegen::lua::AddCustomProperty, codegen::lua::RemoveCustomProperty, codegen::lua::AddSceneGraphNode, diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 651ca58da7..4b2c6ef2ff 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -455,15 +455,6 @@ int propertySetValueSingle(lua_State* L) { return propertySetValue(L); } -int propertyHasProperty(lua_State* L) { - ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::propertyHasProperty"); - const std::string uri = ghoul::lua::value(L); - - properties::Property* prop = property(uri); - ghoul::lua::push(L, prop != nullptr); - return 1; -} - int propertyGetValue(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::propertyGetValue"); const std::string uri = ghoul::lua::value(L); @@ -485,14 +476,23 @@ int propertyGetValue(lua_State* L) { return 1; } +} // namespace openspace::luascriptfunctions + +namespace { + +/** + * Returns whether a property with the given URI exists + */ +[[codegen::luawrap]] bool hasProperty(std::string uri) { + openspace::properties::Property* prop = openspace::property(uri); + return prop != nullptr; +} + /** - * \ingroup LuaScripts - * getProperty * Returns a list of property identifiers that match the passed regular expression */ -int propertyGetProperty(lua_State* L) { - ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::propertyGetProperty"); - std::string regex = ghoul::lua::value(L); +[[codegen::luawrap]] std::vector getProperty(std::string regex) { + using namespace openspace; std::string groupName; if (doesUriContainGroupTag(regex, groupName)) { @@ -511,26 +511,18 @@ int propertyGetProperty(lua_State* L) { // If none then malformed regular expression if (propertyName.empty() && nodeName.empty()) { - LERRORC( - "propertyGetProperty", - fmt::format( - "Malformed regular expression: '{}': Empty both before and after '*'", - regex - ) - ); - return 0; + throw ghoul::lua::LuaError(fmt::format( + "Malformed regular expression: '{}': Empty both before and after '*'", + regex + )); } // Currently do not support several wildcards if (regex.find_first_of("*", wildPos + 1) != std::string::npos) { - LERRORC( - "propertyGetProperty", - fmt::format( - "Malformed regular expression: '{}': " - "Currently only one '*' is supported", regex - ) - ); - return 0; + throw ghoul::lua::LuaError(fmt::format( + "Malformed regular expression: '{}': Currently only one '*' is supported", + regex + )); } } // Literal or tag @@ -602,20 +594,9 @@ int propertyGetProperty(lua_State* L) { res.push_back(id); } - lua_newtable(L); - int number = 1; - for (const std::string& s : res) { - ghoul::lua::push(L, s); - lua_rawseti(L, -2, number); - ++number; - } - return 1; + return res; } -} // namespace openspace::luascriptfunctions - -namespace { - /** * Loads the SceneGraphNode described in the table and adds it to the SceneGraph. */ From 173b22c7d257ba3e73b77066d4cac7a307ad12c1 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 19 Jul 2022 10:20:11 +0200 Subject: [PATCH 3/9] Remove compiler warnings --- ext/ghoul | 2 +- modules/skybrowser/ext/tinyxml2/tinyxml2.cpp | 4 ++++ modules/skybrowser/include/wwtdatahandler.h | 6 ++++++ src/scene/scene_lua.inl | 4 ---- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 2f0b8fb150..9c0718035f 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 2f0b8fb15055fa3ff2a5ca67c12d7dda26f67e38 +Subproject commit 9c0718035f93fca5fbcd1902031fc315c879c774 diff --git a/modules/skybrowser/ext/tinyxml2/tinyxml2.cpp b/modules/skybrowser/ext/tinyxml2/tinyxml2.cpp index b170df3b54..4804cd5ece 100644 --- a/modules/skybrowser/ext/tinyxml2/tinyxml2.cpp +++ b/modules/skybrowser/ext/tinyxml2/tinyxml2.cpp @@ -21,10 +21,12 @@ must not be misrepresented as being the original software. distribution. */ +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wold-style-cast" #pragma GCC diagnostic ignored "-Wsuggest-override" #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif #include "tinyxml2.h" @@ -2990,4 +2992,6 @@ bool XMLPrinter::Visit( const XMLUnknown& unknown ) } // namespace tinyxml2 +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop +#endif diff --git a/modules/skybrowser/include/wwtdatahandler.h b/modules/skybrowser/include/wwtdatahandler.h index b4b1280bcc..b3a45dd46c 100644 --- a/modules/skybrowser/include/wwtdatahandler.h +++ b/modules/skybrowser/include/wwtdatahandler.h @@ -29,11 +29,17 @@ #include #include +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-override" #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif + #include + +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop +#endif namespace openspace::documentation { struct Documentation; } diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 4b2c6ef2ff..af7449144c 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -134,7 +134,6 @@ std::vector findMatchesInAllProperties( // Stores whether we found at least one matching property. If this is false at the end // of the loop, the property name regex was probably misspelled. - bool foundMatching = false; for (properties::Property* prop : properties) { // Check the regular expression for all properties const std::string id = prop->fullyQualifiedIdentifier(); @@ -203,9 +202,6 @@ void applyRegularExpression(lua_State* L, const std::string& regex, using ghoul::lua::errorLocation; using ghoul::lua::luaTypeToString; - const bool isGroupMode = !groupName.empty(); - bool isLiteral = false; - const int type = lua_type(L, -1); std::vector matchingProps = findMatchesInAllProperties( From 9f534330738e19afae829befcb547f6081a1a239 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 19 Jul 2022 10:35:27 +0200 Subject: [PATCH 4/9] Request the current version later in the initialization after the operating system has been detected (#2186) --- modules/space/horizonsfile.cpp | 71 +++++----------------------------- src/engine/openspaceengine.cpp | 9 ++--- src/util/versionchecker.cpp | 10 +---- 3 files changed, 16 insertions(+), 74 deletions(-) diff --git a/modules/space/horizonsfile.cpp b/modules/space/horizonsfile.cpp index 4f6edf0521..29da5853b7 100644 --- a/modules/space/horizonsfile.cpp +++ b/modules/space/horizonsfile.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -52,60 +53,6 @@ namespace { constexpr std::string_view StartTime = "&START_TIME="; constexpr std::string_view StopTime = "&STOP_TIME="; constexpr std::string_view StepSize = "&STEP_SIZE="; - - // URL encoding - constexpr std::string_view WhiteSpace = "%20"; - constexpr std::string_view HashTag = "%23"; - constexpr std::string_view DollarSign = "%24"; - constexpr std::string_view Ampersand = "%26"; - constexpr std::string_view PlusSign = "%2B"; - constexpr std::string_view Comma = "%2C"; - constexpr std::string_view Slash = "%2F"; - constexpr std::string_view Colon = "%3A"; - constexpr std::string_view Semicolon = "%3B"; - constexpr std::string_view EqualsSign = "%3D"; - constexpr std::string_view QuestionMark = "%3F"; - constexpr std::string_view AtSymbol = "%40"; - constexpr std::string_view LeftSquareBracket = "%5B"; - constexpr std::string_view RightSquareBracket = "%5D"; - - std::string replaceAll(std::string string, const std::string& from, - const std::string& to) - { - if (from.empty()) { - return ""; - } - - size_t pos = string.find(from); - while (pos != std::string::npos) { - string.replace(pos, from.length(), to); - - // In case 'to' contains 'from', ex replacing 'x' with 'yx' - size_t offset = pos + to.length(); - pos = string.find(from, offset); - } - return string; - } - - std::string urlEncode(const std::string& string) { - std::string result; - result = replaceAll(string, " ", static_cast(WhiteSpace)); - result = replaceAll(result, "#", static_cast(HashTag)); - result = replaceAll(result, "$", static_cast(DollarSign)); - result = replaceAll(result, "&", static_cast(Ampersand)); - result = replaceAll(result, "+", static_cast(PlusSign)); - result = replaceAll(result, ",", static_cast(Comma)); - result = replaceAll(result, "/", static_cast(Slash)); - result = replaceAll(result, ":", static_cast(Colon)); - result = replaceAll(result, ";", static_cast(Semicolon)); - result = replaceAll(result, "=", static_cast(EqualsSign)); - result = replaceAll(result, "?", static_cast(QuestionMark)); - result = replaceAll(result, "@", static_cast(AtSymbol)); - result = replaceAll(result, "[", static_cast(LeftSquareBracket)); - result = replaceAll(result, "]", static_cast(RightSquareBracket)); - return result; - } - } // namespace namespace openspace { @@ -117,7 +64,7 @@ HorizonsFile::HorizonsFile(std::filesystem::path file) HorizonsFile::HorizonsFile(std::filesystem::path filePath, const std::string& result) { // Write the response into a new file and save it std::ofstream file(filePath); - file << replaceAll(result, "\\n", "\n") << std::endl; + file << ghoul::replaceAll(result, "\\n", "\n") << std::endl; file.close(); _file = std::move(filePath); } @@ -153,16 +100,18 @@ std::string constructHorizonsUrl(HorizonsType type, const std::string& target, throw ghoul::MissingCaseException(); } - url += fmt::format("{}'{}'", Command, urlEncode(target)); - url += fmt::format("{}'{}'", Center, urlEncode(observer)); - url += fmt::format("{}'{}'", StartTime, urlEncode(startTime)); - url += fmt::format("{}'{}'", StopTime, urlEncode(stopTime)); + url += fmt::format("{}'{}'", Command, ghoul::encodeUrl(target)); + url += fmt::format("{}'{}'", Center, ghoul::encodeUrl(observer)); + url += fmt::format("{}'{}'", StartTime, ghoul::encodeUrl(startTime)); + url += fmt::format("{}'{}'", StopTime, ghoul::encodeUrl(stopTime)); if (unit.empty()) { - url += fmt::format("{}'{}'", StepSize, urlEncode(stepSize)); + url += fmt::format("{}'{}'", StepSize, ghoul::encodeUrl(stepSize)); } else { - url += fmt::format("{}'{}{}{}'", StepSize, urlEncode(stepSize), WhiteSpace, unit); + url += fmt::format( + "{}'{}%20{}'", StepSize, ghoul::encodeUrl(stepSize), unit + ); } return url; diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index a28ae88408..6b19693196 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -219,11 +219,6 @@ void OpenSpaceEngine::initialize() { _printEvents = global::configuration->isPrintingEvents; - const std::string versionCheckUrl = global::configuration->versionCheckUrl; - if (!versionCheckUrl.empty()) { - global::versionChecker->requestLatestVersion(versionCheckUrl); - } - std::string cacheFolder = absPath("${CACHE}").string(); if (global::configuration->usePerProfileCache) { std::string profile = global::configuration->profile; @@ -463,6 +458,10 @@ void OpenSpaceEngine::initializeGL() { ); SysCap.logCapabilities(verbosity); + const std::string versionCheckUrl = global::configuration->versionCheckUrl; + if (!versionCheckUrl.empty()) { + global::versionChecker->requestLatestVersion(versionCheckUrl); + } // Check the required OpenGL versions of the registered modules ghoul::systemcapabilities::Version version = diff --git a/src/util/versionchecker.cpp b/src/util/versionchecker.cpp index b50ed5a83e..76d13d48dc 100644 --- a/src/util/versionchecker.cpp +++ b/src/util/versionchecker.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -44,14 +45,7 @@ VersionChecker::~VersionChecker() { void VersionChecker::requestLatestVersion(const std::string& url) { using GCC = ghoul::systemcapabilities::GeneralCapabilitiesComponent; std::string operatingSystem = SysCap.component().operatingSystemString(); - - // Need to escape non-http characters when passing the operating system in the url - for (size_t i = 0; i < operatingSystem.size(); i++) { - if (operatingSystem[i] == ' ') { - operatingSystem.erase(i, 1); - operatingSystem.insert(i, "%20"); - } - } + operatingSystem = ghoul::encodeUrl(operatingSystem); std::string fullUrl = fmt::format( "{}?client_version={}&commit_hash={}&operating_system={}", From 44a9f6421f801c99a32f5ac3b39e1b8de96b4a5a Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 19 Jul 2022 11:51:59 +0200 Subject: [PATCH 5/9] Update submodules, Suppress CMake warnings, Removal of extra image libraries --- CMakeLists.txt | 1 + apps/OpenSpace/ext/sgct | 2 +- apps/TaskRunner/main.cpp | 15 ------------ ext/ghoul | 2 +- modules/fitsfilereader/ext/CCfits | 2 +- modules/fitsfilereader/ext/cfitsio | 2 +- modules/kameleon/ext/kameleon | 2 +- modules/webbrowser/CMakeLists.txt | 2 +- src/rendering/renderengine.cpp | 38 +----------------------------- 9 files changed, 8 insertions(+), 58 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5f461efbe..390c33d82a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ ########################################################################################## cmake_minimum_required(VERSION 3.10 FATAL_ERROR) +cmake_policy(SET CMP0120 NEW) project(OpenSpace) diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index 4e00462a08..c98f023714 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit 4e00462a08d5a38eb71a31a2e2f9ed4c7de72c45 +Subproject commit c98f023714d901bc0f94462af1955ad2b014818f diff --git a/apps/TaskRunner/main.cpp b/apps/TaskRunner/main.cpp index 6fcc1b18ee..d2744e6c2e 100644 --- a/apps/TaskRunner/main.cpp +++ b/apps/TaskRunner/main.cpp @@ -29,8 +29,6 @@ #include #include #include -#include -#include #include #include #include @@ -64,19 +62,6 @@ namespace { const std::string _loggerCat = "TaskRunner Main"; } -void initTextureReaders() { - #ifdef GHOUL_USE_DEVIL - ghoul::io::TextureReader::ref().addReader( - std::make_unique() - ); - #endif // GHOUL_USE_DEVIL - #ifdef GHOUL_USE_FREEIMAGE - ghoul::io::TextureReader::ref().addReader( - std::make_unique() - ); - #endif // GHOUL_USE_FREEIMAGE -} - void performTasks(const std::string& path) { using namespace openspace; diff --git a/ext/ghoul b/ext/ghoul index 9c0718035f..0dacfd1505 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 9c0718035f93fca5fbcd1902031fc315c879c774 +Subproject commit 0dacfd150584ebbe05cf4fdd94eb159abcce76cc diff --git a/modules/fitsfilereader/ext/CCfits b/modules/fitsfilereader/ext/CCfits index 3c16ca3f1e..27f655a80f 160000 --- a/modules/fitsfilereader/ext/CCfits +++ b/modules/fitsfilereader/ext/CCfits @@ -1 +1 @@ -Subproject commit 3c16ca3f1e9a405be7fdbd0db363151eca96629f +Subproject commit 27f655a80febd04a1921edc8894ebbe326137355 diff --git a/modules/fitsfilereader/ext/cfitsio b/modules/fitsfilereader/ext/cfitsio index 8d98f1495b..e8fc91cc4b 160000 --- a/modules/fitsfilereader/ext/cfitsio +++ b/modules/fitsfilereader/ext/cfitsio @@ -1 +1 @@ -Subproject commit 8d98f1495b8c762f1c56e79da33cbd3c7d623d80 +Subproject commit e8fc91cc4b4cb22236d94429202175b7043bf36f diff --git a/modules/kameleon/ext/kameleon b/modules/kameleon/ext/kameleon index 606edb945b..e6978911c5 160000 --- a/modules/kameleon/ext/kameleon +++ b/modules/kameleon/ext/kameleon @@ -1 +1 @@ -Subproject commit 606edb945b62d0151f20270ddb2db4a9f558aaa1 +Subproject commit e6978911c51560457ca1738517ff3cf5290febd4 diff --git a/modules/webbrowser/CMakeLists.txt b/modules/webbrowser/CMakeLists.txt index 591a2bdbf7..6c66c8b05e 100644 --- a/modules/webbrowser/CMakeLists.txt +++ b/modules/webbrowser/CMakeLists.txt @@ -107,7 +107,7 @@ add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper) mark_as_advanced(CEF_DEBUG_INFO_FLAG USE_ATL USE_OFFICIAL_BUILD_SANDBOX USE_SANDBOX) -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") +if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") # The CEF DLL wrapper is raising a lot of warnings on GCC target_compile_options(libcef_dll_wrapper PRIVATE "-w") endif () diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 97a4415473..78b5c92b94 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -66,23 +67,6 @@ #include #include -#ifdef GHOUL_USE_DEVIL -#include -#endif // GHOUL_USE_DEVIL -#ifdef GHOUL_USE_FREEIMAGE -#include -#endif // GHOUL_USE_FREEIMAGE - -#ifdef GHOUL_USE_SOIL -#include -#include -#include -#endif // GHOUL_USE_SOIL - -#ifdef GHOUL_USE_STB_IMAGE -#include -#endif // GHOUL_USE_STB_IMAGE - #include "renderengine_lua.inl" namespace { @@ -427,29 +411,9 @@ void RenderEngine::initialize() { _disableMasterRendering = global::configuration->isRenderingOnMasterDisabled; _screenshotUseDate = global::configuration->shouldUseScreenshotDate; -#ifdef GHOUL_USE_DEVIL - ghoul::io::TextureReader::ref().addReader( - std::make_unique() - ); -#endif // GHOUL_USE_DEVIL -#ifdef GHOUL_USE_FREEIMAGE - ghoul::io::TextureReader::ref().addReader( - std::make_unique() - ); -#endif // GHOUL_USE_FREEIMAGE -#ifdef GHOUL_USE_SOIL - ghoul::io::TextureReader::ref().addReader( - std::make_unique() - ); - ghoul::io::TextureWriter::ref().addWriter( - std::make_unique() - ); -#endif // GHOUL_USE_SOIL -#ifdef GHOUL_USE_STB_IMAGE ghoul::io::TextureReader::ref().addReader( std::make_unique() ); -#endif // GHOUL_USE_STB_IMAGE ghoul::io::TextureReader::ref().addReader( std::make_unique() From 7f7d724f91e95375c9f3af4aadd34d18a33c469e Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 19 Jul 2022 14:00:37 +0200 Subject: [PATCH 6/9] Globally rename OpenSpace Helper to OpenSpace_Helper to remove space in the application name. Also removes need for CMake CMP0037 (closes #2119) --- modules/webbrowser/CMakeLists.txt | 67 ++++++------------- ...manifest => OpenSpace_Helper.exe.manifest} | 0 .../webbrowser/cmake/webbrowser_helpers.cmake | 4 +- modules/webbrowser/webbrowsermodule.cpp | 6 +- 4 files changed, 24 insertions(+), 53 deletions(-) rename modules/webbrowser/{openspace Helper.exe.manifest => OpenSpace_Helper.exe.manifest} (100%) diff --git a/modules/webbrowser/CMakeLists.txt b/modules/webbrowser/CMakeLists.txt index 6c66c8b05e..05e6982237 100644 --- a/modules/webbrowser/CMakeLists.txt +++ b/modules/webbrowser/CMakeLists.txt @@ -46,26 +46,13 @@ cmake_minimum_required(VERSION 2.8.12.1) # Use folders in the resulting project files. set_property(GLOBAL PROPERTY OS_FOLDERS ON) -# "OpenSpace Helper" is not a valid CMake target name under OLD -# https://cmake.org/cmake/help/git-stage/policy/CMP0037.html -cmake_policy(SET CMP0037 OLD) - # Use _ROOT variables # https://cmake.org/cmake/help/git-stage/policy/CMP0074.html cmake_policy(SET CMP0074 NEW) # Specify the CEF distribution version. - -# Release from 03/21/2022 verified to work on Windows. set(CEF_VERSION "102.0.10+gf249b2e+chromium-102.0.5005.115") -# Removing - micahnyc 03/21/2022 -# 73.1.13 has an issue on MacOS: The GUI freezing upon interaction. -# Therefore, we fall back to 3.3578.1867 from 01/29/2019 -#if (APPLE) -# set(CEF_VERSION "3.3578.1867.g0f6d65a") -#endif () - # CEF Sandbox is not working with the latest Visual Studio, so we disable it for now. if (WIN32 OR UNIX) option(USE_SANDBOX OFF) @@ -128,8 +115,8 @@ set(WEBBROWSER_SOURCES_WINDOWS resource.h simple_handler_win.cc ) -APPEND_PLATFORM_SOURCES(WEBBROWSER_SOURCES) -APPEND_PLATFORM_SOURCES(WEBBROWSER_RESOURCES_SOURCES) +append_platform_sources(WEBBROWSER_SOURCES) +append_platform_sources(WEBBROWSER_RESOURCES_SOURCES) set(WEBBROWSER_SOURCES ${WEBBROWSER_SOURCES} ${WEBBROWSER_RESOURCES_SOURCES}) @@ -143,18 +130,18 @@ if (OS_LINUX) list(APPEND WEBBROWSER_HELPER_SOURCES src/processhelperlinux.cpp) set(WEBBROWSER_HELPER_SOURCES_LINUX src/processhelperlinux.cpp) endif() -APPEND_PLATFORM_SOURCES(WEBBROWSER_HELPER_SOURCES) +append_platform_sources(WEBBROWSER_HELPER_SOURCES) set(WEBBROWSER_RESOURCES_MAC_SOURCES_MACOSX mac/Info.plist ) -APPEND_PLATFORM_SOURCES(WEBBROWSER_RESOURCES_MAC_SOURCES) +append_platform_sources(WEBBROWSER_RESOURCES_MAC_SOURCES) set(WEBBROWSER_RESOURCES_MAC_ENGLISH_LPROJ_SRCS_MACOSX mac/English.lproj/InfoPlist.strings mac/English.lproj/MainMenu.xib ) -APPEND_PLATFORM_SOURCES(WEBBROWSER_RESOURCES_MAC_ENGLISH_LPROJ_SRCS) +append_platform_sources(WEBBROWSER_RESOURCES_MAC_ENGLISH_LPROJ_SRCS) set(WEBBROWSER_RESOURCES_SRCS ${WEBBROWSER_RESOURCES_MAC_SOURCES} @@ -163,19 +150,7 @@ set(WEBBROWSER_RESOURCES_SRCS # Place Helper in separate executable # The naming style " Helper" is required by Chromium. -set(CEF_HELPER_FILE_REQUIRES_RENAME FALSE) -if (UNIX AND (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")) - # Linux builds that use GNU Make cannot handle spaces in filenames. For this type - # of build, the build file will have an underscore instead of a space, and this - # will be renamed back to a space when the build is complete. - set(CEF_HELPER_FILE_REQUIRES_RENAME TRUE) -endif() -if (CEF_HELPER_FILE_REQUIRES_RENAME) - # Use '_' instead of ' ' in helper filename - set(CEF_HELPER_TARGET "OpenSpace_Helper" CACHE INTERNAL "CEF_HELPER_TARGET") -else() - set(CEF_HELPER_TARGET "OpenSpace Helper" CACHE INTERNAL "CEF_HELPER_TARGET") -endif() +set(CEF_HELPER_TARGET "OpenSpace_Helper" CACHE INTERNAL "CEF_HELPER_TARGET") set(CEF_HELPER_TARGET_GPU "OpenSpace Helper (GPU)" CACHE INTERNAL "CEF_HELPER_TARGET_GPU") set(CEF_HELPER_TARGET_RENDERER "OpenSpace Helper (Renderer)" CACHE INTERNAL "CEF_HELPER_TARGET_RENDERER") @@ -187,11 +162,11 @@ list(APPEND Targets ${CEF_HELPER_TARGET} ${CEF_HELPER_TARGET_GPU} ${CEF_HELPER_T if (OS_MACOSX) - ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}") + add_logical_target("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}") foreach(target IN LISTS Targets) # Helper executable target. add_executable(${target} MACOSX_BUNDLE ${WEBBROWSER_HELPER_SOURCES}) - SET_EXECUTABLE_TARGET_PROPERTIES(${target}) + set_executable_target_properties(${target}) # add_cef_logical_target("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}") add_dependencies(${target} libcef_dll_wrapper) target_link_libraries(${target} libcef_dll_wrapper ${CEF_STANDARD_LIBS}) @@ -214,7 +189,7 @@ else() message(STATUS "Setting up WebBrowser CEF helper executable: ${CEF_HELPER_TARGET}") set_openspace_cef_target_out_dir() add_executable(${CEF_HELPER_TARGET} ${WEBBROWSER_HELPER_SOURCES}) - SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_HELPER_TARGET}) + set_executable_target_properties(${CEF_HELPER_TARGET}) add_dependencies(${CEF_HELPER_TARGET} libcef_dll_wrapper) # Logical target used to link the libcef library. add_cef_logical_target("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}") @@ -282,7 +257,7 @@ foreach (i ${CEF_BINARY_FILES}) list(APPEND deps "${CEF_BINARY_DIR}/${i}") endforeach() foreach (j ${CEF_RESOURCE_FILES}) -list(APPEND deps "${CEF_RESOURCE_DIR}/${j}") + list(APPEND deps "${CEF_RESOURCE_DIR}/${j}") endforeach() add_external_library_dependencies("${deps}") @@ -293,17 +268,13 @@ if (UNIX AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) DESTINATION ${CEF_ROOT}/${CMAKE_BUILD_TYPE}/ FILES_MATCHING PATTERN * ) + endif () - if (CEF_HELPER_FILE_REQUIRES_RENAME) - # Rename to "OpenSpace Helper" after build & link in order to prevent GNU Make from - # having to deal with the space in the filename - ADD_CUSTOM_COMMAND( - TARGET ${CEF_HELPER_TARGET} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E rename - "$/${CEF_HELPER_TARGET}" - "$/OpenSpace Helper" - COMMENT "Renaming ${CEF_HELPER_TARGET} to 'OpenSpace Helper'" - ) - endif() -endif () - +# Rename to "OpenSpace Helper" after build & link as spaces in targets are not allowed +# add_custom_command( +# TARGET ${CEF_HELPER_TARGET} POST_BUILD +# COMMAND ${CMAKE_COMMAND} -E rename +# "$/${CEF_HELPER_TARGET}" +# "$/OpenSpace Helper" +# COMMENT "Renaming ${CEF_HELPER_TARGET} to 'OpenSpace Helper'" +# ) diff --git a/modules/webbrowser/openspace Helper.exe.manifest b/modules/webbrowser/OpenSpace_Helper.exe.manifest similarity index 100% rename from modules/webbrowser/openspace Helper.exe.manifest rename to modules/webbrowser/OpenSpace_Helper.exe.manifest diff --git a/modules/webbrowser/cmake/webbrowser_helpers.cmake b/modules/webbrowser/cmake/webbrowser_helpers.cmake index 9e363496b7..a10bf9297b 100644 --- a/modules/webbrowser/cmake/webbrowser_helpers.cmake +++ b/modules/webbrowser/cmake/webbrowser_helpers.cmake @@ -131,7 +131,7 @@ function(run_cef_windows_config CEF_TARGET CEF_ROOT MODULE_PATH) if (USE_SANDBOX) # Logical target used to link the cef_sandbox library. message(STATUS "Using CEF in Sandboxed mode.") - ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}") + add_logical_target("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}") target_link_libraries(${CEF_TARGET} cef_sandbox_lib ${CEF_SANDBOX_STANDARD_LIBS}) endif () @@ -151,7 +151,7 @@ function(run_cef_linux_config CEF_TARGET CEF_ROOT) if (USE_SANDBOX) # Logical target used to link the cef_sandbox library. message(STATUS "Using CEF in Sandboxed mode.") - ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}") + add_logical_target("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}") target_link_libraries(${CEF_TARGET} cef_sandbox_lib ${CEF_SANDBOX_STANDARD_LIBS}) endif () diff --git a/modules/webbrowser/webbrowsermodule.cpp b/modules/webbrowser/webbrowsermodule.cpp index de9c418b95..c584cb3575 100644 --- a/modules/webbrowser/webbrowsermodule.cpp +++ b/modules/webbrowser/webbrowsermodule.cpp @@ -43,12 +43,12 @@ namespace { constexpr const char* _loggerCat = "WebBrowser"; #ifdef _MSC_VER - constexpr const char* SubprocessPath = "OpenSpace Helper.exe"; + constexpr const char* SubprocessPath = "OpenSpace_Helper.exe"; #elif defined(__APPLE__) constexpr const char* SubprocessPath = - "../Frameworks/OpenSpace Helper.app/Contents/MacOS/OpenSpace Helper"; + "../Frameworks/OpenSpace Helper.app/Contents/MacOS/OpenSpace_Helper"; #else - constexpr const char* SubprocessPath = "OpenSpace Helper"; + constexpr const char* SubprocessPath = "OpenSpace_Helper"; #endif constexpr openspace::properties::Property::PropertyInfo From 1a052f3c8ca919a7d1e23dec63d065d69b27064b Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 19 Jul 2022 15:42:31 +0200 Subject: [PATCH 7/9] Update to C++20 --- apps/OpenSpace/ext/sgct | 2 +- ext/ghoul | 2 +- modules/base/dashboard/dashboarditemdate.cpp | 8 ++++++-- modules/base/dashboard/dashboarditemdistance.cpp | 2 +- modules/base/dashboard/dashboarditempropertyvalue.cpp | 6 +++++- .../dashboard/dashboarditemsimulationincrement.cpp | 4 ++-- .../util/kameleonfieldlinehelper.cpp | 4 ++-- .../globebrowsing/src/dashboarditemglobelocation.cpp | 4 ++-- modules/skybrowser/src/wwtdatahandler.cpp | 2 +- modules/space/rendering/renderablesmallbody.cpp | 10 ++++++---- src/engine/configuration.cpp | 1 + src/events/event.cpp | 3 +-- support/cmake/set_openspace_compile_settings.cmake | 2 +- support/coding/codegen | 2 +- 14 files changed, 31 insertions(+), 21 deletions(-) diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index c98f023714..f7991b096c 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit c98f023714d901bc0f94462af1955ad2b014818f +Subproject commit f7991b096c79faaaa4c64837c3d1fa0f3334b466 diff --git a/ext/ghoul b/ext/ghoul index 0dacfd1505..5f02615dab 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 0dacfd150584ebbe05cf4fdd94eb159abcce76cc +Subproject commit 5f02615dabf23e471a54f2108912e6126e367c9a diff --git a/modules/base/dashboard/dashboarditemdate.cpp b/modules/base/dashboard/dashboarditemdate.cpp index d9eed5985d..fa02763c3f 100644 --- a/modules/base/dashboard/dashboarditemdate.cpp +++ b/modules/base/dashboard/dashboarditemdate.cpp @@ -91,7 +91,11 @@ void DashboardItemDate::render(glm::vec2& penPosition) { ); try { - RenderFont(*_font, penPosition, fmt::format(_formatString.value().c_str(), time)); + RenderFont( + *_font, + penPosition, + fmt::format(fmt::runtime(_formatString.value()), time) + ); } catch (const fmt::format_error&) { LERRORC("DashboardItemDate", "Illegal format string"); @@ -103,7 +107,7 @@ glm::vec2 DashboardItemDate::size() const { ZoneScoped std::string_view time = global::timeManager->time().UTC(); - return _font->boundingBox(fmt::format(_formatString.value().c_str(), time)); + return _font->boundingBox(fmt::format(fmt::runtime(_formatString.value()), time)); } } // namespace openspace diff --git a/modules/base/dashboard/dashboarditemdistance.cpp b/modules/base/dashboard/dashboarditemdistance.cpp index 8f738e1b24..6074ace28f 100644 --- a/modules/base/dashboard/dashboarditemdistance.cpp +++ b/modules/base/dashboard/dashboarditemdistance.cpp @@ -358,7 +358,7 @@ void DashboardItemDistance::render(glm::vec2& penPosition) { try { char* end = fmt::format_to( _buffer.data(), - _formatString.value().c_str(), + fmt::runtime(_formatString.value()), sourceInfo.second, destinationInfo.second, dist.first, dist.second ); diff --git a/modules/base/dashboard/dashboarditempropertyvalue.cpp b/modules/base/dashboard/dashboarditempropertyvalue.cpp index ac28a1b5c9..318fafacda 100644 --- a/modules/base/dashboard/dashboarditempropertyvalue.cpp +++ b/modules/base/dashboard/dashboarditempropertyvalue.cpp @@ -96,7 +96,11 @@ void DashboardItemPropertyValue::render(glm::vec2& penPosition) { std::string value; _property->getStringValue(value); - RenderFont(*_font, penPosition, fmt::format(_displayString.value(), value)); + RenderFont( + *_font, + penPosition, + fmt::format(fmt::runtime(_displayString.value()), value) + ); penPosition.y -= _font->height(); } } diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.cpp b/modules/base/dashboard/dashboarditemsimulationincrement.cpp index 0b6ffcb951..1d5b660897 100644 --- a/modules/base/dashboard/dashboarditemsimulationincrement.cpp +++ b/modules/base/dashboard/dashboarditemsimulationincrement.cpp @@ -182,7 +182,7 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { *_font, penPosition, fmt::format( - _transitionFormat.value().c_str(), + fmt::runtime(_transitionFormat.value()), targetDeltaTime.first, targetDeltaTime.second, pauseText, currentDeltaTime.first, currentDeltaTime.second @@ -194,7 +194,7 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { *_font, penPosition, fmt::format( - _regularFormat.value().c_str(), + fmt::runtime(_regularFormat.value()), targetDeltaTime.first, targetDeltaTime.second, pauseText ) ); diff --git a/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp b/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp index de50940813..83c9f08995 100644 --- a/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp +++ b/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp @@ -364,8 +364,8 @@ void prepareStateAndKameleonForExtras(ccmc::Kameleon* kameleon, } if (!success) { LWARNING(fmt::format( - "Failed to load at least one of the magnitude variables: {}, {}, {} " - "& {}. Removing ability to store corresponding magnitude", + "Failed to load at least one of the magnitude variables: {}, {}, {}. " + "Removing ability to store corresponding magnitude", s1, s2, s3 )); extraMagVars.erase( diff --git a/modules/globebrowsing/src/dashboarditemglobelocation.cpp b/modules/globebrowsing/src/dashboarditemglobelocation.cpp index 55a1e34316..a017d51f3d 100644 --- a/modules/globebrowsing/src/dashboarditemglobelocation.cpp +++ b/modules/globebrowsing/src/dashboarditemglobelocation.cpp @@ -217,7 +217,7 @@ void DashboardItemGlobeLocation::render(glm::vec2& penPosition) { { end = fmt::format_to( _buffer.data(), - _formatString, lat, lon, dist.first, dist.second + fmt::runtime(_formatString), lat, lon, dist.first, dist.second ); break; } @@ -244,7 +244,7 @@ void DashboardItemGlobeLocation::render(glm::vec2& penPosition) { end = fmt::format_to( _buffer.data(), - _formatString, + fmt::runtime(_formatString), latDeg, latMin, latSec, isNorth ? "N" : "S", lonDeg, lonMin, lonSec, isEast ? "E" : "W", dist.first, dist.second diff --git a/modules/skybrowser/src/wwtdatahandler.cpp b/modules/skybrowser/src/wwtdatahandler.cpp index f8a1b34b27..f45e68b3d6 100644 --- a/modules/skybrowser/src/wwtdatahandler.cpp +++ b/modules/skybrowser/src/wwtdatahandler.cpp @@ -155,7 +155,7 @@ void parseWtmlsFromDisc(std::vector& xmls, { for (const auto& entry : std::filesystem::directory_iterator(directory)) { tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument(); - std::string path = entry.path().u8string(); + std::string path = entry.path().string(); tinyxml2::XMLError successCode = document->LoadFile(path.c_str()); if (successCode == tinyxml2::XMLError::XML_SUCCESS) { diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index 61e0626a6b..caf3396516 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -248,16 +248,18 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { sequentialLineErrors = 0; } catch (std::invalid_argument&) { - const char* errMsg = "Unable to convert field {} to double value "\ - "(invalid_argument exception). Ignoring line {}/{} of {}."; + constexpr std::string_view errMsg = "Unable to convert field {} to " + "double value (invalid_argument exception). Ignoring line {}/{} " + "of {}."; LINFO(fmt::format( errMsg, fieldCount, csvLine + 1, numberOfLines, filename )); } catch (std::out_of_range&) { - const char* errMsg = "Unable to convert field {} to double value "\ - "(out_of_range exception). Ignoring line {}/{} of {}."; + constexpr std::string_view errMsg = "Unable to convert field {} to " + "double value (out_of_range exception). Ignoring line {}/{} of " + "{}."; LINFO(fmt::format( errMsg, fieldCount, csvLine + 1, numberOfLines, filename diff --git a/src/engine/configuration.cpp b/src/engine/configuration.cpp index a1acf617cc..2bff817f1a 100644 --- a/src/engine/configuration.cpp +++ b/src/engine/configuration.cpp @@ -309,6 +309,7 @@ void parseLuaState(Configuration& configuration) { lua_getglobal(s, "sgctconfiginitializeString"); c.sgctConfigNameInitialized = ghoul::lua::value( s, + 1, ghoul::lua::PopValue::Yes ); diff --git a/src/events/event.cpp b/src/events/event.cpp index 16c1d84432..3be53f7c3f 100644 --- a/src/events/event.cpp +++ b/src/events/event.cpp @@ -538,8 +538,7 @@ void logAllEvents(const Event* e) { log(i, *static_cast(e)); break; default: - LINFO(fmt::format("[{}]: Unknown {}", typeid(e).name())); - break; + throw ghoul::MissingCaseException(); } i++; diff --git a/support/cmake/set_openspace_compile_settings.cmake b/support/cmake/set_openspace_compile_settings.cmake index d3020216a9..fd7f0fde1e 100644 --- a/support/cmake/set_openspace_compile_settings.cmake +++ b/support/cmake/set_openspace_compile_settings.cmake @@ -23,7 +23,7 @@ ########################################################################################## function (set_openspace_compile_settings target) - target_compile_features(${target} PRIVATE cxx_std_17) + target_compile_features(${target} PRIVATE cxx_std_20) set(MSVC_WARNINGS "/MP" # Multi-threading support diff --git a/support/coding/codegen b/support/coding/codegen index ae8d21e9aa..8ee86de09a 160000 --- a/support/coding/codegen +++ b/support/coding/codegen @@ -1 +1 @@ -Subproject commit ae8d21e9aa2903c6b13060239ffbb675e92e6a51 +Subproject commit 8ee86de09a2c902448d37d1a2828130839e2582d From 5ff67059e0a8a7306c1dd45d63f78535fac277fc Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 20 Jul 2022 14:16:11 +0200 Subject: [PATCH 8/9] Update Ghoul submodule --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index 5f02615dab..ceffeb5a97 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 5f02615dabf23e471a54f2108912e6126e367c9a +Subproject commit ceffeb5a97832ee9edaa7b554a7da4265d800434 From 05f1f7ba29be23b2795c86375229792d93e70a65 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 20 Jul 2022 14:45:25 +0200 Subject: [PATCH 9/9] Update Ghoul repository --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index ceffeb5a97..de0a992357 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit ceffeb5a97832ee9edaa7b554a7da4265d800434 +Subproject commit de0a9923579e06c62e03592c86ad7f23d15f49aa