a new profile for the 2012 solar storm event, with looping hotkeys (#2071)

* a new profile for the 2012 solar storm event, with looping hotkeys

* added interaction spheres, profile cleanup + better discription

* better actions and moved to assets instead of in profile

* Set unique names for the different fieldline data synchronizations

* single dataset in sequence now rendered before its associated timestamp

* fix read access violation + added redundancy

* load at start up instead of on runtime

Co-authored-by: Alexander Bock <mail@alexanderbock.eu>
This commit is contained in:
ElonOlsson
2022-05-06 10:23:45 -04:00
committed by GitHub
parent e40125a77b
commit 9f463ed09f
9 changed files with 212 additions and 17 deletions
@@ -579,6 +579,10 @@ bool RenderableFieldlinesSequence::prepareForOsflsStreaming() {
}
_states.push_back(newState);
_nStates = _startTimes.size();
if (_nStates == 1) {
// loading dynamicaly is not nessesary if only having one set in the sequence
_loadingStatesDynamically = false;
}
_activeStateIndex = 0;
return true;
}
@@ -826,7 +830,6 @@ bool RenderableFieldlinesSequence::getStatesFromCdfFiles() {
std::unordered_map<std::string, std::vector<glm::vec3>>
extractSeedPointsFromFiles(std::filesystem::path filePath)
{
std::vector<std::string> files;
std::unordered_map<std::string, std::vector<glm::vec3>> outMap;
if (!std::filesystem::is_directory(filePath)) {
@@ -1046,7 +1049,7 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
const double currentTime = data.time.j2000Seconds();
const bool isInInterval = (currentTime >= _startTimes[0]) &&
(currentTime < _sequenceEndTime);
// Check if current time in OpenSpace is within sequence interval
if (isInInterval) {
const size_t nextIdx = _activeTriggerTimeIndex + 1;
@@ -1069,6 +1072,15 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
}
} // else {we're still in same state as previous frame (no changes needed)}
}
// if only one state
else if (_nStates == 1) {
_activeTriggerTimeIndex = 0;
_activeStateIndex = 0;
if (!_hasBeenUpdated) {
updateVertexPositionBuffer();
}
_hasBeenUpdated = true;
}
else {
// Not in interval => set everything to false
_activeTriggerTimeIndex = -1;
@@ -1105,14 +1117,16 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
_newStateIsReady = false;
}
if (_shouldUpdateColorBuffer) {
updateVertexColorBuffer();
_shouldUpdateColorBuffer = false;
}
if (_colorMethod == 1) { //By quantity
if (_shouldUpdateColorBuffer) {
updateVertexColorBuffer();
_shouldUpdateColorBuffer = false;
}
if (_shouldUpdateMaskingBuffer) {
updateVertexMaskingBuffer();
_shouldUpdateMaskingBuffer = false;
if (_shouldUpdateMaskingBuffer) {
updateVertexMaskingBuffer();
_shouldUpdateMaskingBuffer = false;
}
}
}
@@ -1132,6 +1146,9 @@ void RenderableFieldlinesSequence::updateActiveTriggerTimeIndex(double currentTi
else {
_activeTriggerTimeIndex = static_cast<int>(_nStates) - 1;
}
if (_nStates == 1) {
_activeTriggerTimeIndex = 0;
}
}
// Reading state from disk. Must be thread safe
@@ -1150,6 +1167,7 @@ void unbindGL() {
}
void RenderableFieldlinesSequence::updateVertexPositionBuffer() {
if (_activeStateIndex == -1) { return; }
glBindVertexArray(_vertexArrayObject);
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer);
@@ -1169,6 +1187,7 @@ void RenderableFieldlinesSequence::updateVertexPositionBuffer() {
}
void RenderableFieldlinesSequence::updateVertexColorBuffer() {
if (_activeStateIndex == -1) { return; }
glBindVertexArray(_vertexArrayObject);
glBindBuffer(GL_ARRAY_BUFFER, _vertexColorBuffer);
@@ -1194,6 +1213,7 @@ void RenderableFieldlinesSequence::updateVertexColorBuffer() {
}
void RenderableFieldlinesSequence::updateVertexMaskingBuffer() {
if (_activeStateIndex == -1) { return; }
glBindVertexArray(_vertexArrayObject);
glBindBuffer(GL_ARRAY_BUFFER, _vertexMaskingBuffer);
@@ -107,6 +107,10 @@ private:
// True when new state is loaded or user change which quantity used for masking out
// line segments
bool _shouldUpdateMaskingBuffer = false;
// note Elon: rework the case of only one state
// hasBeenUpdated only gets sets once, first iteration of update function, to
// guarantee the vertext position buffer to be initialized.
bool _hasBeenUpdated = false;
// Active index of _states. If(==-1)=>no state available for current time. Always the
// same as _activeTriggerTimeIndex if(_loadingStatesDynamically==true), else