diff --git a/src/editing/terrain/mainterrainform.cpp b/src/editing/terrain/mainterrainform.cpp index 600d74c..33ce6e4 100644 --- a/src/editing/terrain/mainterrainform.cpp +++ b/src/editing/terrain/mainterrainform.cpp @@ -7,6 +7,7 @@ #include "previewterrainshape.h" #include "tools.h" #include "rendering/scenery.h" +#include "rendering/textures/public.h" MainTerrainForm::MainTerrainForm(QWidget *parent) : QWidget(parent), @@ -67,7 +68,19 @@ void MainTerrainForm::refreshFromLocalData() void MainTerrainForm::refreshFromFellowData() { - // TODO Refresh texture info + TexturesDefinition* textures = (TexturesDefinition*)TexturesDefinitionClass.create(); + sceneryGetTextures(textures); + double disp = texturesGetMaximalDisplacement(textures); + TexturesDefinitionClass.destroy(textures); + + if (disp == 0.0) + { + ui->label_info_textures->setText(tr("No displacement textures")); + } + else + { + ui->label_info_textures->setText(tr("Maximal displacement : %1% of total height").arg(100.0 * disp / _terrain->height, 0, 'f', 1)); + } } void MainTerrainForm::updateLocalDataFromScenery() diff --git a/src/editing/terrain/mainterrainform.ui b/src/editing/terrain/mainterrainform.ui index e8372a1..0a74c6d 100644 --- a/src/editing/terrain/mainterrainform.ui +++ b/src/editing/terrain/mainterrainform.ui @@ -298,7 +298,7 @@ - + { textures info } diff --git a/src/editing/terrain/widgetheightmap.cpp b/src/editing/terrain/widgetheightmap.cpp index 3df50dd..b54418e 100644 --- a/src/editing/terrain/widgetheightmap.cpp +++ b/src/editing/terrain/widgetheightmap.cpp @@ -274,7 +274,6 @@ void WidgetHeightMap::timerEvent(QTimerEvent*) void WidgetHeightMap::initializeGL() { - glClearColor(0.0, 0.0, 0.0, 0.0); GLfloat light_diffuse[] = {0.75, 0.74, 0.7, 1.0}; @@ -312,7 +311,6 @@ void WidgetHeightMap::initializeGL() void WidgetHeightMap::resizeGL(int w, int h) { - glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); diff --git a/src/rendering/textures/public.h b/src/rendering/textures/public.h index d0f75e5..a4bfad3 100644 --- a/src/rendering/textures/public.h +++ b/src/rendering/textures/public.h @@ -96,6 +96,8 @@ LayerType texturesGetLayerType(); void texturesAutoPreset(TexturesDefinition* definition, TexturesPreset preset); void texturesLayerAutoPreset(TexturesLayerDefinition* definition, TexturesLayerPreset preset); +double texturesGetMaximalDisplacement(TexturesDefinition* textures); + /*Renderer* cloudsCreatePreviewCoverageRenderer(); Color cloudsGetPreviewCoverage(Renderer* renderer, double x, double y, double scaling, int perspective); diff --git a/src/rendering/textures/tex_tools.c b/src/rendering/textures/tex_tools.c index 83eec73..822ce3c 100644 --- a/src/rendering/textures/tex_tools.c +++ b/src/rendering/textures/tex_tools.c @@ -32,3 +32,20 @@ double texturesGetTriplanarNoise(NoiseGenerator* noise, Vector3 location, Vector return noiseXY * mXY + noiseXZ * mXZ + noiseYZ * mYZ; } + +double texturesGetMaximalDisplacement(TexturesDefinition* textures) +{ + int i, n; + double disp = 0.0; + n = layersCount(textures->layers); + for (i = 0; i < n; i++) + { + TexturesLayerDefinition* layer = layersGetLayer(textures->layers, i); + + if (layer->displacement_height > 0.0) + { + disp += layer->displacement_height; + } + } + return disp; +}