From d401d0105c2d9402f33f2f6571b223e346e0a63e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Sun, 16 Jun 2013 23:01:22 +0200 Subject: [PATCH] A little cleaning, and fixed some camera issues --- TODO | 2 ++ src/editing/common/mainwindow.cpp | 6 ++++-- src/editing/dialogrender.cpp | 1 - src/rendering/auto.c | 21 --------------------- src/rendering/auto.h | 16 ---------------- src/rendering/camera.c | 4 ++-- src/rendering/main.c | 3 --- src/rendering/scenery.c | 18 +++++++++++++++--- src/rendering/scenery.h | 2 +- 9 files changed, 24 insertions(+), 49 deletions(-) delete mode 100644 src/rendering/auto.c delete mode 100644 src/rendering/auto.h diff --git a/TODO b/TODO index 0167dfb..e4eb6b5 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,6 @@ Technology Preview 2 : +- Investigate the preview render threads dying. +- Add initial terrain offset so that the (0,0) coordinates are above water. - Finalize terrain editor. => Add a generation dialog for base noise (overwriting changes). - Get rid of noise dialogs, for simpler settings. diff --git a/src/editing/common/mainwindow.cpp b/src/editing/common/mainwindow.cpp index 38c1b09..d48224d 100644 --- a/src/editing/common/mainwindow.cpp +++ b/src/editing/common/mainwindow.cpp @@ -25,7 +25,6 @@ #include "dialogexplorer.h" #include "rendering/main.h" -#include "rendering/auto.h" #include "rendering/scenery.h" #include "tools.h" @@ -126,6 +125,9 @@ MainWindow::MainWindow(QWidget *parent) : scenerySetCustomDataCallback(MainWindow::guiSaveCallback, MainWindow::guiLoadCallback, this); + // FIXME AutoPreset has already been called by paysagesInit but we need to redo it here because + // the auto apply on FormRender overwrites the camera. Delete this when the render form is no longer a BaseForm. + sceneryAutoPreset(0); refreshAll(); } @@ -170,7 +172,7 @@ void MainWindow::fileNew() { if (QMessageBox::question(this, tr("Paysages 3D - New scenery"), tr("Do you want to start a new scenery ? Any unsaved changes will be lost."), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) { - autoGenRealisticLandscape(0); + sceneryAutoPreset(0); refreshAll(); } } diff --git a/src/editing/dialogrender.cpp b/src/editing/dialogrender.cpp index 64f7d05..00a842c 100644 --- a/src/editing/dialogrender.cpp +++ b/src/editing/dialogrender.cpp @@ -13,7 +13,6 @@ #include "tools.h" #include "rendering/scenery.h" -#include "rendering/auto.h" static DialogRender* _current_dialog; diff --git a/src/rendering/auto.c b/src/rendering/auto.c deleted file mode 100644 index 8b0690a..0000000 --- a/src/rendering/auto.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "auto.h" - -#include -#include -#include - -#include "render.h" -#include "scenery.h" -#include "system.h" -#include "zone.h" - -void autoGenRealisticLandscape(int seed) -{ - if (!seed) - { - seed = time(NULL); - } - srand(seed); - - sceneryAutoPreset(); -} diff --git a/src/rendering/auto.h b/src/rendering/auto.h deleted file mode 100644 index 341594a..0000000 --- a/src/rendering/auto.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _PAYSAGES_AUTO_H_ -#define _PAYSAGES_AUTO_H_ - -#include "renderer.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void autoGenRealisticLandscape(int seed); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/rendering/camera.c b/src/rendering/camera.c index 8967525..f00b475 100644 --- a/src/rendering/camera.c +++ b/src/rendering/camera.c @@ -116,9 +116,9 @@ void cameraValidateDefinition(CameraDefinition* definition, int check_above) } } - if (definition->location.y > 100.0) + if (definition->location.y > 300.0) { - definition->location.y = 100.0; + definition->location.y = 300.0; } definition->forward.x = 1.0; diff --git a/src/rendering/main.c b/src/rendering/main.c index 3006430..2aaaa45 100644 --- a/src/rendering/main.c +++ b/src/rendering/main.c @@ -1,7 +1,6 @@ #include #include -#include "auto.h" #include "tools/data.h" #include "system.h" #include "scenery.h" @@ -24,8 +23,6 @@ void paysagesInit() sceneryInit(); renderInit(); - - autoGenRealisticLandscape(0); } void paysagesQuit() diff --git a/src/rendering/scenery.c b/src/rendering/scenery.c index 292ddd5..1f5dfb5 100644 --- a/src/rendering/scenery.c +++ b/src/rendering/scenery.c @@ -1,5 +1,6 @@ #include "scenery.h" +#include #include "tools/color.h" #include "tools/euclid.h" #include "render.h" @@ -29,6 +30,8 @@ void sceneryInit() _custom_save = NULL; _custom_load = NULL; + + sceneryAutoPreset(0); } void sceneryQuit() @@ -43,13 +46,23 @@ void sceneryQuit() noiseQuit(); } -void sceneryAutoPreset() +void sceneryAutoPreset(int seed) { + if (!seed) + { + seed = time(NULL); + } + srand(seed); + terrainAutoPreset(_terrain, TERRAIN_PRESET_STANDARD); texturesAutoPreset(_textures, TEXTURES_PRESET_IRELAND); atmosphereAutoPreset(_atmosphere, ATMOSPHERE_PRESET_CLEAR_DAY); waterAutoPreset(_water, WATER_PRESET_LAKE); cloudsAutoPreset(_clouds, CLOUDS_PRESET_PARTLY_CLOUDY); + + cameraSetLocation(_camera, VECTOR_ZERO); + cameraSetTarget(_camera, VECTOR_NORTH); + cameraValidateDefinition(_camera, 1); } void scenerySetCustomDataCallback(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data) @@ -203,8 +216,6 @@ Renderer* sceneryCreateStandardRenderer() result = rendererCreate(); - cameraCopyDefinition(_camera, result->render_camera); - result->rayWalking = _rayWalking; result->getPrecision = _getPrecision; @@ -215,6 +226,7 @@ Renderer* sceneryCreateStandardRenderer() void sceneryBindRenderer(Renderer* renderer) { + cameraCopyDefinition(_camera, renderer->render_camera); AtmosphereRendererClass.bind(renderer, _atmosphere); TerrainRendererClass.bind(renderer, _terrain); TexturesRendererClass.bind(renderer, _textures); diff --git a/src/rendering/scenery.h b/src/rendering/scenery.h index 17174d4..0783ab1 100644 --- a/src/rendering/scenery.h +++ b/src/rendering/scenery.h @@ -26,7 +26,7 @@ typedef void (*SceneryCustomDataCallback)(PackStream* stream, void* data); void sceneryInit(); void sceneryQuit(); -void sceneryAutoPreset(); +void sceneryAutoPreset(int seed); void scenerySetCustomDataCallback(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data);