The default scenery for a SoftwareRenderer is now a default scenery (not the global one)

This commit is contained in:
Michaël Lemaire 2013-11-13 23:36:52 +01:00
parent cdd9ef26a2
commit 67105775b6
13 changed files with 42 additions and 40 deletions

View file

@ -232,9 +232,8 @@ void FreeFormHelper::processApplyClicked()
void FreeFormHelper::processExploreClicked()
{
SoftwareRenderer renderer;
SoftwareRenderer renderer(Scenery::getCurrent());
Scenery::getCurrent()->bindToRenderer(&renderer);
emit needAlterRenderer(&renderer);
CameraDefinition* camera = cameraCreateDefinition();
@ -249,9 +248,8 @@ void FreeFormHelper::processExploreClicked()
void FreeFormHelper::processRenderClicked()
{
SoftwareRenderer renderer;
SoftwareRenderer renderer(Scenery::getCurrent());
Scenery::getCurrent()->bindToRenderer(&renderer);
emit needAlterRenderer(&renderer);
DialogRender* dialog = new DialogRender(_form_widget, &renderer);

View file

@ -15,24 +15,14 @@
static AtmosphereDefinition* _definition;
/**************** Previews ****************/
class PreviewSkyEast:public AtmosphereColorPreviewRenderer
class PreviewSkyRenderer:public AtmosphereColorPreviewRenderer
{
public:
void bindEvent(BasePreview* preview) override
PreviewSkyRenderer(double heading):
AtmosphereColorPreviewRenderer(heading)
{
preview->configHdrToneMapping(true);
preview->configScaling(0.5, 5.0, 0.5, 2.5);
}
void updateEvent() override
{
/*AtmosphereRendererClass.bind(renderer, _definition);
renderer->prepare();*/
}
};
class PreviewSkyWest:public AtmosphereColorPreviewRenderer
{
public:
void bindEvent(BasePreview* preview) override
{
preview->configHdrToneMapping(true);
@ -40,8 +30,8 @@ public:
}
void updateEvent() override
{
/*AtmosphereRendererClass.bind(renderer, _definition);
renderer->prepare();*/
getScenery()->setAtmosphere(_definition);
prepare();
}
};
@ -58,8 +48,13 @@ FormAtmosphere::FormAtmosphere(QWidget *parent):
_definition = (AtmosphereDefinition*)AtmosphereDefinitionClass.create();
previewWest = new BasePreview(this);
previewWestRenderer = new PreviewSkyRenderer(M_PI / 2.0);
previewWest->setRenderer(previewWestRenderer);
addPreview(previewWest, QString(tr("West preview")));
previewEast = new BasePreview(this);
previewEastRenderer = new PreviewSkyRenderer(-M_PI / 2.0);
previewEast->setRenderer(previewEastRenderer);
addPreview(previewEast, QString(tr("East preview")));
//addInputEnum(tr("Color model"), (int*)&_definition->model, QStringList(tr("Simplified model (with weather)")) << tr("Complex model"));
@ -73,6 +68,14 @@ FormAtmosphere::FormAtmosphere(QWidget *parent):
revertConfig();
}
FormAtmosphere::~FormAtmosphere()
{
delete previewWest;
delete previewWestRenderer;
delete previewEast;
delete previewEastRenderer;
}
void FormAtmosphere::revertConfig()
{
Scenery::getCurrent()->getAtmosphere(_definition);

View file

@ -12,6 +12,7 @@ class FormAtmosphere : public BaseForm
public:
explicit FormAtmosphere(QWidget *parent = 0);
virtual ~FormAtmosphere();
public slots:
virtual void revertConfig();
@ -23,7 +24,9 @@ protected slots:
private:
BasePreview* previewEast;
Base2dPreviewRenderer* previewEastRenderer;
BasePreview* previewWest;
Base2dPreviewRenderer* previewWestRenderer;
};
#endif

View file

@ -192,7 +192,7 @@ void FormRender::startQuickRender()
{
rendererDelete(_renderer);
}
_renderer = new SoftwareRenderer();
_renderer = new SoftwareRenderer(Scenery::getCurrent());
_renderer_inited = true;
DialogRender* dialog = new DialogRender(this, _renderer);
@ -208,7 +208,7 @@ void FormRender::startRender()
{
rendererDelete(_renderer);
}
_renderer = new SoftwareRenderer();
_renderer = new SoftwareRenderer(Scenery::getCurrent());
_renderer_inited = true;
DialogRender* dialog = new DialogRender(this, _renderer);

View file

@ -90,7 +90,7 @@ QGLWidget(parent)
}
else
{
_renderer = new SoftwareRenderer();
_renderer = new SoftwareRenderer(Scenery::getCurrent());
_renderer_created = true;
}
_opengl_renderer = new OpenGLRenderer(NULL);

