12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) /
1073741824.0f;
}
float
smoothednoise(int x, int y, int seed)
{
float corners =
(noise(x - 1, y - 1, seed) + noise(x + 1, y - 1, seed) +
noise(x - 1, y + 1, seed) + noise(x + 1, y + 1, seed)) /
16;
float sides = (noise(x - 1, y, seed) + noise(x + 1, y, seed) +
noise(x, y - 1, seed) + noise(x, y + 1, seed)) /
8;
float center = noise(x, y, seed) / 4;
return corners + sides + center;
}
float
interpolate(float a, float b, float x)
{
|
<
|
|
<
|
<
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) /
1073741824.0f;
}
float
smoothednoise(int x, int y, int seed)
{
float corners = (noise(x - 1, y - 1, seed) + noise(x + 1, y - 1, seed) +
noise(x - 1, y + 1, seed) + noise(x + 1, y + 1, seed)) / 16;
float sides = (noise(x - 1, y, seed) + noise(x + 1, y, seed) +
noise(x, y - 1, seed) + noise(x, y + 1, seed)) / 8;
float center = noise(x, y, seed) / 4;
return corners + sides + center;
}
float
interpolate(float a, float b, float x)
{
|
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
if (!scale)
scale = 10;
for (int x = b->x; x <= b->x + b->xs; x++) {
for (int y = b->y; y <= b->y + b->ys; y++) {
struct sqr *s = S(x, y);
if (!SOLID(s) && x != b->x + b->xs && y != b->y + b->ys)
s->type = FHF;
s->vdelta =
(int)(perlinnoise_2D(x / ((float)scale) + seed,
y / ((float)scale) + seed, 1000, 0.01f) *
50 +
25);
if (s->vdelta > 128)
s->vdelta = 0;
}
}
}
|
|
|
|
<
<
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
if (!scale)
scale = 10;
for (int x = b->x; x <= b->x + b->xs; x++) {
for (int y = b->y; y <= b->y + b->ys; y++) {
struct sqr *s = S(x, y);
if (!SOLID(s) && x != b->x + b->xs && y != b->y + b->ys)
s->type = FHF;
s->vdelta = (int)(perlinnoise_2D(
x / ((float)scale) + seed,
y / ((float)scale) + seed, 1000, 0.01f) * 50 + 25);
if (s->vdelta > 128)
s->vdelta = 0;
}
}
}
|