Don't copy scenery in the renderer

This commit is contained in:
Michaël Lemaire 2015-08-18 22:29:18 +02:00
parent db0be5204f
commit 56dae1e38e
10 changed files with 20 additions and 41 deletions

View file

@ -203,9 +203,8 @@ int main(int argc, char** argv)
Vector3 step = {conf_camera_step_x, conf_camera_step_y, conf_camera_step_z}; Vector3 step = {conf_camera_step_x, conf_camera_step_y, conf_camera_step_z};
camera->setLocation(camera->getLocation().add(step)); camera->setLocation(camera->getLocation().add(step));
renderer = new SoftwareCanvasRenderer(); renderer = new SoftwareCanvasRenderer(scenery);
renderer->setConfig(conf_render_params); renderer->setConfig(conf_render_params);
renderer->setScenery(scenery);
if (outputcount >= conf_first_picture) if (outputcount >= conf_first_picture)
{ {

View file

@ -17,12 +17,12 @@
MainModelerWindow::MainModelerWindow() MainModelerWindow::MainModelerWindow()
{ {
Scenery scenery; scenery = new Scenery();
scenery.autoPreset(); scenery->autoPreset();
Logs::debug() << "Initialized scenery:\n" << scenery.toString() << std::endl; Logs::debug() << "Initialized scenery:\n" << scenery->toString() << std::endl;
renderer = new OpenGLRenderer(&scenery); renderer = new OpenGLRenderer(scenery);
render_preview_provider = new RenderPreviewProvider(); render_preview_provider = new RenderPreviewProvider();
@ -77,11 +77,6 @@ void MainModelerWindow::setState(const QString &stateName)
rootObject()->setProperty("state", stateName); rootObject()->setProperty("state", stateName);
} }
Scenery *MainModelerWindow::getScenery() const
{
return renderer->getScenery();
}
void MainModelerWindow::keyReleaseEvent(QKeyEvent *event) void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
{ {
if (getState() == "Render Dialog") if (getState() == "Render Dialog")

View file

@ -21,7 +21,7 @@ public:
QString getState() const; QString getState() const;
void setState(const QString &stateName); void setState(const QString &stateName);
Scenery *getScenery() const; inline Scenery *getScenery() const {return scenery;}
inline OpenGLRenderer *getRenderer() const {return renderer;} inline OpenGLRenderer *getRenderer() const {return renderer;}
inline ModelerCameras *getCamera() const {return cameras;} inline ModelerCameras *getCamera() const {return cameras;}
@ -29,6 +29,7 @@ protected:
virtual void keyReleaseEvent(QKeyEvent *event) override; virtual void keyReleaseEvent(QKeyEvent *event) override;
private: private:
Scenery *scenery;
OpenGLRenderer *renderer; OpenGLRenderer *renderer;
AtmosphereModeler *atmosphere; AtmosphereModeler *atmosphere;

View file

@ -76,8 +76,7 @@ void RenderProcess::startRender(Scenery *scenery, const RenderConfig &config)
delete renderer; delete renderer;
} }
renderer = new SoftwareCanvasRenderer(); renderer = new SoftwareCanvasRenderer(scenery);
renderer->setScenery(scenery);
renderer->setConfig(config); renderer->setConfig(config);
destination->setCanvas(renderer->getCanvas()); destination->setCanvas(renderer->getCanvas());

View file

@ -14,7 +14,7 @@ namespace opengl {
class OPENGLSHARED_EXPORT OpenGLRenderer: public SoftwareRenderer class OPENGLSHARED_EXPORT OpenGLRenderer: public SoftwareRenderer
{ {
public: public:
OpenGLRenderer(Scenery* scenery=0); OpenGLRenderer(Scenery* scenery);
virtual ~OpenGLRenderer(); virtual ~OpenGLRenderer();
inline OpenGLSkybox *getSkybox() const {return skybox;} inline OpenGLSkybox *getSkybox() const {return skybox;}

View file

@ -14,7 +14,8 @@
#include "ColorProfile.h" #include "ColorProfile.h"
#include "CanvasPreview.h" #include "CanvasPreview.h"
SoftwareCanvasRenderer::SoftwareCanvasRenderer() SoftwareCanvasRenderer::SoftwareCanvasRenderer(Scenery *scenery):
SoftwareRenderer(scenery)
{ {
started = false; started = false;
finished = false; finished = false;

View file

@ -19,7 +19,7 @@ namespace software {
class SOFTWARESHARED_EXPORT SoftwareCanvasRenderer: public SoftwareRenderer class SOFTWARESHARED_EXPORT SoftwareCanvasRenderer: public SoftwareRenderer
{ {
public: public:
SoftwareCanvasRenderer(); SoftwareCanvasRenderer(Scenery *scenery);
virtual ~SoftwareCanvasRenderer(); virtual ~SoftwareCanvasRenderer();
inline const Canvas *getCanvas() const {return canvas;} inline const Canvas *getCanvas() const {return canvas;}

View file

@ -20,14 +20,9 @@
#include "System.h" #include "System.h"
#include "Thread.h" #include "Thread.h"
SoftwareRenderer::SoftwareRenderer(Scenery* scenery) SoftwareRenderer::SoftwareRenderer(Scenery* scenery):
scenery(scenery)
{ {
this->scenery = new Scenery;
if (scenery)
{
scenery->copy(this->scenery);
}
render_quality = 5; render_quality = 5;
render_camera = new CameraDefinition; render_camera = new CameraDefinition;
@ -61,13 +56,6 @@ SoftwareRenderer::~SoftwareRenderer()
delete terrain_renderer; delete terrain_renderer;
delete textures_renderer; delete textures_renderer;
delete water_renderer; delete water_renderer;
delete scenery;
}
void SoftwareRenderer::setScenery(Scenery* scenery)
{
scenery->copy(this->scenery);
} }
void SoftwareRenderer::prepare() void SoftwareRenderer::prepare()

View file

@ -15,7 +15,7 @@ class SOFTWARESHARED_EXPORT SoftwareRenderer
{ {
public: public:
SoftwareRenderer(Scenery* scenery=0); SoftwareRenderer(Scenery* scenery);
virtual ~SoftwareRenderer(); virtual ~SoftwareRenderer();
/* Render base configuration */ /* Render base configuration */
@ -30,13 +30,6 @@ public:
virtual Vector3 projectPoint(const Vector3 &point); virtual Vector3 projectPoint(const Vector3 &point);
virtual Vector3 unprojectPoint(const Vector3 &point); virtual Vector3 unprojectPoint(const Vector3 &point);
/*!
* \brief Set the scenery to render.
*
* Don't call this after rendering has already started.
*/
virtual void setScenery(Scenery* scenery);
/*! /*!
* \brief Prepare the renderer sub-systems. * \brief Prepare the renderer sub-systems.
* *

View file

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