paysages : Small fix.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@472 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-12-06 14:04:04 +00:00 committed by ThunderK
parent 1b011672a2
commit 237040864d
8 changed files with 56 additions and 56 deletions

View file

@ -28,7 +28,7 @@ void BaseFormLayer::revertConfig()
layersCopy(_layers_original, _layers_modified); layersCopy(_layers_original, _layers_modified);
layerSelectedEvent(currentLayer()); layerSelectedEvent(currentLayer());
} }
BaseForm::revertConfig(); BaseForm::revertConfig();
} }
@ -38,7 +38,7 @@ void BaseFormLayer::applyConfig()
{ {
layersCopy(_layers_modified, _layers_original); layersCopy(_layers_modified, _layers_original);
} }
BaseForm::applyConfig(); BaseForm::applyConfig();
} }
@ -61,17 +61,17 @@ void BaseFormLayer::configChangeEvent()
{ {
if (_layers_modified) if (_layers_modified)
{ {
layerApply(layersGetLayer(_layers_modified, currentLayer())); layerWriteCurrentTo(layersGetLayer(_layers_modified, currentLayer()));
layersValidate(_layers_modified); layersValidate(_layers_modified);
} }
BaseForm::configChangeEvent(); BaseForm::configChangeEvent();
} }
QStringList BaseFormLayer::getLayers() QStringList BaseFormLayer::getLayers()
{ {
QStringList result; QStringList result;
if (_layers_modified) if (_layers_modified)
{ {
for (int i = 0; i < layersCount(_layers_modified); i++) for (int i = 0; i < layersCount(_layers_modified); i++)
@ -79,7 +79,7 @@ QStringList BaseFormLayer::getLayers()
result << QString::fromUtf8(layersGetName(_layers_modified, i)); result << QString::fromUtf8(layersGetName(_layers_modified, i));
} }
} }
return result; return result;
} }
@ -109,7 +109,7 @@ void BaseFormLayer::layerDeletedEvent(int layer)
{ {
layersDeleteLayer(_layers_modified, layer); layersDeleteLayer(_layers_modified, layer);
} }
BaseForm::layerDeletedEvent(layer); BaseForm::layerDeletedEvent(layer);
} }
@ -119,7 +119,7 @@ void BaseFormLayer::layerMovedEvent(int layer, int new_position)
{ {
layersMove(_layers_modified, layer, new_position); layersMove(_layers_modified, layer, new_position);
} }
BaseForm::layerMovedEvent(layer, new_position); BaseForm::layerMovedEvent(layer, new_position);
} }
@ -129,7 +129,7 @@ void BaseFormLayer::layerRenamedEvent(int layer, QString new_name)
{ {
layersSetName(_layers_modified, layer, new_name.toUtf8().data()); layersSetName(_layers_modified, layer, new_name.toUtf8().data());
} }
BaseForm::layerRenamedEvent(layer, new_name); BaseForm::layerRenamedEvent(layer, new_name);
} }
@ -137,8 +137,8 @@ void BaseFormLayer::layerSelectedEvent(int layer)
{ {
if (_layers_modified) if (_layers_modified)
{ {
layerGetCopy(layersGetLayer(_layers_modified, layer)); layerReadCurrentFrom(layersGetLayer(_layers_modified, layer));
} }
BaseForm::layerSelectedEvent(layer); BaseForm::layerSelectedEvent(layer);
} }

View file

@ -17,11 +17,11 @@ public:
public slots: public slots:
virtual void revertConfig(); virtual void revertConfig();
virtual void applyConfig(); virtual void applyConfig();
protected: protected:
void setLayers(Layers* layers); void setLayers(Layers* layers);
virtual void layerGetCopy(void* layer_definition) = 0; virtual void layerReadCurrentFrom(void* layer_definition) = 0;
virtual void layerApply(void* layer_definition) = 0; virtual void layerWriteCurrentTo(void* layer_definition) = 0;
virtual void afterLayerAdded(void* layer_definition); virtual void afterLayerAdded(void* layer_definition);
private: private:

View file

