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;
|
||||||
|
@ -71,12 +76,19 @@ RayCastingResult VegetationRenderer::renderInstance(const SpaceSegment &segment,
|
||||||
|
|
||||||
RayCastingResult VegetationRenderer::getResult(const SpaceSegment &segment, bool only_hit)
|
RayCastingResult VegetationRenderer::getResult(const SpaceSegment &segment, bool only_hit)
|
||||||
{
|
{
|
||||||
// Find instances potentially crossing the segment
|
if (enabled)
|
||||||
// TODO Collect the nearest hit, don't stop at the first one
|
|
||||||
VegetationGridIterator it(segment, this, parent->getScenery()->getVegetation()->debug_model, only_hit);
|
|
||||||
if (not segment.projectedOnYPlane().scaled(1.0 / DEBUG_DENSITY_FACTOR).iterateOnGrid(it))
|
|
||||||
{
|
{
|
||||||
return it.getResult();
|
// Find instances potentially crossing the segment
|
||||||
|
// TODO Collect the nearest hit, don't stop at the first one
|
||||||
|
VegetationGridIterator it(segment, this, parent->getScenery()->getVegetation()->debug_model, only_hit);
|
||||||
|
if (not segment.projectedOnYPlane().scaled(1.0 / DEBUG_DENSITY_FACTOR).iterateOnGrid(it))
|
||||||
|
{
|
||||||
|
return it.getResult();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return RayCastingResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -86,12 +98,19 @@ RayCastingResult VegetationRenderer::getResult(const SpaceSegment &segment, bool
|
||||||
|
|
||||||
bool VegetationRenderer::applyLightFilter(LightComponent &light, const Vector3 &at)
|
bool VegetationRenderer::applyLightFilter(LightComponent &light, const Vector3 &at)
|
||||||
{
|
{
|
||||||
// Get segment to iterate
|
if (enabled)
|
||||||
SpaceSegment segment(at, at.add(light.direction.scale(-1.0 * parent->render_quality)));
|
|
||||||
if (getResult(segment, true).hit)
|
|
||||||
{
|
{
|
||||||
light.color = COLOR_BLACK;
|
// Get segment to iterate
|
||||||
return false;
|
SpaceSegment segment(at, at.add(light.direction.scale(-1.0 * parent->render_quality)));
|
||||||
|
if (getResult(segment, true).hit)
|
||||||
|
{
|
||||||
|
light.color = COLOR_BLACK;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -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