From 69fd2ed8a44f6b09362678b9aef5fc4980d0262d Mon Sep 17 00:00:00 2001 From: Oskar Carlbaum Date: Wed, 18 Oct 2017 23:48:39 +0200 Subject: [PATCH] Remove unnecessary debug messages and return false in update() if renderable is disabled --- .../renderablefieldlinessequence.cpp | 110 +++++++++--------- .../renderablefieldlinessequencesetup.cpp | 8 -- 2 files changed, 56 insertions(+), 62 deletions(-) diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp index ad467f4110..ac0ec033a7 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp @@ -155,74 +155,76 @@ void RenderableFieldlinesSequence::render(const RenderData& data, RendererTasks& } void RenderableFieldlinesSequence::update(const UpdateData& data) { + // This node shouldn't do anything if its been disabled from the gui! + if (!_enabled) { + return; + } + if (_shaderProgram->isDirty()) { _shaderProgram->rebuildFromFile(); } - // This node shouldn't do anything if its been disabled from the gui! - if (_enabled) { - const double currentTime = data.time.j2000Seconds(); - // Check if current time in OpenSpace is within sequence interval - if (isWithinSequenceInterval(currentTime)) { - const int nextIdx = _activeTriggerTimeIndex + 1; - if (_activeTriggerTimeIndex < 0 // true => Previous frame was not within the sequence interval - || currentTime < _startTimes[_activeTriggerTimeIndex] // true => OpenSpace has stepped back to a time represented by another state - || (nextIdx < _nStates && currentTime >= _startTimes[nextIdx])) { // true => OpenSpace has stepped forward to a time represented by another state + const double currentTime = data.time.j2000Seconds(); + // Check if current time in OpenSpace is within sequence interval + if (isWithinSequenceInterval(currentTime)) { + const int nextIdx = _activeTriggerTimeIndex + 1; + if (_activeTriggerTimeIndex < 0 // true => Previous frame was not within the sequence interval + || currentTime < _startTimes[_activeTriggerTimeIndex] // true => OpenSpace has stepped back to a time represented by another state + || (nextIdx < _nStates && currentTime >= _startTimes[nextIdx])) { // true => OpenSpace has stepped forward to a time represented by another state - updateActiveTriggerTimeIndex(currentTime); + updateActiveTriggerTimeIndex(currentTime); - if (_loadingStatesDynamically) { - _mustLoadNewStateFromDisk = true; - } else { - _needsUpdate = true; - _activeStateIndex = _activeTriggerTimeIndex; - } - } // else {we're still in same state as previous frame (no changes needed)} - } else { - // Not in interval => set everything to false - _activeTriggerTimeIndex = -1; - _mustLoadNewStateFromDisk = false; - _needsUpdate = false; - } - - if (_mustLoadNewStateFromDisk) { - if (!_isLoadingStateFromDisk && !_newStateIsReady) { - _isLoadingStateFromDisk = true; - _mustLoadNewStateFromDisk = false; - const std::string filePath = _sourceFiles[_activeTriggerTimeIndex]; - std::thread readBinaryThread([this, filePath] { - this->readNewState(filePath); - }); - readBinaryThread.detach(); - } - } - - if (_needsUpdate || _newStateIsReady) { if (_loadingStatesDynamically) { - _states[0] = std::move(*_newState); + _mustLoadNewStateFromDisk = true; + } else { + _needsUpdate = true; + _activeStateIndex = _activeTriggerTimeIndex; } + } // else {we're still in same state as previous frame (no changes needed)} + } else { + // Not in interval => set everything to false + _activeTriggerTimeIndex = -1; + _mustLoadNewStateFromDisk = false; + _needsUpdate = false; + } - updateVertexPositionBuffer(); + if (_mustLoadNewStateFromDisk) { + if (!_isLoadingStateFromDisk && !_newStateIsReady) { + _isLoadingStateFromDisk = true; + _mustLoadNewStateFromDisk = false; + const std::string filePath = _sourceFiles[_activeTriggerTimeIndex]; + std::thread readBinaryThread([this, filePath] { + this->readNewState(filePath); + }); + readBinaryThread.detach(); + } + } - if (_states[_activeStateIndex].nExtraQuantities() > 0) { - _shouldUpdateColorBuffer = true; - _shouldUpdateMaskingBuffer = true; - } - - // Everything is set and ready for rendering! - _needsUpdate = false; - _newStateIsReady = false; + if (_needsUpdate || _newStateIsReady) { + if (_loadingStatesDynamically) { + _states[0] = std::move(*_newState); } - if (_shouldUpdateColorBuffer) { - updateVertexColorBuffer(); - _shouldUpdateColorBuffer = false; + updateVertexPositionBuffer(); + + if (_states[_activeStateIndex].nExtraQuantities() > 0) { + _shouldUpdateColorBuffer = true; + _shouldUpdateMaskingBuffer = true; } - if (_shouldUpdateMaskingBuffer) { - updateVertexMaskingBuffer(); - _shouldUpdateMaskingBuffer = false; - } + // Everything is set and ready for rendering! + _needsUpdate = false; + _newStateIsReady = false; + } + + if (_shouldUpdateColorBuffer) { + updateVertexColorBuffer(); + _shouldUpdateColorBuffer = false; + } + + if (_shouldUpdateMaskingBuffer) { + updateVertexMaskingBuffer(); + _shouldUpdateMaskingBuffer = false; } } diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp index 112d4090e0..c529394613 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp @@ -574,7 +574,6 @@ void RenderableFieldlinesSequence::definePropertyCallbackFunctions() { bool hasExtras = _states[0].nExtraQuantities() > 0; if (hasExtras) { _pColorQuantity.onChange([this] { - LDEBUG("CHANGED COLORING QUANTITY"); _shouldUpdateColorBuffer = true; _pColorQuantityMin = std::to_string(_colorTableRanges[_pColorQuantity].x); _pColorQuantityMax = std::to_string(_colorTableRanges[_pColorQuantity].y); @@ -587,35 +586,30 @@ void RenderableFieldlinesSequence::definePropertyCallbackFunctions() { }); _pColorQuantityMin.onChange([this] { - LDEBUG("CHANGED MIN VALUE"); float f = stringToFloat(_pColorQuantityMin, _colorTableRanges[_pColorQuantity].x); _pColorQuantityMin = std::to_string(f); _colorTableRanges[_pColorQuantity].x = f; }); _pColorQuantityMax.onChange([this] { - LDEBUG("CHANGED MAX VALUE"); float f = stringToFloat(_pColorQuantityMax, _colorTableRanges[_pColorQuantity].y); _pColorQuantityMax = std::to_string(f); _colorTableRanges[_pColorQuantity].y = f; }); _pMaskingQuantity.onChange([this] { - LDEBUG("CHANGED MASKING QUANTITY"); _shouldUpdateMaskingBuffer = true; _pMaskingMin = std::to_string(_maskingRanges[_pMaskingQuantity].x); _pMaskingMax = std::to_string(_maskingRanges[_pMaskingQuantity].y); }); _pMaskingMin.onChange([this] { - LDEBUG("CHANGED LOWER MASKING LIMIT"); float f = stringToFloat(_pMaskingMin, _maskingRanges[_pMaskingQuantity].x); _pMaskingMin = std::to_string(f); _maskingRanges[_pMaskingQuantity].x = f; }); _pMaskingMax.onChange([this] { - LDEBUG("CHANGED UPPER MASKING LIMIT"); float f = stringToFloat(_pMaskingMax, _maskingRanges[_pMaskingQuantity].y); _pMaskingMax = std::to_string(f); _maskingRanges[_pMaskingQuantity].y = f; @@ -623,7 +617,6 @@ void RenderableFieldlinesSequence::definePropertyCallbackFunctions() { } _pFocusOnOriginBtn.onChange([this] { - LDEBUG("SET FOCUS NODE TO PARENT"); SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(_name); if (!node) { LWARNING("Could not find a node in scenegraph called '" << _name << "'"); @@ -634,7 +627,6 @@ void RenderableFieldlinesSequence::definePropertyCallbackFunctions() { }); _pJumpToStartBtn.onChange([this] { - LDEBUG("Jump in time to start of sequence!"); OsEng.timeManager().time().setTime(_startTimes[0]); }); }