@ -16,10 +16,10 @@ public:
_renderer = rendererCreate(); _renderer = rendererCreate();
_renderer.render_quality = 5; _renderer.render_quality = 5;
_renderer.applyLightStatus = _applyLightStatus; _renderer.applyLightStatus = _applyLightStatus;
_original_layer = layer; _original_layer = layer;
_preview_layer = cloudsLayerCreateDefinition(); _preview_layer = cloudsLayerCreateDefinition();
configScaling(100.0, 1000.0, 20.0, 200.0); configScaling(100.0, 1000.0, 20.0, 200.0);
} }
~PreviewCloudsCoverage() ~PreviewCloudsCoverage()
@ -64,7 +64,7 @@ public:
PreviewCloudsColor(QWidget* parent, CloudsLayerDefinition* layer):BasePreview(parent) PreviewCloudsColor(QWidget* parent, CloudsLayerDefinition* layer):BasePreview(parent)
{ {
LightDefinition light; LightDefinition light;
_original_layer = layer; _original_layer = layer;
_preview_layer = cloudsLayerCreateDefinition(); _preview_layer = cloudsLayerCreateDefinition();
@ -79,14 +79,14 @@ public:
light.reflection = 1.0; light.reflection = 1.0;
lightingAddLight(&_lighting, light); lightingAddLight(&_lighting, light);
lightingValidateDefinition(&_lighting); lightingValidateDefinition(&_lighting);
_renderer = rendererCreate(); _renderer = rendererCreate();
_renderer.render_quality = 8; _renderer.render_quality = 8;
_renderer.alterLight = _alterLight; _renderer.alterLight = _alterLight;
_renderer.getLightStatus = _getLightStatus; _renderer.getLightStatus = _getLightStatus;
_renderer.customData[0] = _preview_layer; _renderer.customData[0] = _preview_layer;
_renderer.customData[1] = &_lighting; _renderer.customData[1] = &_lighting;
configScaling(0.5, 2.0, 0.1, 2.0); configScaling(0.5, 2.0, 0.1, 2.0);
} }
protected: protected:
@ -98,7 +98,7 @@ protected:
start.x = x * _preview_layer->thickness * 0.5; start.x = x * _preview_layer->thickness * 0.5;
start.y = -y * _preview_layer->thickness * 0.5; start.y = -y * _preview_layer->thickness * 0.5;
start.z = _preview_layer->thickness * 0.5; start.z = _preview_layer->thickness * 0.5;
end.x = x * _preview_layer->thickness * 0.5; end.x = x * _preview_layer->thickness * 0.5;
end.y = -y * _preview_layer->thickness * 0.5; end.y = -y * _preview_layer->thickness * 0.5;
end.z = -_preview_layer->thickness * 0.5; end.z = -_preview_layer->thickness * 0.5;
@ -126,7 +126,7 @@ private:
double coverage = curveGetValue(layer->_coverage_by_altitude, position.y / layer->thickness + 0.5); double coverage = curveGetValue(layer->_coverage_by_altitude, position.y / layer->thickness + 0.5);
position.y = 0.0; position.y = 0.0;
double dist = v3Norm(position); double dist = v3Norm(position);
if (dist >= layer->thickness * 0.5) if (dist >= layer->thickness * 0.5)
{ {
return 0.0; return 0.0;
@ -141,12 +141,12 @@ private:
return (density < coverage) ? density : coverage; return (density < coverage) ? density : coverage;
} }
} }
static void _alterLight(Renderer* renderer, LightDefinition* light, Vector3 location) static void _alterLight(Renderer* renderer, LightDefinition* light, Vector3 location)
{ {
light->color = cloudsLayerFilterLight((CloudsLayerDefinition*)renderer->customData[0], renderer, light->color, location, v3Scale(light->direction, -1000.0), v3Scale(light->direction, -1.0)); light->color = cloudsLayerFilterLight((CloudsLayerDefinition*)renderer->customData[0], renderer, light->color, location, v3Scale(light->direction, -1000.0), v3Scale(light->direction, -1.0));
} }
static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location) static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location)
{ {
lightingGetStatus((LightingDefinition*)renderer->customData[1], renderer, location, status); lightingGetStatus((LightingDefinition*)renderer->customData[1], renderer, location, status);
@ -164,7 +164,7 @@ FormClouds::FormClouds(QWidget *parent):
_definition = cloudsCreateDefinition(); _definition = cloudsCreateDefinition();
_layer = cloudsLayerCreateDefinition(); _layer = cloudsLayerCreateDefinition();
_previewCoverage = new PreviewCloudsCoverage(parent, _layer); _previewCoverage = new PreviewCloudsCoverage(parent, _layer);
_previewColor = new PreviewCloudsColor(parent, _layer); _previewColor = new PreviewCloudsColor(parent, _layer);
addPreview(_previewCoverage, tr("Layer coverage (no lighting)")); addPreview(_previewCoverage, tr("Layer coverage (no lighting)"));
@ -204,15 +204,15 @@ void FormClouds::applyConfig()
void FormClouds::configChangeEvent() void FormClouds::configChangeEvent()
{ {
cloudsLayerValidateDefinition(_layer); cloudsLayerValidateDefinition(_layer);
BaseForm::configChangeEvent(); BaseFormLayer::configChangeEvent();
} }
void FormClouds::layerGetCopy(void* layer_definition) void FormClouds::layerReadCurrentFrom(void* layer_definition)
{ {
cloudsLayerCopyDefinition((CloudsLayerDefinition*)layer_definition, _layer); cloudsLayerCopyDefinition((CloudsLayerDefinition*)layer_definition, _layer);
} }
void FormClouds::layerApply(void* layer_definition) void FormClouds::layerWriteCurrentTo(void* layer_definition)
{ {
cloudsLayerCopyDefinition(_layer, (CloudsLayerDefinition*)layer_definition); cloudsLayerCopyDefinition(_layer, (CloudsLayerDefinition*)layer_definition);
} }

View file

@ -18,8 +18,8 @@ public slots:
virtual void applyConfig(); virtual void applyConfig();
protected: protected:
virtual void layerGetCopy(void* layer_definition); virtual void layerReadCurrentFrom(void* layer_definition);
virtual void layerApply(void* layer_definition); virtual void layerWriteCurrentTo(void* layer_definition);
virtual void autoPresetSelected(int preset); virtual void autoPresetSelected(int preset);
protected slots: protected slots:

View file

@ -8,13 +8,13 @@ public:
{ {
_base_canvas = canvas; _base_canvas = canvas;
_preview_canvas = terrainCanvasCreate(); _preview_canvas = terrainCanvasCreate();
//addOsd(QString("geolocation")); //addOsd(QString("geolocation"));
configScaling(1.0, 1.0, 1.0, 1.0); configScaling(1.0, 1.0, 1.0, 1.0);
//configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0); //configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
} }
~PreviewTerrainCanvasHeight() ~PreviewTerrainCanvasHeight()
{ {
terrainCanvasDelete(_preview_canvas); terrainCanvasDelete(_preview_canvas);
@ -34,13 +34,13 @@ protected:
height = heightmapGetValue(&_preview_canvas->height_map, x + 0.5, y + 0.5); height = heightmapGetValue(&_preview_canvas->height_map, x + 0.5, y + 0.5);
col.r = col.g = col.b = (height - _min) / (_max - _min); col.r = col.g = col.b = (height - _min) / (_max - _min);
col.a = 1.0; col.a = 1.0;
mask.r = 0.3; mask.r = 0.3;
mask.g = 0.0; mask.g = 0.0;
mask.b = 0.0; mask.b = 0.0;
mask.a = 1.0 - terrainCanvasGetMaskValue(_preview_canvas, x + 0.5, y + 0.5); mask.a = 1.0 - terrainCanvasGetMaskValue(_preview_canvas, x + 0.5, y + 0.5);
colorMask(&col, &mask); colorMask(&col, &mask);
return colorToQColor(col); return colorToQColor(col);
} }
} }
@ -60,7 +60,7 @@ FormTerrainCanvas::FormTerrainCanvas(QWidget *parent, Layers* layers):
BaseFormLayer(parent, layers) BaseFormLayer(parent, layers)
{ {
_definition = terrainCanvasCreate(); _definition = terrainCanvasCreate();
// TODO Area // TODO Area
//addInputDouble(tr("Apply at height"), &_definition->offset_y, -20.0, 20.0, 0.1, 1.0); //addInputDouble(tr("Apply at height"), &_definition->offset_y, -20.0, 20.0, 0.1, 1.0);
addInputHeightMap(tr("Height map"), &_definition->height_map, _definition); addInputHeightMap(tr("Height map"), &_definition->height_map, _definition);
@ -70,10 +70,10 @@ FormTerrainCanvas::FormTerrainCanvas(QWidget *parent, Layers* layers):
addInputDouble(tr("Detail noise scaling"), &_definition->detail_scaling, 0.0, 20.0, 0.1, 1.0); addInputDouble(tr("Detail noise scaling"), &_definition->detail_scaling, 0.0, 20.0, 0.1, 1.0);
addInputEnum(tr("Mask shape"), &_definition->mask.mode, QStringList(tr("Square")) << tr("Circle")); addInputEnum(tr("Mask shape"), &_definition->mask.mode, QStringList(tr("Square")) << tr("Circle"));
addInputDouble(tr("Mask smoothing"), &_definition->mask.smoothing, 0.0, 1.0, 0.01, 0.1); addInputDouble(tr("Mask smoothing"), &_definition->mask.smoothing, 0.0, 1.0, 0.01, 0.1);
_previewHeight = new PreviewTerrainCanvasHeight(this, _definition); _previewHeight = new PreviewTerrainCanvasHeight(this, _definition);
addPreview(_previewHeight, tr("Height preview (normalized)")); addPreview(_previewHeight, tr("Height preview (normalized)"));
revertConfig(); revertConfig();
} }
@ -82,12 +82,12 @@ FormTerrainCanvas::~FormTerrainCanvas()
terrainCanvasDelete(_definition); terrainCanvasDelete(_definition);
} }
void FormTerrainCanvas::layerGetCopy(void* layer_definition) void FormTerrainCanvas::layerReadCurrentFrom(void* layer_definition)
{ {
terrainCanvasCopy((TerrainCanvas*)layer_definition, _definition); terrainCanvasCopy((TerrainCanvas*)layer_definition, _definition);
} }
void FormTerrainCanvas::layerApply(void* layer_definition) void FormTerrainCanvas::layerWriteCurrentTo(void* layer_definition)
{ {
terrainCanvasCopy(_definition, (TerrainCanvas*)layer_definition); terrainCanvasCopy(_definition, (TerrainCanvas*)layer_definition);
} }

