Loosen trail prepass sampling to guarantee roads
This commit is contained in:
@@ -217,9 +217,9 @@ void worldgen_prepass(worldgen_ctx *ctx, int min_x, int max_x, int min_z, int ma
|
||||
ctx->trail_segment_count = 0;
|
||||
ctx->trail_segment_cap = 0;
|
||||
|
||||
const int step = 64;
|
||||
const int max_points = 64;
|
||||
const double min_spacing = 96.0;
|
||||
const int step = 48;
|
||||
const int max_points = 128;
|
||||
const double min_spacing = 64.0;
|
||||
int cap = max_points;
|
||||
int count = 0;
|
||||
int *px = (int *)malloc((size_t)cap * sizeof(int));
|
||||
@@ -232,7 +232,7 @@ void worldgen_prepass(worldgen_ctx *ctx, int min_x, int max_x, int min_z, int ma
|
||||
for (int z = min_z; z <= max_z; z += step) {
|
||||
for (int x = min_x; x <= max_x; x += step) {
|
||||
double val = land_value(ctx, x, z);
|
||||
if (val < 0.05) continue;
|
||||
if (val < -0.05) continue;
|
||||
int spaced = 1;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
double dx = (double)(x - px[i]);
|
||||
@@ -253,10 +253,10 @@ void worldgen_prepass(worldgen_ctx *ctx, int min_x, int max_x, int min_z, int ma
|
||||
}
|
||||
if (count >= max_points) break;
|
||||
}
|
||||
if (count == 0) {
|
||||
px = (int *)realloc(px, sizeof(int));
|
||||
pz = (int *)realloc(pz, sizeof(int));
|
||||
pv = (double *)realloc(pv, sizeof(double));
|
||||
if (count < 2) {
|
||||
px = (int *)realloc(px, 2 * sizeof(int));
|
||||
pz = (int *)realloc(pz, 2 * sizeof(int));
|
||||
pv = (double *)realloc(pv, 2 * sizeof(double));
|
||||
if (!px || !pz || !pv) {
|
||||
free(px); free(pz); free(pv);
|
||||
return;
|
||||
@@ -264,7 +264,10 @@ void worldgen_prepass(worldgen_ctx *ctx, int min_x, int max_x, int min_z, int ma
|
||||
px[0] = (min_x + max_x) / 2;
|
||||
pz[0] = (min_z + max_z) / 2;
|
||||
pv[0] = 1.0;
|
||||
count = 1;
|
||||
px[1] = max_x - 16;
|
||||
pz[1] = max_z - 16;
|
||||
pv[1] = 0.8;
|
||||
count = 2;
|
||||
}
|
||||
|
||||
/* Select hubs: pick top valued, then farthest from existing hubs */
|
||||
|
||||
Reference in New Issue
Block a user