mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 11:33:44 +01:00
backing up working heightmap.{h,cpp}
This commit is contained in:
parent
a176f9eb36
commit
69e7cd9b5b
@ -248,8 +248,7 @@ void FixedHeightmap::generateContinued(f32 randmax, f32 randfactor,
|
|||||||
s16 a = m_blocksize;
|
s16 a = m_blocksize;
|
||||||
|
|
||||||
// Check that a is a power of two
|
// Check that a is a power of two
|
||||||
if((a & (a-1)) != 0)
|
assert((a & (a-1)) == 0);
|
||||||
throw;
|
|
||||||
|
|
||||||
// Overwrite with GROUNDHEIGHT_NOTFOUND_SETVALUE
|
// Overwrite with GROUNDHEIGHT_NOTFOUND_SETVALUE
|
||||||
for(s16 y=0; y<=a; y++){
|
for(s16 y=0; y<=a; y++){
|
||||||
@ -263,7 +262,7 @@ void FixedHeightmap::generateContinued(f32 randmax, f32 randfactor,
|
|||||||
Seed borders from master heightmap
|
Seed borders from master heightmap
|
||||||
NOTE: Does this actually have any effect on the output?
|
NOTE: Does this actually have any effect on the output?
|
||||||
*/
|
*/
|
||||||
struct SeedSpec
|
/*struct SeedSpec
|
||||||
{
|
{
|
||||||
v2s16 neighbour_start;
|
v2s16 neighbour_start;
|
||||||
v2s16 heightmap_start;
|
v2s16 heightmap_start;
|
||||||
@ -307,7 +306,7 @@ void FixedHeightmap::generateContinued(f32 randmax, f32 randfactor,
|
|||||||
hpos += seeds[i].dir;
|
hpos += seeds[i].dir;
|
||||||
npos += seeds[i].dir;
|
npos += seeds[i].dir;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/*dstream<<"borders seeded:"<<std::endl;
|
/*dstream<<"borders seeded:"<<std::endl;
|
||||||
print();*/
|
print();*/
|
||||||
@ -549,12 +548,27 @@ FixedHeightmap * UnlimitedHeightmap::getHeightmap(v2s16 p_from, bool generate)
|
|||||||
|
|
||||||
m_heightmaps.insert(p, heightmap);
|
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)),
|
if(m_palist)
|
||||||
m_base_generator->getValue(p+v2s16(1,1)),
|
{
|
||||||
m_base_generator->getValue(p+v2s16(0,1)),
|
//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 randmax = m_randmax_generator->getValue(p);
|
||||||
f32 randfactor = m_randfactor_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);
|
ValueGenerator *basegen = new ConstantGenerator(basevalue);
|
||||||
|
|
||||||
UnlimitedHeightmap *hm = new UnlimitedHeightmap
|
UnlimitedHeightmap *hm = new UnlimitedHeightmap
|
||||||
(blocksize, maxgen, factorgen, basegen);
|
(blocksize, maxgen, factorgen, basegen, NULL);
|
||||||
|
|
||||||
for(u32 i=0; i<heightmap_count; i++)
|
for(u32 i=0; i<heightmap_count; i++)
|
||||||
{
|
{
|
||||||
@ -866,7 +880,7 @@ UnlimitedHeightmap * UnlimitedHeightmap::deSerialize(std::istream &is)
|
|||||||
FixedHeightmap::serializedLength(version, blocksize);
|
FixedHeightmap::serializedLength(version, blocksize);
|
||||||
|
|
||||||
UnlimitedHeightmap *hm = new UnlimitedHeightmap
|
UnlimitedHeightmap *hm = new UnlimitedHeightmap
|
||||||
(blocksize, maxgen, factorgen, basegen);
|
(blocksize, maxgen, factorgen, basegen, NULL);
|
||||||
|
|
||||||
for(u32 i=0; i<heightmap_count; i++)
|
for(u32 i=0; i<heightmap_count; i++)
|
||||||
{
|
{
|
||||||
|
@ -502,22 +502,27 @@ private:
|
|||||||
core::map<v2s16, FixedHeightmap*> m_heightmaps;
|
core::map<v2s16, FixedHeightmap*> m_heightmaps;
|
||||||
s16 m_blocksize;
|
s16 m_blocksize;
|
||||||
|
|
||||||
|
// TODO: Remove ValueGenerators
|
||||||
ValueGenerator *m_randmax_generator;
|
ValueGenerator *m_randmax_generator;
|
||||||
ValueGenerator *m_randfactor_generator;
|
ValueGenerator *m_randfactor_generator;
|
||||||
ValueGenerator *m_base_generator;
|
ValueGenerator *m_base_generator;
|
||||||
|
|
||||||
|
PointAttributeList *m_palist;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UnlimitedHeightmap(
|
UnlimitedHeightmap(
|
||||||
s16 blocksize,
|
s16 blocksize,
|
||||||
ValueGenerator *randmax_generator,
|
ValueGenerator *randmax_generator,
|
||||||
ValueGenerator *randfactor_generator,
|
ValueGenerator *randfactor_generator,
|
||||||
ValueGenerator *base_generator
|
ValueGenerator *base_generator,
|
||||||
|
PointAttributeList *palist=NULL
|
||||||
):
|
):
|
||||||
m_blocksize(blocksize),
|
m_blocksize(blocksize),
|
||||||
m_randmax_generator(randmax_generator),
|
m_randmax_generator(randmax_generator),
|
||||||
m_randfactor_generator(randfactor_generator),
|
m_randfactor_generator(randfactor_generator),
|
||||||
m_base_generator(base_generator)
|
m_base_generator(base_generator),
|
||||||
|
m_palist(palist)
|
||||||
{
|
{
|
||||||
assert(m_randmax_generator != NULL);
|
assert(m_randmax_generator != NULL);
|
||||||
assert(m_randfactor_generator != NULL);
|
assert(m_randfactor_generator != NULL);
|
||||||
@ -538,12 +543,6 @@ public:
|
|||||||
delete m_base_generator;
|
delete m_base_generator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void setParams(f32 randmax, f32 randfactor)
|
|
||||||
{
|
|
||||||
m_randmax = randmax;
|
|
||||||
m_randfactor = randfactor;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void print();
|
void print();
|
||||||
|
|
||||||
v2s16 getNodeHeightmapPos(v2s16 p)
|
v2s16 getNodeHeightmapPos(v2s16 p)
|
||||||
|
Loading…
Reference in New Issue
Block a user