adjust some tree shapes

This commit is contained in:
darkrose 2015-06-14 02:37:01 +10:00
parent 9a5eb994de
commit 5d8e522e17
3 changed files with 37 additions and 32 deletions

View File

@ -1718,11 +1718,11 @@ void ServerEnvironment::step(float dtime)
search.push_back(CONTENT_IGNORE);
core::map<v3s16, MapBlock*> 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<content_t> search;
search.push_back(CONTENT_AIR);

View File

@ -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<trunk_h; ii++)
{
if(vmanip.m_area.contains(p1))
for (s16 ii=0; ii<trunk_h; ii++) {
if (vmanip.m_area.contains(p1))
vmanip.m_data[vmanip.m_area.index(p1)] = treenode;
p1.Y++;
}
@ -56,25 +55,26 @@ static void make_tree(ManualMapVoxelManipulator &vmanip, 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<u8> leaves_d(leaves_a.getVolume());
for(s32 i=0; i<leaves_a.getVolume(); i++)
for (s32 i=0; i<leaves_a.getVolume(); i++) {
leaves_d[i] = 0;
}
// Force leaves at near the end of the trunk
{
s16 d = 1;
for(s16 z=-d; z<=d; z++)
for(s16 y=-d; y<=d; y++)
for(s16 x=-d; x<=d; x++)
{
s16 rad = 3;
for (s16 y=-1; y<=1; y++) {
for (s16 z=-rad; z<=rad; z++) {
for (s16 x=-rad; x<=rad; x++) {
if (rad < 3 || (z > -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)

View File

@ -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<u8> leaves_d(leaves_a.getVolume());
for (s32 i=0; i<leaves_a.getVolume(); i++) {
leaves_d[i] = 0;
}
// Force leaves at near the end of the trunk
for (s16 z=-1; z<=1; z++) {
s16 rad = 3;
for (s16 y=-1; y<=1; y++) {
for (s16 x=-1; x<=1; x++) {
leaves_d[leaves_a.index(v3s16(x,y,z))] = 1;
for (s16 z=-rad; z<=rad; z++) {
for (s16 x=-rad; x<=rad; x++) {
if (rad < 3 || (z > -rad && z < rad) || (x > -rad && x < rad))
leaves_d[leaves_a.index(v3s16(x,y,z))] = 1;
}
}
rad--;
}
// Add leaves randomly