summaryrefslogtreecommitdiff
path: root/src/heightmap.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-01-15 15:55:03 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-01-15 15:55:03 +0200
commit69e7cd9b5b36783ec83a663789a95a3c512809c4 (patch)
treeefaf95b26620e8bde5f0803e37c8d0ec16e9c56f /src/heightmap.cpp
parenta176f9eb36033196040443991a0723c39886b8a2 (diff)
downloadminetest-69e7cd9b5b36783ec83a663789a95a3c512809c4.tar.gz
minetest-69e7cd9b5b36783ec83a663789a95a3c512809c4.tar.bz2
minetest-69e7cd9b5b36783ec83a663789a95a3c512809c4.zip
backing up working heightmap.{h,cpp}
Diffstat (limited to 'src/heightmap.cpp')
-rw-r--r--src/heightmap.cpp38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/heightmap.cpp b/src/heightmap.cpp
index 6e785fcc5..2f7ecc4dc 100644
--- a/src/heightmap.cpp
+++ b/src/heightmap.cpp
@@ -248,8 +248,7 @@ void FixedHeightmap::generateContinued(f32 randmax, f32 randfactor,
s16 a = m_blocksize;
// Check that a is a power of two
- if((a & (a-1)) != 0)
- throw;
+ assert((a & (a-1)) == 0);
// Overwrite with GROUNDHEIGHT_NOTFOUND_SETVALUE
for(s16 y=0; y<=a; y++){
@@ -263,7 +262,7 @@ void FixedHeightmap::generateContinued(f32 randmax, f32 randfactor,
Seed borders from master heightmap
NOTE: Does this actually have any effect on the output?
*/
- struct SeedSpec
+ /*struct SeedSpec
{
v2s16 neighbour_start;
v2s16 heightmap_start;
@@ -307,7 +306,7 @@ void FixedHeightmap::generateContinued(f32 randmax, f32 randfactor,
hpos += seeds[i].dir;
npos += seeds[i].dir;
}
- }
+ }*/
/*dstream<<"borders seeded:"<<std::endl;
print();*/
@@ -548,13 +547,28 @@ FixedHeightmap * UnlimitedHeightmap::getHeightmap(v2s16 p_from, bool generate)
FixedHeightmap *heightmap = new FixedHeightmap(this, p, m_blocksize);
m_heightmaps.insert(p, heightmap);
+
+ f32 corners[4];
- f32 corners[4] = {
- m_base_generator->getValue(p+v2s16(0,0)),
- m_base_generator->getValue(p+v2s16(1,0)),
- m_base_generator->getValue(p+v2s16(1,1)),
- m_base_generator->getValue(p+v2s16(0,1)),
- };
+ if(m_palist)
+ {
+ //TODO: palist must be taken into account in generateContinued.
+ // It is almost useless in here.
+ s32 div = 2 * 16;
+ Settings *attr = m_palist->getNearAttr(p / div);
+ assert(attr);
+ corners[0] = attr->getFloat("baseheight");
+ corners[1] = attr->getFloat("baseheight");
+ corners[2] = attr->getFloat("baseheight");
+ corners[3] = attr->getFloat("baseheight");
+ }
+ else
+ {
+ corners[0] = m_base_generator->getValue(p+v2s16(0,0));
+ corners[1] = m_base_generator->getValue(p+v2s16(1,0));
+ corners[2] = m_base_generator->getValue(p+v2s16(1,1));
+ corners[3] = m_base_generator->getValue(p+v2s16(0,1));
+ }
f32 randmax = m_randmax_generator->getValue(p);
f32 randfactor = m_randfactor_generator->getValue(p);
@@ -829,7 +843,7 @@ UnlimitedHeightmap * UnlimitedHeightmap::deSerialize(std::istream &is)
ValueGenerator *basegen = new ConstantGenerator(basevalue);
UnlimitedHeightmap *hm = new UnlimitedHeightmap
- (blocksize, maxgen, factorgen, basegen);
+ (blocksize, maxgen, factorgen, basegen, NULL);
for(u32 i=0; i<heightmap_count; i++)
{
@@ -866,7 +880,7 @@ UnlimitedHeightmap * UnlimitedHeightmap::deSerialize(std::istream &is)
FixedHeightmap::serializedLength(version, blocksize);
UnlimitedHeightmap *hm = new UnlimitedHeightmap
- (blocksize, maxgen, factorgen, basegen);
+ (blocksize, maxgen, factorgen, basegen, NULL);
for(u32 i=0; i<heightmap_count; i++)
{