summaryrefslogtreecommitdiffstats
path: root/src/Generating/Trees.h
blob: 82c33cf531ab6898057692ce6685887270762d74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282

// Trees.h

// Interfaces to helper functions used for generating trees

/*
Note that all of these functions must generate the same tree image for the same input (x, y, z, seq)
	- cStructGenTrees depends on this
To generate a random image for the (x, y, z) coords, pass an arbitrary value as (seq).
Each function returns two arrays of blocks, "logs" and "other". The point is that logs are of higher priority,
logs can overwrite others(leaves), but others shouldn't overwrite logs. This is an optimization for the generator.
*/





#pragma once

#include "../Noise/Noise.h"
#include "../ChunkDef.h"  // For sSetBlockVector




// Blocks that don't block tree growth:
#define CASE_TREE_ALLOWED_BLOCKS \
	case E_BLOCK_AIR:            \
	case E_BLOCK_LEAVES:         \
	case E_BLOCK_NEW_LEAVES:     \
	case E_BLOCK_SNOW:           \
	case E_BLOCK_TALL_GRASS:     \
	case E_BLOCK_DEAD_BUSH:      \
	case E_BLOCK_SAPLING:        \
	case E_BLOCK_VINES

// Blocks that a tree may overwrite when growing:
#define CASE_TREE_OVERWRITTEN_BLOCKS                                                                   \
	case E_BLOCK_AIR:                                                                                  \
	/* case E_BLOCK_LEAVES: LEAVES are a special case, they can be overwritten only by log. Handled in \
	 * cChunkMap::ReplaceTreeBlocks(). */                                                              \
	case E_BLOCK_SNOW:                                                                                 \
	case E_BLOCK_TALL_GRASS:                                                                           \
	case E_BLOCK_BIG_FLOWER:                                                                           \
	case E_BLOCK_DEAD_BUSH:                                                                            \
	case E_BLOCK_SAPLING:                                                                              \
	case E_BLOCK_VINES





/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a tree at the specified coords
 * (lowest trunk block) in the specified biome */
void GetTreeImageByBiome(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	EMCSBiome a_Biome,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random apple tree */
void GetAppleTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a small (nonbranching) apple
 * tree */
void GetSmallAppleTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a large (branching) apple tree
 */
void GetLargeAppleTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks with the logs of a tree branch of the provided log type.
The length of the branch can be changed with the a_BranchLength.
The initial direction is a_StartDirection. The direction can be manipulated with a_Direction to create a curve.
Returns the position of the last log block placed. */
Vector3d GetTreeBranch(
	BLOCKTYPE a_BlockType,
	NIBBLETYPE a_BlockMeta,
	Vector3i a_BlockPos,
	int a_BranchLength,
	Vector3d a_StartDirection,
	Vector3d a_Direction,
	sSetBlockVector & a_LogBlocks
);

/** Returns the meta for a log from the given direction */
NIBBLETYPE GetLogMetaFromDirection(NIBBLETYPE a_BlockMeta, Vector3d a_Direction);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random birch tree */
void GetBirchTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random acacia tree */
void GetAcaciaTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random darkoak tree */
void GetDarkoakTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random large birch tree */
void GetTallBirchTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random conifer tree. The
 * probability to get a large pine is higher than a spruce tree */
void GetConiferTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks,
	bool a_Large = false
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random spruce */
void GetSpruceTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks,
	bool a_Large = false
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random pine */
void GetPineTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks,
	bool a_Large = false
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random small spruce (short
 * conifer, two layers of leaves) */
void GetSmallSpruceTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random small pine (tall
 * conifer, little leaves at top) */
void GetSmallPineTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random large spruce (short
 * conifer, multiple layers of leaves) */
void GetLargeSpruceTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random large pine (tall
 * conifer, little leaves at top) */
void GetLargePineTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random swampland tree */
void GetSwampTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random apple bush (for
 * jungles) */
void GetAppleBushImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a random jungle tree */
void GetJungleTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks,
	bool a_Large
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a large jungle tree (2x2 trunk)
 */
void GetLargeJungleTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks (dirt & leaves) with the blocks required to form a small jungle tree (1x1 trunk)
 */
void GetSmallJungleTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks with the blocks required to form the red mushroom */
void GetRedMushroomTreeImage(
	Vector3i vector3,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);

/** Fills a_LogBlocks and a_OtherBlocks with the blocks required to form the brown mushroom */
void GetBrownMushroomTreeImage(
	Vector3i a_BlockPos,
	cNoise & a_Noise,
	int a_Seq,
	sSetBlockVector & a_LogBlocks,
	sSetBlockVector & a_OtherBlocks
);