@@ -67,6 +67,7 @@ size_t DecorationManager::placeAllDecos(Mapgen *mg, u32 blockseed,
67
67
68
68
// /////////////////////////////////////////////////////////////////////////////
69
69
70
+
70
71
void Decoration::resolveNodeNames ()
71
72
{
72
73
getIdsFromNrBacklog (&c_place_on);
@@ -192,15 +193,8 @@ size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed,
192
193
if (y < y_min_disp || y > y_max_disp || y < nmin.Y || y > nmax.Y )
193
194
continue ;
194
195
195
- if (y + getHeight () > mg->vm ->m_area .MaxEdge .Y ) {
196
+ if (y + getHeight () > mg->vm ->m_area .MaxEdge .Y )
196
197
continue ;
197
- #if 0
198
- printf("Decoration at (%d %d %d) cut off\n", x, y, z);
199
- //add to queue
200
- MutexAutoLock cutofflock(cutoff_mutex);
201
- cutoffs.push_back(CutoffData(x, y, z, height));
202
- #endif
203
- }
204
198
205
199
if (mg->biomemap && !biomes.empty ()) {
206
200
std::unordered_set<u8>::const_iterator iter =
@@ -219,60 +213,6 @@ size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed,
219
213
}
220
214
221
215
222
- #if 0
223
- void Decoration::placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
224
- {
225
- PcgRandom pr(blockseed + 53);
226
- std::vector<CutoffData> handled_cutoffs;
227
-
228
- // Copy over the cutoffs we're interested in so we don't needlessly hold a lock
229
- {
230
- MutexAutoLock cutofflock(cutoff_mutex);
231
- for (std::list<CutoffData>::iterator i = cutoffs.begin();
232
- i != cutoffs.end(); ++i) {
233
- CutoffData cutoff = *i;
234
- v3s16 p = cutoff.p;
235
- s16 height = cutoff.height;
236
- if (p.X < nmin.X || p.X > nmax.X ||
237
- p.Z < nmin.Z || p.Z > nmax.Z)
238
- continue;
239
- if (p.Y + height < nmin.Y || p.Y > nmax.Y)
240
- continue;
241
-
242
- handled_cutoffs.push_back(cutoff);
243
- }
244
- }
245
-
246
- // Generate the cutoffs
247
- for (size_t i = 0; i != handled_cutoffs.size(); i++) {
248
- v3s16 p = handled_cutoffs[i].p;
249
- s16 height = handled_cutoffs[i].height;
250
-
251
- if (p.Y + height > nmax.Y) {
252
- //printf("Decoration at (%d %d %d) cut off again!\n", p.X, p.Y, p.Z);
253
- cuttoffs.push_back(v3s16(p.X, p.Y, p.Z));
254
- }
255
-
256
- generate(mg, &pr, nmax.Y, nmin.Y - p.Y, v3s16(p.X, nmin.Y, p.Z));
257
- }
258
-
259
- // Remove cutoffs that were handled from the cutoff list
260
- {
261
- MutexAutoLock cutofflock(cutoff_mutex);
262
- for (std::list<CutoffData>::iterator i = cutoffs.begin();
263
- i != cutoffs.end(); ++i) {
264
-
265
- for (size_t j = 0; j != handled_cutoffs.size(); j++) {
266
- CutoffData coff = *i;
267
- if (coff.p == handled_cutoffs[j].p)
268
- i = cutoffs.erase(i);
269
- }
270
- }
271
- }
272
- }
273
- #endif
274
-
275
-
276
216
// /////////////////////////////////////////////////////////////////////////////
277
217
278
218
@@ -324,6 +264,7 @@ int DecoSimple::getHeight()
324
264
325
265
// /////////////////////////////////////////////////////////////////////////////
326
266
267
+
327
268
size_t DecoSchematic::generate (MMVManip *vm, PcgRandom *pr, v3s16 p)
328
269
{
329
270
// Schematic could have been unloaded but not the decoration
@@ -336,11 +277,17 @@ size_t DecoSchematic::generate(MMVManip *vm, PcgRandom *pr, v3s16 p)
336
277
337
278
if (flags & DECO_PLACE_CENTER_X)
338
279
p.X -= (schematic->size .X - 1 ) / 2 ;
339
- if (flags & DECO_PLACE_CENTER_Y)
340
- p.Y -= (schematic->size .Y - 1 ) / 2 ;
341
280
if (flags & DECO_PLACE_CENTER_Z)
342
281
p.Z -= (schematic->size .Z - 1 ) / 2 ;
343
282
283
+ if (flags & DECO_PLACE_CENTER_Y)
284
+ p.Y -= (schematic->size .Y - 1 ) / 2 ;
285
+ else
286
+ p.Y += place_offset_y;
287
+ // Check shifted schematic base is in voxelmanip
288
+ if (p.Y < vm->m_area .MinEdge .Y )
289
+ return 0 ;
290
+
344
291
Rotation rot = (rotation == ROTATE_RAND) ?
345
292
(Rotation)pr->range (ROTATE_0, ROTATE_270) : rotation;
346
293
@@ -355,8 +302,8 @@ size_t DecoSchematic::generate(MMVManip *vm, PcgRandom *pr, v3s16 p)
355
302
int DecoSchematic::getHeight ()
356
303
{
357
304
// Account for a schematic being sunk into the ground by flag.
358
- // When placed normally account for how a schematic is placed
359
- // sunk 1 node into the ground.
305
+ // When placed normally account for how a schematic is by default placed
306
+ // sunk 1 node into the ground or is vertically shifted by 'y_offset' .
360
307
return (flags & DECO_PLACE_CENTER_Y) ?
361
- (schematic->size .Y - 1 ) / 2 : schematic->size .Y - 1 ;
308
+ (schematic->size .Y - 1 ) / 2 : schematic->size .Y - 1 + place_offset_y ;
362
309
}
0 commit comments