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

This commit is contained in:
Ylva Selling
2022-10-12 11:08:24 -04:00
parent 2dd981aed3
commit 4a8e4a35bc
2 changed files with 9 additions and 2 deletions

View File

@@ -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;
};

View File

@@ -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();