From 4347d7f454ba6cce0dffd321c628127cd037d72b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Thu, 31 Dec 2015 01:29:59 +0100 Subject: [PATCH] Removed unused definition members --- TODO | 1 + src/basics/FractalNoise.cpp | 22 +++++------------ src/basics/FractalNoise.h | 4 --- src/definition/TextureLayerDefinition.cpp | 30 ++++++++--------------- src/definition/TextureLayerDefinition.h | 6 ----- src/interface/commandline/tests.cpp | 1 - 6 files changed, 17 insertions(+), 47 deletions(-) diff --git a/TODO b/TODO index 6858107..c1b5d84 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,7 @@ Technlology Preview 2 : - Rewrite UI in QtQuick, with full-window OpenGL editor. - Streamline the definition system, with undo and events. +- Switch all noise generators to FractalNoise, and restore detail-based fractal levels. - Implement copy-on-write on definitions (to avoid copying whole heightmaps for instance). - Add clouds to OpenGL with 3d textures. - Refactor medium traversal to unify clouds, atmosphere and god rays. diff --git a/src/basics/FractalNoise.cpp b/src/basics/FractalNoise.cpp index 92e7266..a6c29bc 100644 --- a/src/basics/FractalNoise.cpp +++ b/src/basics/FractalNoise.cpp @@ -5,8 +5,6 @@ FractalNoise::FractalNoise() { height = 1.0; step_scaling = 2.0; step_height = 0.5; - slope = 0.0; - ridge = 0.0; } FractalNoise::~FractalNoise() { @@ -22,14 +20,6 @@ void FractalNoise::setStep(double scaling_factor, double height_factor) { this->step_height = scaling_factor * height_factor; } -void FractalNoise::setSlope(double slope_factor) { - this->slope = slope_factor; -} - -void FractalNoise::setRidge(double ridge_factor) { - this->ridge = ridge_factor; -} - void FractalNoise::setState(const NoiseState &state) { state.copy(&this->state); } @@ -38,8 +28,8 @@ double FractalNoise::get1d(double detail, double x) const { double current_scaling = scaling; double current_height = height; double result = 0.0; - int state_level_count = state.level_offsets.size(); - int i = 0; + auto state_level_count = state.level_offsets.size(); + decltype(state_level_count) i = 0; while (current_height >= detail) { const NoiseState::NoiseOffset &offset = state.level_offsets[i]; @@ -62,8 +52,8 @@ double FractalNoise::get2d(double detail, double x, double y) const { double current_scaling = scaling; double current_height = height; double result = 0.0; - int state_level_count = state.level_offsets.size(); - int i = 0; + auto state_level_count = state.level_offsets.size(); + decltype(state_level_count) i = 0; while (current_height >= detail) { const NoiseState::NoiseOffset &offset = state.level_offsets[i]; @@ -86,8 +76,8 @@ double FractalNoise::get3d(double detail, double x, double y, double z) const { double current_scaling = scaling; double current_height = height; double result = 0.0; - int state_level_count = state.level_offsets.size(); - int i = 0; + auto state_level_count = state.level_offsets.size(); + decltype(state_level_count) i = 0; while (current_height >= detail) { const NoiseState::NoiseOffset &offset = state.level_offsets[i]; diff --git a/src/basics/FractalNoise.h b/src/basics/FractalNoise.h index e6e3058..769e98b 100644 --- a/src/basics/FractalNoise.h +++ b/src/basics/FractalNoise.h @@ -31,8 +31,6 @@ class BASICSSHARED_EXPORT FractalNoise { void setScaling(double scaling, double height = 1.0); void setStep(double scaling_factor, double height_factor = 1.0); - void setSlope(double slope_factor); - void setRidge(double ridge_factor); void setState(const NoiseState &state); double get1d(double detail, double x) const; @@ -50,8 +48,6 @@ class BASICSSHARED_EXPORT FractalNoise { double height; double step_scaling; double step_height; - double slope; - double ridge; }; } } diff --git a/src/definition/TextureLayerDefinition.cpp b/src/definition/TextureLayerDefinition.cpp index 8a1fcd1..2d59fc8 100644 --- a/src/definition/TextureLayerDefinition.cpp +++ b/src/definition/TextureLayerDefinition.cpp @@ -54,20 +54,19 @@ void TextureLayerDefinition::validate() { } } -void TextureLayerDefinition::copy(DefinitionNode *_destination) const { - DefinitionNode::copy(_destination); +void TextureLayerDefinition::copy(DefinitionNode *destination) const { + DefinitionNode::copy(destination); - TextureLayerDefinition *destination = (TextureLayerDefinition *)_destination; + if (auto tex_destination = static_cast(destination)) { + terrain_zone->copy(tex_destination->terrain_zone); - terrain_zone->copy(destination->terrain_zone); + tex_destination->displacement_scaling = displacement_scaling; + tex_destination->displacement_height = displacement_height; + *tex_destination->material = *material; - destination->displacement_scaling = displacement_scaling; - destination->displacement_height = displacement_height; - destination->displacement_offset = displacement_offset; - *destination->material = *material; - - _displacement_noise->copy(destination->_displacement_noise); - _detail_noise->copy(destination->_detail_noise); + _displacement_noise->copy(tex_destination->_displacement_noise); + _detail_noise->copy(tex_destination->_detail_noise); + } } void TextureLayerDefinition::save(PackStream *stream) const { @@ -76,7 +75,6 @@ void TextureLayerDefinition::save(PackStream *stream) const { terrain_zone->save(stream); stream->write(&displacement_scaling); stream->write(&displacement_height); - stream->write(&displacement_offset); material->save(stream); _displacement_noise->save(stream); @@ -89,7 +87,6 @@ void TextureLayerDefinition::load(PackStream *stream) { terrain_zone->load(stream); stream->read(&displacement_scaling); stream->read(&displacement_height); - stream->read(&displacement_offset); material->load(stream); _displacement_noise->load(stream); @@ -106,7 +103,6 @@ void TextureLayerDefinition::applyPreset(TextureLayerPreset preset, RandomGenera case TEXTURES_LAYER_PRESET_MUD: displacement_height = 0.02; displacement_scaling = 3.0; - displacement_offset = 0.0; material->setColor(0.015, 0.014, 0.014, 1.0); material->reflection = 0.003; material->shininess = 4.0; @@ -115,7 +111,6 @@ void TextureLayerDefinition::applyPreset(TextureLayerPreset preset, RandomGenera terrain_zone->addHeightRangeQuick(1.0, 0.6, 0.7, 1.0, 1.0); displacement_height = 0.3; displacement_scaling = 2.0; - displacement_offset = 0.0; material->setColor(0.6, 0.55, 0.57, 1.0); material->reflection = 0.006; material->shininess = 6.0; @@ -125,7 +120,6 @@ void TextureLayerDefinition::applyPreset(TextureLayerPreset preset, RandomGenera terrain_zone->addSlopeRangeQuick(1.0, 0.0, 0.0, 0.05, 0.4); displacement_height = 0.0; displacement_scaling = 1.0; - displacement_offset = 0.0; material->setColor(0.12, 0.19, 0.035, 1.0); material->reflection = 0.001; material->shininess = 4.0; @@ -135,7 +129,6 @@ void TextureLayerDefinition::applyPreset(TextureLayerPreset preset, RandomGenera terrain_zone->addSlopeRangeQuick(1.0, 0.0, 0.0, 0.1, 0.4); displacement_height = 0.05; displacement_scaling = 5.0; - displacement_offset = 0.0; material->setColor(1.2, 1.1, 0.9, 1.0); material->reflection = 0.008; material->shininess = 1.0; @@ -145,13 +138,10 @@ void TextureLayerDefinition::applyPreset(TextureLayerPreset preset, RandomGenera terrain_zone->addSlopeRangeQuick(1.0, 0.0, 0.0, 0.2, 1.0); displacement_height = 0.1; displacement_scaling = 1.0; - displacement_offset = 0.0; material->setColor(5.0, 5.0, 5.0, 1.0); material->reflection = 0.02; material->shininess = 0.6; break; - default: - break; } validate(); diff --git a/src/definition/TextureLayerDefinition.h b/src/definition/TextureLayerDefinition.h index c326018..119c6fb 100644 --- a/src/definition/TextureLayerDefinition.h +++ b/src/definition/TextureLayerDefinition.h @@ -35,16 +35,10 @@ class DEFINITIONSHARED_EXPORT TextureLayerDefinition : public DefinitionNode { Zone *terrain_zone; double displacement_scaling; double displacement_height; - double displacement_offset; - /*double detail_scaling; - double detail_height;*/ SurfaceMaterial *material; - /*double cancel_displacement_factor; - TexturesMergeMode merge_mode;*/ NoiseGenerator *_displacement_noise; NoiseGenerator *_detail_noise; - /*Curve* _local_slope_condition;*/ }; } } diff --git a/src/interface/commandline/tests.cpp b/src/interface/commandline/tests.cpp index 7981aed..ca81b98 100644 --- a/src/interface/commandline/tests.cpp +++ b/src/interface/commandline/tests.cpp @@ -71,7 +71,6 @@ static void testGroundShadowQuality() { TextureLayerDefinition texture(NULL, "test"); texture.displacement_height = 0.3; texture.displacement_scaling = 2.0; - texture.displacement_offset = 0.0; texture.material->setColor(0.6, 0.55, 0.57, 1.0); texture.material->reflection = 0.006; texture.material->shininess = 6.0;