#include "content_sao.h"
#include "nodedef.h"
#include "voxelalgorithms.h"
-#include "profiler.h"
#include "settings.h" // For g_settings
#include "emerge.h"
#include "dungeongen.h"
this->biomemap = new u8[csize.X * csize.Z];
this->heightmap = new s16[csize.X * csize.Z];
+ this->heatmap = NULL;
+ this->humidmap = NULL;
MapgenV5Params *sp = (MapgenV5Params *)params->sparams;
this->spflags = sp->spflags;
noise_height = new Noise(&sp->np_height, seed, csize.X, csize.Z);
// 3D terrain noise
- noise_cave1 = new Noise(&sp->np_cave1, seed, csize.X, csize.Y + 2, csize.Z);
- noise_cave2 = new Noise(&sp->np_cave2, seed, csize.X, csize.Y + 2, csize.Z);
- noise_ground = new Noise(&sp->np_ground, seed, csize.X, csize.Y + 2, csize.Z);
+ noise_cave1 = new Noise(&sp->np_cave1, seed, csize.X, csize.Y + 2, csize.Z);
+ noise_cave2 = new Noise(&sp->np_cave2, seed, csize.X, csize.Y + 2, csize.Z);
+ noise_ground = new Noise(&sp->np_ground, seed, csize.X, csize.Y + 2, csize.Z);
// Biome noise
- noise_heat = new Noise(¶ms->np_biome_heat, seed, csize.X, csize.Z);
- noise_humidity = new Noise(¶ms->np_biome_humidity, seed, csize.X, csize.Z);
+ noise_heat = new Noise(¶ms->np_biome_heat, seed, csize.X, csize.Z);
+ noise_humidity = new Noise(¶ms->np_biome_humidity, seed, csize.X, csize.Z);
+ noise_heat_blend = new Noise(¶ms->np_biome_heat_blend, seed, csize.X, csize.Z);
+ noise_humidity_blend = new Noise(¶ms->np_biome_humidity_blend, seed, csize.X, csize.Z);
//// Resolve nodes to be used
INodeDefManager *ndef = emerge->ndef;
delete noise_heat;
delete noise_humidity;
+ delete noise_heat_blend;
+ delete noise_humidity_blend;
delete[] heightmap;
delete[] biomemap;
noise_cave2->perlinMap3D(x, y, z);
}
- if (node_max.Y >= BIOMEGEN_BASE_V5) {
- noise_filler_depth->perlinMap2D(x, z);
- noise_heat->perlinMap2D(x, z);
- noise_humidity->perlinMap2D(x, z);
+ noise_filler_depth->perlinMap2D(x, z);
+ noise_heat->perlinMap2D(x, z);
+ noise_humidity->perlinMap2D(x, z);
+ noise_heat_blend->perlinMap2D(x, z);
+ noise_humidity_blend->perlinMap2D(x, z);
+
+ for (s32 i = 0; i < csize.X * csize.Z; i++) {
+ noise_heat->result[i] += noise_heat_blend->result[i];
+ noise_humidity->result[i] += noise_humidity_blend->result[i];
}
+ heatmap = noise_heat->result;
+ humidmap = noise_humidity->result;
//printf("calculateNoise: %dus\n", t.stop());
}
MgStoneType MapgenV5::generateBiomes(float *heat_map, float *humidity_map)
{
- if (node_max.Y < BIOMEGEN_BASE_V5)
- return STONE;
-
v3s16 em = vm->m_area.getExtent();
u32 index = 0;
MgStoneType stone_type = STONE;
void MapgenV5::generateCaves(int max_stone_y)
{
- u32 index = 0;
- u32 index2d = 0;
+ if (max_stone_y >= node_min.Y) {
+ u32 index = 0;
- for (s16 z=node_min.Z; z<=node_max.Z; z++) {
- for (s16 y=node_min.Y - 1; y<=node_max.Y + 1; y++) {
+ for (s16 z = node_min.Z; z <= node_max.Z; z++)
+ for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
u32 i = vm->m_area.index(node_min.X, y, z);
- for (s16 x=node_min.X; x<=node_max.X; x++, i++, index++, index2d++) {
+ for (s16 x = node_min.X; x <= node_max.X; x++, i++, index++) {
float d1 = contour(noise_cave1->result[index]);
float d2 = contour(noise_cave2->result[index]);
if (d1*d2 > 0.125) {
- Biome *biome = (Biome *)bmgr->getRaw(biomemap[index2d]);
content_t c = vm->m_data[i].getContent();
- if (!ndef->get(c).is_ground_content || c == CONTENT_AIR ||
- (y <= water_level &&
- c != biome->c_stone &&
- c != c_stone))
+ if (!ndef->get(c).is_ground_content || c == CONTENT_AIR)
continue;
vm->m_data[i] = MapNode(CONTENT_AIR);
}
}
- index2d -= ystride;
}
- index2d += ystride;
}
if (node_max.Y > LARGE_CAVE_DEPTH)