The default scenery for a SoftwareRenderer is now a default scenery (not the global one)
This commit is contained in:
parent
cdd9ef26a2
commit
67105775b6
13 changed files with 42 additions and 40 deletions
|
@ -232,9 +232,8 @@ void FreeFormHelper::processApplyClicked()
|
||||||
|
|
||||||
void FreeFormHelper::processExploreClicked()
|
void FreeFormHelper::processExploreClicked()
|
||||||
{
|
{
|
||||||
SoftwareRenderer renderer;
|
SoftwareRenderer renderer(Scenery::getCurrent());
|
||||||
|
|
||||||
Scenery::getCurrent()->bindToRenderer(&renderer);
|
|
||||||
emit needAlterRenderer(&renderer);
|
emit needAlterRenderer(&renderer);
|
||||||
|
|
||||||
CameraDefinition* camera = cameraCreateDefinition();
|
CameraDefinition* camera = cameraCreateDefinition();
|
||||||
|
@ -249,9 +248,8 @@ void FreeFormHelper::processExploreClicked()
|
||||||
|
|
||||||
void FreeFormHelper::processRenderClicked()
|
void FreeFormHelper::processRenderClicked()
|
||||||
{
|
{
|
||||||
SoftwareRenderer renderer;
|
SoftwareRenderer renderer(Scenery::getCurrent());
|
||||||
|
|
||||||
Scenery::getCurrent()->bindToRenderer(&renderer);
|
|
||||||
emit needAlterRenderer(&renderer);
|
emit needAlterRenderer(&renderer);
|
||||||
|
|
||||||
DialogRender* dialog = new DialogRender(_form_widget, &renderer);
|
DialogRender* dialog = new DialogRender(_form_widget, &renderer);
|
||||||
|
|
|
@ -15,24 +15,14 @@
|
||||||
static AtmosphereDefinition* _definition;
|
static AtmosphereDefinition* _definition;
|
||||||
|
|
||||||
/**************** Previews ****************/
|
/**************** Previews ****************/
|
||||||
class PreviewSkyEast:public AtmosphereColorPreviewRenderer
|
class PreviewSkyRenderer:public AtmosphereColorPreviewRenderer
|
||||||
{
|
{
|
||||||
public:
|
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
|
void bindEvent(BasePreview* preview) override
|
||||||
{
|
{
|
||||||
preview->configHdrToneMapping(true);
|
preview->configHdrToneMapping(true);
|
||||||
|
@ -40,8 +30,8 @@ public:
|
||||||
}
|
}
|
||||||
void updateEvent() override
|
void updateEvent() override
|
||||||
{
|
{
|
||||||
/*AtmosphereRendererClass.bind(renderer, _definition);
|
getScenery()->setAtmosphere(_definition);
|
||||||
renderer->prepare();*/
|
prepare();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,8 +48,13 @@ FormAtmosphere::FormAtmosphere(QWidget *parent):
|
||||||
_definition = (AtmosphereDefinition*)AtmosphereDefinitionClass.create();
|
_definition = (AtmosphereDefinition*)AtmosphereDefinitionClass.create();
|
||||||
|
|
||||||
previewWest = new BasePreview(this);
|
previewWest = new BasePreview(this);
|
||||||
|
previewWestRenderer = new PreviewSkyRenderer(M_PI / 2.0);
|
||||||
|
previewWest->setRenderer(previewWestRenderer);
|
||||||
addPreview(previewWest, QString(tr("West preview")));
|
addPreview(previewWest, QString(tr("West preview")));
|
||||||
|
|
||||||
previewEast = new BasePreview(this);
|
previewEast = new BasePreview(this);
|
||||||
|
previewEastRenderer = new PreviewSkyRenderer(-M_PI / 2.0);
|
||||||
|
previewEast->setRenderer(previewEastRenderer);
|
||||||
addPreview(previewEast, QString(tr("East preview")));
|
addPreview(previewEast, QString(tr("East preview")));
|
||||||
|
|
||||||
//addInputEnum(tr("Color model"), (int*)&_definition->model, QStringList(tr("Simplified model (with weather)")) << tr("Complex model"));
|
//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();
|
revertConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FormAtmosphere::~FormAtmosphere()
|
||||||
|
{
|
||||||
|
delete previewWest;
|
||||||
|
delete previewWestRenderer;
|
||||||
|
delete previewEast;
|
||||||
|
delete previewEastRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
void FormAtmosphere::revertConfig()
|
void FormAtmosphere::revertConfig()
|
||||||
{
|
{
|
||||||
Scenery::getCurrent()->getAtmosphere(_definition);
|
Scenery::getCurrent()->getAtmosphere(_definition);
|
||||||
|
|
|
@ -12,6 +12,7 @@ class FormAtmosphere : public BaseForm
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FormAtmosphere(QWidget *parent = 0);
|
explicit FormAtmosphere(QWidget *parent = 0);
|
||||||
|
virtual ~FormAtmosphere();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void revertConfig();
|
virtual void revertConfig();
|
||||||
|
@ -23,7 +24,9 @@ protected slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BasePreview* previewEast;
|
BasePreview* previewEast;
|
||||||
|
Base2dPreviewRenderer* previewEastRenderer;
|
||||||
BasePreview* previewWest;
|
BasePreview* previewWest;
|
||||||
|
Base2dPreviewRenderer* previewWestRenderer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -192,7 +192,7 @@ void FormRender::startQuickRender()
|
||||||
{
|
{
|
||||||
rendererDelete(_renderer);
|
rendererDelete(_renderer);
|
||||||
}
|
}
|
||||||
_renderer = new SoftwareRenderer();
|
_renderer = new SoftwareRenderer(Scenery::getCurrent());
|
||||||
_renderer_inited = true;
|
_renderer_inited = true;
|
||||||
|
|
||||||
DialogRender* dialog = new DialogRender(this, _renderer);
|
DialogRender* dialog = new DialogRender(this, _renderer);
|
||||||
|
@ -208,7 +208,7 @@ void FormRender::startRender()
|
||||||
{
|
{
|
||||||
rendererDelete(_renderer);
|
rendererDelete(_renderer);
|
||||||
}
|
}
|
||||||
_renderer = new SoftwareRenderer();
|
_renderer = new SoftwareRenderer(Scenery::getCurrent());
|
||||||
_renderer_inited = true;
|
_renderer_inited = true;
|
||||||
|
|
||||||
DialogRender* dialog = new DialogRender(this, _renderer);
|
DialogRender* dialog = new DialogRender(this, _renderer);
|
||||||
|
|
|
@ -90,7 +90,7 @@ QGLWidget(parent)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_renderer = new SoftwareRenderer();
|
_renderer = new SoftwareRenderer(Scenery::getCurrent());
|
||||||
_renderer_created = true;
|
_renderer_created = true;
|
||||||
}
|
}
|
||||||
_opengl_renderer = new OpenGLRenderer(NULL);
|
_opengl_renderer = new OpenGLRenderer(NULL);
|
||||||
|
|
|
@ -145,8 +145,8 @@ static inline int _checkHit(Vector3 eye, Vector3 direction, Vector3* hit, Vector
|
||||||
return _checkHitGround(eye, direction, hit);
|
return _checkHitGround(eye, direction, hit);
|
||||||
}
|
}
|
||||||
|
|
||||||
AtmosphereColorPreviewRenderer::AtmosphereColorPreviewRenderer():
|
AtmosphereColorPreviewRenderer::AtmosphereColorPreviewRenderer(double heading):
|
||||||
heading(0.0)
|
heading(heading)
|
||||||
{
|
{
|
||||||
cameraSetLocation(render_camera, Vector3(0.0, 7.0, 0.0));
|
cameraSetLocation(render_camera, Vector3(0.0, 7.0, 0.0));
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ AtmosphereColorPreviewRenderer::AtmosphereColorPreviewRenderer():
|
||||||
Color AtmosphereColorPreviewRenderer::getColor2D(double x, double y, double)
|
Color AtmosphereColorPreviewRenderer::getColor2D(double x, double y, double)
|
||||||
{
|
{
|
||||||
Vector3 eye = {0.0, 7.0, 0.0};
|
Vector3 eye = {0.0, 7.0, 0.0};
|
||||||
Vector3 direction = {x, y, -1.0};
|
Vector3 direction = {x, -y, -1.0};
|
||||||
Vector3 hit, normal;
|
Vector3 hit, normal;
|
||||||
Matrix4 rotation;
|
Matrix4 rotation;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace preview {
|
||||||
class AtmosphereColorPreviewRenderer:public Base2dPreviewRenderer
|
class AtmosphereColorPreviewRenderer:public Base2dPreviewRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AtmosphereColorPreviewRenderer();
|
AtmosphereColorPreviewRenderer(double heading);
|
||||||
|
|
||||||
virtual Color getColor2D(double x, double y, double scaling) override;
|
virtual Color getColor2D(double x, double y, double scaling) override;
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,10 @@
|
||||||
Base2dPreviewRenderer::Base2dPreviewRenderer():
|
Base2dPreviewRenderer::Base2dPreviewRenderer():
|
||||||
SoftwareRenderer()
|
SoftwareRenderer()
|
||||||
{
|
{
|
||||||
scenery = new Scenery();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Base2dPreviewRenderer::~Base2dPreviewRenderer()
|
Base2dPreviewRenderer::~Base2dPreviewRenderer()
|
||||||
{
|
{
|
||||||
delete scenery;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Base2dPreviewRenderer::bindEvent(BasePreview*)
|
void Base2dPreviewRenderer::bindEvent(BasePreview*)
|
||||||
|
|
|
@ -22,9 +22,6 @@ public:
|
||||||
|
|
||||||
virtual void updateEvent();
|
virtual void updateEvent();
|
||||||
virtual Color getColor2D(double x, double y, double scaling);
|
virtual Color getColor2D(double x, double y, double scaling);
|
||||||
|
|
||||||
protected:
|
|
||||||
Scenery* scenery;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -646,10 +646,7 @@ QColor BasePreview::getPixelColor(int x, int y)
|
||||||
{
|
{
|
||||||
col = colorProfileApply(_hdr_profile, col);
|
col = colorProfileApply(_hdr_profile, col);
|
||||||
}
|
}
|
||||||
else
|
col.normalize();
|
||||||
{
|
|
||||||
colorNormalize(&col);
|
|
||||||
}
|
|
||||||
return QColor::fromRgbF(col.r, col.g, col.b, col.a);
|
return QColor::fromRgbF(col.r, col.g, col.b, col.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,12 @@ SoftwareRenderer::SoftwareRenderer(Scenery* scenery)
|
||||||
if (scenery)
|
if (scenery)
|
||||||
{
|
{
|
||||||
this->scenery = scenery;
|
this->scenery = scenery;
|
||||||
|
own_scenery = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->scenery = Scenery::getCurrent();
|
this->scenery = new Scenery;
|
||||||
|
own_scenery = true;
|
||||||
}
|
}
|
||||||
this->scenery->bindToRenderer(this);
|
this->scenery->bindToRenderer(this);
|
||||||
}
|
}
|
||||||
|
@ -47,6 +49,11 @@ SoftwareRenderer::~SoftwareRenderer()
|
||||||
delete atmosphere_renderer;
|
delete atmosphere_renderer;
|
||||||
|
|
||||||
delete fluid_medium;
|
delete fluid_medium;
|
||||||
|
|
||||||
|
if (own_scenery)
|
||||||
|
{
|
||||||
|
delete scenery;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftwareRenderer::prepare()
|
void SoftwareRenderer::prepare()
|
||||||
|
@ -56,6 +63,7 @@ void SoftwareRenderer::prepare()
|
||||||
atmosphere_renderer = new SoftwareBrunetonAtmosphereRenderer(this);
|
atmosphere_renderer = new SoftwareBrunetonAtmosphereRenderer(this);
|
||||||
|
|
||||||
// Setup transitional renderers (for C-legacy subsystems)
|
// Setup transitional renderers (for C-legacy subsystems)
|
||||||
|
AtmosphereDefinitionClass.copy(scenery->getAtmosphere(), atmosphere->definition);
|
||||||
atmosphere->applyAerialPerspective = _legacyApplyAerialPerspective;
|
atmosphere->applyAerialPerspective = _legacyApplyAerialPerspective;
|
||||||
atmosphere->getSkyColor = _legacyGetSkyColor;
|
atmosphere->getSkyColor = _legacyGetSkyColor;
|
||||||
atmosphere->getLightingStatus = _legacyGetLightingStatus;
|
atmosphere->getLightingStatus = _legacyGetLightingStatus;
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Scenery* scenery;
|
Scenery* scenery;
|
||||||
|
bool own_scenery;
|
||||||
FluidMediumManager* fluid_medium;
|
FluidMediumManager* fluid_medium;
|
||||||
BaseAtmosphereRenderer* atmosphere_renderer;
|
BaseAtmosphereRenderer* atmosphere_renderer;
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,17 +11,14 @@ class FluidMediumManager_Test:public BaseTestCase
|
||||||
protected:
|
protected:
|
||||||
virtual void setUp()
|
virtual void setUp()
|
||||||
{
|
{
|
||||||
scenery = new Scenery();
|
renderer = new SoftwareRenderer();
|
||||||
renderer = new SoftwareRenderer(scenery);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void tearDown()
|
virtual void tearDown()
|
||||||
{
|
{
|
||||||
delete renderer;
|
delete renderer;
|
||||||
delete scenery;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Scenery* scenery;
|
|
||||||
SoftwareRenderer* renderer;
|
SoftwareRenderer* renderer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue