From d0bd8ee511e8dd070adab249087a16f3a8f5f907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Sat, 24 Nov 2012 14:19:43 +0000 Subject: [PATCH] paysages : Several bugfixes. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@466 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- TODO | 1 + gui_qt/basepreview.cpp | 8 ++++---- gui_qt/dialogrender.cpp | 2 +- gui_qt/formtextures.cpp | 12 ++++++++++-- gui_qt/inputcolor.cpp | 5 +++-- gui_qt/inputcurve.cpp | 5 +++-- gui_qt/inputdouble.cpp | 14 ++++++++++---- gui_qt/inputdouble.h | 3 +++ gui_qt/inputint.cpp | 2 +- lib_paysages/color.c | 1 + lib_paysages/water.c | 3 +++ 11 files changed, 40 insertions(+), 16 deletions(-) diff --git a/TODO b/TODO index 7d0fe9e..f209f77 100644 --- a/TODO +++ b/TODO @@ -16,6 +16,7 @@ Technology Preview 2 : => Add detail boost (adds granularity) => Add step boost (for marching algorithms) - Waves noise should not change layers offsets each time a setting is changed (layers are reconstructed currently). +- Fix rendering when inside a cloud layer, with other upper or lower layers. - Add "hardness to light" and shadow control ("minimum lighting") to material. Technlogy Preview 3 : diff --git a/gui_qt/basepreview.cpp b/gui_qt/basepreview.cpp index b6e1af7..a856c5d 100644 --- a/gui_qt/basepreview.cpp +++ b/gui_qt/basepreview.cpp @@ -427,7 +427,7 @@ void BasePreview::updateData() { } -QColor BasePreview::getColor(double x, double y) +QColor BasePreview::getColor(double, double) { return QColor(0, 0, 0); } @@ -606,7 +606,7 @@ void BasePreview::choiceSelected(QAction* action) } } -void BasePreview::showEvent(QShowEvent* event) +void BasePreview::showEvent(QShowEvent*) { updateChunks(); } @@ -643,7 +643,7 @@ void BasePreview::resizeEvent(QResizeEvent* event) this->_lock_drawing->unlock(); } -void BasePreview::paintEvent(QPaintEvent* event) +void BasePreview::paintEvent(QPaintEvent*) { QPainter painter(this); painter.drawImage(0, 0, *this->_pixbuf); @@ -964,7 +964,7 @@ void BasePreview::wheelEvent(QWheelEvent* event) event->accept(); } -void BasePreview::leaveEvent(QEvent* event) +void BasePreview::leaveEvent(QEvent*) { _info->setVisible(false); } diff --git a/gui_qt/dialogrender.cpp b/gui_qt/dialogrender.cpp index 46d5675..773c084 100644 --- a/gui_qt/dialogrender.cpp +++ b/gui_qt/dialogrender.cpp @@ -58,7 +58,7 @@ public: setMinimumSize(800, 600); } - void paintEvent(QPaintEvent* event) + void paintEvent(QPaintEvent*) { QPainter painter(this); painter.drawImage(0, 0, *_current_dialog->pixbuf); diff --git a/gui_qt/formtextures.cpp b/gui_qt/formtextures.cpp index bd17dad..8b4db04 100644 --- a/gui_qt/formtextures.cpp +++ b/gui_qt/formtextures.cpp @@ -179,10 +179,18 @@ void FormTextures::applyConfig() void FormTextures::layerGetCopy(void* layer_definition) { - texturesLayerCopyDefinition((TextureLayerDefinition*)layer_definition, _layer); + TextureLayerDefinition* source = (TextureLayerDefinition*)layer_definition; + texturesLayerCopyDefinition(source, _layer); + + zoneGetHeightCurve(source->zone, _supp.height_curve); + zoneGetSlopeCurve(source->zone, _supp.slope_curve); } void FormTextures::layerApply(void* layer_definition) { - texturesLayerCopyDefinition(_layer, (TextureLayerDefinition*)layer_definition); + TextureLayerDefinition* destination = (TextureLayerDefinition*)layer_definition; + texturesLayerCopyDefinition(_layer, destination); + + zoneSetHeightCurve(destination->zone, _supp.height_curve); + zoneSetSlopeCurve(destination->zone, _supp.slope_curve); } diff --git a/gui_qt/inputcolor.cpp b/gui_qt/inputcolor.cpp index e858e0e..db6bdbe 100644 --- a/gui_qt/inputcolor.cpp +++ b/gui_qt/inputcolor.cpp @@ -4,6 +4,7 @@ #include #include #include +#include "tools.h" class ColorPreview:public QWidget { @@ -13,7 +14,7 @@ public: { } - void paintEvent(QPaintEvent* event) + void paintEvent(QPaintEvent*) { QPainter painter(this); painter.fillRect(this->rect(), col); @@ -50,7 +51,7 @@ void InputColor::applyValue() void InputColor::revert() { - ((ColorPreview*)_preview)->col = QColor::fromRgbF(_value->r, _value->g, _value->b); + ((ColorPreview*)_preview)->col = colorToQColor(*_value); BaseInput::revert(); } diff --git a/gui_qt/inputcurve.cpp b/gui_qt/inputcurve.cpp index 6058cda..baa0b15 100644 --- a/gui_qt/inputcurve.cpp +++ b/gui_qt/inputcurve.cpp @@ -4,6 +4,7 @@ #include #include #include "dialogcurve.h" +#include "tools.h" class CurveSmallPreview:public QWidget { @@ -17,13 +18,13 @@ public: _ymax = ymax; } - void paintEvent(QPaintEvent* event) + void paintEvent(QPaintEvent*) { if (!_curve) { return; } - + QPainter painter(this); int width = this->width(); int height = this->height(); diff --git a/gui_qt/inputdouble.cpp b/gui_qt/inputdouble.cpp index 39b2226..8583dd2 100644 --- a/gui_qt/inputdouble.cpp +++ b/gui_qt/inputdouble.cpp @@ -39,22 +39,28 @@ void InputDouble::updatePreview() BaseInput::updatePreview(); } -void InputDouble::applyValue() +double InputDouble::getValue() { + double result; int ivalue = _slider->value(); if (ivalue == _slider->maximum()) { - *_value = _max; + result = _max; } else { - *_value = _min + ((double)ivalue) * _small_step; + result = _min + ((double)ivalue) * _small_step; } if (fabs(*_value) < 0.0000001) { - *_value = 0.0; + result = 0.0; } + return result; +} +void InputDouble::applyValue() +{ + *_value = getValue(); BaseInput::applyValue(); } diff --git a/gui_qt/inputdouble.h b/gui_qt/inputdouble.h index 6df19e0..89115c5 100644 --- a/gui_qt/inputdouble.h +++ b/gui_qt/inputdouble.h @@ -16,6 +16,9 @@ public slots: virtual void updatePreview(); virtual void applyValue(); virtual void revert(); + +protected: + double getValue(); private: QSlider* _slider; diff --git a/gui_qt/inputint.cpp b/gui_qt/inputint.cpp index 016e8bf..15ded3d 100644 --- a/gui_qt/inputint.cpp +++ b/gui_qt/inputint.cpp @@ -16,7 +16,7 @@ void InputInt::updatePreview() void InputInt::applyValue() { - *_value = (int)_dvalue; + *_value = (int)getValue(); InputDouble::applyValue(); } diff --git a/lib_paysages/color.c b/lib_paysages/color.c index 34bc0f3..227907c 100644 --- a/lib_paysages/color.c +++ b/lib_paysages/color.c @@ -127,6 +127,7 @@ double colorNormalize(Color* col) { double max = colorGetValue(col); + assert(max >= 0.0); assert(col->r >= 0.0); assert(col->g >= 0.0); assert(col->b >= 0.0); diff --git a/lib_paysages/water.c b/lib_paysages/water.c index 58a8413..f0f6aed 100644 --- a/lib_paysages/water.c +++ b/lib_paysages/water.c @@ -61,6 +61,8 @@ WaterDefinition waterCreateDefinition() result.height = -4.0; result._waves_noise = noiseCreateGenerator(); + waterAutoPreset(&result, WATER_PRESET_LAKE); + return result; } @@ -115,6 +117,7 @@ void waterAutoPreset(WaterDefinition* definition, WaterPreset preset) definition->foam_material.base.r = 0.8; definition->foam_material.base.g = 0.8; definition->foam_material.base.b = 0.8; + definition->foam_material.base.a = 1.0; definition->foam_material.reflection = 0.4; definition->foam_material.shininess = 1.5;