Skip to content

Commit d75b171

Browse files
author
proller
committedNov 10, 2013
Fix spaces float islands code
1 parent a92e90f commit d75b171

File tree

1 file changed

+41
-46
lines changed

1 file changed

+41
-46
lines changed
 

Diff for: ‎src/mapgen_indev.cpp

+41-46
Original file line numberDiff line numberDiff line change
@@ -345,52 +345,47 @@ void MapgenIndev::generateFloatIslands(int min_y) {
345345
*/
346346

347347
void MapgenIndev::generateFloatIslands(int min_y) {
348-
if (node_min.Y < min_y) return;
349-
PseudoRandom pr(blockseed + 985);
350-
// originally from http://forum.minetest.net/viewtopic.php?id=4776
351-
float RAR = 0.8 * farscale(0.4, node_min.Y); // 0.4; // Island rarity.
352-
float AMPY = 24; // 24; // Amplitude of island centre y variation.
353-
float TGRAD = 24; // 24; // Noise gradient to create top surface.
354-
float BGRAD = 24; // 24; // Noise gradient to create bottom surface.
355-
356-
v3s16 p0(node_min.X, node_min.Y, node_min.Z);
357-
MapNode n1(c_stone);
358-
359-
float xl = node_max.X - node_min.X;
360-
float yl = node_max.Y - node_min.Y;
361-
float zl = node_max.Z - node_min.Z;
362-
u32 zstride = xl + 1;
363-
float midy = node_min.Y + yl * 0.5;
364-
u32 index = 0;
365-
for (int z1 = 0; z1 <= zl; ++z1)
366-
{
367-
for (int y1 = 0; y1 <= yl; ++y1)
368-
{
369-
for (int x1 = 0; x1 <= xl; ++x1, ++index)
370-
{
371-
int y = y1 + node_min.Y;
372-
u32 index2d = z1 * zstride + x1;
373-
float noise3 = noiseindev_float_islands3->result[index2d];
374-
float pmidy = midy + noise3 / 1.5 * AMPY;
375-
float noise1 = noiseindev_float_islands1->result[index];
376-
float offset = y > pmidy ? (y - pmidy) / TGRAD : (pmidy - y) / BGRAD;
377-
float noise1off = noise1 - offset - RAR;
378-
if (noise1off > 0 && noise1off < 0.7) {
379-
float noise2 = noiseindev_float_islands2->result[index];
380-
if (noise2 - noise1off > -0.7){
381-
v3s16 p = p0 + v3s16(x1, y1, z1);
382-
u32 i = vm->m_area.index(p);
383-
if (!vm->m_area.contains(i))
384-
continue;
385-
// Cancel if not air
386-
if (vm->m_data[i].getContent() != CONTENT_AIR)
387-
continue;
388-
vm->m_data[i] = n1;
389-
}
390-
}
391-
}
392-
}
393-
}
348+
if (node_min.Y < min_y) return;
349+
PseudoRandom pr(blockseed + 985);
350+
// originally from http://forum.minetest.net/viewtopic.php?id=4776
351+
float RAR = 0.8 * farscale(0.4, node_min.Y); // 0.4; // Island rarity in chunk layer. -0.4 = thick layer with holes, 0 = 50%, 0.4 = desert rarity, 0.7 = very rare.
352+
float AMPY = 24; // 24; // Amplitude of island centre y variation.
353+
float TGRAD = 24; // 24; // Noise gradient to create top surface. Tallness of island top.
354+
float BGRAD = 24; // 24; // Noise gradient to create bottom surface. Tallness of island bottom.
355+
356+
v3s16 p0(node_min.X, node_min.Y, node_min.Z);
357+
MapNode n1(c_stone);
358+
359+
float xl = node_max.X - node_min.X;
360+
float yl = node_max.Y - node_min.Y;
361+
float zl = node_max.Z - node_min.Z;
362+
u32 zstride = xl + 1;
363+
float midy = node_min.Y + yl * 0.5;
364+
u32 index = 0;
365+
for (int z1 = 0; z1 <= zl; ++z1)
366+
for (int y1 = 0; y1 <= yl; ++y1)
367+
for (int x1 = 0; x1 <= xl; ++x1, ++index) {
368+
int y = y1 + node_min.Y;
369+
u32 index2d = z1 * zstride + x1;
370+
float noise3 = noiseindev_float_islands3->result[index2d];
371+
float pmidy = midy + noise3 / 1.5 * AMPY;
372+
float noise1 = noiseindev_float_islands1->result[index];
373+
float offset = y > pmidy ? (y - pmidy) / TGRAD : (pmidy - y) / BGRAD;
374+
float noise1off = noise1 - offset - RAR;
375+
if (noise1off > 0 && noise1off < 0.7) {
376+
float noise2 = noiseindev_float_islands2->result[index];
377+
if (noise2 - noise1off > -0.7) {
378+
v3s16 p = p0 + v3s16(x1, y1, z1);
379+
u32 i = vm->m_area.index(p);
380+
if (!vm->m_area.contains(i))
381+
continue;
382+
// Cancel if not air
383+
if (vm->m_data[i].getContent() != CONTENT_AIR)
384+
continue;
385+
vm->m_data[i] = n1;
386+
}
387+
}
388+
}
394389
}
395390

396391
void MapgenIndev::generateExperimental() {

0 commit comments

Comments
 (0)