View file

@ -145,8 +145,8 @@ static inline int _checkHit(Vector3 eye, Vector3 direction, Vector3* hit, Vector
return _checkHitGround(eye, direction, hit);
}
AtmosphereColorPreviewRenderer::AtmosphereColorPreviewRenderer():
heading(0.0)
AtmosphereColorPreviewRenderer::AtmosphereColorPreviewRenderer(double heading):
heading(heading)
{
cameraSetLocation(render_camera, Vector3(0.0, 7.0, 0.0));
}
@ -154,7 +154,7 @@ AtmosphereColorPreviewRenderer::AtmosphereColorPreviewRenderer():
Color AtmosphereColorPreviewRenderer::getColor2D(double x, double y, double)
{
Vector3 eye = {0.0, 7.0, 0.0};
Vector3 direction = {x, y, -1.0};
Vector3 direction = {x, -y, -1.0};
Vector3 hit, normal;
Matrix4 rotation;

View file

@ -9,7 +9,7 @@ namespace preview {
class AtmosphereColorPreviewRenderer:public Base2dPreviewRenderer
{
public:
AtmosphereColorPreviewRenderer();
AtmosphereColorPreviewRenderer(double heading);
virtual Color getColor2D(double x, double y, double scaling) override;

View file

@ -6,12 +6,10 @@
Base2dPreviewRenderer::Base2dPreviewRenderer():
SoftwareRenderer()
{
scenery = new Scenery();
}
Base2dPreviewRenderer::~Base2dPreviewRenderer()
{
delete scenery;
}
void Base2dPreviewRenderer::bindEvent(BasePreview*)

View file

@ -22,9 +22,6 @@ public:
virtual void updateEvent();
virtual Color getColor2D(double x, double y, double scaling);
protected:
Scenery* scenery;
};
}

View file

@ -646,10 +646,7 @@ QColor BasePreview::getPixelColor(int x, int y)
{
col = colorProfileApply(_hdr_profile, col);
}
else
{
colorNormalize(&col);
}
col.normalize();
return QColor::fromRgbF(col.r, col.g, col.b, col.a);
}

View file

@ -34,10 +34,12 @@ SoftwareRenderer::SoftwareRenderer(Scenery* scenery)
if (scenery)
{
this->scenery = scenery;
own_scenery = false;
}
else
{
this->scenery = Scenery::getCurrent();
this->scenery = new Scenery;
own_scenery = true;
}
this->scenery->bindToRenderer(this);
}
@ -47,6 +49,11 @@ SoftwareRenderer::~SoftwareRenderer()
delete atmosphere_renderer;
delete fluid_medium;
if (own_scenery)
{
delete scenery;
}
}
void SoftwareRenderer::prepare()
@ -56,6 +63,7 @@ void SoftwareRenderer::prepare()
atmosphere_renderer = new SoftwareBrunetonAtmosphereRenderer(this);
// Setup transitional renderers (for C-legacy subsystems)
AtmosphereDefinitionClass.copy(scenery->getAtmosphere(), atmosphere->definition);
atmosphere->applyAerialPerspective = _legacyApplyAerialPerspective;
atmosphere->getSkyColor = _legacyGetSkyColor;
atmosphere->getLightingStatus = _legacyGetLightingStatus;

View file

@ -36,6 +36,7 @@ public:
private:
Scenery* scenery;
bool own_scenery;
FluidMediumManager* fluid_medium;
BaseAtmosphereRenderer* atmosphere_renderer;
};

View file

@ -11,17 +11,14 @@ class FluidMediumManager_Test:public BaseTestCase
protected:
virtual void setUp()
{
scenery = new Scenery();
renderer = new SoftwareRenderer(scenery);
renderer = new SoftwareRenderer();
}
virtual void tearDown()
{
delete renderer;
delete scenery;
}
Scenery* scenery;
SoftwareRenderer* renderer;
};