From 5d8e522e17bcab0322d5efb578d3518ffeff431c Mon Sep 17 00:00:00 2001 From: darkrose Date: Sun, 14 Jun 2015 02:37:01 +1000 Subject: [PATCH] adjust some tree shapes --- src/environment.cpp | 8 ++++---- src/mapgen.cpp | 50 +++++++++++++++++++++++---------------------- src/plantgrowth.cpp | 11 ++++++---- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/environment.cpp b/src/environment.cpp index 6afd129..e7783a1 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -1718,11 +1718,11 @@ void ServerEnvironment::step(float dtime) search.push_back(CONTENT_IGNORE); core::map modified_blocks; - if (!searchNearInv(p,v3s16(-10,2,-10),v3s16(10,12,10),search,NULL)) { - plantgrowth_largetree(this,p); - }else{ + //if (!searchNearInv(p,v3s16(-10,2,-10),v3s16(10,12,10),search,NULL)) { + //plantgrowth_largetree(this,p); + //}else{ plantgrowth_tree(this,p); - } + //} }else if (n.envticks > 15) { std::vector search; search.push_back(CONTENT_AIR); diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 2d88e46..1a3609e 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -46,9 +46,8 @@ static void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0) s16 trunk_h = myrand_range(5,6); v3s16 p1 = p0; - for(s16 ii=0; ii leaves_d(leaves_a.getVolume()); - for(s32 i=0; i -rad && z < rad) || (x > -rad && x < rad)) leaves_d[leaves_a.index(v3s16(x,y,z))] = 1; - } + } + } + rad--; } // Add leaves randomly - for(u32 iii=0; iii<7; iii++) - { + for (u32 iii=0; iii<7; iii++) { s16 d = 1; v3s16 p( @@ -83,31 +83,33 @@ static void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0) myrand_range(leaves_a.MinEdge.Z, leaves_a.MaxEdge.Z-d) ); - for(s16 z=0; z<=d; z++) - for(s16 y=0; y<=d; y++) - for(s16 x=0; x<=d; x++) - { + for (s16 z=0; z<=d; z++) { + for (s16 y=0; y<=d; y++) { + for (s16 x=0; x<=d; x++) { leaves_d[leaves_a.index(p+v3s16(x,y,z))] = 1; } + } + } } // Blit leaves to vmanip - for(s16 z=leaves_a.MinEdge.Z; z<=leaves_a.MaxEdge.Z; z++) - for(s16 y=leaves_a.MinEdge.Y; y<=leaves_a.MaxEdge.Y; y++) - for(s16 x=leaves_a.MinEdge.X; x<=leaves_a.MaxEdge.X; x++) - { + for (s16 z=leaves_a.MinEdge.Z; z<=leaves_a.MaxEdge.Z; z++) { + for (s16 y=leaves_a.MinEdge.Y; y<=leaves_a.MaxEdge.Y; y++) { + for (s16 x=leaves_a.MinEdge.X; x<=leaves_a.MaxEdge.X; x++) { v3s16 p(x,y,z); p += p1; - if(vmanip.m_area.contains(p) == false) + if (vmanip.m_area.contains(p) == false) continue; u32 vi = vmanip.m_area.index(p); - if(vmanip.m_data[vi].getContent() != CONTENT_AIR + if (vmanip.m_data[vi].getContent() != CONTENT_AIR && vmanip.m_data[vi].getContent() != CONTENT_IGNORE) continue; u32 i = leaves_a.index(x,y,z); if (leaves_d[i] == 1) vmanip.m_data[vi] = leavesnode; } + } + } } static void make_appletree(ManualMapVoxelManipulator &vmanip, v3s16 p0) diff --git a/src/plantgrowth.cpp b/src/plantgrowth.cpp index f6e9a49..5ced00a 100644 --- a/src/plantgrowth.cpp +++ b/src/plantgrowth.cpp @@ -42,19 +42,22 @@ void plantgrowth_tree(ServerEnvironment *env, v3s16 p0) // p1 is now the last piece of the trunk p1.Y -= 1; - VoxelArea leaves_a(v3s16(-2,-1,-2), v3s16(2,2,2)); + VoxelArea leaves_a(v3s16(-3,-1,-3), v3s16(3,2,3)); Buffer leaves_d(leaves_a.getVolume()); for (s32 i=0; i -rad && z < rad) || (x > -rad && x < rad)) + leaves_d[leaves_a.index(v3s16(x,y,z))] = 1; } } + rad--; } // Add leaves randomly