Fixed vegetation definition, due to layers refactoring in master
This commit is contained in:
parent
8cf2881a73
commit
01992a0019
6 changed files with 13 additions and 12 deletions
|
@ -119,7 +119,7 @@ bool Layers::applyDiff(const DefinitionDiff *diff, bool backward) {
|
||||||
|
|
||||||
void Layers::generateInitDiffs(std::vector<const DefinitionDiff *> *diffs) const {
|
void Layers::generateInitDiffs(std::vector<const DefinitionDiff *> *diffs) const {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto layer: layers) {
|
for (auto layer : layers) {
|
||||||
auto diff = new LayersDiff(this, LayersDiff::LAYER_ADDED, i++);
|
auto diff = new LayersDiff(this, LayersDiff::LAYER_ADDED, i++);
|
||||||
diff->saveLayer(*layer);
|
diff->saveLayer(*layer);
|
||||||
diffs->push_back(diff);
|
diffs->push_back(diff);
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
#include "VegetationLayerDefinition.h"
|
#include "VegetationLayerDefinition.h"
|
||||||
#include "VegetationModelDefinition.h"
|
#include "VegetationModelDefinition.h"
|
||||||
|
|
||||||
static DefinitionNode *_layer_constructor(Layers *parent) {
|
static DefinitionNode *_layer_constructor(Layers *parent, const std::string &name) {
|
||||||
return new VegetationLayerDefinition(parent);
|
return new VegetationLayerDefinition(parent, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
VegetationDefinition::VegetationDefinition(DefinitionNode *parent) : Layers(parent, "vegetation", _layer_constructor) {
|
VegetationDefinition::VegetationDefinition(DefinitionNode *parent) : Layers(parent, "vegetation", _layer_constructor) {
|
||||||
|
@ -12,7 +12,7 @@ VegetationDefinition::VegetationDefinition(DefinitionNode *parent) : Layers(pare
|
||||||
|
|
||||||
double VegetationDefinition::getMaxHeight() const {
|
double VegetationDefinition::getMaxHeight() const {
|
||||||
double max_height = 0.0;
|
double max_height = 0.0;
|
||||||
int n = count();
|
int n = getLayerCount();
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
double layer_height = getVegetationLayer(i)->getMaxHeight();
|
double layer_height = getVegetationLayer(i)->getMaxHeight();
|
||||||
|
@ -25,13 +25,13 @@ double VegetationDefinition::getMaxHeight() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VegetationDefinition::applyPreset(VegetationPreset preset) {
|
void VegetationDefinition::applyPreset(VegetationPreset preset) {
|
||||||
VegetationLayerDefinition *layer;
|
VegetationLayerDefinition layer(this, "temp");
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
if (preset == VEGETATION_PRESET_TEMPERATE) {
|
if (preset == VEGETATION_PRESET_TEMPERATE) {
|
||||||
layer = getVegetationLayer(addLayer());
|
layer.applyPreset(VegetationLayerDefinition::VEGETATION_BASIC_TREES);
|
||||||
layer->applyPreset(VegetationLayerDefinition::VEGETATION_BASIC_TREES);
|
layer.setName("Basic tree");
|
||||||
layer->setName("Basic tree");
|
addLayer(layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
#include "VegetationModelDefinition.h"
|
#include "VegetationModelDefinition.h"
|
||||||
#include "VegetationPresenceDefinition.h"
|
#include "VegetationPresenceDefinition.h"
|
||||||
|
|
||||||
VegetationLayerDefinition::VegetationLayerDefinition(DefinitionNode *parent) : DefinitionNode(parent, "layer") {
|
VegetationLayerDefinition::VegetationLayerDefinition(DefinitionNode *parent, const std::string &name)
|
||||||
|
: DefinitionNode(parent, name, "vegetationlayer") {
|
||||||
model = new VegetationModelDefinition(this);
|
model = new VegetationModelDefinition(this);
|
||||||
presence = new VegetationPresenceDefinition(this);
|
presence = new VegetationPresenceDefinition(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace definition {
|
||||||
*/
|
*/
|
||||||
class DEFINITIONSHARED_EXPORT VegetationLayerDefinition : public DefinitionNode {
|
class DEFINITIONSHARED_EXPORT VegetationLayerDefinition : public DefinitionNode {
|
||||||
public:
|
public:
|
||||||
VegetationLayerDefinition(DefinitionNode *parent);
|
VegetationLayerDefinition(DefinitionNode *parent, const std::string &name);
|
||||||
|
|
||||||
inline const VegetationPresenceDefinition *getPresence() const {
|
inline const VegetationPresenceDefinition *getPresence() const {
|
||||||
return presence;
|
return presence;
|
||||||
|
|
|
@ -103,7 +103,7 @@ RayCastingResult VegetationRenderer::getBoundResult(const SpaceSegment &segment,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate all layers and instances
|
// Iterate all layers and instances
|
||||||
int n = vegetation->count();
|
int n = vegetation->getLayerCount();
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
VegetationLayerDefinition *layer = vegetation->getVegetationLayer(i);
|
VegetationLayerDefinition *layer = vegetation->getVegetationLayer(i);
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ TEST(Layers, generateInitDiffs) {
|
||||||
EXPECT_EQ(3, (int)diffs.size());
|
EXPECT_EQ(3, (int)diffs.size());
|
||||||
|
|
||||||
Layers layers1(NULL, "layers", _construc1);
|
Layers layers1(NULL, "layers", _construc1);
|
||||||
for (auto diff: diffs) {
|
for (auto diff : diffs) {
|
||||||
layers1.applyDiff(diff);
|
layers1.applyDiff(diff);
|
||||||
}
|
}
|
||||||
ASSERT_EQ(3, layers1.getLayerCount());
|
ASSERT_EQ(3, layers1.getLayerCount());
|
||||||
|
|
Loading…
Reference in a new issue