Line data Source code
1 : /*
2 : Minetest
3 : Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4 :
5 : This program is free software; you can redistribute it and/or modify
6 : it under the terms of the GNU Lesser General Public License as published by
7 : the Free Software Foundation; either version 2.1 of the License, or
8 : (at your option) any later version.
9 :
10 : This program is distributed in the hope that it will be useful,
11 : but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 : GNU Lesser General Public License for more details.
14 :
15 : You should have received a copy of the GNU Lesser General Public License along
16 : with this program; if not, write to the Free Software Foundation, Inc.,
17 : 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 : */
19 :
20 : #include "mapgen_singlenode.h"
21 : #include "voxel.h"
22 : #include "mapblock.h"
23 : #include "mapnode.h"
24 : #include "map.h"
25 : #include "nodedef.h"
26 : #include "voxelalgorithms.h"
27 : #include "profiler.h"
28 : #include "emerge.h"
29 :
30 :
31 0 : MapgenSinglenode::MapgenSinglenode(int mapgenid,
32 : MapgenParams *params, EmergeManager *emerge)
33 0 : : Mapgen(mapgenid, params, emerge)
34 : {
35 0 : flags = params->flags;
36 :
37 0 : INodeDefManager *ndef = emerge->ndef;
38 :
39 0 : c_node = ndef->getId("mapgen_singlenode");
40 0 : if (c_node == CONTENT_IGNORE)
41 0 : c_node = CONTENT_AIR;
42 0 : }
43 :
44 :
45 0 : MapgenSinglenode::~MapgenSinglenode()
46 : {
47 0 : }
48 :
49 : //////////////////////// Map generator
50 :
51 0 : void MapgenSinglenode::makeChunk(BlockMakeData *data)
52 : {
53 : // Pre-conditions
54 : assert(data->vmanip);
55 : assert(data->nodedef);
56 : assert(data->blockpos_requested.X >= data->blockpos_min.X &&
57 : data->blockpos_requested.Y >= data->blockpos_min.Y &&
58 : data->blockpos_requested.Z >= data->blockpos_min.Z);
59 : assert(data->blockpos_requested.X <= data->blockpos_max.X &&
60 : data->blockpos_requested.Y <= data->blockpos_max.Y &&
61 : data->blockpos_requested.Z <= data->blockpos_max.Z);
62 :
63 0 : this->generating = true;
64 0 : this->vm = data->vmanip;
65 0 : this->ndef = data->nodedef;
66 :
67 0 : v3s16 blockpos_min = data->blockpos_min;
68 0 : v3s16 blockpos_max = data->blockpos_max;
69 :
70 : // Area of central chunk
71 0 : v3s16 node_min = blockpos_min*MAP_BLOCKSIZE;
72 0 : v3s16 node_max = (blockpos_max+v3s16(1,1,1))*MAP_BLOCKSIZE-v3s16(1,1,1);
73 :
74 0 : blockseed = getBlockSeed2(node_min, data->seed);
75 :
76 0 : MapNode n_node(c_node);
77 :
78 0 : for (s16 z = node_min.Z; z <= node_max.Z; z++)
79 0 : for (s16 y = node_min.Y; y <= node_max.Y; y++) {
80 0 : u32 i = vm->m_area.index(node_min.X, y, z);
81 0 : for (s16 x = node_min.X; x <= node_max.X; x++) {
82 0 : if (vm->m_data[i].getContent() == CONTENT_IGNORE)
83 0 : vm->m_data[i] = n_node;
84 0 : i++;
85 : }
86 : }
87 :
88 : // Add top and bottom side of water to transforming_liquid queue
89 0 : updateLiquid(&data->transforming_liquid, node_min, node_max);
90 :
91 : // Calculate lighting
92 0 : if (flags & MG_LIGHT)
93 0 : calcLighting(node_min, node_max);
94 :
95 0 : this->generating = false;
96 0 : }
97 :
98 0 : int MapgenSinglenode::getGroundLevelAtPoint(v2s16 p)
99 : {
100 0 : return 0;
101 3 : }
102 :
|