@@ -46,8 +46,10 @@ BiomeManager::BiomeManager(Server *server) :
46
46
b->depth_filler = -MAX_MAP_GENERATION_LIMIT;
47
47
b->depth_water_top = 0 ;
48
48
b->depth_riverbed = 0 ;
49
- b->y_min = -MAX_MAP_GENERATION_LIMIT;
50
- b->y_max = MAX_MAP_GENERATION_LIMIT;
49
+ b->min_pos = v3s16 (-MAX_MAP_GENERATION_LIMIT,
50
+ -MAX_MAP_GENERATION_LIMIT, -MAX_MAP_GENERATION_LIMIT);
51
+ b->max_pos = v3s16 (MAX_MAP_GENERATION_LIMIT,
52
+ MAX_MAP_GENERATION_LIMIT, MAX_MAP_GENERATION_LIMIT);
51
53
b->heat_point = 0.0 ;
52
54
b->humidity_point = 0.0 ;
53
55
b->vertical_blend = 0 ;
@@ -106,7 +108,7 @@ float BiomeManager::getHumidityAtPosOriginal(v3s16 pos, NoiseParams &np_humidity
106
108
107
109
108
110
// For BiomeGen type 'BiomeGenOriginal'
109
- Biome *BiomeManager::getBiomeFromNoiseOriginal (float heat, float humidity, s16 y )
111
+ Biome *BiomeManager::getBiomeFromNoiseOriginal (float heat, float humidity, v3s16 pos )
110
112
{
111
113
Biome *biome_closest = nullptr ;
112
114
Biome *biome_closest_blend = nullptr ;
@@ -115,14 +117,17 @@ Biome *BiomeManager::getBiomeFromNoiseOriginal(float heat, float humidity, s16 y
115
117
116
118
for (size_t i = 1 ; i < getNumObjects (); i++) {
117
119
Biome *b = (Biome *)getRaw (i);
118
- if (!b || y > b->y_max + b->vertical_blend || y < b->y_min )
120
+ if (!b ||
121
+ pos.Y < b->min_pos .Y || pos.Y > b->max_pos .Y + b->vertical_blend ||
122
+ pos.X < b->min_pos .X || pos.X > b->max_pos .X ||
123
+ pos.Z < b->min_pos .Z || pos.Z > b->max_pos .Z )
119
124
continue ;
120
125
121
126
float d_heat = heat - b->heat_point ;
122
127
float d_humidity = humidity - b->humidity_point ;
123
128
float dist = (d_heat * d_heat) + (d_humidity * d_humidity);
124
129
125
- if (y <= b->y_max ) { // Within y limits of biome b
130
+ if (pos. Y <= b->max_pos . Y ) { // Within y limits of biome b
126
131
if (dist < dist_min) {
127
132
dist_min = dist;
128
133
biome_closest = b;
@@ -133,10 +138,10 @@ Biome *BiomeManager::getBiomeFromNoiseOriginal(float heat, float humidity, s16 y
133
138
}
134
139
}
135
140
136
- mysrand (y + (heat + humidity) / 2 );
141
+ mysrand (pos. Y + (heat + humidity) / 2 );
137
142
if (biome_closest_blend &&
138
143
myrand_range (0 , biome_closest_blend->vertical_blend ) >=
139
- y - biome_closest_blend->y_max )
144
+ pos. Y - biome_closest_blend->max_pos . Y )
140
145
return biome_closest_blend;
141
146
142
147
return (biome_closest) ? biome_closest : (Biome *)getRaw (BIOME_NONE);
@@ -206,7 +211,7 @@ Biome *BiomeGenOriginal::calcBiomeAtPoint(v3s16 pos) const
206
211
NoisePerlin2D (&m_params->np_humidity , pos.X , pos.Z , m_params->seed ) +
207
212
NoisePerlin2D (&m_params->np_humidity_blend , pos.X , pos.Z , m_params->seed );
208
213
209
- return calcBiomeFromNoise (heat, humidity, pos. Y );
214
+ return calcBiomeFromNoise (heat, humidity, pos);
210
215
}
211
216
212
217
@@ -226,13 +231,15 @@ void BiomeGenOriginal::calcBiomeNoise(v3s16 pmin)
226
231
}
227
232
228
233
229
- biome_t *BiomeGenOriginal::getBiomes (s16 *heightmap)
234
+ biome_t *BiomeGenOriginal::getBiomes (s16 *heightmap, v3s16 pmin )
230
235
{
231
- for (s32 i = 0 ; i != m_csize.X * m_csize.Z ; i++) {
236
+ for (s16 zr = 0 ; zr < m_csize.Z ; zr++)
237
+ for (s16 xr = 0 ; xr < m_csize.X ; xr++) {
238
+ s32 i = zr * m_csize.X + xr;
232
239
Biome *biome = calcBiomeFromNoise (
233
240
noise_heat->result [i],
234
241
noise_humidity->result [i],
235
- heightmap[i]);
242
+ v3s16 (pmin. X + xr, heightmap[i], pmin. Z + zr) );
236
243
237
244
biomemap[i] = biome->index ;
238
245
}
@@ -245,20 +252,20 @@ Biome *BiomeGenOriginal::getBiomeAtPoint(v3s16 pos) const
245
252
{
246
253
return getBiomeAtIndex (
247
254
(pos.Z - m_pmin.Z ) * m_csize.X + (pos.X - m_pmin.X ),
248
- pos. Y );
255
+ pos);
249
256
}
250
257
251
258
252
- Biome *BiomeGenOriginal::getBiomeAtIndex (size_t index, s16 y ) const
259
+ Biome *BiomeGenOriginal::getBiomeAtIndex (size_t index, v3s16 pos ) const
253
260
{
254
261
return calcBiomeFromNoise (
255
262
noise_heat->result [index ],
256
263
noise_humidity->result [index ],
257
- y );
264
+ pos );
258
265
}
259
266
260
267
261
- Biome *BiomeGenOriginal::calcBiomeFromNoise (float heat, float humidity, s16 y ) const
268
+ Biome *BiomeGenOriginal::calcBiomeFromNoise (float heat, float humidity, v3s16 pos ) const
262
269
{
263
270
Biome *biome_closest = nullptr ;
264
271
Biome *biome_closest_blend = nullptr ;
@@ -267,14 +274,17 @@ Biome *BiomeGenOriginal::calcBiomeFromNoise(float heat, float humidity, s16 y) c
267
274
268
275
for (size_t i = 1 ; i < m_bmgr->getNumObjects (); i++) {
269
276
Biome *b = (Biome *)m_bmgr->getRaw (i);
270
- if (!b || y > b->y_max + b->vertical_blend || y < b->y_min )
277
+ if (!b ||
278
+ pos.Y < b->min_pos .Y || pos.Y > b->max_pos .Y + b->vertical_blend ||
279
+ pos.X < b->min_pos .X || pos.X > b->max_pos .X ||
280
+ pos.Z < b->min_pos .Z || pos.Z > b->max_pos .Z )
271
281
continue ;
272
282
273
283
float d_heat = heat - b->heat_point ;
274
284
float d_humidity = humidity - b->humidity_point ;
275
285
float dist = (d_heat * d_heat) + (d_humidity * d_humidity);
276
286
277
- if (y <= b->y_max ) { // Within y limits of biome b
287
+ if (pos. Y <= b->max_pos . Y ) { // Within y limits of biome b
278
288
if (dist < dist_min) {
279
289
dist_min = dist;
280
290
biome_closest = b;
@@ -288,11 +298,11 @@ Biome *BiomeGenOriginal::calcBiomeFromNoise(float heat, float humidity, s16 y) c
288
298
// Carefully tune pseudorandom seed variation to avoid single node dither
289
299
// and create larger scale blending patterns similar to horizontal biome
290
300
// blend.
291
- mysrand (y + (heat + humidity) / 2 );
301
+ mysrand (pos. Y + (heat + humidity) / 2 );
292
302
293
303
if (biome_closest_blend &&
294
304
myrand_range (0 , biome_closest_blend->vertical_blend ) >=
295
- y - biome_closest_blend->y_max )
305
+ pos. Y - biome_closest_blend->max_pos . Y )
296
306
return biome_closest_blend;
297
307
298
308
return (biome_closest) ? biome_closest : (Biome *)m_bmgr->getRaw (BIOME_NONE);
0 commit comments