mapgen improvements almost done

This commit is contained in:
darkrose 2017-07-19 23:02:07 +10:00
parent da3f690e4d
commit 9a6fc2e69e
10 changed files with 87 additions and 251 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 563 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 914 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 563 B

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 825 B

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 337 B

After

Width:  |  Height:  |  Size: 974 B

BIN
data/textures/menubg0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -664,72 +664,32 @@ void SpeedTests()
void drawMenuBackground(video::IVideoDriver* driver) void drawMenuBackground(video::IVideoDriver* driver)
{ {
char buff[1024]; char buff[1024];
core::dimension2d<u32> screensize = driver->getScreenSize(); core::dimension2d<s32> screensize(driver->getScreenSize());
video::ITexture *mud = NULL; video::ITexture *background = NULL;
video::ITexture *stone = NULL; if (path_get((char*)"texture",(char*)"menubg0.png",1,buff,1024))
video::ITexture *grass = NULL; background = driver->getTexture(buff);
if (path_get((char*)"texture",(char*)"mud.png",1,buff,1024)) if (!background)
mud = driver->getTexture(buff); return;
if (path_get((char*)"texture",(char*)"stone.png",1,buff,1024))
stone = driver->getTexture(buff);
if (path_get((char*)"texture",(char*)"grass_side.png",1,buff,1024))
grass = driver->getTexture(buff);
if (mud && stone && grass) {
video::ITexture *texture;
s32 texturesize = 128;
s32 tiled_y = screensize.Height / texturesize + 1;
s32 tiled_x = screensize.Width / texturesize + 1;
s32 grassline = (tiled_y/4)*3;
texture = stone; core::dimension2d<s32> texturesize(background->getSize());
for (s32 y=0; y<tiled_y; y++) core::rect<s32> image(0,0,texturesize.Width,texturesize.Height);
for (s32 x=0; x<tiled_x; x++) { core::rect<s32> pos(
if (y == grassline) { (texturesize.Width/2)-(screensize.Width/2),
core::rect<s32> rect(0,0,texturesize,texturesize); (texturesize.Height/2)-(screensize.Height/2),
rect += v2s32(x*texturesize, y*texturesize); texturesize.Width,
driver->draw2DImage( texturesize.Height
mud, );
rect, driver->draw2DImage(
core::rect<s32>( background,
core::position2d<s32>(0,0), image,
core::dimension2di(mud->getSize()) pos,
), NULL,
NULL, NULL,
NULL, true
true );
);
driver->draw2DImage(
grass,
rect,
core::rect<s32>(
core::position2d<s32>(0,0),
core::dimension2di(grass->getSize())
),
NULL,
NULL,
true
);
texture = mud;
}else{
core::rect<s32> rect(0,0,texturesize,texturesize);
rect += v2s32(x*texturesize, y*texturesize);
driver->draw2DImage(
texture,
rect,
core::rect<s32>(
core::position2d<s32>(0,0),
core::dimension2di(texture->getSize())
),
NULL,
NULL,
true
);
}
}
}
} }
class StderrLogOutput: public ILogOutput class StderrLogOutput: public ILogOutput

View File

