From 1f58b866e664c3effa5d5b046e1ed3e39b8102c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Sat, 10 Nov 2012 17:05:01 +0000 Subject: [PATCH] paysages : Small fixes. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@462 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- TODO | 11 +++--- gui_qt/baseformlayer.cpp | 3 +- lib_paysages/camera.c | 12 +++---- lib_paysages/scenery.c | 18 ---------- lib_paysages/scenery.h | 4 --- lib_paysages/system.c | 2 ++ lib_paysages/system.h | 16 +++++++++ lib_paysages/terraincanvas.c | 2 +- lib_paysages/vegetation.c | 68 ------------------------------------ lib_paysages/vegetation.h | 46 ------------------------ 10 files changed, 33 insertions(+), 149 deletions(-) delete mode 100644 lib_paysages/vegetation.c delete mode 100644 lib_paysages/vegetation.h diff --git a/TODO b/TODO index e680d85..0d1f996 100644 --- a/TODO +++ b/TODO @@ -1,11 +1,7 @@ Technology Preview 2 : - Fully move layer management from BaseForm to BaseFormLayer. - Replace math.h methods by optimized ones (fastfloor, fastsin...). -- Replace terrain canvas editor by full sculpting editor. - => Add a generation dialog, with fixed resolution. - => Store local terrain modifications in fully dynamic canvas. - => Add map preview with editor area. - => Allow camera move and zoom. +- Add foam to water. - Finalize Preetham's model usage => Apply model to atmosphere (aerial perspective) => Find a proper model for night sky (maybe Shirley) @@ -16,6 +12,11 @@ Technology Preview 2 : Technlogy Preview 3 : - Add logarithmic sliders for some float values. +- Replace terrain canvas editor by full sculpting editor. + => Add a generation dialog, with fixed resolution. + => Store local terrain modifications in fully dynamic canvas. + => Add map preview with editor area. + => Allow camera move and zoom. - Improve previews. => Add user markers on OSD. => Add areas marking. diff --git a/gui_qt/baseformlayer.cpp b/gui_qt/baseformlayer.cpp index 8c930ae..cff43f5 100644 --- a/gui_qt/baseformlayer.cpp +++ b/gui_qt/baseformlayer.cpp @@ -8,7 +8,8 @@ BaseFormLayer::BaseFormLayer(QWidget* parent, Layers* layers) : BaseForm(parent, _layers_modified = NULL; if (layers) { - setLayers(layers); + _layers_original = layers; + _layers_modified = layersCreateCopy(_layers_original); } } diff --git a/lib_paysages/camera.c b/lib_paysages/camera.c index 21f67a6..84221a0 100644 --- a/lib_paysages/camera.c +++ b/lib_paysages/camera.c @@ -2,7 +2,6 @@ #include #include -#include #include "euclid.h" #include "render.h" #include "shared/types.h" @@ -287,11 +286,12 @@ Vector3 cameraUnproject(CameraDefinition* camera, Renderer* renderer, Vector3 po static inline void _updateBox(Vector3* point, double* xmin, double* xmax, double* ymin, double* ymax, double* zmax) { - *xmin = MIN(*xmin, point->x); - *xmax = MAX(*xmax, point->x); - *ymin = MIN(*ymin, point->y); - *ymax = MAX(*ymax, point->y); - *zmax = MAX(*zmax, point->z); + *xmin = (*xmin < point->x) ? *xmin : point->x; + *ymin = (*ymin < point->y) ? *ymin : point->y; + + *xmax = (*xmax > point->x) ? *xmax : point->x; + *ymax = (*ymax > point->y) ? *ymax : point->y; + *zmax = (*zmax > point->z) ? *zmax : point->z; } int cameraIsBoxInView(CameraDefinition* camera, Vector3 center, double xsize, double ysize, double zsize) diff --git a/lib_paysages/scenery.c b/lib_paysages/scenery.c index 1a3fbeb..38ddd16 100644 --- a/lib_paysages/scenery.c +++ b/lib_paysages/scenery.c @@ -5,7 +5,6 @@ #include "euclid.h" #include "render.h" #include "system.h" -#include "vegetation.h" static AtmosphereDefinition _atmosphere; static CameraDefinition _camera; @@ -14,7 +13,6 @@ static LightingDefinition _lighting; static SkyDefinition _sky; static TerrainDefinition _terrain; static TexturesDefinition _textures; -static VegetationDefinition* _vegetation; static WaterDefinition _water; static SceneryCustomDataCallback _custom_save = NULL; @@ -33,7 +31,6 @@ void sceneryInit() _sky = skyCreateDefinition(); _terrain = terrainCreateDefinition(); _textures = texturesCreateDefinition(); - _vegetation = vegetationCreateDefinition(); _water = waterCreateDefinition(); _custom_save = NULL; @@ -49,7 +46,6 @@ void sceneryQuit() skyDeleteDefinition(&_sky); terrainDeleteDefinition(&_terrain); texturesDeleteDefinition(&_textures); - vegetationDeleteDefinition(_vegetation); waterDeleteDefinition(&_water); lightingQuit(); @@ -73,7 +69,6 @@ void scenerySave(PackStream* stream) skySave(stream, &_sky); terrainSave(stream, &_terrain); texturesSave(stream, &_textures); - vegetationSave(stream, _vegetation); waterSave(stream, &_water); if (_custom_save) @@ -94,7 +89,6 @@ void sceneryLoad(PackStream* stream) skyLoad(stream, &_sky); terrainLoad(stream, &_terrain); texturesLoad(stream, &_textures); - vegetationLoad(stream, _vegetation); waterLoad(stream, &_water); atmosphereValidateDefinition(&_atmosphere); @@ -104,7 +98,6 @@ void sceneryLoad(PackStream* stream) skyValidateDefinition(&_sky); terrainValidateDefinition(&_terrain); texturesValidateDefinition(&_textures); - vegetationValidateDefinition(_vegetation); waterValidateDefinition(&_water); if (_custom_load) @@ -195,17 +188,6 @@ void sceneryGetTextures(TexturesDefinition* textures) texturesCopyDefinition(&_textures, textures); } -void scenerySetVegetation(VegetationDefinition* vegetation) -{ - vegetationCopyDefinition(vegetation, _vegetation); - vegetationValidateDefinition(_vegetation); -} - -void sceneryGetTVegetation(VegetationDefinition* vegetation) -{ - vegetationCopyDefinition(_vegetation, vegetation); -} - void scenerySetWater(WaterDefinition* water) { waterCopyDefinition(water, &_water); diff --git a/lib_paysages/scenery.h b/lib_paysages/scenery.h index f8cc370..acd0595 100644 --- a/lib_paysages/scenery.h +++ b/lib_paysages/scenery.h @@ -15,7 +15,6 @@ #include "sky.h" #include "terrain.h" #include "textures.h" -#include "vegetation.h" #include "water.h" #include "pack.h" #include "renderer.h" @@ -55,9 +54,6 @@ void sceneryGetTerrain(TerrainDefinition* terrain); void scenerySetTextures(TexturesDefinition* textures); void sceneryGetTextures(TexturesDefinition* textures); -void scenerySetVegetation(VegetationDefinition* vegetation); -void sceneryGetVegetation(VegetationDefinition* vegetation); - void scenerySetWater(WaterDefinition* water); void sceneryGetWater(WaterDefinition* water); diff --git a/lib_paysages/system.c b/lib_paysages/system.c index 04f88af..83755c2 100644 --- a/lib_paysages/system.c +++ b/lib_paysages/system.c @@ -49,7 +49,9 @@ static int _getCoreCount() void systemInit() { +#ifndef GLIB_VERSION_2_32 g_thread_init(NULL); +#endif _core_count = _getCoreCount(); ilInit(); iluInit(); diff --git a/lib_paysages/system.h b/lib_paysages/system.h index eebf441..c87b528 100644 --- a/lib_paysages/system.h +++ b/lib_paysages/system.h @@ -4,6 +4,7 @@ /* Library dependent features */ #include "color.h" +#include #ifdef __cplusplus extern "C" { @@ -27,8 +28,12 @@ typedef GThread Thread; static inline Thread* threadCreate(ThreadFunction function, void* data) { +#ifdef GLIB_VERSION_2_32 + return g_thread_new("thread", (GThreadFunc)function, data); +#else GError* error; return g_thread_create((GThreadFunc)function, data, 1, &error); +#endif } static inline void* threadJoin(Thread* thread) @@ -40,12 +45,23 @@ typedef GMutex Mutex; static inline Mutex* mutexCreate() { +#ifdef GLIB_VERSION_2_32 + Mutex* mutex = malloc(sizeof(Mutex)); + g_mutex_init(mutex); + return mutex; +#else return g_mutex_new(); +#endif } static inline void mutexDestroy(Mutex* mutex) { +#ifdef GLIB_VERSION_2_32 + g_mutex_clear(mutex); + free(mutex); +#else g_mutex_free(mutex); +#endif } static inline void mutexAcquire(Mutex* mutex) diff --git a/lib_paysages/terraincanvas.c b/lib_paysages/terraincanvas.c index 8f82c07..2eefaa6 100644 --- a/lib_paysages/terraincanvas.c +++ b/lib_paysages/terraincanvas.c @@ -122,7 +122,7 @@ Vector3 terrainCanvasApply(TerrainCanvas* canvas, Vector3 location) location.z <= canvas->area.location_z + canvas->area.size_z) { double inside_x, inside_z; - double height, distance; + double height; /* Get height map displacement */ geoareaToLocal(&canvas->area, location.x, location.z, &inside_x, &inside_z); diff --git a/lib_paysages/vegetation.c b/lib_paysages/vegetation.c deleted file mode 100644 index af8acda..0000000 --- a/lib_paysages/vegetation.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "vegetation.h" - -#define MAX_LAYER_COUNT 50 - -struct VegetationDefinition { - int nb_layers; - VegetationLayerDefinition layers[MAX_LAYER_COUNT]; -}; - -void vegetationSave(PackStream* stream, VegetationDefinition* definition) -{ -} - -void vegetationLoad(PackStream* stream, VegetationDefinition* definition) -{ -} - -VegetationDefinition* vegetationCreateDefinition() -{ -} - -void vegetationDeleteDefinition(VegetationDefinition* definition) -{ -} - -void vegetationCopyDefinition(VegetationDefinition* source, VegetationDefinition* destination) -{ -} - -void vegetationValidateDefinition(VegetationDefinition* definition) -{ -} - -VegetationLayerDefinition vegetationLayerCreateDefinition() -{ -} - -void vegetationLayerDeleteDefinition(VegetationLayerDefinition* definition) -{ -} - -void vegetationLayerCopyDefinition(VegetationLayerDefinition* source, VegetationLayerDefinition* destination) -{ -} - -void vegetationLayerValidateDefinition(VegetationLayerDefinition* definition) -{ -} - -int vegetationGetLayerCount(VegetationDefinition* definition) -{ -} - -int vegetationGetLayer(VegetationDefinition* definition, int position, VegetationLayerDefinition* layer) -{ -} - -int vegetationSetLayer(VegetationDefinition* definition, int position, VegetationLayerDefinition* layer) -{ -} - -int vegetationAddLayer(VegetationDefinition* definition) -{ -} - -void vegetationDeleteLayer(VegetationDefinition* definition, int layer) -{ -} diff --git a/lib_paysages/vegetation.h b/lib_paysages/vegetation.h deleted file mode 100644 index d9d6b62..0000000 --- a/lib_paysages/vegetation.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef _PAYSAGES_VEGETATION_H_ -#define _PAYSAGES_VEGETATION_H_ - -#include "pack.h" -#include "zone.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define VEGETATION_MAX_LAYERS 50 - -typedef struct -{ - Zone* zone; - double max_height; -} VegetationLayerDefinition; - -typedef struct VegetationDefinition VegetationDefinition; - -void vegetationSave(PackStream* stream, VegetationDefinition* definition); -void vegetationLoad(PackStream* stream, VegetationDefinition* definition); - -VegetationDefinition* vegetationCreateDefinition(); -void vegetationDeleteDefinition(VegetationDefinition* definition); -void vegetationCopyDefinition(VegetationDefinition* source, VegetationDefinition* destination); -void vegetationValidateDefinition(VegetationDefinition* definition); - -VegetationLayerDefinition vegetationLayerCreateDefinition(); -void vegetationLayerDeleteDefinition(VegetationLayerDefinition* definition); -void vegetationLayerCopyDefinition(VegetationLayerDefinition* source, VegetationLayerDefinition* destination); -void vegetationLayerValidateDefinition(VegetationLayerDefinition* definition); - -int vegetationGetLayerCount(VegetationDefinition* definition); -int vegetationGetLayer(VegetationDefinition* definition, int position, VegetationLayerDefinition* layer); -int vegetationSetLayer(VegetationDefinition* definition, int position, VegetationLayerDefinition* layer); -int vegetationAddLayer(VegetationDefinition* definition); -void vegetationDeleteLayer(VegetationDefinition* definition, int layer); - -/*double vegetationGetLayerCoverage(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail);*/ - -#ifdef __cplusplus -} -#endif - -#endif