2015-10-18 22:26:25 +00:00
|
|
|
#include "NoiseNode.h"
|
|
|
|
|
2016-01-03 19:22:06 +00:00
|
|
|
#include "NoiseFunctionSimplex.h"
|
2015-10-18 22:26:25 +00:00
|
|
|
#include "Logs.h"
|
|
|
|
|
2016-01-03 19:22:06 +00:00
|
|
|
NoiseNode::NoiseNode(DefinitionNode *parent, const string &name) : DefinitionNode(parent, name) {
|
|
|
|
noise = new NoiseFunctionSimplex();
|
2015-10-18 22:26:25 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
NoiseNode::~NoiseNode() {
|
2015-10-18 22:26:25 +00:00
|
|
|
delete noise;
|
|
|
|
}
|
|
|
|
|
2016-01-04 00:13:14 +00:00
|
|
|
void NoiseNode::randomize(RandomGenerator &random) {
|
|
|
|
noise->randomize(random);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NoiseNode::setConfig(double scaling, double step_scaling, double height, double step_height) {
|
|
|
|
noise->setScaling(scaling, height);
|
|
|
|
noise->setStep(step_scaling, step_height);
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void NoiseNode::save(PackStream *stream) const {
|
2015-10-18 22:26:25 +00:00
|
|
|
noise->save(stream);
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void NoiseNode::load(PackStream *stream) {
|
2015-10-18 22:26:25 +00:00
|
|
|
noise->load(stream);
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void NoiseNode::copy(DefinitionNode *destination) const {
|
|
|
|
if (destination->getTypeName() == getTypeName()) {
|
2016-01-03 19:22:06 +00:00
|
|
|
auto tdestination = static_cast<NoiseNode *>(destination);
|
|
|
|
if (tdestination) {
|
|
|
|
noise->copy(tdestination->noise);
|
|
|
|
}
|
2015-11-09 21:30:46 +00:00
|
|
|
} else {
|
2015-12-13 19:08:38 +00:00
|
|
|
Logs::error("Definition") << "Can't copy from " << getTypeName() << " to " << destination->getTypeName()
|
|
|
|
<< endl;
|
2015-10-18 22:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-03 19:22:06 +00:00
|
|
|
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());
|
2015-10-18 22:26:25 +00:00
|
|
|
}
|