@ -74,8 +74,6 @@ void make_block(BlockMakeData *data)
s16 approx_groundlevel = (s16)get_sector_average_ground_level(data, v2s16(blockpos.X, blockpos.Z)); s16 approx_groundlevel = (s16)get_sector_average_ground_level(data, v2s16(blockpos.X, blockpos.Z));
s16 approx_ground_depth = approx_groundlevel - (node_min.Y+MAP_BLOCKSIZE/2);
s16 minimum_groundlevel = (s16)get_sector_minimum_ground_level(data, v2s16(blockpos.X, blockpos.Z)); s16 minimum_groundlevel = (s16)get_sector_minimum_ground_level(data, v2s16(blockpos.X, blockpos.Z));
// Minimum amount of ground above the top of the central block // Minimum amount of ground above the top of the central block
s16 minimum_ground_depth = minimum_groundlevel - node_max.Y; s16 minimum_ground_depth = minimum_groundlevel - node_max.Y;
@ -99,9 +97,6 @@ void make_block(BlockMakeData *data)
/* /*
Make some 3D noise Make some 3D noise
*/ */
//NoiseBuffer noisebuf1;
//NoiseBuffer noisebuf2;
NoiseBuffer noisebuf_cave; NoiseBuffer noisebuf_cave;
NoiseBuffer noisebuf_ground_crumbleness; NoiseBuffer noisebuf_ground_crumbleness;
NoiseBuffer noisebuf_ground_wetness; NoiseBuffer noisebuf_ground_wetness;
@ -109,40 +104,28 @@ void make_block(BlockMakeData *data)
v3f minpos_f(node_min.X, node_min.Y, node_min.Z); v3f minpos_f(node_min.X, node_min.Y, node_min.Z);
v3f maxpos_f(node_max.X, node_max.Y, node_max.Z); v3f maxpos_f(node_max.X, node_max.Y, node_max.Z);
//TimeTaker timer("noisebuf.create");
/* /*
Cave noise Cave noise
*/ */
#if 1
noisebuf_cave.create(get_cave_noise1_params(data->seed), noisebuf_cave.create(get_cave_noise1_params(data->seed),
minpos_f.X, minpos_f.Y, minpos_f.Z, minpos_f.X, minpos_f.Y, minpos_f.Z,
maxpos_f.X, maxpos_f.Y, maxpos_f.Z, maxpos_f.X, maxpos_f.Y, maxpos_f.Z,
2, 2, 2); 2.0, 2.0, 2.0);
noisebuf_cave.multiply(get_cave_noise2_params(data->seed)); noisebuf_cave.multiply(get_cave_noise2_params(data->seed));
#endif
/* /*
Ground noise Ground noise
*/ */
// Sample length
v3f sl = v3f(4.0, 4.0, 4.0);
/*
Ground property noise
*/
sl = v3f(2.5, 2.5, 2.5);
noisebuf_ground_crumbleness.create( noisebuf_ground_crumbleness.create(
get_ground_crumbleness_params(data->seed), get_ground_crumbleness_params(data->seed),
minpos_f.X, minpos_f.Y, minpos_f.Z, minpos_f.X, minpos_f.Y, minpos_f.Z,
maxpos_f.X, maxpos_f.Y+5, maxpos_f.Z, maxpos_f.X, maxpos_f.Y+5, maxpos_f.Z,
sl.X, sl.Y, sl.Z); 2.5, 2.5, 2.5);
noisebuf_ground_wetness.create( noisebuf_ground_wetness.create(
get_ground_wetness_params(data->seed), get_ground_wetness_params(data->seed),
minpos_f.X, minpos_f.Y, minpos_f.Z, minpos_f.X, minpos_f.Y, minpos_f.Z,
maxpos_f.X, maxpos_f.Y+5, maxpos_f.Z, maxpos_f.X, maxpos_f.Y+5, maxpos_f.Z,
sl.X, sl.Y, sl.Z); 2.5, 2.5, 2.5);
} }
@ -198,166 +181,57 @@ void make_block(BlockMakeData *data)
{ {
PseudoRandom mineralrandom(blockseed); PseudoRandom mineralrandom(blockseed);
uint8_t minerals[15] = {
MINERAL_COAL, // all
MINERAL_TIN, // > -48 (-3)
MINERAL_COPPER,
MINERAL_SALT, // > -16 (-1)
MINERAL_COAL, // all
MINERAL_QUARTZ, // < -16 (-1)
MINERAL_SILVER, // < -32 (-2)
MINERAL_GOLD,
MINERAL_IRON, // < -48 (-3)
MINERAL_MITHRIL, // < -64 (-4)
MINERAL_RUBY, // < -72 (-5)
MINERAL_TURQUOISE,
MINERAL_AMETHYST,
MINERAL_SAPPHIRE,
MINERAL_SUNSTONE
};
/* int start_index = 0;
Add mithril blocks int end_index = 2;
*/ int count = 0;
for (s16 i=0; i<approx_ground_depth/4; i++) { int prob;
if (mineralrandom.next()%50 == 0) {
s16 x = mineralrandom.range(node_min.X+1, node_max.X-1);
s16 y = mineralrandom.range(node_min.Y+1, node_max.Y-1);
s16 z = mineralrandom.range(node_min.Z+1, node_max.Z-1);
// TODO: at random, some should be gems
u8 type = mineralrandom.next()%12;
switch (type) {
case 0:
type = MINERAL_RUBY;
break;
case 1:
type = MINERAL_TURQUOISE;
break;
case 2:
type = MINERAL_AMETHYST;
break;
case 3:
type = MINERAL_SAPPHIRE;
break;
case 4:
type = MINERAL_SUNSTONE;
break;
default:
type = MINERAL_MITHRIL;
}
for (u16 i=0; i<27; i++) {
v3s16 p = v3s16(x,y,z) + g_27dirs[i];
u32 vi = vmanip.m_area.index(p);
if (vmanip.m_data[vi].getContent() == base_content && mineralrandom.next()%8 == 0)
vmanip.m_data[vi] = MapNode(base_content,type);
}
} if (data->blockpos.Y > -2) {
} end_index = 3;
/* }else if (data->blockpos.Y < -4) {
Add others start_index = 4;
*/ end_index = 14;
if (limestone) { }else if (data->blockpos.Y < -3) {
/* start_index = 4;
Add tin/quartz (and rare coal) end_index = 9;
*/
u16 a = mineralrandom.range(0,15);
a = a*a*a;
u16 amount = 20;
u16 rareness = 40 / amount;
if (rareness == 0)
rareness = 1;
if (mineralrandom.next()%rareness == 0) {
u16 a = mineralrandom.next() % 16;
u16 amnt = amount * a*a*a / 1000;
for (s16 i=0; i<amnt; i++) {
s16 x = mineralrandom.range(node_min.X+1, node_max.X-1);
s16 y = mineralrandom.range(node_min.Y+1, node_max.Y-1);
s16 z = mineralrandom.range(node_min.Z+1, node_max.Z-1);
u8 type = mineralrandom.next()%12;
if (type == 0) {
type = MINERAL_COAL;
}else if (type > 8) {
type = MINERAL_QUARTZ;
}else if (type > 4) {
type = MINERAL_COPPER;
}else{
type = MINERAL_TIN;
}
for (u16 i=0; i<27; i++) {
v3s16 p = v3s16(x,y,z) + g_27dirs[i];
u32 vi = vmanip.m_area.index(p);
if (vmanip.m_data[vi].getContent() == CONTENT_LIMESTONE && mineralrandom.next()%8 == 0)
vmanip.m_data[vi] = MapNode(CONTENT_LIMESTONE, type);
}
}
}
}else{ }else{
{ start_index = 4;
u16 a = mineralrandom.range(0,15); end_index = 8;
a = a*a*a; }
u16 amount = 20 * a/1000;
for (s16 i=0; i<amount; i++) {
s16 x = mineralrandom.range(node_min.X+1, node_max.X-1);
s16 y = mineralrandom.range(node_min.Y+1, node_max.Y-1);
s16 z = mineralrandom.range(node_min.Z+1, node_max.Z-1);
u8 base_content = CONTENT_STONE; count = (end_index-start_index)+1;
MapNode new_content(CONTENT_IGNORE);
u32 sparseness = 6;
if (noisebuf_ground_crumbleness.get(x,y+5,z) < -0.1) { for (s16 i=0; i<20; i++) {
new_content = MapNode(CONTENT_STONE, MINERAL_COAL); s16 x = mineralrandom.range(node_min.X+1, node_max.X-1);
}else if (noisebuf_ground_wetness.get(x,y+5,z) > 0.1) { s16 y = mineralrandom.range(node_min.Y+1, node_max.Y-1);
new_content = MapNode(CONTENT_STONE, MINERAL_IRON); s16 z = mineralrandom.range(node_min.Z+1, node_max.Z-1);
}else if (noisebuf_ground_crumbleness.get(x,y,z) > 0.4) { u8 type = mineralrandom.next()%count;
new_content = MapNode(CONTENT_STONE, MINERAL_SILVER); for (u16 i=0; i<27; i++) {
}else if (noisebuf_ground_crumbleness.get(x,y,z) > 0.3) { v3s16 p = v3s16(x,y,z) + g_27dirs[i];
new_content = MapNode(CONTENT_STONE, MINERAL_QUARTZ); u32 vi = vmanip.m_area.index(p);
}else if (noisebuf_ground_crumbleness.get(x,y,z) > 0.2) { prob = 4;
new_content = MapNode(CONTENT_STONE, MINERAL_COPPER); if (minerals[type] == MINERAL_COAL)
}else if (noisebuf_ground_crumbleness.get(x,y,z) > 0.1) { prob = 2;
new_content = MapNode(CONTENT_STONE, MINERAL_TIN); if (vmanip.m_data[vi].getContent() == base_content && mineralrandom.next()%prob == 0)
}else if (noisebuf_ground_wetness.get(x,y+5,z) > 0.0) { vmanip.m_data[vi] = MapNode(base_content,minerals[type]);
new_content = MapNode(CONTENT_STONE, MINERAL_GOLD);
}
if (new_content.getContent() != CONTENT_IGNORE) {
for (u16 i=0; i<27; i++) {
v3s16 p = v3s16(x,y,z) + g_27dirs[i];
u32 vi = vmanip.m_area.index(p);
if (vmanip.m_data[vi].getContent() == base_content && mineralrandom.next()%sparseness == 0)
vmanip.m_data[vi] = new_content;
}
}
}
}
/*
Add coal
*/
u16 coal_amount = 30;
u16 coal_rareness = 60 / coal_amount;
if (coal_rareness == 0)
coal_rareness = 1;
if (mineralrandom.next()%coal_rareness == 0) {
u16 a = mineralrandom.next() % 16;
u16 amount = coal_amount * a*a*a / 1000;
for (s16 i=0; i<amount; i++) {
s16 x = mineralrandom.range(node_min.X+1, node_max.X-1);
s16 y = mineralrandom.range(node_min.Y+1, node_max.Y-1);
s16 z = mineralrandom.range(node_min.Z+1, node_max.Z-1);
for (u16 i=0; i<27; i++) {
v3s16 p = v3s16(x,y,z) + g_27dirs[i];
u32 vi = vmanip.m_area.index(p);
if (vmanip.m_data[vi].getContent() == CONTENT_STONE && mineralrandom.next()%8 == 0)
vmanip.m_data[vi] = MapNode(CONTENT_STONE, MINERAL_COAL);
}
}
}
/*
Add iron
*/
u16 iron_amount = 8;
u16 iron_rareness = 60 / iron_amount;
if (iron_rareness == 0)
iron_rareness = 1;
if (mineralrandom.next()%iron_rareness == 0) {
u16 a = mineralrandom.next() % 16;
u16 amount = iron_amount * a*a*a / 1000;
for (s16 i=0; i<amount; i++) {
s16 x = mineralrandom.range(node_min.X+1, node_max.X-1);
s16 y = mineralrandom.range(node_min.Y+1, node_max.Y-1);
s16 z = mineralrandom.range(node_min.Z+1, node_max.Z-1);
for (u16 i=0; i<27; i++) {
v3s16 p = v3s16(x,y,z) + g_27dirs[i];
u32 vi = vmanip.m_area.index(p);
if (vmanip.m_data[vi].getContent() == CONTENT_STONE && mineralrandom.next()%8 == 0)
vmanip.m_data[vi] = MapNode(CONTENT_STONE, MINERAL_IRON);
}
}
} }
} }
} }
@ -707,7 +581,6 @@ void make_block(BlockMakeData *data)
n->getContent() == CONTENT_MUD n->getContent() == CONTENT_MUD
|| n->getContent() == CONTENT_CLAY || n->getContent() == CONTENT_CLAY
|| n->getContent() == CONTENT_SAND || n->getContent() == CONTENT_SAND
|| n->getContent() == CONTENT_JUNGLETREE
) { ) {
found = true; found = true;
break; break;
@ -731,11 +604,11 @@ void make_block(BlockMakeData *data)
switch (data->biome) { switch (data->biome) {
case BIOME_WOODLANDS: case BIOME_WOODLANDS:
v = grassnoise.get(p.X,p.Y,p.Z); v = grassnoise.get(p.X,p.Y,p.Z);
if (v < -0.5) { if (v > -0.6 && v < -0.55) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_POTATO; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_POTATO;
}else if (v < -0.4) { }else if (v > -0.55 && v < -0.5) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_CARROT; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_CARROT;
}else if (v < -0.3) { }else if (v > -0.5 && v < -0.45) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_BEETROOT; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_BEETROOT;
}else{ }else{
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_WILDGRASS_LONG; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_WILDGRASS_LONG;
@ -743,14 +616,14 @@ void make_block(BlockMakeData *data)
break; break;
case BIOME_JUNGLE: case BIOME_JUNGLE:
v = grassnoise.get(p.X,p.Y,p.Z); v = grassnoise.get(p.X,p.Y,p.Z);
if (v < -0.3) { if (v > -0.5 && v < -0.48) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_JUNGLEFERN;
}else if (v > -0.5 && v < -0.499) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_TEA; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_TEA;
}else if (v > -0.4 && v < -0.399) { }else if (v > -0.48 && v < -0.46) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_COFFEE; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_COFFEE;
}else if (v > -0.3 && v < -0.299) { }else if (v > -0.46 && v < -0.44) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_GRAPEVINE; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_GRAPEVINE;
}else if (((int)(v*10.0))%2 == 1) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_JUNGLEFERN;
}else{ }else{
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_JUNGLEGRASS; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_JUNGLEGRASS;
} }
@ -764,15 +637,21 @@ void make_block(BlockMakeData *data)
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_WHEAT; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_WHEAT;
}else if (v > -0.4 && v < -0.399) { }else if (v > -0.4 && v < -0.399) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_PUMPKIN; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_PUMPKIN;
}else if (v > -0.3 && v < -0.299) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FLOWER_DAFFODIL;
}else if (v > -0.2 && v < -0.199) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FLOWER_ROSE;
}else if (v > -0.1 && v < -0.099) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FLOWER_TULIP;
}else{ }else{
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_WILDGRASS_LONG; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_WILDGRASS_LONG;
} }
break; break;
case BIOME_FOREST: case BIOME_FOREST:
v = grassnoise.get(p.X,p.Y,p.Z); v = grassnoise.get(p.X,p.Y,p.Z);
if (v > -0.5 && v < -0.499) { if (v > -0.5 && v < -0.4) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_COTTON; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_COTTON;
}else if (v > -0.4 && v < -0.399) { }else if (v > -0.4 && v < -0.3) {
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_MELON; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_FARM_MELON;
}else{ }else{
vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_WILDGRASS_LONG; vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_WILDGRASS_LONG;

View File

@ -165,9 +165,6 @@ uint32_t get_grass_density(BlockMakeData *data, v2s16 p)
}else if (data->biome == BIOME_LAKE || data->biome == BIOME_WOODLANDS) { }else if (data->biome == BIOME_LAKE || data->biome == BIOME_WOODLANDS) {
if (r < 1) if (r < 1)
r = 5; r = 5;
}else if (data->biome == BIOME_OCEAN) {
if (r)
r /= 5;
} }
return r*3; return r*3;