Fixed vegetation definition, due to layers refactoring in master

This commit is contained in:
Michaël Lemaire 2015-11-20 01:16:48 +01:00
parent 8cf2881a73
commit 01992a0019
6 changed files with 13 additions and 12 deletions

View file

@ -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);
} }
} }

View file

@ -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);
} }

View file

@ -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;

View file

@ -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);