paysages3d/src/definition/NoiseNode.cpp
Michaël Lemaire 959f0ddf8f Updated NoiseNode to use FractalNoise instead of NoiseGenerator
Also fixed the range returned by NoiseFunctionSimplex (when
used by FractalNoise), and added a test to validate it.
2016-01-03 20:22:06 +01:00

39 lines
1.1 KiB
C++

#include "NoiseNode.h"
#include "NoiseFunctionSimplex.h"
#include "Logs.h"
NoiseNode::NoiseNode(DefinitionNode *parent, const string &name) : DefinitionNode(parent, name) {
noise = new NoiseFunctionSimplex();
}
NoiseNode::~NoiseNode() {
delete noise;
}
void NoiseNode::save(PackStream *stream) const {
noise->save(stream);
}
void NoiseNode::load(PackStream *stream) {
noise->load(stream);
}
void NoiseNode::copy(DefinitionNode *destination) const {
if (destination->getTypeName() == getTypeName()) {
auto tdestination = static_cast<NoiseNode *>(destination);
if (tdestination) {
noise->copy(tdestination->noise);
}
} else {
Logs::error("Definition") << "Can't copy from " << getTypeName() << " to " << destination->getTypeName()
<< endl;
}
}
string NoiseNode::toString(int indent) const {
return DefinitionNode::toString(indent) + " - scaling: " + to_string(noise->getScaling()) + " step " +
to_string(noise->getStepScaling()) + " - height: " + to_string(noise->getHeight()) + " step " +
to_string(noise->getStepScaling());
}