Commit 4a8e4a35 authored by Ylva Selling's avatar Ylva Selling
Browse files

Create timer that allows the browser to reload before changing the border radius

parent 2dd981ae
Showing with 9 additions and 2 deletions
+9 -2
......@@ -37,6 +37,7 @@ namespace openspace {
class ScreenSpaceSkyBrowser : public ScreenSpaceRenderable, public WwtCommunicator {
public:
static constexpr int RadiusTimeOut = 25;
explicit ScreenSpaceSkyBrowser(const ghoul::Dictionary& dictionary);
~ScreenSpaceSkyBrowser() override;
......@@ -80,6 +81,7 @@ private:
bool _ratioIsDirty = false;
bool _radiusIsDirty = false;
bool _isInitialized = false;
int _borderRadiusTimer = -1;
float _ratio = 1.f;
};
......
......@@ -129,6 +129,7 @@ ScreenSpaceSkyBrowser::ScreenSpaceSkyBrowser(const ghoul::Dictionary& dictionary
_scale.onChange([this]() {
updateTextureResolution();
_borderRadiusTimer = 0;
});
_useRadiusAzimuthElevation.onChange(
......@@ -325,11 +326,15 @@ void ScreenSpaceSkyBrowser::update() {
if (_shouldReload) {
_isInitialized = false;
}
if (_radiusIsDirty && _isInitialized) {
// After the texture has been updated, wait a little bit before updating the border
// radius so the browser has time to update its size
if (_radiusIsDirty && _isInitialized && _borderRadiusTimer == RadiusTimeOut) {
setBorderRadius(_borderRadius);
_radiusIsDirty = false;
_borderRadiusTimer = -1;
}
_borderRadiusTimer++;
ScreenSpaceRenderable::update();
WwtCommunicator::update();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment