Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add jungles back

  • Loading branch information...
commit 32e46fcb2e0bf903d0fe9b55a7a29a042490e9a3 1 parent 2351b84
@celeron55 authored
View
1  games/minimal/mods/default/mapgen.lua
@@ -19,6 +19,7 @@ minetest.register_alias("mapgen_cobble", "default:cobble")
minetest.register_alias("mapgen_mossycobble", "default:mossycobble")
minetest.register_alias("mapgen_dirt_with_grass", "default:dirt_with_grass")
minetest.register_alias("mapgen_junglegrass", "default:junglegrass")
+minetest.register_alias("mapgen_jungletree", "default:jungletree")
minetest.register_alias("mapgen_stone_with_coal", "default:stone_with_coal")
minetest.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
minetest.register_alias("mapgen_mese", "default:mese")
View
187 src/mapgen.cpp
@@ -870,7 +870,6 @@ double tree_amount_2d(u64 seed, v2s16 p)
return 0.04 * (noise-zeroval) / (1.0-zeroval);
}
-#if 0
double surface_humidity_2d(u64 seed, v2s16 p)
{
double noise = noise2d_perlin(
@@ -884,6 +883,7 @@ double surface_humidity_2d(u64 seed, v2s16 p)
return noise;
}
+#if 0
/*
Incrementally find ground level from 3d noise
*/
@@ -1195,9 +1195,14 @@ void make_block(BlockMakeData *data)
int volume_blocks = (blockpos_max.X - blockpos_min.X + 1)
* (blockpos_max.Y - blockpos_min.Y + 1)
* (blockpos_max.Z - blockpos_max.Z + 1);
+ /*int volume_blocks_real = (blockpos_max.X - blockpos_min.X + 1)
+ * (blockpos_max.Y - blockpos_min.Y + 1)
+ * (blockpos_max.Z - blockpos_min.Z + 1);*/
int volume_nodes = volume_blocks *
MAP_BLOCKSIZE*MAP_BLOCKSIZE*MAP_BLOCKSIZE;
+ /*int volume_nodes_real = volume_blocks_real *
+ MAP_BLOCKSIZE*MAP_BLOCKSIZE*MAP_BLOCKSIZE;*/
// Generated surface area
//double gen_area_nodes = MAP_BLOCKSIZE*MAP_BLOCKSIZE * rel_volume;
@@ -2099,8 +2104,17 @@ void make_block(BlockMakeData *data)
}
/*
+ Calculate some stuff
+ */
+
+ v2s16 p2d_center((node_min.X + node_max.X)/2, (node_min.Z + node_max.Z)/2);
+ float surface_humidity = surface_humidity_2d(data->seed, p2d_center);
+ bool is_jungle = surface_humidity > 0.75;
+
+ /*
Generate some trees
*/
+
assert(central_area_size.X == central_area_size.Z);
{
// Divide area into parts
@@ -2152,12 +2166,123 @@ void make_block(BlockMakeData *data)
}
p.Y++;
// Make a tree
- treegen::make_tree(vmanip, p, false, ndef);
+ if(is_jungle)
+ treegen::make_jungletree(vmanip, p, ndef);
+ else
+ treegen::make_tree(vmanip, p, false, ndef);
+ }
+ }
+ }
+
+ /*
+ If close to ground level, add jungle grass
+ */
+ if(node_min.Y < WATER_LEVEL && node_max.Y >= WATER_LEVEL && is_jungle)
+ {
+ PseudoRandom grassrandom(blockseed);
+ assert(central_area_size.X == central_area_size.Z);
+ // Divide area into parts
+ s16 div = 8;
+ s16 sidelen = central_area_size.X / div;
+ double area = sidelen * sidelen;
+ for(s16 x0=0; x0<div; x0++)
+ for(s16 z0=0; z0<div; z0++)
+ {
+ // Center position of part of division
+ v2s16 p2d_center(
+ node_min.X + sidelen/2 + sidelen*x0,
+ node_min.Z + sidelen/2 + sidelen*z0
+ );
+ // Minimum edge of part of division
+ v2s16 p2d_min(
+ node_min.X + sidelen*x0,
+ node_min.Z + sidelen*z0
+ );
+ // Maximum edge of part of division
+ v2s16 p2d_max(
+ node_min.X + sidelen + sidelen*x0 - 1,
+ node_min.Z + sidelen + sidelen*z0 - 1
+ );
+ // Amount of trees
+ u32 grass_count = 10.0 * area * tree_amount_2d(data->seed, p2d_center);
+ // Put trees in random places on part of division
+ for(u32 i=0; i<grass_count; i++)
+ {
+ s16 x = myrand_range(p2d_min.X, p2d_max.X);
+ s16 z = myrand_range(p2d_min.Y, p2d_max.Y);
+ s16 y = find_ground_level_from_noise(data->seed, v2s16(x,z), 4);
+ if(y < WATER_LEVEL)
+ continue;
+ if(y < node_min.Y || y > node_max.Y)
+ continue;
+ /*
+ Find exact ground level
+ */
+ v3s16 p(x,y+6,z);
+ bool found = false;
+ for(; p.Y >= y-6; p.Y--)
+ {
+ u32 i = vmanip.m_area.index(p);
+ MapNode *n = &vmanip.m_data[i];
+ if(data->nodedef->get(*n).is_ground_content)
+ {
+ found = true;
+ break;
+ }
+ }
+ // If not found, handle next one
+ if(found == false)
+ continue;
+ p.Y++;
+ if(vmanip.m_area.contains(p) == false)
+ continue;
+ if(vmanip.m_data[vmanip.m_area.index(p)].getContent() != CONTENT_AIR)
+ continue;
+ /*p.Y--;
+ if(vmanip.m_area.contains(p))
+ vmanip.m_data[vmanip.m_area.index(p)] = c_dirt;
+ p.Y++;*/
+ if(vmanip.m_area.contains(p))
+ vmanip.m_data[vmanip.m_area.index(p)] = c_junglegrass;
}
}
}
#if 0
+ /*
+ Add some kind of random stones
+ */
+
+ u32 random_stone_count = gen_area_nodes *
+ randomstone_amount_2d(data->seed, p2d_center);
+ // Put in random places on part of division
+ for(u32 i=0; i<random_stone_count; i++)
+ {
+ s16 x = myrand_range(node_min.X, node_max.X);
+ s16 z = myrand_range(node_min.Z, node_max.Z);
+ s16 y = find_ground_level_from_noise(data->seed, v2s16(x,z), 1);
+ // Don't add under water level
+ /*if(y < WATER_LEVEL)
+ continue;*/
+ // Don't add if doesn't belong to this block
+ if(y < node_min.Y || y > node_max.Y)
+ continue;
+ v3s16 p(x,y,z);
+ // Filter placement
+ /*{
+ u32 i = vmanip->m_area.index(v3s16(p));
+ MapNode *n = &vmanip->m_data[i];
+ if(n->getContent() != c_dirt && n->getContent() != c_dirt_with_grass)
+ continue;
+ }*/
+ // Will be placed one higher
+ p.Y++;
+ // Add it
+ make_randomstone(vmanip, p);
+ }
+#endif
+
+#if 0
/*
Make base ground level
*/
@@ -2379,17 +2504,6 @@ void make_block(BlockMakeData *data)
}
/*
- Calculate some stuff
- */
-
- float surface_humidity = surface_humidity_2d(data->seed, p2d_center);
- bool is_jungle = surface_humidity > 0.75;
- // Amount of trees
- u32 tree_count = gen_area_nodes * tree_amount_2d(data->seed, p2d_center);
- if(is_jungle)
- tree_count *= 5;
-
- /*
Add trees
*/
PseudoRandom treerandom(blockseed);
@@ -2467,53 +2581,6 @@ void make_block(BlockMakeData *data)
}
}
- /*
- Add jungle grass
- */
- if(is_jungle)
- {
- PseudoRandom grassrandom(blockseed);
- for(u32 i=0; i<surface_humidity*5*tree_count; i++)
- {
- s16 x = grassrandom.range(node_min.X, node_max.X);
- s16 z = grassrandom.range(node_min.Z, node_max.Z);
- s16 y = find_ground_level_from_noise(data->seed, v2s16(x,z), 4);
- if(y < WATER_LEVEL)
- continue;
- if(y < node_min.Y || y > node_max.Y)
- continue;
- /*
- Find exact ground level
- */
- v3s16 p(x,y+6,z);
- bool found = false;
- for(; p.Y >= y-6; p.Y--)
- {
- u32 i = vmanip->m_area.index(p);
- MapNode *n = &vmanip->m_data[i];
- if(data->nodedef->get(*n).is_ground_content)
- {
- found = true;
- break;
- }
- }
- // If not found, handle next one
- if(found == false)
- continue;
- p.Y++;
- if(vmanip.m_area.contains(p) == false)
- continue;
- if(vmanip.m_data[vmanip.m_area.index(p)].getContent() != CONTENT_AIR)
- continue;
- /*p.Y--;
- if(vmanip.m_area.contains(p))
- vmanip.m_data[vmanip.m_area.index(p)] = c_dirt;
- p.Y++;*/
- if(vmanip.m_area.contains(p))
- vmanip.m_data[vmanip.m_area.index(p)] = c_junglegrass;
- }
- }
-
#if 0
/*
Add some kind of random stones
View
6 src/treegen.cpp
@@ -428,8 +428,7 @@ v3f transposeMatrix(irr::core::matrix4 M, v3f v)
return translated;
}
-#if 0
-static void make_jungletree(VoxelManipulator &vmanip, v3s16 p0,
+void make_jungletree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
INodeDefManager *ndef)
{
MapNode treenode(ndef->getId("mapgen_jungletree"));
@@ -515,6 +514,5 @@ static void make_jungletree(VoxelManipulator &vmanip, v3s16 p0,
vmanip.m_data[vi] = leavesnode;
}
}
-#endif
-}; // namespace treegen
+}; // namespace treegen
View
2  src/treegen.h
@@ -49,6 +49,8 @@ MapNode fruitnode;
// Add default tree
void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
bool is_apple_tree, INodeDefManager *ndef);
+ void make_jungletree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
+ INodeDefManager *ndef);
// Add L-Systems tree (used by engine)
void make_ltree(ManualMapVoxelManipulator &vmanip, v3s16 p0, INodeDefManager *ndef,
Please sign in to comment.
Something went wrong with that request. Please try again.