From 231386d50192a798fd30d49ae758da254f4a9db1 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Mon, 28 Feb 2011 14:51:57 +0200 Subject: [PATCH] tweaked mapgen --- data/grass.png | Bin 876 -> 874 bytes data/mud.png | Bin 763 -> 758 bytes src/main.cpp | 8 +- src/map.cpp | 195 +++++++++++++++++++++++++++++++------------------ src/map.h | 1 + 5 files changed, 130 insertions(+), 74 deletions(-) diff --git a/data/grass.png b/data/grass.png index 47d7b11fe953ceb517ac7886d9fe1dba91317eac..bfe80aec2ff2f3a483125366505c1111969162df 100644 GIT binary patch delta 790 zcmV+x1L^$i2I>ZoVSfxC2KfQ6!~g&S>PbXFR5;5e$XjmXQ~-eC-}dp{NgT&eMr z(ciKc_F2iGX@690%ldWCS+!WM&)ciy<~G3!&b)072*ae3XCmLmGa9ZxP7v!&&D3+C zgQtf*<*8>rpI|G8n;+(2_Nd07?|bq?jU}KeY<7o%T;+&GSaaQMZpOHmFltj><5T{xaO-zDVU|BFU z8oQ#P>`ENhME7(qj z{ceuzTdH%1X_|Cr!6I3*`g@0OD|A&0qUir{bbpx6MpT8t%(Li@iXcchm;`}E7+YAjpxQ&HS{wpg*MqjA9vXJp3EeUf zmWFuUp16NLkt{vp#3tQHnzF`nO~#Wcnjv{fH(;22_-@YUFDc>F#j|~OuPOfl`8jmo UXb+WmCjbBd07*qoM6N<$g6l7fj{pDw delta 792 zcmV+z1Lyqe2J8lqVSfN663=K{qyPW{>`6pHR5;5e$V+nLL;!%{UsAWMhb3EzWrrk8 z2$?DfRkNT9)|`P`u;U8sxB^##B@2eC83sF(vEzpnS+-u5+RcJ*`58a``bGzVj}u9h zHaKo;+<~O5Tkan|qiYqOF`zh~*`;ej&*6G4BN!&j&x*%j?H{tp@oT$K!* zCH5S24^N9d$5N3bBL-)O`)?DF3f)>LrO1m0TR@#V?20p)&M|)e?K?e-Lza&Pwj;0& zm+khzD6;S!fsQnsdvt4|ZLpN4R{;SbXB*7AYDkYqrhnH7K`3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PYEL7Ip;cFL1Ff5m1oZ#JEyuK|bN#wUr zLZo=;h<`-kcJCUBalYVGM_}1~w}~eYzOEz7itV;ie5U2tyu6b4?_&j8fV^LL+tLb+ z5aH?#TPwt7t*Yv9Xc)4V28PT>Q{%^s&hj6Mo8<9+Z6;HxFgKLpr1$3Suys^uV$TSu zbAzXo1e1;jxQ6`VOa1Xg=a_m%so3 N002ovPDHLkV1m0@Sk?dl diff --git a/src/main.cpp b/src/main.cpp index 2c9e9cf7..01dd93ff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -253,7 +253,8 @@ Doing now (most important at the top): * not done === Next -* Somehow generate trees +* Generate trees better + - Add a "trees_added" flag to sector, or something === Fixmes * Check the fixmes in the list above @@ -275,7 +276,6 @@ Doing now (most important at the top): * Switch to using a safe way for the self and env pointers * Make some global environment hooks, like node placed and general on_step() -* Map should make the appropriate MapEditEvents * Add a global Lua spawn handler and such * Get rid of MapBlockObjects * Other players could be sent to clients as LuaCAOs @@ -1306,7 +1306,9 @@ void updateMapPlotTexture(v2f centerpos, video::IVideoDriver* driver, c.set(255, 160, 160, 160); else if(h < WATER_LEVEL - 0.5) // Water c.set(255, 50, 50, 255); - else if(h < WATER_LEVEL + 2) // Sand + else if(h < WATER_LEVEL + 2 + && get_have_sand(client->getMapSeed(), pf)) + // Sand c.set(255, 237, 201, 175); #if 1 else if(h < WATER_LEVEL + 10) // Green diff --git a/src/map.cpp b/src/map.cpp index bca56a6f..6ba0f0d1 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1875,9 +1875,9 @@ void make_tree(VoxelManipulator &vmanip, v3s16 p0) MapNode treenode(CONTENT_TREE); MapNode leavesnode(CONTENT_LEAVES); - vmanip.emerge(VoxelArea(p0-v3s16(2,0,2),p0+v3s16(2,6,2))); + vmanip.emerge(VoxelArea(p0-v3s16(2,0,2),p0+v3s16(2,7+2,2))); - s16 trunk_h = myrand_range(3, 6); + s16 trunk_h = myrand_range(4, 7); v3s16 p1 = p0; for(s16 ii=0; ii -0.15); +} + // -1->0, 0->1, 1->0 double contour(double v) { @@ -2014,46 +2022,52 @@ double base_rock_level_2d(u64 seed, v2f p) //h += 30 * m2; }*/ - // Huge mountains - double m3 = 150.0 - 800.0 * noise2d_perlin_abs( - 0.5+(float)p.X/2000., 0.5+(float)p.Y/2000., - (seed>>32)+985251, 9, 0.5); - if(m3 > h) - h = m3; - /*double tm2 = contour_flat_top(-1.0 + 3.0 * noise2d_perlin( 0.0+(float)p.X/300., 0.0+(float)p.Y/300., (seed>>32)+78593, 5, 0.55), 0.15); h += 30 * tm2;*/ #if 1 + // Huge mountains + double m3 = 150.0 - 500.0 * noise2d_perlin_abs( + 0.324+(float)p.X/2000., 0.423+(float)p.Y/2000., + (seed>>32)+985251, 9, 0.55); + if(m3 > h) + h = m3; +#endif + +#if 1 + // Some kind of hill chains or something { - double a1 = 30 - 100. * noise2d_perlin_abs( - 0.5+(float)p.X/250., 0.5+(float)p.Y/250., - seed+850342, 5, 0.63); + double a1 = 30 - 130. * noise2d_perlin_abs( + 0.5+(float)p.X/500., 0.5+(float)p.Y/500., + seed+850342, 6, 0.63); double d = 15; if(a1 > d) a1 = d + sqrt(a1-d); - if(a1 > h) - h = a1; + /*if(a1 > h) + h = a1;*/ + if(a1 > 0) + h += a1; } #endif #if 1 - double base = 35. * noise2d_perlin( + double base = -5. + 25. * noise2d_perlin( 0.5+(float)p.X/500., 0.5+(float)p.Y/500., - (seed>>32)+653876, 7, 0.55); + (seed>>32)+653876, 7, 0.6); #else double base = 0; #endif #if 1 - double higher = 50. * noise2d_perlin( + double higher = 40. * noise2d_perlin( 0.5+(float)p.X/250., 0.5+(float)p.Y/250., - seed+39292, 6, 0.63); + seed+39292, 7, 0.55); /*double higher = 50. * noise2d_perlin_abs( 0.5+(float)p.X/250., 0.5+(float)p.Y/250., seed+85039, 5, 0.63);*/ + //higher = 25; if(higher > base) { @@ -2062,24 +2076,43 @@ double base_rock_level_2d(u64 seed, v2f p) 0.5+(float)p.X/250., 0.5+(float)p.Y/250., seed-932, 7, 0.7); b = rangelim(b, 0.0, 1000.0); +#if 1 b = pow(b, 5); - b *= 7; + b *= 16; b = rangelim(b, 3.0, 1000.0); //dstream<<"b="<= surface_y_max + d_up && block_low_y_f > WATER_LEVEL + d_up) @@ -4152,14 +4197,14 @@ MapBlock * ServerMap::generateBlock( block_type = BT_SURFACE; } - if(block_type == BT_GROUND || block_type == BT_SKY) + if(/*block_type == BT_GROUND ||*/ block_type == BT_SKY) { lowest_ground_y = surface_y_min; highest_ground_y = surface_y_max; } } - if(block_type == BT_SURFACE) + if(block_type == BT_SURFACE || block_type == BT_GROUND) { /* Generate ground precisely @@ -4204,9 +4249,11 @@ MapBlock * ServerMap::generateBlock( Calculate material */ + v3f real_pos_f = intToFloat(real_pos, 1); + v2f real_pos_f_2d(real_pos_f.X, real_pos_f.Z); double depth_guess; bool is_ground = is_base_ground(m_seed, - intToFloat(real_pos, 1), &depth_guess); + real_pos_f, &depth_guess); // Estimate the surface height float surface_y_f = (float)real_y + depth_guess; @@ -4243,9 +4290,13 @@ MapBlock * ServerMap::generateBlock( // If it's surface_depth under ground, it's stone if((float)real_y <= surface_y_f - surface_depth - 0.75) { - n.d = CONTENT_STONE; + if(is_underground_mud(m_seed, real_pos_f)) + n.d = CONTENT_MUD; + else + n.d = CONTENT_STONE; } - else if(surface_y_f <= WATER_LEVEL + 2.0) + else if(surface_y_f <= WATER_LEVEL + 2.1 + && get_have_sand(m_seed, real_pos_f_2d)) { n.d = CONTENT_SAND; } @@ -4357,7 +4408,7 @@ MapBlock * ServerMap::generateBlock( MapNode n_fill; if(block_type == BT_GROUND) { - n_fill.d = CONTENT_STONE; + //n_fill.d = CONTENT_STONE; } else if(block_type == BT_SKY) { @@ -4838,13 +4889,14 @@ continue_generating: /* Add trees */ +#if 1 if(some_part_underground && !completely_underground) { MapVoxelManipulator vm(this); double a = tree_amount_2d(m_seed, v2s16(p_nodes.X+8, p_nodes.Z+8)); u16 tree_count = (u16)(a*MAP_BLOCKSIZE*MAP_BLOCKSIZE); - for(u16 i=0; i