some meshgen and map rendering updates
[voxelands-alt.git] / src / map / mapgen_basic.c
blob3abbfb5084bfa31eb69afb812871a7f1a9bd1ca6
1 /************************************************************************
2 * mapgen_basic.c
3 * voxelands - 3d voxel world sandbox game
4 * Copyright (C) Lisa 'darkrose' Milne 2016 <lisa@ltmnet.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>
18 ************************************************************************/
20 #include "common.h"
22 #define _MAPGEN_LOCAL
23 #include "map.h"
24 #include "content_block.h"
26 /* generate an underground region */
27 void mapgen_underground(pos_t *p)
29 pos_t os[8] = {
30 {-16,-16,-16},
31 {-16,-16,0},
32 {-16,0,0},
33 {-16,0,-16},
34 {0,-16,-16},
35 {0,0,-16},
36 {0,-16,0},
37 {0,0,0}
39 pos_t cp;
40 chunk_t *ch;
41 int i;
43 for (i=0; i<8; i++) {
44 cp.x = p->x+os[i].x;
45 cp.y = p->y+os[i].y;
46 cp.z = p->z+os[i].z;
48 ch = mapgen_create_chunk(&cp);
49 if (!ch)
50 continue;
52 mapgen_fill_chunk(ch,CONTENT_STONE);
53 ch->state &= ~CHUNK_STATE_UNGENERATED;
54 map_add_chunk(ch);
58 /* TODO: should be moved to mapgen_space.c */
59 void mapgen_space(pos_t *p)
61 /* TODO: ... and not do this */
62 mapgen_air(p);
65 /* generate an air region */
66 void mapgen_air(pos_t *p)
68 pos_t os[8] = {
69 {-16,-16,-16},
70 {-16,-16,0},
71 {-16,0,0},
72 {-16,0,-16},
73 {0,-16,-16},
74 {0,0,-16},
75 {0,-16,0},
76 {0,0,0}
78 pos_t cp;
79 chunk_t *ch;
80 int i;
82 for (i=0; i<8; i++) {
83 cp.x = p->x+os[i].x;
84 cp.y = p->y+os[i].y;
85 cp.z = p->z+os[i].z;
87 ch = mapgen_create_chunk(&cp);
88 if (!ch)
89 continue;
91 mapgen_fill_chunk(ch,CONTENT_AIR);
92 ch->state &= ~CHUNK_STATE_UNGENERATED;
93 map_add_chunk(ch);