View file

@ -13,10 +13,10 @@ class FormTerrainCanvas : public BaseFormLayer
public: public:
FormTerrainCanvas(QWidget* parent, Layers* layers); FormTerrainCanvas(QWidget* parent, Layers* layers);
~FormTerrainCanvas(); ~FormTerrainCanvas();
protected: protected:
virtual void layerGetCopy(void* layer_definition); virtual void layerReadCurrentFrom(void* layer_definition);
virtual void layerApply(void* layer_definition); virtual void layerWriteCurrentTo(void* layer_definition);
virtual void afterLayerAdded(void* layer_definition); virtual void afterLayerAdded(void* layer_definition);
private: private:

View file

@ -18,17 +18,17 @@ public:
PreviewTexturesCoverage(QWidget* parent, TextureLayerDefinition* layer):BasePreview(parent) PreviewTexturesCoverage(QWidget* parent, TextureLayerDefinition* layer):BasePreview(parent)
{ {
_terrain = terrainCreateDefinition(); _terrain = terrainCreateDefinition();
_renderer = rendererCreate(); _renderer = rendererCreate();
_renderer.render_quality = 3; _renderer.render_quality = 3;
_renderer.getTerrainHeight = _getTerrainHeight; _renderer.getTerrainHeight = _getTerrainHeight;
_renderer.customData[0] = &_terrain; _renderer.customData[0] = &_terrain;
_original_layer = layer; _original_layer = layer;
_preview_layer = texturesLayerCreateDefinition(); _preview_layer = texturesLayerCreateDefinition();
addOsd(QString("geolocation")); addOsd(QString("geolocation"));
configScaling(0.5, 200.0, 1.0, 50.0); configScaling(0.5, 200.0, 1.0, 50.0);
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0); configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
} }
@ -74,7 +74,7 @@ public:
_original_layer = layer; _original_layer = layer;
_preview_layer = texturesLayerCreateDefinition(); _preview_layer = texturesLayerCreateDefinition();
_lighting = lightingCreateDefinition(); _lighting = lightingCreateDefinition();
light.color = COLOR_WHITE; light.color = COLOR_WHITE;
light.direction.x = 0.0; light.direction.x = 0.0;
@ -85,7 +85,7 @@ public:
light.reflection = 1.0; light.reflection = 1.0;
lightingAddLight(&_lighting, light); lightingAddLight(&_lighting, light);
lightingValidateDefinition(&_lighting); lightingValidateDefinition(&_lighting);
_renderer = rendererCreate(); _renderer = rendererCreate();
_renderer.render_quality = 3; _renderer.render_quality = 3;
_renderer.getLightStatus = _getLightStatus; _renderer.getLightStatus = _getLightStatus;
@ -93,9 +93,9 @@ public:
_renderer.camera_location.x = 0.0; _renderer.camera_location.x = 0.0;
_renderer.camera_location.y = 20.0; _renderer.camera_location.y = 20.0;
_renderer.camera_location.z = 0.0; _renderer.camera_location.z = 0.0;
_zone = zoneCreate(); _zone = zoneCreate();
configScaling(0.01, 1.0, 0.01, 0.1); configScaling(0.01, 1.0, 0.01, 0.1);
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0); configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
} }
@ -123,7 +123,7 @@ private:
TextureLayerDefinition* _original_layer; TextureLayerDefinition* _original_layer;
TextureLayerDefinition* _preview_layer; TextureLayerDefinition* _preview_layer;
LightingDefinition _lighting; LightingDefinition _lighting;
static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location) static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location)
{ {
lightingGetStatus((LightingDefinition*)renderer->customData[0], renderer, location, status); lightingGetStatus((LightingDefinition*)renderer->customData[0], renderer, location, status);
@ -177,7 +177,7 @@ void FormTextures::applyConfig()
scenerySetTextures(&_definition); scenerySetTextures(&_definition);
} }
void FormTextures::layerGetCopy(void* layer_definition) void FormTextures::layerReadCurrentFrom(void* layer_definition)
{ {
TextureLayerDefinition* source = (TextureLayerDefinition*)layer_definition; TextureLayerDefinition* source = (TextureLayerDefinition*)layer_definition;
texturesLayerCopyDefinition(source, _layer); texturesLayerCopyDefinition(source, _layer);
@ -186,11 +186,11 @@ void FormTextures::layerGetCopy(void* layer_definition)
zoneGetSlopeCurve(source->zone, _supp.slope_curve); zoneGetSlopeCurve(source->zone, _supp.slope_curve);
} }
void FormTextures::layerApply(void* layer_definition) void FormTextures::layerWriteCurrentTo(void* layer_definition)
{ {
TextureLayerDefinition* destination = (TextureLayerDefinition*)layer_definition; TextureLayerDefinition* destination = (TextureLayerDefinition*)layer_definition;
texturesLayerCopyDefinition(_layer, destination); texturesLayerCopyDefinition(_layer, destination);
zoneSetHeightCurve(destination->zone, _supp.height_curve); zoneSetHeightCurve(destination->zone, _supp.height_curve);
zoneSetSlopeCurve(destination->zone, _supp.slope_curve); zoneSetSlopeCurve(destination->zone, _supp.slope_curve);
} }

View file

@ -19,8 +19,8 @@ public slots:
virtual void applyConfig(); virtual void applyConfig();
protected: protected:
virtual void layerGetCopy(void* layer_definition); virtual void layerReadCurrentFrom(void* layer_definition);
virtual void layerApply(void* layer_definition); virtual void layerWriteCurrentTo(void* layer_definition);
private: private:
TexturesDefinition _definition; TexturesDefinition _definition;