Add ability to disable vegetation rendering
It is disabled in opengl rendering for now
This commit is contained in:
parent
b430f6037e
commit
cd7f30ecae
4 changed files with 48 additions and 14 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include "OpenGLWater.h"
|
#include "OpenGLWater.h"
|
||||||
#include "OpenGLTerrain.h"
|
#include "OpenGLTerrain.h"
|
||||||
#include "CloudsRenderer.h"
|
#include "CloudsRenderer.h"
|
||||||
|
#include "VegetationRenderer.h"
|
||||||
#include "Color.h"
|
#include "Color.h"
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
#include "LightingManager.h"
|
#include "LightingManager.h"
|
||||||
|
@ -61,6 +62,16 @@ OpenGLRenderer::~OpenGLRenderer()
|
||||||
delete shared_state;
|
delete shared_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenGLRenderer::prepare()
|
||||||
|
{
|
||||||
|
SoftwareRenderer::prepare();
|
||||||
|
|
||||||
|
getCloudsRenderer()->setEnabled(false);
|
||||||
|
getLightingManager()->setSpecularity(false);
|
||||||
|
getGodRaysSampler()->setEnabled(false);
|
||||||
|
getVegetationRenderer()->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGLRenderer::initialize()
|
void OpenGLRenderer::initialize()
|
||||||
{
|
{
|
||||||
ready = functions->initializeOpenGLFunctions();
|
ready = functions->initializeOpenGLFunctions();
|
||||||
|
@ -71,10 +82,6 @@ void OpenGLRenderer::initialize()
|
||||||
|
|
||||||
prepare();
|
prepare();
|
||||||
|
|
||||||
getCloudsRenderer()->setEnabled(false);
|
|
||||||
getLightingManager()->setSpecularity(false);
|
|
||||||
getGodRaysSampler()->setEnabled(false);
|
|
||||||
|
|
||||||
skybox->initialize();
|
skybox->initialize();
|
||||||
skybox->updateScenery();
|
skybox->updateScenery();
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ public:
|
||||||
inline OpenGLTerrain *getTerrain() const {return terrain;}
|
inline OpenGLTerrain *getTerrain() const {return terrain;}
|
||||||
inline bool isDisplayed() const {return displayed;}
|
inline bool isDisplayed() const {return displayed;}
|
||||||
|
|
||||||
|
virtual void prepare() override;
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
void prepareOpenGLState();
|
void prepareOpenGLState();
|
||||||
void resize(int width, int height);
|
void resize(int width, int height);
|
||||||
|
|
|
@ -47,6 +47,11 @@ VegetationRenderer::VegetationRenderer(SoftwareRenderer *parent):
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VegetationRenderer::setEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
this->enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
RayCastingResult VegetationRenderer::renderInstance(const SpaceSegment &segment, const VegetationInstance &instance, bool only_hit)
|
RayCastingResult VegetationRenderer::renderInstance(const SpaceSegment &segment, const VegetationInstance &instance, bool only_hit)
|
||||||
{
|
{
|
||||||
RayCastingResult final;
|
RayCastingResult final;
|
||||||
|
@ -70,6 +75,8 @@ RayCastingResult VegetationRenderer::renderInstance(const SpaceSegment &segment,
|
||||||
}
|
}
|
||||||
|
|
||||||
RayCastingResult VegetationRenderer::getResult(const SpaceSegment &segment, bool only_hit)
|
RayCastingResult VegetationRenderer::getResult(const SpaceSegment &segment, bool only_hit)
|
||||||
|
{
|
||||||
|
if (enabled)
|
||||||
{
|
{
|
||||||
// Find instances potentially crossing the segment
|
// Find instances potentially crossing the segment
|
||||||
// TODO Collect the nearest hit, don't stop at the first one
|
// TODO Collect the nearest hit, don't stop at the first one
|
||||||
|
@ -83,8 +90,15 @@ RayCastingResult VegetationRenderer::getResult(const SpaceSegment &segment, bool
|
||||||
return RayCastingResult();
|
return RayCastingResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return RayCastingResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool VegetationRenderer::applyLightFilter(LightComponent &light, const Vector3 &at)
|
bool VegetationRenderer::applyLightFilter(LightComponent &light, const Vector3 &at)
|
||||||
|
{
|
||||||
|
if (enabled)
|
||||||
{
|
{
|
||||||
// Get segment to iterate
|
// Get segment to iterate
|
||||||
SpaceSegment segment(at, at.add(light.direction.scale(-1.0 * parent->render_quality)));
|
SpaceSegment segment(at, at.add(light.direction.scale(-1.0 * parent->render_quality)));
|
||||||
|
@ -98,3 +112,8 @@ bool VegetationRenderer::applyLightFilter(LightComponent &light, const Vector3 &
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,11 @@ class SOFTWARESHARED_EXPORT VegetationRenderer: public LightFilter
|
||||||
public:
|
public:
|
||||||
VegetationRenderer(SoftwareRenderer *parent);
|
VegetationRenderer(SoftwareRenderer *parent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Totally enable or disable the vegetation layers rendering.
|
||||||
|
*/
|
||||||
|
void setEnabled(bool enabled);
|
||||||
|
|
||||||
inline SoftwareRenderer *getParent() const {return parent;}
|
inline SoftwareRenderer *getParent() const {return parent;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +34,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SoftwareRenderer *parent;
|
SoftwareRenderer *parent;
|
||||||
|
bool enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue