2013-11-17 21:36:18 +00:00
|
|
|
#include "TerrainHeightMap.h"
|
|
|
|
|
|
|
|
#include "TerrainDefinition.h"
|
2014-09-15 10:32:27 +00:00
|
|
|
#include "PaintedGridBrush.h"
|
2013-11-17 21:36:18 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
TerrainHeightMap::TerrainHeightMap(TerrainDefinition *terrain) : PaintedGrid(terrain), terrain(terrain) {
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void TerrainHeightMap::copy(DefinitionNode *_destination) const {
|
|
|
|
TerrainHeightMap *destination = (TerrainHeightMap *)_destination;
|
2013-11-17 21:36:18 +00:00
|
|
|
|
|
|
|
destination->terrain = terrain;
|
|
|
|
|
2014-09-15 10:32:27 +00:00
|
|
|
PaintedGrid::copy(destination);
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
double TerrainHeightMap::getInitialValue(double x, double y) const {
|
2015-09-10 16:16:57 +00:00
|
|
|
return terrain->getInterpolatedHeight(x, y, false, false);
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void TerrainHeightMap::brushElevation(const PaintedGridBrush &brush, double x, double y, double value, bool commit) {
|
2014-09-15 10:32:27 +00:00
|
|
|
PaintedGridBrushRaiseLower sbrush(brush);
|
2015-09-21 17:37:17 +00:00
|
|
|
applyBrush(sbrush, x, y, value / terrain->height, commit);
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void TerrainHeightMap::brushFlatten(const PaintedGridBrush &brush, double x, double y, double height, double force,
|
|
|
|
bool commit) {
|
2014-09-15 10:32:27 +00:00
|
|
|
PaintedGridBrushFlatten sbrush(brush, height);
|
2015-09-21 17:37:17 +00:00
|
|
|
applyBrush(sbrush, x, y, force / terrain->height, commit);
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void TerrainHeightMap::brushSmooth(const PaintedGridBrush &brush, double x, double y, double value, bool commit) {
|
2014-09-15 10:32:27 +00:00
|
|
|
PaintedGridBrushSmooth sbrush(brush);
|
2015-09-21 17:37:17 +00:00
|
|
|
applyBrush(sbrush, x, y, value / terrain->height, commit);
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void TerrainHeightMap::brushAddNoise(const PaintedGridBrush &brush, double x, double y, NoiseGenerator *generator,
|
|
|
|
double value, bool commit) {
|
2014-09-15 10:32:27 +00:00
|
|
|
PaintedGridBrushAddNoise sbrush(brush, generator);
|
2015-09-21 17:37:17 +00:00
|
|
|
applyBrush(sbrush, x, y, value / terrain->height, commit);
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void TerrainHeightMap::brushReset(const PaintedGridBrush &brush, double x, double y, double value, bool commit) {
|
2014-09-15 10:32:27 +00:00
|
|
|
PaintedGridBrushReset sbrush(brush);
|
2015-09-21 17:37:17 +00:00
|
|
|
applyBrush(sbrush, x, y, value / terrain->height, commit);
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void TerrainHeightMap::clearPainting() {
|
2015-09-21 17:37:17 +00:00
|
|
|
PaintedGrid::clearPainting();
|
|
|
|
|
|
|
|
terrain->validate();
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void TerrainHeightMap::endBrushStroke() {
|
2015-09-21 17:37:17 +00:00
|
|
|
PaintedGrid::endBrushStroke();
|
|
|
|
|
|
|
|
terrain->validate();
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|