Fixed clouds layers being deleted in scenery by opengl renderer

This commit is contained in:
Michaël Lemaire 2015-08-19 19:28:36 +02:00
parent 0058a0a8e3
commit 3599c3aecf
5 changed files with 18 additions and 14 deletions

View file

@ -6,6 +6,7 @@
#include "OpenGLSkybox.h"
#include "OpenGLWater.h"
#include "OpenGLTerrain.h"
#include "CloudsRenderer.h"
#include "Scenery.h"
#include "LightingManager.h"
#include "Logs.h"
@ -57,7 +58,7 @@ void OpenGLRenderer::initialize()
prepare();
disableClouds();
getCloudsRenderer()->setEnabled(false);
getLightingManager()->setSpecularity(false);
skybox->initialize();

View file

@ -17,6 +17,7 @@
CloudsRenderer::CloudsRenderer(SoftwareRenderer* parent):
parent(parent)
{
enabled = true;
fake_renderer = new BaseCloudLayerRenderer(parent);
CloudLayerDefinition* fake_layer = new CloudLayerDefinition(NULL);
@ -39,6 +40,11 @@ CloudsRenderer::~CloudsRenderer()
delete fake_model;
}
void CloudsRenderer::setEnabled(bool enabled)
{
this->enabled = enabled;
}
void CloudsRenderer::update()
{
for (auto renderer : layer_renderers)
@ -138,7 +144,7 @@ Color CloudsRenderer::getColor(const Vector3 &eye, const Vector3 &location, cons
CloudsDefinition* definition = parent->getScenery()->getClouds();
int n = definition->count();
if (n < 1)
if (not enabled or n < 1)
{
return base;
}
@ -164,7 +170,7 @@ bool CloudsRenderer::applyLightFilter(LightComponent &light, const Vector3 &at)
CloudsDefinition* definition = parent->getScenery()->getClouds();
int n = definition->count();
if (n < 1)
if (not enabled or n < 1)
{
return true;
}

View file

@ -17,6 +17,11 @@ public:
CloudsRenderer(SoftwareRenderer* parent);
virtual ~CloudsRenderer();
/**
* Enable or disable the whole cloud rendering.
*/
void setEnabled(bool enabled);
/*!
* \brief Update the renderer with the bound scenery.
*
@ -58,6 +63,7 @@ public:
*/
virtual bool applyLightFilter(LightComponent &light, const Vector3 &at) override;
private:
bool enabled;
SoftwareRenderer* parent;
std::vector<BaseCloudLayerRenderer*> layer_renderers;

View file

@ -86,11 +86,6 @@ void SoftwareRenderer::prepare()
//fluid_medium->registerMedium(water_renderer);
}
void SoftwareRenderer::disableClouds()
{
scenery->getClouds()->clear();
}
void SoftwareRenderer::disableAtmosphere()
{
LightComponent light;

View file

@ -38,16 +38,12 @@ public:
*/
virtual void prepare();
/*!
* \brief Disable the clouds feature.
*
* This toggle is permanent, provided the clouds part of the sceney is not changed.
*/
void disableClouds();
/*!
* \brief Disable atmosphere and sky lighting, replacing it by static lights.
*
* This function needs to be called after each prepare().
*
* WARNING : This method changes the scenery attached to the renderer !
*/
void disableAtmosphere();
void disableAtmosphere(const std::vector<LightComponent> &lights);