3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
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.
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.
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.
20 #include "util/numeric.h"
23 #include "mapgen_v5.h"
24 #include "mapgen_v6.h"
25 #include "mapgen_v7.h"
28 NoiseParams nparams_caveliquids(0, 1, v3f(150.0, 150.0, 150.0), 776, 3, 0.6, 2.0);
31 ///////////////////////////////////////// Caves V5
34 CaveV5::CaveV5(MapgenV5 *mg, PseudoRandom *ps) {
37 this->ndef = mg->ndef;
38 this->water_level = mg->water_level;
40 this->c_water_source = mg->c_water_source;
41 this->c_lava_source = mg->c_lava_source;
42 this->c_ice = mg->c_ice;
43 this->np_caveliquids = &nparams_caveliquids;
45 dswitchint = ps->range(1, 14);
46 flooded = ps->range(1, 2) == 2;
48 part_max_length_rs = ps->range(2, 4);
49 tunnel_routepoints = ps->range(5, ps->range(15, 30));
50 min_tunnel_diameter = 5;
51 max_tunnel_diameter = ps->range(7, ps->range(8, 24));
53 large_cave_is_flat = (ps->range(0, 1) == 0);
57 void CaveV5::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height) {
60 main_direction = v3f(0, 0, 0);
62 // Allowed route area size in nodes
63 ar = node_max - node_min + v3s16(1, 1, 1);
64 // Area starting point in nodes
68 //(this should be more than the maximum radius of the tunnel)
70 s16 more = MYMAX(MAP_BLOCKSIZE - max_tunnel_diameter / 2 - insure, 1);
71 ar += v3s16(1,0,1) * more * 2;
72 of -= v3s16(1,0,1) * more;
75 // Allow half a diameter + 7 over stone surface
76 route_y_max = -of.Y + max_stone_y + max_tunnel_diameter / 2 + 7;
78 // Limit maximum to area
79 route_y_max = rangelim(route_y_max, 0, ar.Y - 1);
82 if (node_min.Y < water_level && node_max.Y > water_level) {
83 min = water_level - max_tunnel_diameter/3 - of.Y;
84 route_y_max = water_level + max_tunnel_diameter/3 - of.Y;
86 route_y_min = ps->range(min, min + max_tunnel_diameter);
87 route_y_min = rangelim(route_y_min, 0, route_y_max);
89 s16 route_start_y_min = route_y_min;
90 s16 route_start_y_max = route_y_max;
92 route_start_y_min = rangelim(route_start_y_min, 0, ar.Y - 1);
93 route_start_y_max = rangelim(route_start_y_max, route_start_y_min, ar.Y - 1);
95 // Randomize starting position
97 (float)(ps->next() % ar.X) + 0.5,
98 (float)(ps->range(route_start_y_min, route_start_y_max)) + 0.5,
99 (float)(ps->next() % ar.Z) + 0.5
102 // Add generation notify begin event
103 v3s16 abs_pos(of.X + orp.X, of.Y + orp.Y, of.Z + orp.Z);
104 GenNotifyType notifytype = GENNOTIFY_LARGECAVE_BEGIN;
105 mg->gennotify.addEvent(notifytype, abs_pos);
107 // Generate some tunnel starting from orp
108 for (u16 j = 0; j < tunnel_routepoints; j++)
109 makeTunnel(j % dswitchint == 0);
111 // Add generation notify end event
112 abs_pos = v3s16(of.X + orp.X, of.Y + orp.Y, of.Z + orp.Z);
113 notifytype = GENNOTIFY_LARGECAVE_END;
114 mg->gennotify.addEvent(notifytype, abs_pos);
118 void CaveV5::makeTunnel(bool dirswitch) {
121 s16 min_d = min_tunnel_diameter;
122 s16 max_d = max_tunnel_diameter;
123 rs = ps->range(min_d, max_d);
124 s16 rs_part_max_length_rs = rs * part_max_length_rs;
128 rs_part_max_length_rs,
129 rs_part_max_length_rs / 2,
130 rs_part_max_length_rs
134 // Jump downward sometimes
136 (float)(ps->next() % maxlen.X) - (float)maxlen.X / 2,
137 (float)(ps->next() % maxlen.Y) - (float)maxlen.Y / 2,
138 (float)(ps->next() % maxlen.Z) - (float)maxlen.Z / 2
141 // Do not make caves that are above ground.
142 // It is only necessary to check the startpoint and endpoint.
143 v3s16 orpi(orp.X, orp.Y, orp.Z);
144 v3s16 veci(vec.X, vec.Y, vec.Z);
147 p = orpi + veci + of + rs / 2;
148 if (p.Z >= node_min.Z && p.Z <= node_max.Z &&
149 p.X >= node_min.X && p.X <= node_max.X) {
150 u32 index = (p.Z - node_min.Z) * mg->ystride + (p.X - node_min.X);
151 s16 h = mg->heightmap[index];
154 } else if (p.Y > water_level) {
155 return; // If it's not in our heightmap, use a simple heuristic
158 p = orpi + of + rs / 2;
159 if (p.Z >= node_min.Z && p.Z <= node_max.Z &&
160 p.X >= node_min.X && p.X <= node_max.X) {
161 u32 index = (p.Z - node_min.Z) * mg->ystride + (p.X - node_min.X);
162 s16 h = mg->heightmap[index];
165 } else if (p.Y > water_level) {
169 vec += main_direction;
174 else if (rp.X >= ar.X)
177 if (rp.Y < route_y_min)
179 else if (rp.Y >= route_y_max)
180 rp.Y = route_y_max - 1;
184 else if (rp.Z >= ar.Z)
189 float veclen = vec.getLength();
193 // Every second section is rough
194 bool randomize_xz = (ps->range(1, 2) == 1);
197 for (float f = 0; f < 1.0; f += 1.0 / veclen)
198 carveRoute(vec, f, randomize_xz);
204 void CaveV5::carveRoute(v3f vec, float f, bool randomize_xz) {
205 MapNode airnode(CONTENT_AIR);
206 MapNode waternode(c_water_source);
207 MapNode lavanode(c_lava_source);
209 v3s16 startp(orp.X, orp.Y, orp.Z);
212 float nval = NoisePerlin3D(np_caveliquids, startp.X,
213 startp.Y, startp.Z, mg->seed);
214 MapNode liquidnode = nval < 0.40 ? lavanode : waternode;
216 v3f fp = orp + vec * f;
217 fp.X += 0.1 * ps->range(-10, 10);
218 fp.Z += 0.1 * ps->range(-10, 10);
219 v3s16 cp(fp.X, fp.Y, fp.Z);
224 d0 += ps->range(-1, 1);
225 d1 += ps->range(-1, 1);
228 for (s16 z0 = d0; z0 <= d1; z0++) {
229 s16 si = rs / 2 - MYMAX(0, abs(z0) - rs / 7 - 1);
230 for (s16 x0 = -si - ps->range(0,1); x0 <= si - 1 + ps->range(0,1); x0++) {
231 s16 maxabsxz = MYMAX(abs(x0), abs(z0));
233 s16 si2 = rs / 2 - MYMAX(0, maxabsxz - rs / 7 - 1);
235 for (s16 y0 = -si2; y0 <= si2; y0++) {
236 if (large_cave_is_flat) {
237 // Make large caves not so tall
238 if (rs > 7 && abs(y0) >= rs / 3)
242 v3s16 p(cp.X + x0, cp.Y + y0, cp.Z + z0);
245 if (vm->m_area.contains(p) == false)
248 u32 i = vm->m_area.index(p);
249 content_t c = vm->m_data[i].getContent();
250 if (!ndef->get(c).is_ground_content)
253 int full_ymin = node_min.Y - MAP_BLOCKSIZE;
254 int full_ymax = node_max.Y + MAP_BLOCKSIZE;
256 if (flooded && full_ymin < water_level &&
257 full_ymax > water_level)
258 vm->m_data[i] = (p.Y <= water_level) ?
260 else if (flooded && full_ymax < water_level)
261 vm->m_data[i] = (p.Y < startp.Y - 4) ?
262 liquidnode : airnode;
264 vm->m_data[i] = airnode;
271 ///////////////////////////////////////// Caves V6
274 CaveV6::CaveV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool is_large_cave) {
277 this->ndef = mg->ndef;
278 this->water_level = mg->water_level;
279 this->large_cave = is_large_cave;
282 this->c_water_source = mg->c_water_source;
283 this->c_lava_source = mg->c_lava_source;
285 min_tunnel_diameter = 2;
286 max_tunnel_diameter = ps->range(2, 6);
287 dswitchint = ps->range(1, 14);
291 part_max_length_rs = ps->range(2,4);
292 tunnel_routepoints = ps->range(5, ps->range(15,30));
293 min_tunnel_diameter = 5;
294 max_tunnel_diameter = ps->range(7, ps->range(8,24));
296 part_max_length_rs = ps->range(2,9);
297 tunnel_routepoints = ps->range(10, ps->range(15,30));
300 large_cave_is_flat = (ps->range(0,1) == 0);
304 void CaveV6::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height) {
307 max_stone_y = max_stone_height;
308 main_direction = v3f(0, 0, 0);
310 // Allowed route area size in nodes
311 ar = node_max - node_min + v3s16(1, 1, 1);
312 // Area starting point in nodes
316 //(this should be more than the maximum radius of the tunnel)
317 const s16 max_spread_amount = MAP_BLOCKSIZE;
319 s16 more = MYMAX(max_spread_amount - max_tunnel_diameter / 2 - insure, 1);
320 ar += v3s16(1,0,1) * more * 2;
321 of -= v3s16(1,0,1) * more;
324 // Allow half a diameter + 7 over stone surface
325 route_y_max = -of.Y + max_stone_y + max_tunnel_diameter / 2 + 7;
327 // Limit maximum to area
328 route_y_max = rangelim(route_y_max, 0, ar.Y - 1);
332 if (node_min.Y < water_level && node_max.Y > water_level) {
333 min = water_level - max_tunnel_diameter/3 - of.Y;
334 route_y_max = water_level + max_tunnel_diameter/3 - of.Y;
336 route_y_min = ps->range(min, min + max_tunnel_diameter);
337 route_y_min = rangelim(route_y_min, 0, route_y_max);
340 s16 route_start_y_min = route_y_min;
341 s16 route_start_y_max = route_y_max;
343 route_start_y_min = rangelim(route_start_y_min, 0, ar.Y-1);
344 route_start_y_max = rangelim(route_start_y_max, route_start_y_min, ar.Y-1);
346 // Randomize starting position
348 (float)(ps->next() % ar.X) + 0.5,
349 (float)(ps->range(route_start_y_min, route_start_y_max)) + 0.5,
350 (float)(ps->next() % ar.Z) + 0.5
353 // Add generation notify begin event
354 v3s16 abs_pos(of.X + orp.X, of.Y + orp.Y, of.Z + orp.Z);
355 GenNotifyType notifytype = large_cave ?
356 GENNOTIFY_LARGECAVE_BEGIN : GENNOTIFY_CAVE_BEGIN;
357 mg->gennotify.addEvent(notifytype, abs_pos);
359 // Generate some tunnel starting from orp
360 for (u16 j = 0; j < tunnel_routepoints; j++)
361 makeTunnel(j % dswitchint == 0);
363 // Add generation notify end event
364 abs_pos = v3s16(of.X + orp.X, of.Y + orp.Y, of.Z + orp.Z);
365 notifytype = large_cave ?
366 GENNOTIFY_LARGECAVE_END : GENNOTIFY_CAVE_END;
367 mg->gennotify.addEvent(notifytype, abs_pos);
371 void CaveV6::makeTunnel(bool dirswitch) {
372 if (dirswitch && !large_cave) {
373 main_direction = v3f(
374 ((float)(ps->next() % 20) - (float)10) / 10,
375 ((float)(ps->next() % 20) - (float)10) / 30,
376 ((float)(ps->next() % 20) - (float)10) / 10
378 main_direction *= (float)ps->range(0, 10) / 10;
382 s16 min_d = min_tunnel_diameter;
383 s16 max_d = max_tunnel_diameter;
384 rs = ps->range(min_d, max_d);
385 s16 rs_part_max_length_rs = rs * part_max_length_rs;
390 rs_part_max_length_rs,
391 rs_part_max_length_rs / 2,
392 rs_part_max_length_rs
396 rs_part_max_length_rs,
397 ps->range(1, rs_part_max_length_rs),
398 rs_part_max_length_rs
403 (float)(ps->next() % maxlen.X) - (float)maxlen.X / 2,
404 (float)(ps->next() % maxlen.Y) - (float)maxlen.Y / 2,
405 (float)(ps->next() % maxlen.Z) - (float)maxlen.Z / 2
408 // Jump downward sometimes
409 if (!large_cave && ps->range(0, 12) == 0) {
411 (float)(ps->next() % maxlen.X) - (float)maxlen.X / 2,
412 (float)(ps->next() % (maxlen.Y * 2)) - (float)maxlen.Y,
413 (float)(ps->next() % maxlen.Z) - (float)maxlen.Z / 2
417 // Do not make caves that are entirely above ground.
418 // It is only necessary to check the startpoint and endpoint.
419 v3s16 orpi(orp.X, orp.Y, orp.Z);
420 v3s16 veci(vec.X, vec.Y, vec.Z);
424 v3s16 p1 = orpi + veci + of + rs / 2;
425 if (p1.Z >= node_min.Z && p1.Z <= node_max.Z &&
426 p1.X >= node_min.X && p1.X <= node_max.X) {
427 u32 index1 = (p1.Z - node_min.Z) * mg->ystride +
429 h1 = mg->heightmap[index1];
431 h1 = water_level; // If not in heightmap
434 v3s16 p2 = orpi + of + rs / 2;
435 if (p2.Z >= node_min.Z && p2.Z <= node_max.Z &&
436 p2.X >= node_min.X && p2.X <= node_max.X) {
437 u32 index2 = (p2.Z - node_min.Z) * mg->ystride +
439 h2 = mg->heightmap[index2];
444 if (p1.Y > h1 && p2.Y > h2) // If startpoint and endpoint are above ground
447 vec += main_direction;
452 else if (rp.X >= ar.X)
455 if (rp.Y < route_y_min)
457 else if (rp.Y >= route_y_max)
458 rp.Y = route_y_max - 1;
462 else if (rp.Z >= ar.Z)
467 float veclen = vec.getLength();
468 // As odd as it sounds, veclen is *exactly* 0.0 sometimes, causing a FPE
472 // Every second section is rough
473 bool randomize_xz = (ps2->range(1, 2) == 1);
476 for (float f = 0; f < 1.0; f += 1.0 / veclen)
477 carveRoute(vec, f, randomize_xz);
483 void CaveV6::carveRoute(v3f vec, float f, bool randomize_xz) {
484 MapNode airnode(CONTENT_AIR);
485 MapNode waternode(c_water_source);
486 MapNode lavanode(c_lava_source);
488 v3s16 startp(orp.X, orp.Y, orp.Z);
491 v3f fp = orp + vec * f;
492 fp.X += 0.1 * ps->range(-10, 10);
493 fp.Z += 0.1 * ps->range(-10, 10);
494 v3s16 cp(fp.X, fp.Y, fp.Z);
499 d0 += ps->range(-1, 1);
500 d1 += ps->range(-1, 1);
503 for (s16 z0 = d0; z0 <= d1; z0++) {
504 s16 si = rs / 2 - MYMAX(0, abs(z0) - rs / 7 - 1);
505 for (s16 x0 = -si - ps->range(0,1); x0 <= si - 1 + ps->range(0,1); x0++) {
506 s16 maxabsxz = MYMAX(abs(x0), abs(z0));
507 s16 si2 = rs / 2 - MYMAX(0, maxabsxz - rs / 7 - 1);
508 for (s16 y0 = -si2; y0 <= si2; y0++) {
509 if (large_cave_is_flat) {
510 // Make large caves not so tall
511 if (rs > 7 && abs(y0) >= rs / 3)
515 v3s16 p(cp.X + x0, cp.Y + y0, cp.Z + z0);
518 if (vm->m_area.contains(p) == false)
521 u32 i = vm->m_area.index(p);
522 content_t c = vm->m_data[i].getContent();
523 if (!ndef->get(c).is_ground_content)
527 int full_ymin = node_min.Y - MAP_BLOCKSIZE;
528 int full_ymax = node_max.Y + MAP_BLOCKSIZE;
530 if (flooded && full_ymin < water_level &&
531 full_ymax > water_level) {
532 vm->m_data[i] = (p.Y <= water_level) ?
534 } else if (flooded && full_ymax < water_level) {
535 vm->m_data[i] = (p.Y < startp.Y - 2) ?
538 vm->m_data[i] = airnode;
541 if (c == CONTENT_IGNORE || c == CONTENT_AIR)
544 vm->m_data[i] = airnode;
545 vm->m_flags[i] |= VMANIP_FLAG_CAVE;
553 ///////////////////////////////////////// Caves V7
556 CaveV7::CaveV7(MapgenV7 *mg, PseudoRandom *ps) {
559 this->ndef = mg->ndef;
560 this->water_level = mg->water_level;
562 this->c_water_source = mg->c_water_source;
563 this->c_lava_source = mg->c_lava_source;
564 this->c_ice = mg->c_ice;
565 this->np_caveliquids = &nparams_caveliquids;
567 dswitchint = ps->range(1, 14);
568 flooded = ps->range(1, 2) == 2;
570 part_max_length_rs = ps->range(2, 4);
571 tunnel_routepoints = ps->range(5, ps->range(15, 30));
572 min_tunnel_diameter = 5;
573 max_tunnel_diameter = ps->range(7, ps->range(8, 24));
575 large_cave_is_flat = (ps->range(0, 1) == 0);
579 void CaveV7::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height) {
582 max_stone_y = max_stone_height;
583 main_direction = v3f(0, 0, 0);
585 // Allowed route area size in nodes
586 ar = node_max - node_min + v3s16(1, 1, 1);
587 // Area starting point in nodes
591 //(this should be more than the maximum radius of the tunnel)
593 s16 more = MYMAX(MAP_BLOCKSIZE - max_tunnel_diameter / 2 - insure, 1);
594 ar += v3s16(1,0,1) * more * 2;
595 of -= v3s16(1,0,1) * more;
598 // Allow half a diameter + 7 over stone surface
599 route_y_max = -of.Y + max_stone_y + max_tunnel_diameter / 2 + 7;
601 // Limit maximum to area
602 route_y_max = rangelim(route_y_max, 0, ar.Y - 1);
605 if (node_min.Y < water_level && node_max.Y > water_level) {
606 min = water_level - max_tunnel_diameter/3 - of.Y;
607 route_y_max = water_level + max_tunnel_diameter/3 - of.Y;
609 route_y_min = ps->range(min, min + max_tunnel_diameter);
610 route_y_min = rangelim(route_y_min, 0, route_y_max);
612 s16 route_start_y_min = route_y_min;
613 s16 route_start_y_max = route_y_max;
615 route_start_y_min = rangelim(route_start_y_min, 0, ar.Y - 1);
616 route_start_y_max = rangelim(route_start_y_max, route_start_y_min, ar.Y - 1);
618 // Randomize starting position
620 (float)(ps->next() % ar.X) + 0.5,
621 (float)(ps->range(route_start_y_min, route_start_y_max)) + 0.5,
622 (float)(ps->next() % ar.Z) + 0.5
625 // Add generation notify begin event
626 v3s16 abs_pos(of.X + orp.X, of.Y + orp.Y, of.Z + orp.Z);
627 GenNotifyType notifytype = GENNOTIFY_LARGECAVE_BEGIN;
628 mg->gennotify.addEvent(notifytype, abs_pos);
630 // Generate some tunnel starting from orp
631 for (u16 j = 0; j < tunnel_routepoints; j++)
632 makeTunnel(j % dswitchint == 0);
634 // Add generation notify end event
635 abs_pos = v3s16(of.X + orp.X, of.Y + orp.Y, of.Z + orp.Z);
636 notifytype = GENNOTIFY_LARGECAVE_END;
637 mg->gennotify.addEvent(notifytype, abs_pos);
641 void CaveV7::makeTunnel(bool dirswitch) {
644 s16 min_d = min_tunnel_diameter;
645 s16 max_d = max_tunnel_diameter;
646 rs = ps->range(min_d, max_d);
647 s16 rs_part_max_length_rs = rs * part_max_length_rs;
651 rs_part_max_length_rs,
652 rs_part_max_length_rs / 2,
653 rs_part_max_length_rs
657 // Jump downward sometimes
659 (float)(ps->next() % maxlen.X) - (float)maxlen.X / 2,
660 (float)(ps->next() % maxlen.Y) - (float)maxlen.Y / 2,
661 (float)(ps->next() % maxlen.Z) - (float)maxlen.Z / 2
664 // Do not make caves that are above ground.
665 // It is only necessary to check the startpoint and endpoint.
666 v3s16 orpi(orp.X, orp.Y, orp.Z);
667 v3s16 veci(vec.X, vec.Y, vec.Z);
670 p = orpi + veci + of + rs / 2;
671 if (p.Z >= node_min.Z && p.Z <= node_max.Z &&
672 p.X >= node_min.X && p.X <= node_max.X) {
673 u32 index = (p.Z - node_min.Z) * mg->ystride + (p.X - node_min.X);
674 s16 h = mg->ridge_heightmap[index];
677 } else if (p.Y > water_level) {
678 return; // If it's not in our heightmap, use a simple heuristic
681 p = orpi + of + rs / 2;
682 if (p.Z >= node_min.Z && p.Z <= node_max.Z &&
683 p.X >= node_min.X && p.X <= node_max.X) {
684 u32 index = (p.Z - node_min.Z) * mg->ystride + (p.X - node_min.X);
685 s16 h = mg->ridge_heightmap[index];
688 } else if (p.Y > water_level) {
692 vec += main_direction;
697 else if (rp.X >= ar.X)
700 if (rp.Y < route_y_min)
702 else if (rp.Y >= route_y_max)
703 rp.Y = route_y_max - 1;
707 else if (rp.Z >= ar.Z)
712 float veclen = vec.getLength();
716 // Every second section is rough
717 bool randomize_xz = (ps->range(1, 2) == 1);
720 for (float f = 0; f < 1.0; f += 1.0 / veclen)
721 carveRoute(vec, f, randomize_xz);
727 void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz) {
728 MapNode airnode(CONTENT_AIR);
729 MapNode waternode(c_water_source);
730 MapNode lavanode(c_lava_source);
732 v3s16 startp(orp.X, orp.Y, orp.Z);
735 float nval = NoisePerlin3D(np_caveliquids, startp.X,
736 startp.Y, startp.Z, mg->seed);
737 MapNode liquidnode = (nval < 0.40 && node_max.Y < MGV7_LAVA_DEPTH) ?
738 lavanode : waternode;
740 v3f fp = orp + vec * f;
741 fp.X += 0.1 * ps->range(-10, 10);
742 fp.Z += 0.1 * ps->range(-10, 10);
743 v3s16 cp(fp.X, fp.Y, fp.Z);
748 d0 += ps->range(-1, 1);
749 d1 += ps->range(-1, 1);
752 for (s16 z0 = d0; z0 <= d1; z0++) {
753 s16 si = rs / 2 - MYMAX(0, abs(z0) - rs / 7 - 1);
754 for (s16 x0 = -si - ps->range(0,1); x0 <= si - 1 + ps->range(0,1); x0++) {
755 s16 maxabsxz = MYMAX(abs(x0), abs(z0));
757 s16 si2 = rs / 2 - MYMAX(0, maxabsxz - rs / 7 - 1);
759 for (s16 y0 = -si2; y0 <= si2; y0++) {
760 if (large_cave_is_flat) {
761 // Make large caves not so tall
762 if (rs > 7 && abs(y0) >= rs / 3)
766 v3s16 p(cp.X + x0, cp.Y + y0, cp.Z + z0);
769 if (vm->m_area.contains(p) == false)
772 u32 i = vm->m_area.index(p);
773 content_t c = vm->m_data[i].getContent();
774 if (!ndef->get(c).is_ground_content)
777 int full_ymin = node_min.Y - MAP_BLOCKSIZE;
778 int full_ymax = node_max.Y + MAP_BLOCKSIZE;
780 if (flooded && full_ymin < water_level &&
781 full_ymax > water_level)
782 vm->m_data[i] = (p.Y <= water_level) ?
784 else if (flooded && full_ymax < water_level)
785 vm->m_data[i] = (p.Y < startp.Y - 4) ?
786 liquidnode : airnode;
788 vm->m_data[i] = airnode;