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
|
|
|
|
|
|
|
TerrainHeightMap::TerrainHeightMap(TerrainDefinition* terrain):
|
2014-09-15 10:32:27 +00:00
|
|
|
PaintedGrid(terrain), terrain(terrain)
|
2013-11-17 21:36:18 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-08-12 20:21:10 +00:00
|
|
|
void TerrainHeightMap::copy(DefinitionNode* _destination) const
|
2013-11-17 21:36:18 +00:00
|
|
|
{
|
|
|
|
TerrainHeightMap* destination = (TerrainHeightMap*)_destination;
|
|
|
|
|
|
|
|
destination->terrain = terrain;
|
|
|
|
|
2014-09-15 10:32:27 +00:00
|
|
|
PaintedGrid::copy(destination);
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2014-09-15 10:32:27 +00:00
|
|
|
double TerrainHeightMap::getInitialValue(double x, double y) const
|
2013-11-17 21:36:18 +00:00
|
|
|
{
|
2015-09-10 16:16:57 +00:00
|
|
|
return terrain->getInterpolatedHeight(x, y, false, false);
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2014-09-15 10:32:27 +00:00
|
|
|
void TerrainHeightMap::brushElevation(const PaintedGridBrush &brush, double x, double y, double value)
|
2013-11-17 21:36:18 +00:00
|
|
|
{
|
2014-09-15 10:32:27 +00:00
|
|
|
PaintedGridBrushRaiseLower sbrush(brush);
|
|
|
|
applyBrush(sbrush, x, y, value / terrain->height);
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2014-09-15 10:32:27 +00:00
|
|
|
void TerrainHeightMap::brushFlatten(const PaintedGridBrush &brush, double x, double y, double height, double force)
|
2013-11-17 21:36:18 +00:00
|
|
|
{
|
2014-09-15 10:32:27 +00:00
|
|
|
PaintedGridBrushFlatten sbrush(brush, height);
|
|
|
|
applyBrush(sbrush, x, y, force / terrain->height);
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2014-09-15 10:32:27 +00:00
|
|
|
void TerrainHeightMap::brushSmooth(const PaintedGridBrush &brush, double x, double y, double value)
|
2013-11-17 21:36:18 +00:00
|
|
|
{
|
2014-09-15 10:32:27 +00:00
|
|
|
PaintedGridBrushSmooth sbrush(brush);
|
|
|
|
applyBrush(sbrush, x, y, value / terrain->height);
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2014-09-15 10:32:27 +00:00
|
|
|
void TerrainHeightMap::brushAddNoise(const PaintedGridBrush &brush, double x, double y, NoiseGenerator* generator, double value)
|
2013-11-17 21:36:18 +00:00
|
|
|
{
|
2014-09-15 10:32:27 +00:00
|
|
|
PaintedGridBrushAddNoise sbrush(brush, generator);
|
|
|
|
applyBrush(sbrush, x, y, value / terrain->height);
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2014-09-15 10:32:27 +00:00
|
|
|
void TerrainHeightMap::brushReset(const PaintedGridBrush &brush, double x, double y, double value)
|
2013-11-17 21:36:18 +00:00
|
|
|
{
|
2014-09-15 10:32:27 +00:00
|
|
|
PaintedGridBrushReset sbrush(brush);
|
|
|
|
applyBrush(sbrush, x, y, value / terrain->height);
|
2013-11-17 21:36:18 +00:00
|
|
|
}
|