Discourage trails crossing water

This commit is contained in:
chelsea
2025-12-02 22:48:59 -06:00
parent 8edafec024
commit cda6f08ad3
2 changed files with 10 additions and 0 deletions

Binary file not shown.

View File

@@ -2621,8 +2621,18 @@ static int build_trail_path(worldgen_ctx *ctx, double ax, double az, double bx,
double next_height = heights[ni]; double next_height = heights[ni];
double slope = fabs(next_height - current_height); double slope = fabs(next_height - current_height);
if (slope > 3.0) continue; if (slope > 3.0) continue;
int water = 0;
int wx = (int)llround(min_x + nx * TRAIL_CELL_SIZE);
int wz = (int)llround(min_z + nz * TRAIL_CELL_SIZE);
column_data cd = get_column_data(ctx, wx, wz);
if (cd.has_water && next_height <= cd.water_surface) {
water = 1;
}
double base_cost = (neighbors[n][0] == 0 || neighbors[n][1] == 0) ? 1.0 : 1.41421356237; double base_cost = (neighbors[n][0] == 0 || neighbors[n][1] == 0) ? 1.0 : 1.41421356237;
double cost = base_cost * (1.0 + slope * 6.0); double cost = base_cost * (1.0 + slope * 6.0);
if (water) {
cost += 10.0;
}
if (dist[current] + cost < dist[ni]) { if (dist[current] + cost < dist[ni]) {
dist[ni] = dist[current] + cost; dist[ni] = dist[current] + cost;
prev[ni] = current; prev[ni] = current;