mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-04 18:11:01 -05:00
Force recompilation of the RenderableGlobe shader when moving layers (closes #3295)
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
#include <modules/globebrowsing/src/layergroup.h>
|
||||
|
||||
#include <modules/globebrowsing/src/layer.h>
|
||||
#include <modules/globebrowsing/src/layermanager.h>
|
||||
#include <modules/globebrowsing/src/renderableglobe.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/events/event.h>
|
||||
@@ -216,6 +218,16 @@ void LayerGroup::moveLayer(int oldPosition, int newPosition) {
|
||||
_subOwners.erase(oldPosOwner);
|
||||
auto newPosOwner = _subOwners.begin() + newPosition;
|
||||
_subOwners.insert(newPosOwner, owner);
|
||||
|
||||
// If we change the order of the layers, we need to inform the RenderableGlobe's
|
||||
// shader as it might no longer be valid. This can happen if we change the order of
|
||||
// two layers with different types and the uniforms between the two types are not
|
||||
// compatible
|
||||
LayerManager* manager = dynamic_cast<LayerManager*>(_owner);
|
||||
ghoul_assert(manager, "Hierarchy error: Layer. Owner is not LayerManager");
|
||||
RenderableGlobe* renderable = dynamic_cast<RenderableGlobe*>(manager->owner());
|
||||
ghoul_assert(manager, "Hierarchy error: LayerManager. Owner is not RenderableGlobe");
|
||||
renderable->invalidateShader();
|
||||
}
|
||||
|
||||
std::vector<Layer*> LayerGroup::layers() const {
|
||||
|
||||
@@ -1028,6 +1028,10 @@ const glm::dmat4& RenderableGlobe::modelTransform() const {
|
||||
return _cachedModelTransform;
|
||||
}
|
||||
|
||||
void RenderableGlobe::invalidateShader() {
|
||||
_shadersNeedRecompilation = true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Rendering code
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -122,6 +122,9 @@ public:
|
||||
|
||||
const glm::dmat4& modelTransform() const;
|
||||
|
||||
// Will cause the shaders to be recompiled
|
||||
void invalidateShader();
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user