Mapgen objects: Enable heatmap and humidmap for all biome api mapgens

master
paramat 2015-06-19 00:17:03 +01:00
parent d7190df07e
commit 70da8a940b
6 changed files with 49 additions and 31 deletions

View File

@ -77,6 +77,8 @@ Mapgen::Mapgen()
ndef = NULL; ndef = NULL;
heightmap = NULL; heightmap = NULL;
biomemap = NULL; biomemap = NULL;
heatmap = NULL;
humidmap = NULL;
} }
@ -94,6 +96,8 @@ Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) :
ndef = NULL; ndef = NULL;
heightmap = NULL; heightmap = NULL;
biomemap = NULL; biomemap = NULL;
heatmap = NULL;
humidmap = NULL;
} }

View File

@ -152,6 +152,8 @@ public:
u32 blockseed; u32 blockseed;
s16 *heightmap; s16 *heightmap;
u8 *biomemap; u8 *biomemap;
float *heatmap;
float *humidmap;
v3s16 csize; v3s16 csize;
GenerateNotifier gennotify; GenerateNotifier gennotify;

View File

@ -58,6 +58,8 @@ MapgenV5::MapgenV5(int mapgenid, MapgenParams *params, EmergeManager *emerge)
this->biomemap = new u8[csize.X * csize.Z]; this->biomemap = new u8[csize.X * csize.Z];
this->heightmap = new s16[csize.X * csize.Z]; this->heightmap = new s16[csize.X * csize.Z];
this->heatmap = NULL;
this->humidmap = NULL;
MapgenV5Params *sp = (MapgenV5Params *)params->sparams; MapgenV5Params *sp = (MapgenV5Params *)params->sparams;
this->spflags = sp->spflags; this->spflags = sp->spflags;
@ -341,6 +343,9 @@ void MapgenV5::calculateNoise()
noise_heat->result[i] += noise_heat_blend->result[i]; noise_heat->result[i] += noise_heat_blend->result[i];
noise_humidity->result[i] += noise_humidity_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()); //printf("calculateNoise: %dus\n", t.stop());
} }

View File

@ -24,9 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define LARGE_CAVE_DEPTH -256 #define LARGE_CAVE_DEPTH -256
/////////////////// Mapgen V5 flags
//#define MGV5_ 0x01
class BiomeManager; class BiomeManager;
extern FlagDesc flagdesc_mapgen_v5[]; extern FlagDesc flagdesc_mapgen_v5[];

View File

@ -61,6 +61,8 @@ MapgenV7::MapgenV7(int mapgenid, MapgenParams *params, EmergeManager *emerge)
this->biomemap = new u8[csize.X * csize.Z]; this->biomemap = new u8[csize.X * csize.Z];
this->heightmap = new s16[csize.X * csize.Z]; this->heightmap = new s16[csize.X * csize.Z];
this->heatmap = NULL;
this->humidmap = NULL;
this->ridge_heightmap = new s16[csize.X * csize.Z]; this->ridge_heightmap = new s16[csize.X * csize.Z];
MapgenV7Params *sp = (MapgenV7Params *)params->sparams; MapgenV7Params *sp = (MapgenV7Params *)params->sparams;
@ -376,6 +378,9 @@ void MapgenV7::calculateNoise()
noise_heat->result[i] += noise_heat_blend->result[i]; noise_heat->result[i] += noise_heat_blend->result[i];
noise_humidity->result[i] += noise_humidity_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()); //printf("calculateNoise: %dus\n", t.stop());
} }

View File

@ -510,21 +510,26 @@ int ModApiMapgen::l_get_mapgen_object(lua_State *L)
return 1; return 1;
} }
case MGOBJ_HEATMAP: { // Mapgen V7 specific objects case MGOBJ_HEATMAP: {
case MGOBJ_HUMIDMAP: if (!mg->heatmap)
if (strcmp(emerge->params.mg_name.c_str(), "v7"))
return 0;
MapgenV7 *mgv7 = (MapgenV7 *)mg;
float *arr = (mgobj == MGOBJ_HEATMAP) ?
mgv7->noise_heat->result : mgv7->noise_humidity->result;
if (!arr)
return 0; return 0;
lua_newtable(L); lua_newtable(L);
for (size_t i = 0; i != maplen; i++) { for (size_t i = 0; i != maplen; i++) {
lua_pushnumber(L, arr[i]); lua_pushnumber(L, mg->heatmap[i]);
lua_rawseti(L, -2, i + 1);
}
return 1;
}
case MGOBJ_HUMIDMAP: {
if (!mg->humidmap)
return 0;
lua_newtable(L);
for (size_t i = 0; i != maplen; i++) {
lua_pushnumber(L, mg->humidmap[i]);
lua_rawseti(L, -2, i + 1); lua_rawseti(L, -2, i + 1);
} }