diff --git a/ext/ghoul b/ext/ghoul index 0461bf1f44..9e6f9abe90 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 0461bf1f44b58e04fb21d929b0f385e1120da7b4 +Subproject commit 9e6f9abe90b90157c52c6182b390a619062835b9 diff --git a/include/openspace/engine/globals.h b/include/openspace/engine/globals.h index c7133339bf..523936c496 100644 --- a/include/openspace/engine/globals.h +++ b/include/openspace/engine/globals.h @@ -122,7 +122,8 @@ static VersionChecker& versionChecker = detail::gVersionChecker(); static VirtualPropertyManager& virtualPropertyManager = detail::gVirtualPropertyManager(); static WindowDelegate& windowDelegate = detail::gWindowDelegate(); static configuration::Configuration& configuration = detail::gConfiguration(); -static interaction::InteractionMonitor& interactionMonitor = detail::gInteractionMonitor(); +static interaction::InteractionMonitor& interactionMonitor = + detail::gInteractionMonitor(); static interaction::JoystickInputStates& joystickInputStates = detail::gJoystickInputStates(); static interaction::WebsocketInputStates& websocketInputStates = diff --git a/include/openspace/engine/windowdelegate.h b/include/openspace/engine/windowdelegate.h index 1bef12d181..3d79719021 100644 --- a/include/openspace/engine/windowdelegate.h +++ b/include/openspace/engine/windowdelegate.h @@ -112,9 +112,9 @@ struct WindowDelegate { double (*getHorizFieldOfView)() = []() { return 0.0; }; void (*setHorizFieldOfView)(float hFovDeg) = [](float) { }; - - void* (*getNativeWindowHandle)(size_t windowIndex) = [](size_t) -> void* { - return nullptr; + + void* (*getNativeWindowHandle)(size_t windowIndex) = [](size_t) -> void* { + return nullptr; }; using GLProcAddress = void(*)(void); diff --git a/include/openspace/interaction/navigationhandler.h b/include/openspace/interaction/navigationhandler.h index 66b1e3942b..24d3ef495b 100644 --- a/include/openspace/interaction/navigationhandler.h +++ b/include/openspace/interaction/navigationhandler.h @@ -135,7 +135,7 @@ public: WebsocketCameraStates::AxisInvert::No, WebsocketCameraStates::AxisNormalize shouldNormalize = WebsocketCameraStates::AxisNormalize::No); - + NavigationState navigationState() const; NavigationState navigationState(const SceneGraphNode& referenceFrame) const; diff --git a/include/openspace/interaction/orbitalnavigator.h b/include/openspace/interaction/orbitalnavigator.h index 623cc5fd3f..f2ad409223 100644 --- a/include/openspace/interaction/orbitalnavigator.h +++ b/include/openspace/interaction/orbitalnavigator.h @@ -79,10 +79,10 @@ public: JoystickCameraStates& joystickStates(); const JoystickCameraStates& joystickStates() const; - + WebsocketCameraStates& websocketStates(); const WebsocketCameraStates& websocketStates() const; - + ScriptCameraStates& scriptStates(); const ScriptCameraStates& scriptStates() const; @@ -246,19 +246,22 @@ private: * Translates the horizontal direction. If far from the anchor object, this will * result in an orbital rotation around the object. This function does not affect the * rotation but only the position. - * \returns a position vector adjusted in the horizontal direction. + * + * \return a position vector adjusted in the horizontal direction. */ glm::dvec3 translateHorizontally(double deltaTime, const glm::dvec3& cameraPosition, const glm::dvec3& objectPosition, const glm::dquat& globalCameraRotation, const SurfacePositionHandle& positionHandle) const; /** - * Moves the camera along a vector, camPosToCenterPosDiff, until it reaches the focusLimit. - * The velocity of the zooming depend on distFromCameraToFocus and the final frame - * where the camera stops moving depends on the distance set in the variable focusLimit. - * The bool determines whether to move/fly towards the focus node or away from it. - * \returns a new position of the camera, closer to the focusLimit than the previous - * position. + * Moves the camera along a vector, camPosToCenterPosDiff, until it reaches the + * focusLimit. The velocity of the zooming depend on distFromCameraToFocus and the + * final frame where the camera stops moving depends on the distance set in the + * variable focusLimit. The bool determines whether to move/fly towards the focus node + * or away from it. + * + * \return a new position of the camera, closer to the focusLimit than the previous + * position */ glm::dvec3 moveCameraAlongVector(const glm::dvec3& camPos, double distFromCameraToFocus, const glm::dvec3& camPosToCenterPosDiff, @@ -267,14 +270,16 @@ private: /* * Adds rotation to the camera position so that it follows the rotation of the anchor * node defined by the differential anchorNodeRotationDiff. - * \returns a position updated with the rotation defined by anchorNodeRotationDiff + * + * \return a position updated with the rotation defined by anchorNodeRotationDiff */ glm::dvec3 followAnchorNodeRotation(const glm::dvec3& cameraPosition, const glm::dvec3& objectPosition, const glm::dquat& anchorNodeRotationDiff) const; /** * Updates the global rotation so that it points towards the anchor node. - * \returns a global rotation quaternion defining a rotation towards the anchor node. + * + * \return a global rotation quaternion defining a rotation towards the anchor node */ glm::dquat rotateGlobally(const glm::dquat& globalCameraRotation, const glm::dquat& aimNodeRotationDiff, @@ -290,7 +295,8 @@ private: /** * Rotates the camera around the out vector of the surface. - * \returns a quaternion adjusted to rotate around the out vector of the surface. + * + * \return a quaternion adjusted to rotate around the out vector of the surface */ glm::dquat rotateHorizontally(double deltaTime, const glm::dquat& globalCameraRotation, @@ -298,8 +304,9 @@ private: /** * Push the camera out to the surface of the object. - * \returns a position vector adjusted to be at least minHeightAboveGround meters - * above the actual surface of the object + * + * \return a position vector adjusted to be at least minHeightAboveGround meters + * above the actual surface of the object */ glm::dvec3 pushToSurface(double minHeightAboveGround, const glm::dvec3& cameraPosition, const glm::dvec3& objectPosition, diff --git a/include/openspace/interaction/websocketcamerastates.h b/include/openspace/interaction/websocketcamerastates.h index 0b0bc5c4a9..d7bbd66613 100644 --- a/include/openspace/interaction/websocketcamerastates.h +++ b/include/openspace/interaction/websocketcamerastates.h @@ -106,7 +106,8 @@ private: namespace ghoul { template <> -std::string to_string(const openspace::interaction::WebsocketCameraStates::AxisType& type); +std::string to_string( + const openspace::interaction::WebsocketCameraStates::AxisType& type); template <> openspace::interaction::WebsocketCameraStates::AxisType diff --git a/include/openspace/interaction/websocketinputstate.h b/include/openspace/interaction/websocketinputstate.h index 576e0c4c24..3068e22294 100644 --- a/include/openspace/interaction/websocketinputstate.h +++ b/include/openspace/interaction/websocketinputstate.h @@ -84,9 +84,9 @@ constexpr const int MaxWebsockets = 16; struct WebsocketInputStates : public std::unordered_map { /** * This function adds the contributions of all connected websockets for the provided - * \p axis. After adding each websockets contribution, the result is clamped to [-1,1]. - * If a websocket does not possess a particular axis, it's does not contribute to the - * sum. + * \p axis. After adding each websockets contribution, the result is clamped to + * [-1,1]. If a websocket does not possess a particular axis, it's does not contribute + * to the sum. * * \param axis The numerical axis for which the values are added * \return The summed axis values of all connected websockets diff --git a/include/openspace/rendering/abufferrenderer.h b/include/openspace/rendering/abufferrenderer.h index 275d41c897..3505c13292 100644 --- a/include/openspace/rendering/abufferrenderer.h +++ b/include/openspace/rendering/abufferrenderer.h @@ -80,7 +80,6 @@ public: void setLightness(float lightness) override; void setColorSpace(unsigned int colorspace) override; - void enableBloom(bool enable) override; void enableHistogram(bool enable) override; diff --git a/include/openspace/rendering/framebufferrenderer.h b/include/openspace/rendering/framebufferrenderer.h index 70330f2243..52df76befd 100644 --- a/include/openspace/rendering/framebufferrenderer.h +++ b/include/openspace/rendering/framebufferrenderer.h @@ -71,17 +71,17 @@ public: void updateHDRAndFiltering(); void updateFXAA(); void updateDownscaledVolume(); - + void setResolution(glm::ivec2 res) override; void setHDRExposure(float hdrExposure) override; void setGamma(float gamma) override; void setHue(float hue) override; void setValue(float value) override; void setSaturation(float sat) override; - + void enableFXAA(bool enable) override; void setDisableHDR(bool disable) override; - + void update() override; void performRaycasterTasks(const std::vector& tasks); void performDeferredTasks(const std::vector& tasks); @@ -114,7 +114,7 @@ private: void updateDownscaleTextures(); void updateExitVolumeTextures(); void writeDownscaledVolume(); - + std::map _raycastData; RaycasterProgObjMap _exitPrograms; RaycasterProgObjMap _raycastPrograms; @@ -131,7 +131,7 @@ private: UniformCache(hdrFeedingTexture, blackoutFactor, hdrExposure, gamma, Hue, Saturation, Value) _hdrUniformCache; UniformCache(renderedTexture, inverseScreenSize) _fxaaUniformCache; - UniformCache(downscaledRenderedVolume, downscaledRenderedVolumeDepth) + UniformCache(downscaledRenderedVolume, downscaledRenderedVolumeDepth) _writeDownscaledVolumeUniformCache; GLint _defaultFBO; @@ -158,7 +158,7 @@ private: GLuint hdrFilteringFramebuffer; GLuint hdrFilteringTexture; } _hdrBuffers; - + struct { GLuint fxaaFramebuffer; GLuint fxaaTexture; @@ -176,18 +176,18 @@ private: bool _dirtyDeferredcastData; bool _dirtyRaycastData; bool _dirtyResolution; - + glm::ivec2 _resolution = glm::ivec2(0); int _nAaSamples; bool _enableFXAA = true; bool _disableHDR = false; - + float _hdrExposure = 3.7f; float _gamma = 0.95f; float _hue = 1.f; float _saturation = 1.f; float _value = 1.f; - + ghoul::Dictionary _rendererData; }; diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 5216060d6d..29f12f2c4a 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -211,7 +211,7 @@ private: properties::BoolProperty _disableMasterRendering; properties::FloatProperty _globalBlackOutFactor; - + properties::BoolProperty _enableFXAA; properties::BoolProperty _disableHDRPipeline; @@ -221,13 +221,13 @@ private: properties::FloatProperty _hue; properties::FloatProperty _saturation; properties::FloatProperty _value; - + properties::FloatProperty _horizFieldOfView; properties::Vec3Property _globalRotation; properties::Vec3Property _screenSpaceRotation; properties::Vec3Property _masterRotation; - + uint64_t _frameNumber = 0; unsigned int _latestScreenshotNumber = 0; diff --git a/include/openspace/rendering/volumeraycaster.h b/include/openspace/rendering/volumeraycaster.h index 29c159f442..1534c51ff8 100644 --- a/include/openspace/rendering/volumeraycaster.h +++ b/include/openspace/rendering/volumeraycaster.h @@ -139,7 +139,7 @@ public: private: /** - * Maximum number of integration steps to be executed by the volume integrator. + * Maximum number of integration steps to be executed by the volume integrator. */ int _rayCastMaxSteps = 1000; diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 86bffe0658..ecc42bb9ff 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -198,7 +198,7 @@ private: properties::DoubleProperty _distFromCamToNode; properties::DoubleProperty _screenSizeRadius; properties::FloatProperty _visibilityDistance; - + // This variable is used for the rate-limiting of the screenspace positions (if they // are calculated when _computeScreenSpaceValues is true) std::chrono::high_resolution_clock::time_point _lastScreenSpaceUpdateTime; diff --git a/include/openspace/util/touch.h b/include/openspace/util/touch.h index 3d1e1bf8a4..2f5f1d6deb 100644 --- a/include/openspace/util/touch.h +++ b/include/openspace/util/touch.h @@ -52,7 +52,7 @@ struct TouchInput { double timestamp; // timestamp in seconds from global touch initialization }; -// The TouchInputHolder holds one or many TouchInputs, in order to track the history of +// The TouchInputHolder holds one or many TouchInputs, in order to track the history of // the finger/input device class TouchInputHolder { public: @@ -62,7 +62,7 @@ public: // Fails upon a too similar input as last. // Updates time for the last input if same position. bool tryAddInput(TouchInput input); - + void clearInputs(); // Checks whether or not this Holder actually holds a specific input (based on IDs) diff --git a/modules/base/rendering/renderablelabels.cpp b/modules/base/rendering/renderablelabels.cpp index 2fa6c17ba4..f83752a8c1 100644 --- a/modules/base/rendering/renderablelabels.cpp +++ b/modules/base/rendering/renderablelabels.cpp @@ -48,7 +48,7 @@ namespace { constexpr const char* _loggerCat = "base::RenderableLabels"; - + constexpr const char* MeterUnit = "m"; constexpr const char* KilometerUnit = "Km"; constexpr const char* MegameterUnit = "Mm"; @@ -203,7 +203,7 @@ documentation::Documentation RenderableLabels::Documentation() { LabelColorInfo.identifier, new DoubleVector4Verifier, Optional::Yes, - LabelColorInfo.description, + LabelColorInfo.description, }, { LabelColorInfo.identifier, @@ -392,7 +392,7 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary) addProperty(_labelText); addProperty(_labelOrientationOption); - + _labelColor.setViewOption(properties::Property::ViewOptions::Color); if (dictionary.hasKey(LabelColorInfo.identifier)) { _labelColor = dictionary.value(LabelColorInfo.identifier); @@ -634,7 +634,7 @@ void RenderableLabels::render(const RenderData& data, RendererTasks&) { //} float fadeInVariable = 1.f; - + if (_enableFadingEffect) { float distanceNodeToCamera = glm::distance( data.camera.positionVec3(), @@ -644,7 +644,6 @@ void RenderableLabels::render(const RenderData& data, RendererTasks&) { float eUnit = unit(_fadeEndUnitOption); float startX = _fadeStartDistance * sUnit; float endX = _fadeEndDistance * eUnit; - //fadeInVariable = changedPerlinSmoothStepFunc(distanceNodeToCamera, startX, endX); fadeInVariable = linearSmoothStepFunc( distanceNodeToCamera, startX, @@ -676,7 +675,7 @@ void RenderableLabels::render(const RenderData& data, RendererTasks&) { glm::dvec3 orthoUp = glm::normalize(glm::cross(cameraViewDirectionWorld, orthoRight)); renderLabels(data, modelViewProjectionMatrix, orthoRight, orthoUp, fadeInVariable); - + //if (additiveBlending) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(true); @@ -688,18 +687,18 @@ void RenderableLabels::setLabelText(const std::string & newText) { _labelText = newText; } -void RenderableLabels::renderLabels(const RenderData& data, +void RenderableLabels::renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix, const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, float fadeInVariable) { glm::vec4 textColor = _labelColor; - + textColor.a *= fadeInVariable; textColor.a *= _opacity; ghoul::fontrendering::FontRenderer::ProjectedLabelsInformation labelInfo; - + labelInfo.orthoRight = orthoRight; labelInfo.orthoUp = orthoUp; labelInfo.minSize = static_cast(_labelMinSize); @@ -716,7 +715,7 @@ void RenderableLabels::renderLabels(const RenderData& data, glm::vec3 transformedPos( _transformationMatrix * glm::dvec4(data.modelTransform.translation, 1.0) ); - + ghoul::fontrendering::FontRenderer::defaultProjectionRenderer().render( *_font, transformedPos, @@ -727,11 +726,11 @@ void RenderableLabels::renderLabels(const RenderData& data, } float RenderableLabels::changedPerlinSmoothStepFunc(float x, float startX, - float endX) const + float endX) const { - float f1 = 6.f * powf((x - startX), 5.f) - 15.f * powf((x - startX), 4.f) + + float f1 = 6.f * powf((x - startX), 5.f) - 15.f * powf((x - startX), 4.f) + 10.f * powf((x - startX), 3.f); - float f2 = -6.f * powf((x - endX), 5.f) + 15.f * powf((x - endX), 4.f) - + float f2 = -6.f * powf((x - endX), 5.f) + 15.f * powf((x - endX), 4.f) - 10.f * powf((x - endX), 3.f) + 1.f; float f3 = 1.f; @@ -743,7 +742,7 @@ float RenderableLabels::changedPerlinSmoothStepFunc(float x, float startX, } else if (x >= endX) { return std::clamp(f2, 0.f, 1.f); - } + } } float RenderableLabels::linearSmoothStepFunc(float x, float startX, float endX, @@ -754,7 +753,7 @@ float RenderableLabels::linearSmoothStepFunc(float x, float startX, float endX, float f1 = sdiv * (x - startX) + 1.f; float f2 = ediv * (x - endX) + 1.f; float f3 = 1.f; - + if (x <= startX) { return std::clamp(f1, 0.f, 1.f); } diff --git a/modules/base/rendering/renderablelabels.h b/modules/base/rendering/renderablelabels.h index c35d52d451..7d0466b9d0 100644 --- a/modules/base/rendering/renderablelabels.h +++ b/modules/base/rendering/renderablelabels.h @@ -100,7 +100,7 @@ private: const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, float fadeInVariable); float changedPerlinSmoothStepFunc(float x, float startX, float endX) const; - + float linearSmoothStepFunc(float x, float startX, float endX, float sUnit, float eUnit) const; diff --git a/modules/base/rendering/renderablenodeline.cpp b/modules/base/rendering/renderablenodeline.cpp index 4dc4291a55..fdf2acf398 100644 --- a/modules/base/rendering/renderablenodeline.cpp +++ b/modules/base/rendering/renderablenodeline.cpp @@ -146,7 +146,9 @@ RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary) _lineColor = dictionary.value(LineColorInfo.identifier); } if (dictionary.hasKey(LineWidthInfo.identifier)) { - _lineWidth = static_cast(dictionary.value(LineWidthInfo.identifier)); + _lineWidth = static_cast( + dictionary.value(LineWidthInfo.identifier) + ); } _start.onChange([&]() { validateNodes(); }); @@ -264,7 +266,7 @@ void RenderableNodeLine::updateVertexData() { void RenderableNodeLine::render(const RenderData& data, RendererTasks&) { updateVertexData(); - + _program->activate(); glm::dmat4 anchorTranslation(1.0); @@ -316,7 +318,7 @@ void RenderableNodeLine::render(const RenderData& data, RendererTasks&) { // Bind and draw bindGL(); glDrawArrays(GL_LINES, 0, 2); - + // Restore GL State unbindGL(); _program->deactivate(); diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index b6fa66ff23..8ad12a9d93 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -344,7 +344,7 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { } auto render = [renderLines, renderPoints, p = _programObject, &data, - &modelTransform, pointSize = _appearance.pointSize.value(), + &modelTransform, pointSize = _appearance.pointSize.value(), c = _uniformCache, lw = _appearance.lineWidth] (RenderInformation& info, int nVertices, int offset) { @@ -366,14 +366,13 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { p->setUniform(c.nVertices, nVertices); - #ifndef __APPLE__ glm::ivec2 resolution = global::renderEngine.renderingResolution(); p->setUniform(c.resolution, resolution); p->setUniform(c.lineWidth, ceil((2.f * 1.f + lw) * std::sqrt(2.f))); #endif - + if (renderPoints) { // The stride parameter determines the distance between larger points and // smaller ones @@ -444,7 +443,7 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { ); glm::dvec3 trailPosWorld = glm::dvec3( - modelTransform * _primaryRenderInformation._localTransform * + modelTransform * _primaryRenderInformation._localTransform * glm::dvec4(0.0, 0.0, 0.0, 1.0) ); const double distance = glm::distance( diff --git a/modules/cefwebgui/cefwebguimodule.cpp b/modules/cefwebgui/cefwebguimodule.cpp index 2d5b7c520d..839e5182c5 100644 --- a/modules/cefwebgui/cefwebguimodule.cpp +++ b/modules/cefwebgui/cefwebguimodule.cpp @@ -225,9 +225,9 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) if (isGuiWindow && isMaster && _instance) { if (global::windowDelegate.windowHasResized() || _instance->_shouldReshape) { + glm::ivec2 csws = global::windowDelegate.currentSubwindowSize(); _instance->reshape(static_cast( - static_cast(global::windowDelegate.currentSubwindowSize()) * - global::windowDelegate.dpiScaling() + static_cast(csws) * global::windowDelegate.dpiScaling() )); _instance->_shouldReshape = false; } diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index 688d518611..2e5612e913 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -424,7 +424,10 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di , _drawLabels(DrawLabelInfo, false) , _pixelSizeControl(PixelSizeControlInfo, false) , _colorOption(ColorOptionInfo, properties::OptionProperty::DisplayType::Dropdown) - , _datavarSizeOption(SizeOptionInfo, properties::OptionProperty::DisplayType::Dropdown) + , _datavarSizeOption( + SizeOptionInfo, + properties::OptionProperty::DisplayType::Dropdown + ) , _fadeInDistance( FadeInDistancesInfo, glm::vec2(0.f), @@ -548,7 +551,7 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di ); } } - + if (dictionary.hasKey(ExactColorMapInfo.identifier)) { _isColorMapExact = dictionary.value(ExactColorMapInfo.identifier); } @@ -583,12 +586,12 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di _datavarSizeOption.onChange([&]() { _dataIsDirty = true; - _datavarSizeOptionString = _optionConversionSizeMap[_datavarSizeOption.value()]; - }); + _datavarSizeOptionString = _optionConversionSizeMap[_datavarSizeOption]; + }); addProperty(_datavarSizeOption); _hasDatavarSize = true; - } + } if (dictionary.hasKey(PolygonSidesInfo.identifier)) { _polygonSides = static_cast( @@ -673,13 +676,11 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di addProperty(_correctionSizeFactor); } - if (dictionary.hasKey(PixelSizeControlInfo.identifier)) { _pixelSizeControl = dictionary.value(PixelSizeControlInfo.identifier); addProperty(_pixelSizeControl); } - } bool RenderableBillboardsCloud::isReady() const { @@ -1086,7 +1087,7 @@ void RenderableBillboardsCloud::update(const UpdateData&) { sizeof(float) * 9, reinterpret_cast(sizeof(float) * 8) ); - } + } else if (_hasColorMapFile) { glEnableVertexAttribArray(positionAttrib); glVertexAttribPointer( @@ -1607,10 +1608,11 @@ void RenderableBillboardsCloud::createDataSlice() { } // what datavar in use for the index color - int colorMapInUse = _hasColorMapFile ? _variableDataPositionMap[_colorOptionString] : 0; - + int colorMapInUse = + _hasColorMapFile ? _variableDataPositionMap[_colorOptionString] : 0; + // what datavar in use for the size scaling (if present) - int sizeScalingInUse = _hasDatavarSize ? + int sizeScalingInUse = _hasDatavarSize ? _variableDataPositionMap[_datavarSizeOptionString] : -1; auto addDatavarSizeScalling = [&](size_t i, int datavarInUse) { @@ -1625,7 +1627,7 @@ void RenderableBillboardsCloud::createDataSlice() { float minColorIdx = std::numeric_limits::max(); float maxColorIdx = std::numeric_limits::min(); - + for (size_t i = 0; i < _fullData.size(); i += _nValuesPerAstronomicalObject) { float colorIdx = _fullData[i + 3 + colorMapInUse]; maxColorIdx = colorIdx >= maxColorIdx ? colorIdx : maxColorIdx; @@ -1671,7 +1673,7 @@ void RenderableBillboardsCloud::createDataSlice() { } else { float ncmap = static_cast(_colorMapData.size()); - float normalization = ((cmax != cmin) && (ncmap > 2)) ? + float normalization = ((cmax != cmin) && (ncmap > 2)) ? (ncmap - 2) / (cmax - cmin) : 0; colorIndex = (variableColor - cmin) * normalization + 1; colorIndex = colorIndex < 0 ? 0 : colorIndex; diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.h b/modules/digitaluniverse/rendering/renderablebillboardscloud.h index 15d4d241e6..7953806824 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.h +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.h @@ -144,7 +144,7 @@ private: correctionSizeFactor, color, alphaValue, scaleFactor, up, right, fadeInValue, screenSize, spriteTexture, hasColormap, enabledRectSizeControl, hasDvarScaling ) _uniformCache; - + std::shared_ptr _font; std::string _speckFile; diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index 9023fe154d..c71403dc76 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -149,7 +149,10 @@ namespace { return; } - fileStream.write(reinterpret_cast(&CurrentCacheVersion), sizeof(int8_t)); + fileStream.write( + reinterpret_cast(&CurrentCacheVersion), + sizeof(int8_t) + ); fileStream.write(reinterpret_cast(&nPoints), sizeof(int64_t)); fileStream.write(reinterpret_cast(&pointsRatio), sizeof(float)); uint64_t nPositions = static_cast(positions.size()); @@ -291,7 +294,7 @@ RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary) _downScaleVolumeRendering.setVisibility(properties::Property::Visibility::Developer); if (volumeDictionary.hasKey(DownscaleVolumeRenderingInfo.identifier)) { - _downScaleVolumeRendering = + _downScaleVolumeRendering = volumeDictionary.value(DownscaleVolumeRenderingInfo.identifier); } @@ -331,7 +334,7 @@ void RenderableGalaxy::initializeGL() { _aspect = static_cast(_volumeDimensions); _aspect /= std::max(std::max(_aspect.x, _aspect.y), _aspect.z); - // The volume + // The volume volume::RawVolumeReader> reader( _volumeFilename, _volumeDimensions @@ -657,7 +660,7 @@ void RenderableGalaxy::renderPoints(const RenderData& data) { glm::dmat4(1.0), glm::pi(), glm::dvec3(1.0, 0.0, 0.0)) * - glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) * + glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) * glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0) ); @@ -737,7 +740,7 @@ void RenderableGalaxy::renderBillboards(const RenderData& data) { glm::dmat4(1.0), glm::pi(), glm::dvec3(1.0, 0.0, 0.0)) * - glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) * + glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) * glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0) ); diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index ce70591800..b3bfcd144d 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -697,7 +697,7 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) _ringsComponent.initialize(); addPropertySubOwner(_ringsComponent); _hasRings = true; - + ghoul::Dictionary ringsDic; dictionary.getValue("Rings", ringsDic); } @@ -799,7 +799,7 @@ void RenderableGlobe::render(const RenderData& data, RendererTasks& rendererTask if (_hasRings && _ringsComponent.isEnabled()) { _ringsComponent.draw(lightRenderData, RingsComponent::GeometryOnly); } - + glEnable(GL_BLEND); _shadowComponent.setViewDepthMap(false); @@ -968,7 +968,7 @@ const glm::dmat4& RenderableGlobe::modelTransform() const { // Rendering code ////////////////////////////////////////////////////////////////////////////////////////// -void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, +void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, const ShadowComponent::ShadowMapData& shadowData, bool renderGeomOnly) { @@ -986,7 +986,7 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, const float dsf = static_cast( _generalProperties.currentLodScaleFactor * _ellipsoid.minimumRadius() ); - + // We are setting the setIgnoreUniformLocationError as it is not super trivial // and brittle to figure out apriori whether the uniform was optimized away // or not. It should be something long the lines of: @@ -1108,9 +1108,9 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, const bool hasWaterLayer = !_layerManager.layerGroup( layergroupid::GroupID::WaterMasks ).activeLayers().empty(); - + _globalRenderer.program->setUniform("modelViewTransform", modelViewTransform); - + const bool hasHeightLayer = !_layerManager.layerGroup( layergroupid::HeightLayers ).activeLayers().empty(); @@ -1136,7 +1136,7 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, const glm::vec3 directionToSunCameraSpace = glm::vec3(viewTransform * glm::dvec4(directionToSunWorldSpace, 0)); // @TODO (abock, 2020-04-14); This is just a bandaid for issue #1136. The better - // way is to figure out with the uniform is optimized away. I assume that it is + // way is to figure out with the uniform is optimized away. I assume that it is // because the shader doesn't get recompiled when the last layer of the night // or water is disabled; so the shader thinks it has to do the calculation, but // there are actually no layers left @@ -1166,7 +1166,7 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, const glm::vec3 directionToSunCameraSpace = glm::vec3(viewTransform * glm::dvec4(directionToSunWorldSpace, 0)); // @TODO (abock, 2020-04-14); This is just a bandaid for issue #1136. The better - // way is to figure out with the uniform is optimized away. I assume that it is + // way is to figure out with the uniform is optimized away. I assume that it is // because the shader doesn't get recompiled when the last layer of the night // or water is disabled; so the shader thinks it has to do the calculation, but // there are actually no layers left @@ -1346,9 +1346,9 @@ void RenderableGlobe::renderChunkGlobally(const Chunk& chunk, const RenderData& // Shadow Mapping ghoul::opengl::TextureUnit shadowMapUnit; if (_generalProperties.shadowMapping && shadowData.shadowDepthTexture != 0) { - // Adding the model transformation to the final shadow matrix so we have a - // complete transformation from the model coordinates to the clip space of - // the light position. + // Adding the model transformation to the final shadow matrix so we have a + // complete transformation from the model coordinates to the clip space of the + // light position. program.setUniform( "shadowMatrix", shadowData.shadowMatrix * modelTransform() @@ -1362,14 +1362,14 @@ void RenderableGlobe::renderChunkGlobally(const Chunk& chunk, const RenderData& } glEnable(GL_DEPTH_TEST); - + if (!renderGeomOnly) { glEnable(GL_CULL_FACE); glCullFace(GL_BACK); } _grid.drawUsingActiveProgram(); - + for (GPULayerGroup& l : _globalRenderer.gpuLayerGroups) { l.deactivate(); } @@ -1476,9 +1476,9 @@ void RenderableGlobe::renderChunkLocally(const Chunk& chunk, const RenderData& d // Shadow Mapping ghoul::opengl::TextureUnit shadowMapUnit; if (_generalProperties.shadowMapping && shadowData.shadowDepthTexture != 0) { - // Adding the model transformation to the final shadow matrix so we have a - // complete transformation from the model coordinates to the clip space of - // the light position. + // Adding the model transformation to the final shadow matrix so we have a + // complete transformation from the model coordinates to the clip space of the + // light position. program.setUniform( "shadowMatrix", shadowData.shadowMatrix * modelTransform() @@ -1496,7 +1496,7 @@ void RenderableGlobe::renderChunkLocally(const Chunk& chunk, const RenderData& d glEnable(GL_CULL_FACE); glCullFace(GL_BACK); } - + _grid.drawUsingActiveProgram(); for (GPULayerGroup& l : _localRenderer.gpuLayerGroups) { diff --git a/modules/globebrowsing/src/renderableglobe.h b/modules/globebrowsing/src/renderableglobe.h index 48f77d3042..ab4045d893 100644 --- a/modules/globebrowsing/src/renderableglobe.h +++ b/modules/globebrowsing/src/renderableglobe.h @@ -188,7 +188,7 @@ private: */ float getHeight(const glm::dvec3& position) const; - void renderChunks(const RenderData& data, RendererTasks& rendererTask, + void renderChunks(const RenderData& data, RendererTasks& rendererTask, const ShadowComponent::ShadowMapData& shadowData = {}, bool renderGeomOnly = false ); diff --git a/modules/globebrowsing/src/ringscomponent.cpp b/modules/globebrowsing/src/ringscomponent.cpp index 45559754ab..4a45be2517 100644 --- a/modules/globebrowsing/src/ringscomponent.cpp +++ b/modules/globebrowsing/src/ringscomponent.cpp @@ -52,7 +52,7 @@ namespace { constexpr const char* _loggerCat = "RingsComponent"; constexpr const std::array UniformNames = { - "modelViewProjectionMatrix", "textureOffset", "transparency", "_nightFactor", + "modelViewProjectionMatrix", "textureOffset", "transparency", "_nightFactor", "sunPosition", "ringTexture", "shadowMatrix", "shadowMapTexture", "zFightingPercentage" }; @@ -180,7 +180,7 @@ RingsComponent::RingsComponent(const ghoul::Dictionary& dictionary) , _ringsDictionary(dictionary) { using ghoul::filesystem::File; - + if (dictionary.hasKey("Rings")) { // @TODO (abock, 2019-12-16) It would be better to not store the dictionary long // term and rather extract the values directly here. This would require a bit of @@ -188,7 +188,7 @@ RingsComponent::RingsComponent(const ghoul::Dictionary& dictionary) // class-initializer list though dictionary.getValue("Rings", _ringsDictionary); } - + documentation::testSpecificationAndThrow( Documentation(), _ringsDictionary, @@ -310,20 +310,20 @@ void RingsComponent::draw(const RenderData& data, else if (renderPass == GeometryOnly) { _geometryOnlyShader->activate(); } - + const glm::dmat4 modelTransform = glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * glm::dmat4(data.modelTransform.rotation) * glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); - const glm::dmat4 modelViewProjectionTransform = - glm::dmat4(data.camera.projectionMatrix()) * data.camera.combinedViewMatrix() + const glm::dmat4 modelViewProjectionTransform = + glm::dmat4(data.camera.projectionMatrix()) * data.camera.combinedViewMatrix() * modelTransform; ghoul::opengl::TextureUnit ringTextureUnit; if (renderPass == GeometryAndShading) { _shader->setUniform( - _uniformCache.modelViewProjectionMatrix, + _uniformCache.modelViewProjectionMatrix, modelViewProjectionTransform ); _shader->setUniform(_uniformCache.textureOffset, _offset); @@ -336,18 +336,18 @@ void RingsComponent::draw(const RenderData& data, _texture->bind(); _shader->setUniform(_uniformCache.ringTexture, ringTextureUnit); - // Adding the model transformation to the final shadow matrix so we have a - // complete transformation from the model coordinates to the clip space of + // Adding the model transformation to the final shadow matrix so we have a + // complete transformation from the model coordinates to the clip space of // the light position. _shader->setUniform( - _uniformCache.shadowMatrix, + _uniformCache.shadowMatrix, shadowData.shadowMatrix * modelTransform ); ghoul::opengl::TextureUnit shadowMapUnit; shadowMapUnit.activate(); glBindTexture(GL_TEXTURE_2D, shadowData.shadowDepthTexture); - + _shader->setUniform(_uniformCache.shadowMapTexture, shadowMapUnit); } else if (renderPass == GeometryOnly) { @@ -386,8 +386,8 @@ void RingsComponent::update(const UpdateData& data) { if (_geometryOnlyShader->isDirty()) { _geometryOnlyShader->rebuildFromFile(); ghoul::opengl::updateUniformLocations( - *_geometryOnlyShader, - _geomUniformCache, + *_geometryOnlyShader, + _geomUniformCache, GeomUniformNames ); } diff --git a/modules/globebrowsing/src/ringscomponent.h b/modules/globebrowsing/src/ringscomponent.h index c501c4a9de..62980e1bf6 100644 --- a/modules/globebrowsing/src/ringscomponent.h +++ b/modules/globebrowsing/src/ringscomponent.h @@ -54,18 +54,16 @@ public: GeometryOnly, GeometryAndShading }; - + RingsComponent(const ghoul::Dictionary& dictionary); void initialize(); void initializeGL(); void deinitializeGL(); - + bool isReady() const; - void draw( - const RenderData& data, - const RingsComponent::RenderPass renderPass, + void draw(const RenderData& data, const RingsComponent::RenderPass renderPass, const ShadowComponent::ShadowMapData& shadowData = {} ); void update(const UpdateData& data); @@ -90,11 +88,11 @@ private: std::unique_ptr _shader; std::unique_ptr _geometryOnlyShader; - UniformCache(modelViewProjectionMatrix, textureOffset, transparency, nightFactor, + UniformCache(modelViewProjectionMatrix, textureOffset, transparency, nightFactor, sunPosition, ringTexture, shadowMatrix, shadowMapTexture, zFightingPercentage ) _uniformCache; - UniformCache(modelViewProjectionMatrix, textureOffset, ringTexture) - _geomUniformCache; + UniformCache(modelViewProjectionMatrix, textureOffset, ringTexture + ) _geomUniformCache; std::unique_ptr _texture; std::unique_ptr _textureFile; diff --git a/modules/globebrowsing/src/shadowcomponent.cpp b/modules/globebrowsing/src/shadowcomponent.cpp index 3d59598e7b..2ab97a86fc 100644 --- a/modules/globebrowsing/src/shadowcomponent.cpp +++ b/modules/globebrowsing/src/shadowcomponent.cpp @@ -55,7 +55,7 @@ namespace { constexpr const char* _loggerCat = "ShadowComponent"; - + constexpr openspace::properties::Property::PropertyInfo SaveDepthTextureInfo = { "SaveDepthTextureInfo", "Save Depth Texture", @@ -197,7 +197,7 @@ ShadowComponent::ShadowComponent(const ghoul::Dictionary& dictionary) if (_shadowMapDictionary.hasKey(DepthMapSizeInfo.identifier)) { - glm::vec2 depthMapSize = + glm::vec2 depthMapSize = _shadowMapDictionary.value(DepthMapSizeInfo.identifier); _shadowDepthTextureWidth = depthMapSize.x; _shadowDepthTextureHeight = depthMapSize.y; @@ -240,42 +240,42 @@ RenderData ShadowComponent::begin(const RenderData& data) { // =========================================== // Builds light's ModelViewProjectionMatrix: // =========================================== - + glm::dvec3 diffVector = glm::dvec3(_sunPosition) - data.modelTransform.translation; double originalLightDistance = glm::length(diffVector); glm::dvec3 lightDirection = glm::normalize(diffVector); - + // Percentage of the original light source distance (to avoid artifacts) - //double multiplier = originalLightDistance * + //double multiplier = originalLightDistance * // (static_cast(_distanceFraction)/1.0E5); double multiplier = originalLightDistance * (static_cast(_distanceFraction) / 1E17); - + // New light source position - //glm::dvec3 lightPosition = data.modelTransform.translation + + //glm::dvec3 lightPosition = data.modelTransform.translation + // (lightDirection * multiplier); glm::dvec3 lightPosition = data.modelTransform.translation + (diffVector * multiplier); //// Light Position //glm::dvec3 lightPosition = glm::dvec3(_sunPosition); - + //=============== Manually Created Camera Matrix =================== //================================================================== // camera Z glm::dvec3 cameraZ = lightDirection; - + // camera X glm::dvec3 upVector = glm::dvec3(0.0, 1.0, 0.0); - glm::dvec3 cameraX = glm::normalize(glm::cross(upVector, cameraZ)); - + glm::dvec3 cameraX = glm::normalize(glm::cross(upVector, cameraZ)); + // camera Y glm::dvec3 cameraY = glm::cross(cameraZ, cameraX); // init 4x4 matrix glm::dmat4 cameraRotationMatrix(1.0); - + double* matrix = glm::value_ptr(cameraRotationMatrix); matrix[0] = cameraX.x; matrix[4] = cameraX.y; @@ -288,31 +288,31 @@ RenderData ShadowComponent::begin(const RenderData& data) { matrix[10] = cameraZ.z; // set translation part - // We aren't setting the position here because it is set in + // We aren't setting the position here because it is set in // the camera->setPosition() //matrix[12] = -glm::dot(cameraX, lightPosition); //matrix[13] = -glm::dot(cameraY, lightPosition); //matrix[14] = -glm::dot(cameraZ, lightPosition); - + _lightCamera = std::move(std::unique_ptr(new Camera(data.camera))); _lightCamera->setPositionVec3(lightPosition); _lightCamera->setRotation(glm::dquat(glm::inverse(cameraRotationMatrix))); //======================================================================= //======================================================================= - + //============= Light Matrix by Camera Matrices Composition ============= //======================================================================= glm::dmat4 lightProjectionMatrix = glm::dmat4(_lightCamera->projectionMatrix()); - - // The model transformation missing in the final shadow matrix is add when rendering each - // object (using its transformations provided by the RenderData structure) - _shadowData.shadowMatrix = - _toTextureCoordsMatrix * lightProjectionMatrix * + + // The model transformation missing in the final shadow matrix is add when rendering + // each object (using its transformations provided by the RenderData structure) + _shadowData.shadowMatrix = + _toTextureCoordsMatrix * lightProjectionMatrix * _lightCamera->combinedViewMatrix(); - + // Saves current state glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); glGetIntegerv(GL_VIEWPORT, _mViewport); @@ -337,8 +337,7 @@ RenderData ShadowComponent::begin(const RenderData& data) { glEnable(GL_DEPTH_TEST); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - + //glEnable(GL_CULL_FACE); //checkGLError("begin() -- enabled cull face"); //glCullFace(GL_FRONT); @@ -372,7 +371,7 @@ void ShadowComponent::end() { }; glDrawBuffers(3, drawBuffers); glViewport(_mViewport[0], _mViewport[1], _mViewport[2], _mViewport[3]); - + if (_faceCulling) { glEnable(GL_CULL_FACE); glCullFace(_faceToCull); @@ -399,9 +398,9 @@ void ShadowComponent::end() { } glClearColor( - _colorClearValue[0], - _colorClearValue[1], - _colorClearValue[2], + _colorClearValue[0], + _colorClearValue[1], + _colorClearValue[2], _colorClearValue[3] ); glClearDepth(_depthClearValue); @@ -433,14 +432,14 @@ void ShadowComponent::end() { glBindVertexArray(_quadVAO); glDrawArrays(GL_TRIANGLES, 0, 6); - + _renderDMProgram->deactivate(); } } void ShadowComponent::update(const UpdateData&) { _sunPosition = global::renderEngine.scene()->sceneGraphNode("Sun")->worldPosition(); - + glm::ivec2 renderingResolution = global::renderEngine.renderingResolution(); if (_dynamicDepthTextureRes && ((_shadowDepthTextureWidth != renderingResolution.x) || (_shadowDepthTextureHeight != renderingResolution.y))) @@ -454,7 +453,7 @@ void ShadowComponent::update(const UpdateData&) { void ShadowComponent::createDepthTexture() { glGenTextures(1, &_shadowDepthTexture); updateDepthTexture(); - + _shadowData.shadowDepthTexture = _shadowDepthTexture; //_shadowData.positionInLightSpaceTexture = _positionInLightSpaceTexture; } @@ -462,13 +461,13 @@ void ShadowComponent::createDepthTexture() { void ShadowComponent::createShadowFBO() { // Saves current FBO first glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); - + glGenFramebuffers(1, &_shadowFBO); glBindFramebuffer(GL_FRAMEBUFFER, _shadowFBO); glFramebufferTexture( - GL_FRAMEBUFFER, - GL_DEPTH_ATTACHMENT, - _shadowDepthTexture, + GL_FRAMEBUFFER, + GL_DEPTH_ATTACHMENT, + _shadowDepthTexture, 0 ); @@ -478,7 +477,7 @@ void ShadowComponent::createShadowFBO() { // _positionInLightSpaceTexture, // 0 //); - + //GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_NONE, GL_NONE }; GLenum drawBuffers[] = { GL_NONE, GL_NONE, GL_NONE }; glDrawBuffers(3, drawBuffers); @@ -561,7 +560,7 @@ void ShadowComponent::saveDepthBuffer() { if (ppmFile.is_open()) { ppmFile << "P3" << std::endl; - ppmFile << _shadowDepthTextureWidth << " " << _shadowDepthTextureHeight + ppmFile << _shadowDepthTextureWidth << " " << _shadowDepthTextureHeight << std::endl; ppmFile << "255" << std::endl; @@ -601,7 +600,7 @@ void ShadowComponent::saveDepthBuffer() { if (ppmFile.is_open()) { ppmFile << "P3" << std::endl; - ppmFile << _shadowDepthTextureWidth << " " << _shadowDepthTextureHeight + ppmFile << _shadowDepthTextureWidth << " " << _shadowDepthTextureHeight << std::endl; ppmFile << "255" << std::endl; diff --git a/modules/globebrowsing/src/shadowcomponent.h b/modules/globebrowsing/src/shadowcomponent.h index 180b9aeccd..3c39293697 100644 --- a/modules/globebrowsing/src/shadowcomponent.h +++ b/modules/globebrowsing/src/shadowcomponent.h @@ -70,7 +70,7 @@ public: RenderData begin(const RenderData& data); void end(); void update(const UpdateData& data); - + static documentation::Documentation Documentation(); bool isEnabled() const; @@ -101,13 +101,13 @@ private: properties::TriggerProperty _saveDepthTexture; properties::IntProperty _distanceFraction; properties::BoolProperty _enabled; - + ghoul::Dictionary _shadowMapDictionary; - + int _shadowDepthTextureHeight = 4096; int _shadowDepthTextureWidth = 4096; bool _dynamicDepthTextureRes = true; - + GLuint _shadowDepthTexture = 0; GLuint _positionInLightSpaceTexture = 0; GLuint _shadowFBO = 0; diff --git a/modules/globebrowsing/src/timequantizer.h b/modules/globebrowsing/src/timequantizer.h index f8907e3359..19decc6fa9 100644 --- a/modules/globebrowsing/src/timequantizer.h +++ b/modules/globebrowsing/src/timequantizer.h @@ -65,7 +65,7 @@ public: * * \param checkTime An ISO8601 date/time string to clamp if falls outside of range * - * \returns clamped value of input parameter, will be equal to the start value if + * \returns clamped value of input parameter, will be equal to the start value if * less than start, equal to end if greater than end, or equal to input * parameter if falls in-between */ @@ -227,7 +227,7 @@ public: /* * Increment operation for the date/time - * + * * \param value integer value for number of units in an operation * \param unit single char that specifies the unit of increment. Allowable units are: * (y)ear, (M)onth, (d)ay, (h)our, (m)inute, (s)econd @@ -254,7 +254,7 @@ public: * \returns The number of decrements that were performed in order to get as close as * possible to the target, where each decrement is defined by the value & * unit (and approximated but not fixed by the resolution param) - */ + */ int decrement(int value, char unit, double error, double resolution); /* diff --git a/modules/server/servermodule.cpp b/modules/server/servermodule.cpp index 95abd7c4ab..47974dfe50 100644 --- a/modules/server/servermodule.cpp +++ b/modules/server/servermodule.cpp @@ -87,7 +87,7 @@ void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) { for (const std::string& key : interfaces.keys()) { ghoul::Dictionary interfaceDictionary = interfaces.value(key); - // @TODO (abock, 2019-09-17); This is a hack to make the parsing of the + // @TODO (abock, 2019-09-17); This is a hack to make the parsing of the // openspace.cfg file not corrupt the heap and cause a potential crash at shutdown // (see ticket https://github.com/OpenSpace/OpenSpace/issues/982) // The AllowAddresses are specified externally and are injected here diff --git a/modules/server/src/topics/flightcontrollertopic.cpp b/modules/server/src/topics/flightcontrollertopic.cpp index aedb5f3367..963a2b95bc 100644 --- a/modules/server/src/topics/flightcontrollertopic.cpp +++ b/modules/server/src/topics/flightcontrollertopic.cpp @@ -89,7 +89,8 @@ namespace { // Friction JSON Keys constexpr const char* FrictionEngagedKey = "engaged"; - constexpr const char* FrictionPropertyUri = "NavigationHandler.OrbitalNavigator.Friction"; + constexpr const char* FrictionPropertyUri = + "NavigationHandler.OrbitalNavigator.Friction"; constexpr const char* FrictionRotationKey = "rotation"; constexpr const char* FrictionZoomKey = "zoom"; constexpr const char* FrictionRollKey = "roll"; @@ -179,7 +180,9 @@ bool FlightControllerTopic::isDone() const { void FlightControllerTopic::handleJson(const nlohmann::json& json) { auto it = CommandMap.find(json[TypeKey]); if (it == CommandMap.end()) { - LWARNING(fmt::format("Poorly formatted JSON command: no '{}' in payload", TypeKey)); + LWARNING( + fmt::format("Poorly formatted JSON command: no '{}' in payload", TypeKey) + ); return; } @@ -290,10 +293,12 @@ void FlightControllerTopic::updateView(const nlohmann::json& json) const { void FlightControllerTopic::changeFocus(const nlohmann::json& json) const { if (json[FocusKey].find(SceneNodeName) == json[FocusKey].end()) { const std::string j = json; - LWARNING(fmt::format("Could not find {} key in JSON. JSON was:\n{}", FocusKey, j)); + LWARNING( + fmt::format("Could not find {} key in JSON. JSON was:\n{}", FocusKey, j) + ); return; } - + const std::string focus = json[FocusKey][SceneNodeName]; const SceneGraphNode* node = global::renderEngine.scene()->sceneGraphNode(focus); if (node) { @@ -308,7 +313,9 @@ void FlightControllerTopic::changeFocus(const nlohmann::json& json) const { void FlightControllerTopic::setRenderableEnabled(const nlohmann::json& json) const { if (json[RenderableKey].find(SceneNodeName) == json[RenderableKey].end()) { const std::string j = json; - LWARNING(fmt::format("Could not find {} key in JSON. JSON was:\n{}", FocusKey, j)); + LWARNING( + fmt::format("Could not find {} key in JSON. JSON was:\n{}", FocusKey, j) + ); return; } @@ -426,7 +433,7 @@ void FlightControllerTopic::processInputState(const nlohmann::json& json) { _inputState.axes[std::distance(AxisIndexMap.begin(), mapIt)] = float(it.value()); } } - + void FlightControllerTopic::processLua(const nlohmann::json &json) { const std::string script = json[LuaScript]; global::scriptEngine.queueScript( @@ -434,5 +441,5 @@ void FlightControllerTopic::processLua(const nlohmann::json &json) { openspace::scripting::ScriptEngine::RemoteScripting::Yes ); } - + } // namespace openspace diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index c2225d1f8d..9d45571345 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include namespace { constexpr const char* ProgramName = "OrbitalKepler"; @@ -434,7 +434,7 @@ void RenderableOrbitalKepler::initializeGL() { ); } ); - + _uniformCache.modelView = _programObject->uniformLocation("modelViewTransform"); _uniformCache.projection = _programObject->uniformLocation("projectionTransform"); _uniformCache.lineFade = _programObject->uniformLocation("lineFade"); @@ -444,7 +444,7 @@ void RenderableOrbitalKepler::initializeGL() { updateBuffers(); } - + void RenderableOrbitalKepler::deinitializeGL() { glDeleteBuffers(1, &_vertexBuffer); glDeleteVertexArrays(1, &_vertexArray); @@ -535,7 +535,7 @@ void RenderableOrbitalKepler::updateBuffers() { ); for (size_t j = 0 ; j < (_segmentSize[orbitIdx] + 1); ++j) { - double timeOffset = orbit.period * + double timeOffset = orbit.period * static_cast(j)/ static_cast(_segmentSize[orbitIdx]); glm::dvec3 position = _keplerTranslator.position({ @@ -563,7 +563,7 @@ void RenderableOrbitalKepler::updateBuffers() { GL_ARRAY_BUFFER, _vertexBufferData.size() * sizeof(TrailVBOLayout), _vertexBufferData.data(), - GL_STATIC_DRAW + GL_STATIC_DRAW ); glEnableVertexAttribArray(0); @@ -581,5 +581,5 @@ void RenderableOrbitalKepler::updateBuffers() { glBindVertexArray(0); } - + } // namespace opensapce diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index ab0279a99e..420b93b5b6 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include namespace { constexpr const char* ProgramName = "RenderableSatellites"; @@ -121,9 +121,8 @@ documentation::Documentation RenderableSatellites::Documentation() { RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary) : RenderableOrbitalKepler(dictionary) -{ -} - +{} + void RenderableSatellites::readDataFile(const std::string& filename) { if (!FileSys.fileExists(filename)) { throw ghoul::RuntimeError(fmt::format( @@ -137,8 +136,11 @@ void RenderableSatellites::readDataFile(const std::string& filename) { file.exceptions(std::ifstream::failbit | std::ifstream::badbit); file.open(filename); - std::streamoff numberOfLines = std::count(std::istreambuf_iterator(file), - std::istreambuf_iterator(), '\n' ); + std::streamoff numberOfLines = std::count( + std::istreambuf_iterator(file), + std::istreambuf_iterator(), + '\n' + ); file.seekg(std::ios_base::beg); // reset iterator to beginning of file _numObjects = numberOfLines / nLineEntriesPerSatellite; diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index 07666e32c2..8ba63ed855 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include namespace { constexpr const char* ProgramName = "RenderableSmallBody"; @@ -140,8 +140,8 @@ RenderableSmallBody::RenderableSmallBody(const ghoul::Dictionary& dictionary) { _upperLimitCallbackHandle = _upperLimit.onChange(_reinitializeTrailBuffers); addProperty(_upperLimit); -} - +} + void RenderableSmallBody::readDataFile(const std::string& filename) { if (!FileSys.fileExists(filename)) { throw ghoul::RuntimeError(fmt::format( @@ -154,7 +154,7 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { file.open(filename); std::streamoff numberOfLines = std::count( - std::istreambuf_iterator(file), + std::istreambuf_iterator(file), std::istreambuf_iterator(), '\n' ); diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index 377f8c77bd..2778673233 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -1026,8 +1026,6 @@ void RenderableStars::render(const RenderData& data, RendererTasks&) { _program->setUniform(_uniformCache.alphaValue, _alphaValue); } - - ghoul::opengl::TextureUnit psfUnit; psfUnit.activate(); @@ -1479,7 +1477,7 @@ void RenderableStars::readSpeckFile() { for (int i = 0; i < _nValuesPerStar; ++i) { str >> values[i]; } - + bool nullArray = true; for (float v : values) { if (v != 0.0) { diff --git a/modules/space/tasks/generatedebrisvolumetask.cpp b/modules/space/tasks/generatedebrisvolumetask.cpp index d7bf763a45..3946f9ccc2 100644 --- a/modules/space/tasks/generatedebrisvolumetask.cpp +++ b/modules/space/tasks/generatedebrisvolumetask.cpp @@ -44,7 +44,6 @@ namespace { - constexpr const char* ProgramName = "RenderableSatellites"; constexpr const char* _loggerCat = "SpaceDebris"; @@ -62,13 +61,11 @@ namespace { // constexpr const char* KeyInputPath3 = "InputPath3"; // constexpr const char* KeyInputPath4 = "InputPath4"; - constexpr const char* KeyLowerDomainBound = "LowerDomainBound"; - constexpr const char* KeyUpperDomainBound = "UpperDomainBound"; + constexpr const char* KeyUpperDomainBound = "UpperDomainBound"; +} // namespace -} - -namespace openspace{ +namespace openspace { namespace volume { // The list of leap years only goes until 2056 as we need to touch this file then // again anyway ;) @@ -263,14 +260,14 @@ double epochFromSubstring(const std::string& epochString) { std::vector readTLEFile(const std::string& filename){ ghoul_assert(FileSys.fileExists(filename), "The filename must exist"); - + std::vector data; std::ifstream file; file.exceptions(std::ifstream::failbit | std::ifstream::badbit); file.open(filename); - int numberOfLines = std::count(std::istreambuf_iterator(file), + int numberOfLines = std::count(std::istreambuf_iterator(file), std::istreambuf_iterator(), '\n' ); file.seekg(std::ios_base::beg); // reset iterator to beginning of file @@ -281,7 +278,7 @@ std::vector readTLEFile(const std::string& filename){ for (int i = 0; i < numberOfObjects; i++) { std::getline(file, line); // get rid of title - + KeplerParameters keplerElements; std::getline(file, line); @@ -379,21 +376,19 @@ std::vector readTLEFile(const std::string& filename){ glm::dvec3 cartesianToSphericalCoord(glm::dvec3 position){ glm::dvec3 sphericalPosition; - //sphericalPosition.x = pow(pow(position.x,2)+pow(position.y,2)+pow(position.z,2) , 0.5); //abs(position.x + position.y + position.z); // r - //sphericalPosition.y = atan(position.y/position.x); // theta - //sphericalPosition.z = atan(pow(pow(position.x,2)+pow(position.y,2),0.5)/position.z); // abs(position.x + position.y) // p - - sphericalPosition.x = sqrt(pow(position.x,2)+pow(position.y,2)+pow(position.z,2)); // r [0, MaxApogee] - sphericalPosition.y = acos(position.z/sphericalPosition.x); // theta [0, pi] - sphericalPosition.z = atan2(position.y,position.x); // phi [-pi, pi] -> [0, 2*pi] - // if(sphericalPosition.y < 0) - sphericalPosition.z += 3.14159265358979323846264338327950288; + // r [0, MaxApogee] + sphericalPosition.x = sqrt(pow(position.x,2)+pow(position.y,2)+pow(position.z,2)); + // theta [0, pi] + sphericalPosition.y = acos(position.z/sphericalPosition.x); + // phi [-pi, pi] -> [0, 2*pi] + sphericalPosition.z = atan2(position.y,position.x); + sphericalPosition.z += glm::pi(); return sphericalPosition; } - -std::vector getPositionBuffer(std::vector tleData, double timeInSeconds, std::string gridType) { - +std::vector getPositionBuffer(std::vector tleData, + double timeInSeconds, std::string gridType) +{ float minTheta = 0.0; float minPhi = 0.0; float maxTheta = 0.0; @@ -437,14 +432,14 @@ std::vector getPositionBuffer(std::vector tleData, } // LINFO(fmt::format("pos: {} ", sphPos)); positionBuffer.push_back(sphPos); - + } else { positionBuffer.push_back(position); } - - + + } LINFO(fmt::format("max theta: {} ", maxTheta)); LINFO(fmt::format("max phi: {} ", maxPhi)); @@ -456,7 +451,7 @@ std::vector getPositionBuffer(std::vector tleData, // std::vector generatePositions(int numberOfPositions) { // std::vector positions; - + // float radius = 700000; // meter // float degreeStep = 360 / numberOfPositions; @@ -483,7 +478,7 @@ float getMaxApogee(std::vector inData){ double ah = dataElement.semiMajorAxis * (1 + dataElement.eccentricity); if (ah > maxApogee) maxApogee = ah; - } + } return static_cast(maxApogee*1000); // * 1000 for meters } @@ -501,7 +496,7 @@ int getIndexFromPosition(glm::dvec3 position, glm::uvec3 dim, float maxApogee, s ,static_cast(newPosition.y * dim.y / (2 * (maxApogee + epsilon))) ,static_cast(newPosition.z * dim.z / (2 * (maxApogee + epsilon)))); - + return coordinateIndex.z * (dim.x * dim.y) + coordinateIndex.y * dim.x + coordinateIndex.x; } else if(gridType == "Spherical"){ @@ -517,7 +512,7 @@ int getIndexFromPosition(glm::dvec3 position, glm::uvec3 dim, float maxApogee, s ,static_cast(position.y * dim.y / (3.14159265358979323846264338327950288)) ,static_cast(position.z * dim.z / (2*3.14159265358979323846264338327950288))); - + // LINFO(fmt::format("index coords: {} ", coordinateIndex)); // LINFO(fmt::format("index dim: {} ", dim)); // LINFO(fmt::format("index va: {} ", coordinateIndex.y * (dim.x * dim.y) + coordinateIndex.z * dim.x + coordinateIndex.x)); @@ -529,7 +524,7 @@ int getIndexFromPosition(glm::dvec3 position, glm::uvec3 dim, float maxApogee, s } double getVoxelVolume(int index, RawVolume& raw, glm::uvec3 dim, float maxApogee){ - // get coords from index + // get coords from index glm::uvec3 coords = raw.indexToCoords(index); double rMax = maxApogee / dim.x; @@ -585,10 +580,9 @@ GenerateDebrisVolumeTask::GenerateDebrisVolumeTask(const ghoul::Dictionary& dict _gridType = dictionary.value(KeyGridType); _lowerDomainBound = dictionary.value(KeyLowerDomainBound); _upperDomainBound = dictionary.value(KeyUpperDomainBound); - + _TLEDataVector = readTLEFile(_inputPath); _maxApogee = getMaxApogee(_TLEDataVector); - } std::string GenerateDebrisVolumeTask::description() { @@ -603,7 +597,7 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal SpiceManager::ref().unloadKernel(kernel); }; - ////////// + ////////// //1. read TLE-data and position of debris elements. // std::vectorTLEDataVector = readTLEFile(_inputPath); // std::vectorTLEDataVector1 = readTLEFile(_inputPath1); @@ -620,7 +614,7 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal // ----- or ----- if only one // _TLEDataVector = readTLEFile(_inputPath); - + ////////// VolumeGridType GridType = VolumeGridType::Cartesian; if(_gridType == "Spherical"){ @@ -637,7 +631,7 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal /** SEQUENCE * 1. handle timeStep * 1.1 either ignore last timeperiod from the latest whole timestep to _endTime - * 1.2 or extend endTime to be equal to next full timestep + * 1.2 or extend endTime to be equal to next full timestep * 2. loop to create a rawVolume for each timestep. */ @@ -659,7 +653,7 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal // 2. for(int i=0 ; i<=numberOfIterations ; ++i) { - std::vector startPositionBuffer = getPositionBuffer(_TLEDataVector, startTimeInSeconds+(i*timeStep), _gridType); //+(i*timeStep) + std::vector startPositionBuffer = getPositionBuffer(_TLEDataVector, startTimeInSeconds+(i*timeStep), _gridType); //+(i*timeStep) //LINFO(fmt::format("pos: {} ", startPositionBuffer[4])); double *densityArrayp = new double[size](); @@ -678,16 +672,16 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal densityArrayp = mapDensityToVoxels(densityArrayp, testBuffer, _dimensions, _maxApogee, _gridType); */ // create object rawVolume - + //glm::vec3 domainSize = _upperDomainBound - _lowerDomainBound; - + // TODO: Create a forEachSatallite and set(cell, value) to combine mapDensityToVoxel // and forEachVoxel for less time complexity. rawVolume.forEachVoxel([&](glm::uvec3 cell, float) { // glm::vec3 coord = _lowerDomainBound + // glm::vec3(cell) / glm::vec3(_dimensions) * domainSize; float value = getDensityAt(cell, densityArrayp, rawVolume); // (coord) - + rawVolume.set(cell, value); minVal = std::min(minVal, value); @@ -705,22 +699,22 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal size_t lastIndex = _rawVolumeOutputPath.find_last_of("."); std::string rawOutputName = _rawVolumeOutputPath.substr(0, lastIndex); - rawOutputName += std::to_string(i) + ".rawvolume"; + rawOutputName += std::to_string(i) + ".rawvolume"; lastIndex = _dictionaryOutputPath.find_last_of("."); std::string dictionaryOutputName = _dictionaryOutputPath.substr(0, lastIndex); - dictionaryOutputName += std::to_string(i) + ".dictionary"; + dictionaryOutputName += std::to_string(i) + ".dictionary"; ghoul::filesystem::File file(rawOutputName); const std::string directory = file.directoryName(); if (!FileSys.directoryExists(directory)) { FileSys.createDirectory(directory, ghoul::filesystem::FileSystem::Recursive::Yes); } - + volume::RawVolumeWriter writer(rawOutputName); writer.write(rawVolumeQueue.front()); rawVolumeQueue.pop(); - + RawVolumeMetadata metadata; // alternatively metadata.hasTime = false; metadata.time = Time::convertTime(_startTime)+(i*timeStep); @@ -745,7 +739,6 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal std::fstream f(dictionaryOutputName, std::ios::out); f << "return " << metadataString; f.close(); - } } diff --git a/modules/space/tasks/generatedebrisvolumetask.h b/modules/space/tasks/generatedebrisvolumetask.h index 887f75be60..1a0225b4f2 100644 --- a/modules/space/tasks/generatedebrisvolumetask.h +++ b/modules/space/tasks/generatedebrisvolumetask.h @@ -59,7 +59,7 @@ private: std::string _timeStep; std::string _endTime; std::string _inputPath; - + glm::uvec3 _dimensions; glm::vec3 _lowerDomainBound; glm::vec3 _upperDomainBound; diff --git a/modules/space/translation/keplertranslation.h b/modules/space/translation/keplertranslation.h index 83c8fd6233..0370822e9e 100644 --- a/modules/space/translation/keplertranslation.h +++ b/modules/space/translation/keplertranslation.h @@ -78,7 +78,7 @@ public: * be passed to the constructor */ static documentation::Documentation Documentation(); - + /** * Sets the internal values for the Keplerian elements and the epoch as a string of * the form YYYY MM DD HH:mm:ss. @@ -120,7 +120,7 @@ public: void setKeplerElements(double eccentricity, double semiMajorAxis, double inclination, double ascendingNode, double argumentOfPeriapsis, double meanAnomalyAtEpoch, double orbitalPeriod, double epoch); - + /// Default construct that initializes all the properties and member variables KeplerTranslation(); diff --git a/modules/spacecraftinstruments/util/projectioncomponent.cpp b/modules/spacecraftinstruments/util/projectioncomponent.cpp index 704b361b6b..847a45523c 100644 --- a/modules/spacecraftinstruments/util/projectioncomponent.cpp +++ b/modules/spacecraftinstruments/util/projectioncomponent.cpp @@ -69,7 +69,8 @@ namespace { constexpr const char* sequenceTypePlaybook = "playbook"; constexpr const char* sequenceTypeHybrid = "hybrid"; constexpr const char* sequenceTypeInstrumentTimes = "instrument-times"; - constexpr const char* sequenceTypeImageAndInstrumentTimes = "image-and-instrument-times"; + constexpr const char* sequenceTypeImageAndInstrumentTimes = + "image-and-instrument-times"; constexpr const char* placeholderFile = "${DATA}/placeholder.png"; @@ -381,7 +382,9 @@ void ProjectionComponent::initialize(const std::string& identifier, ) ); - std::string timesSequenceSource = absPath(dictionary.value(keyTimesSequenceDir)); + std::string timesSequenceSource = absPath( + dictionary.value(keyTimesSequenceDir) + ); ghoul::Dictionary timesTranslationDictionary; dictionary.getValue(keyTimesTranslation, timesTranslationDictionary); diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index 71deff0318..2c7ba9a106 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -680,7 +680,8 @@ int TouchInteraction::interpretInteraction(const std::vector& double res = 0.0; float lastAngle = lastPoint.angleToPos(_centroid.x, _centroid.y); - float currentAngle = inputHolder.latestInput().angleToPos(_centroid.x, _centroid.y); + float currentAngle = + inputHolder.latestInput().angleToPos(_centroid.x, _centroid.y); if (lastAngle > currentAngle + 1.5 * glm::pi()) { res = currentAngle + (2.0 * glm::pi() - lastAngle); } @@ -820,9 +821,7 @@ void TouchInteraction::computeVelocities(const std::vector& li #endif _constTimeDecayCoeff.zoom = 1.0; - _vel.zoom = zoomFactor * - _pinchZoomFactor * - _zoomSensitivityProportionalDist * + _vel.zoom = zoomFactor * _pinchZoomFactor * _zoomSensitivityProportionalDist * std::max(_touchScreenSize.value() * 0.1, 1.0); break; } @@ -1033,7 +1032,7 @@ void TouchInteraction::step(double dt, bool directTouch) { centerToActualSurfaceModelSpace; const double nodeRadius = length(centerToActualSurface); - // Because of heightmaps we should make sure we do not go through the surface + // Because of heightmaps we need to ensure we don't go through the surface if (_zoomInLimit.value() < nodeRadius) { #ifdef TOUCH_DEBUG_PROPERTIES LINFO(fmt::format("{}: Zoom In limit should be larger than anchor " @@ -1058,9 +1057,9 @@ void TouchInteraction::step(double dt, bool directTouch) { const double distanceFromSurface = length(currentPosDistance) - anchor->boundingSphere(); if (distanceFromSurface > 0.1) { - const double ratioOfDistanceToNodeVsSurface = + const double ratioOfDistanceToNodeVsSurf = length(currentPosDistance) / distanceFromSurface; - if (ratioOfDistanceToNodeVsSurface > _zoomSensitivityDistanceThreshold) { + if (ratioOfDistanceToNodeVsSurf > _zoomSensitivityDistanceThreshold) { zoomVelocity *= pow( std::abs(distanceFromSurface), static_cast(_zoomSensitivityExponential) @@ -1072,8 +1071,8 @@ void TouchInteraction::step(double dt, bool directTouch) { } } - const glm::dvec3 zoomDistanceIncrement = directionToCenter * zoomVelocity * dt; - const double newPosDistance = length(centerToCamera + zoomDistanceIncrement); + const glm::dvec3 zoomDistanceInc = directionToCenter * zoomVelocity * dt; + const double newPosDistance = length(centerToCamera + zoomDistanceInc); // Possible with other navigations performed outside touch interaction const bool currentPosViolatingZoomOutLimit = @@ -1182,7 +1181,7 @@ void TouchInteraction::resetAfterInput() { _lastVel.zoom = 0.0; _lastVel.roll = 0.0; _lastVel.pan = glm::dvec2(0.0); - + _constTimeDecayCoeff.zoom = computeConstTimeDecayCoefficient(_vel.zoom); _pinchInputs[0].clearInputs(); _pinchInputs[1].clearInputs(); diff --git a/modules/touch/src/win32_touch.cpp b/modules/touch/src/win32_touch.cpp index 1118094768..b10b50ca32 100644 --- a/modules/touch/src/win32_touch.cpp +++ b/modules/touch/src/win32_touch.cpp @@ -91,9 +91,9 @@ LRESULT CALLBACK HookCallback(int nCode, WPARAM wParam, LPARAM lParam) { //Implementation from microsoft STL of high_resolution_clock(steady_clock): const long long freq = gFrequency; const long long whole = (info.PerformanceCount / freq) * std::micro::den; - const long long part = (info.PerformanceCount % freq) * + const long long part = (info.PerformanceCount % freq) * std::micro::den / freq; - const std::chrono::microseconds timestamp = + const std::chrono::microseconds timestamp = std::chrono::duration(whole + part) - gStartTime; RECT rect; diff --git a/modules/toyvolume/rendering/renderabletoyvolume.cpp b/modules/toyvolume/rendering/renderabletoyvolume.cpp index ab642b0a13..46dc7ffca8 100644 --- a/modules/toyvolume/rendering/renderabletoyvolume.cpp +++ b/modules/toyvolume/rendering/renderabletoyvolume.cpp @@ -69,7 +69,8 @@ namespace { "" // @TODO Missing documentation }; - constexpr openspace::properties::Property::PropertyInfo DownscaleVolumeRenderingInfo = { + constexpr openspace::properties::Property::PropertyInfo DownscaleVolumeRenderingInfo = + { "Downscale", "Downscale Factor Volume Rendering", "This value set the downscaling factor" diff --git a/modules/vislab/rendering/renderabledistancelabel.cpp b/modules/vislab/rendering/renderabledistancelabel.cpp index eac120946d..db6d3c0cef 100644 --- a/modules/vislab/rendering/renderabledistancelabel.cpp +++ b/modules/vislab/rendering/renderabledistancelabel.cpp @@ -53,8 +53,8 @@ namespace { constexpr openspace::properties::Property::PropertyInfo CustomUnitDescriptorInfo = { "CustomUnitDescriptor", "Custom Unit Descriptor", - "Property to define a custom unit descriptor to use to describe the distance value." - "Defaults to the units SI descriptor if not specified." + "Property to define a custom unit descriptor to use to describe the distance " + "value. Defaults to the units SI descriptor if not specified." }; } @@ -111,7 +111,8 @@ RenderableDistanceLabel::RenderableDistanceLabel(const ghoul::Dictionary& dictio addProperty(_distanceUnit); } if (dictionary.hasKey(CustomUnitDescriptorInfo.identifier)) { - _customUnitDescriptor = dictionary.value(CustomUnitDescriptorInfo.identifier); + _customUnitDescriptor = + dictionary.value(CustomUnitDescriptorInfo.identifier); addProperty(_customUnitDescriptor); } } @@ -144,7 +145,9 @@ void RenderableDistanceLabel::update(const UpdateData&) { } // Get distance as string and remove fractional part - std::string distanceText = std::to_string(std::round(nodeline->distance() / scale)); + std::string distanceText = std::to_string( + std::round(nodeline->distance() / scale) + ); int pos = static_cast(distanceText.find(".")); std::string subStr = distanceText.substr(pos); distanceText.erase(pos, subStr.size()); diff --git a/modules/webbrowser/include/eventhandler.h b/modules/webbrowser/include/eventhandler.h index e08f2fbfc7..870eb49a47 100644 --- a/modules/webbrowser/include/eventhandler.h +++ b/modules/webbrowser/include/eventhandler.h @@ -87,7 +87,7 @@ private: #ifdef WIN32 /** * Build a CEF touch event based on our internal structure - * + * * Note: as of 02/21/2020 we are using an older version of CEF on OSX * than WIN32. * This version does not handle the CefTouchEvent type and does diff --git a/modules/webbrowser/src/eventhandler.cpp b/modules/webbrowser/src/eventhandler.cpp index b7f4d55c96..6d9645b9a0 100644 --- a/modules/webbrowser/src/eventhandler.cpp +++ b/modules/webbrowser/src/eventhandler.cpp @@ -475,9 +475,9 @@ CefTouchEvent EventHandler::touchEvent(const TouchInput& input, event.x = windowPos.x; event.y = windowPos.y; event.type = eventType; - const std::vector> &keyModVec = + const std::vector>& keyModVec = global::navigationHandler.inputState().pressedKeys(); - for (auto keyModPair : keyModVec) { + for (const std::pair& keyModPair : keyModVec) { const KeyModifier mods = keyModVec[0].second; event.modifiers |= static_cast(mapToCefModifiers(mods)); } diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index 936b7c4672..6f75683ccb 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -188,8 +188,8 @@ std::shared_ptr DownloadManager::downloadFile( &progressCb }; #if LIBCURL_VERSION_NUM >= 0x072000 - // xferinfo was introduced in 7.32.0, if a lower curl version is used the progress - // will not be shown for downloads on the splash screen + // xferinfo was introduced in 7.32.0, if a lower curl version is used the + // progress will not be shown for downloads on the splash screen curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, xferinfo); // NOLINT curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &p); // NOLINT #endif diff --git a/src/interaction/orbitalnavigator.cpp b/src/interaction/orbitalnavigator.cpp index efcd4bace1..9f5e005b6e 100644 --- a/src/interaction/orbitalnavigator.cpp +++ b/src/interaction/orbitalnavigator.cpp @@ -145,16 +145,18 @@ namespace { constexpr openspace::properties::Property::PropertyInfo ApplyLinearFlightInfo = { "ApplyLinearFlight", "Apply Linear Flight", - "This property makes the camera move to the specified distance 'FlightDestinationDistance' while facing the anchor" + "This property makes the camera move to the specified distance " + "'FlightDestinationDistance' while facing the anchor" }; - constexpr openspace::properties::Property::PropertyInfo FlightDestinationDistanceInfo = { + constexpr openspace::properties::Property::PropertyInfo FlightDestinationDistInfo = { "FlightDestinationDistance", "Flight Destination Distance", "The final distance we want to fly to, with regards to the anchor node." }; - constexpr openspace::properties::Property::PropertyInfo FlightDestinationFactorInfo = { + constexpr openspace::properties::Property::PropertyInfo FlightDestinationFactorInfo = + { "FlightDestinationFactor", "Flight Destination Factor", "The minimal distance factor that we need to reach to end linear flight." @@ -236,7 +238,7 @@ OrbitalNavigator::OrbitalNavigator() , _minimumAllowedDistance(MinimumDistanceInfo, 10.0f, 0.0f, 10000.f) , _velocitySensitivity(VelocityZoomControlInfo, 0.02f, 0.01f, 0.15f) , _applyLinearFlight(ApplyLinearFlightInfo, false) - , _flightDestinationDistance(FlightDestinationDistanceInfo, 2e8f, 0.0f, 1e10f) + , _flightDestinationDistance(FlightDestinationDistInfo, 2e8f, 0.0f, 1e10f) , _flightDestinationFactor(FlightDestinationFactorInfo, 1E-4, 1E-6, 0.5) , _mouseSensitivity(MouseSensitivityInfo, 15.0f, 1.0f, 50.f) , _joystickSensitivity(JoystickSensitivityInfo, 10.0f, 1.0f, 50.f) @@ -442,16 +444,17 @@ void OrbitalNavigator::updateCameraStateFromStates(double deltaTime) { if (_applyLinearFlight) { // Calculate a position handle based on the camera position in world space glm::dvec3 camPosToAnchorPosDiff = prevCameraPosition - anchorPos; - // Use the boundingsphere to get an approximate distance to the surface of the node + // Use the boundingsphere to get an approximate distance to the node surface double nodeRadius = static_cast(_anchorNode->boundingSphere()); - double distFromCameraToFocus = glm::distance(prevCameraPosition, anchorPos) - nodeRadius; + double distFromCameraToFocus = + glm::distance(prevCameraPosition, anchorPos) - nodeRadius; // Make the approximation delta size depending on the flight distance - double arrivalThreshold = _flightDestinationDistance.value() * _flightDestinationFactor; - - // Fly towards the flight destination distance. When getting closer than arrivalThreshold terminate the flight - if (abs(distFromCameraToFocus - _flightDestinationDistance.value()) > arrivalThreshold) { + double arrivalThreshold = _flightDestinationDistance * _flightDestinationFactor; + // Fly towards the flight destination distance. When getting closer than + // arrivalThreshold terminate the flight + if (abs(distFromCameraToFocus - _flightDestinationDistance) > arrivalThreshold) { pose.position = moveCameraAlongVector( pose.position, distFromCameraToFocus, @@ -460,7 +463,7 @@ void OrbitalNavigator::updateCameraStateFromStates(double deltaTime) { ); } else { - _applyLinearFlight.setValue(false); + _applyLinearFlight = false; } } diff --git a/src/interaction/websocketcamerastates.cpp b/src/interaction/websocketcamerastates.cpp index d3769213bc..9fefc15d02 100644 --- a/src/interaction/websocketcamerastates.cpp +++ b/src/interaction/websocketcamerastates.cpp @@ -32,12 +32,13 @@ namespace openspace::interaction { -WebsocketCameraStates::WebsocketCameraStates(double sensitivity, double velocityScaleFactor) +WebsocketCameraStates::WebsocketCameraStates(double sensitivity, + double velocityScaleFactor) : CameraInteractionStates(sensitivity, velocityScaleFactor) {} void WebsocketCameraStates::updateStateFromInput(const InputState& inputState, - double deltaTime) + double deltaTime) { std::pair globalRotation = { false, glm::dvec2(0.0) }; std::pair zoom = { false, 0.0 }; @@ -115,7 +116,7 @@ void WebsocketCameraStates::updateStateFromInput(const InputState& inputState, } } } - + if (globalRotation.first) { _globalRotationState.velocity.set(globalRotation.second, deltaTime); } @@ -164,7 +165,8 @@ void WebsocketCameraStates::setAxisMapping(int axis, AxisType mapping, _axisMapping[axis].normalize = shouldNormalize; } -WebsocketCameraStates::AxisInformation WebsocketCameraStates::axisMapping(int axis) const { +WebsocketCameraStates::AxisInformation WebsocketCameraStates::axisMapping(int axis) const +{ return _axisMapping[axis]; } diff --git a/src/interaction/websocketinputstate.cpp b/src/interaction/websocketinputstate.cpp index 3f6851d33a..9ccccf12cb 100644 --- a/src/interaction/websocketinputstate.cpp +++ b/src/interaction/websocketinputstate.cpp @@ -39,7 +39,9 @@ float WebsocketInputStates::axis(int axis) const { begin(), end(), 0.f, - [axis](float value, const std::pair state) { + [axis](float value, + const std::pair state) + { if (state.second->isConnected) { value += state.second->axes[axis]; } @@ -58,9 +60,10 @@ bool WebsocketInputStates::button(int button, WebsocketAction action) const { bool res = std::any_of( begin(), end(), - [button, action](const std::pair state) { + [button, action](const std::pair state) + { return state.second->isConnected ? - ( state.second->buttons[button] == action ) + (state.second->buttons[button] == action) : false; } ); diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index 5a3ff016cd..c5280097ad 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -76,7 +76,7 @@ namespace { constexpr const std::array HDRUniformNames = { - "hdrFeedingTexture", "blackoutFactor", "hdrExposure", "gamma", + "hdrFeedingTexture", "blackoutFactor", "hdrExposure", "gamma", "Hue", "Saturation", "Value" }; @@ -456,8 +456,8 @@ void FramebufferRenderer::initialize() { glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO); ghoul::opengl::updateUniformLocations( - *_hdrFilteringProgram, - _hdrUniformCache, + *_hdrFilteringProgram, + _hdrUniformCache, HDRUniformNames ); ghoul::opengl::updateUniformLocations( @@ -525,7 +525,7 @@ void FramebufferRenderer::deferredcastersChanged(Deferredcaster&, void FramebufferRenderer::applyTMO(float blackoutFactor) { const bool doPerformanceMeasurements = global::performanceManager.isEnabled(); std::unique_ptr perfInternal; - + if (doPerformanceMeasurements) { perfInternal = std::make_unique( "FramebufferRenderer::render::TMO" @@ -536,7 +536,7 @@ void FramebufferRenderer::applyTMO(float blackoutFactor) { ghoul::opengl::TextureUnit hdrFeedingTextureUnit; hdrFeedingTextureUnit.activate(); glBindTexture(GL_TEXTURE_2D, _pingPongBuffers.colorTexture[_pingPongIndex]); - + _hdrFilteringProgram->setUniform( _hdrUniformCache.hdrFeedingTexture, hdrFeedingTextureUnit @@ -683,7 +683,7 @@ void FramebufferRenderer::writeDownscaledVolume() { _writeDownscaledVolumeUniformCache.downscaledRenderedVolume, downscaledTextureUnit ); - + ghoul::opengl::TextureUnit downscaledDepthUnit; downscaledDepthUnit.activate(); glBindTexture( @@ -1160,7 +1160,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac glEnable(GL_DEPTH_TEST); } _pingPongIndex = 0; - + // Measurements cache variable const bool doPerformanceMeasurements = global::performanceManager.isEnabled(); @@ -1173,7 +1173,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac if (!scene || !camera) { return; - } + } { // deferred g-buffer @@ -1236,7 +1236,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac GLDebugGroup group("Deferred Caster Tasks"); // We use ping pong rendering in order to be able to - // render to the same final buffer, multiple + // render to the same final buffer, multiple // deferred tasks at same time (e.g. more than 1 ATM being seen at once) glBindFramebuffer(GL_FRAMEBUFFER, _pingPongBuffers.framebuffer); glDrawBuffers(1, &ColorAttachment01Array[_pingPongIndex]); @@ -1263,7 +1263,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac // Disabling depth test for filtering and hdr glDisable(GL_DEPTH_TEST); - + glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); if (_enableFXAA) { @@ -1277,7 +1277,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac // by the Operating System. Also, the resolve procedure is executed in this step. glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO); } - + { // Apply the selected TMO on the results and resolve the result to the default FBO GLDebugGroup group("Apply TMO"); @@ -1290,7 +1290,6 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO); applyFXAA(); } - } void FramebufferRenderer::performRaycasterTasks(const std::vector& tasks) { @@ -1312,11 +1311,11 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector } if (raycaster->downscaleRender() < 1.f) { - float scaleDown = raycaster->downscaleRender(); glBindFramebuffer(GL_FRAMEBUFFER, _downscaleVolumeRendering.framebuffer); - glViewport(viewport[0], viewport[1], viewport[2] * scaleDown, viewport[3] * scaleDown); - if (_downscaleVolumeRendering.currentDownscaleFactor != scaleDown) { - _downscaleVolumeRendering.currentDownscaleFactor = scaleDown; + const float s = raycaster->downscaleRender(); + glViewport(viewport[0], viewport[1], viewport[2] * s, viewport[3] * s); + if (_downscaleVolumeRendering.currentDownscaleFactor != s) { + _downscaleVolumeRendering.currentDownscaleFactor = s; updateDownscaleTextures(); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -1357,7 +1356,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector if (raycastProgram) { raycastProgram->setUniform("rayCastSteps", raycaster->maxSteps()); - + raycaster->preRaycast(_raycastData[raycaster], *raycastProgram); ghoul::opengl::TextureUnit exitColorTextureUnit; @@ -1383,7 +1382,10 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector ); } else { - raycastProgram->setUniform("windowSize", static_cast(_resolution)); + raycastProgram->setUniform( + "windowSize", + static_cast(_resolution) + ); } glDisable(GL_DEPTH_TEST); diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 99d6637790..c6b06dfde5 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -319,14 +319,13 @@ RenderEngine::RenderEngine() }); addProperty(_disableHDRPipeline); - _hdrExposure.onChange([this]() { if (_renderer) { _renderer->setHDRExposure(_hdrExposure); } }); addProperty(_hdrExposure); - + _gamma.onChange([this]() { if (_renderer) { _renderer->setGamma(_gamma); @@ -342,7 +341,7 @@ RenderEngine::RenderEngine() }); addProperty(_hue); - + _saturation.onChange([this]() { if (_renderer) { _renderer->setSaturation(_saturation); @@ -350,7 +349,7 @@ RenderEngine::RenderEngine() }); addProperty(_saturation); - + _value.onChange([this]() { if (_renderer) { _renderer->setValue(_value); diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index 1f5574816f..59334604ef 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -346,7 +346,7 @@ void Scene::render(const RenderData& data, RendererTasks& tasks) { if (global::callback::webBrowserPerformanceHotfix) { (*global::callback::webBrowserPerformanceHotfix)(); } - + { ZoneScopedN("Get Error Hack") diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 1e00beee8c..37aa928996 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -643,7 +643,9 @@ int addInterestingTime(lua_State* L) { std::string time = ghoul::lua::value(L, 2, ghoul::lua::PopValue::No); lua_pop(L, 2); - global::renderEngine.scene()->addInterestingTime({ std::move(name), std::move(time) }); + global::renderEngine.scene()->addInterestingTime( + { std::move(name), std::move(time) } + ); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 5177ea9c69..aa1239cefd 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -707,7 +707,7 @@ void SceneGraphNode::computeScreenSpaceData(RenderData& newData) { } glm::ivec2 res = global::windowDelegate.currentSubwindowSize(); - + // Get the radius of node double nodeRadius = static_cast(this->boundingSphere()); diff --git a/src/scripting/scriptengine_lua.inl b/src/scripting/scriptengine_lua.inl index 4ffce5c454..562d8c9600 100644 --- a/src/scripting/scriptengine_lua.inl +++ b/src/scripting/scriptengine_lua.inl @@ -417,7 +417,10 @@ int saveLastChangeToProfile(lua_State* L) { printInternal(ghoul::logging::LogLevel::Error, L); } if (!fileout) { - ghoul::lua::push(L, fmt::format("Could not open tmp profile '{}'", tempAssetPath)); + ghoul::lua::push( + L, + fmt::format("Could not open tmp profile '{}'", tempAssetPath) + ); printInternal(ghoul::logging::LogLevel::Error, L); }