Refine wall base and ladder access
This commit is contained in:
Binary file not shown.
@@ -3570,7 +3570,7 @@ static void generate_chunk_border_wall(worldgen_ctx *ctx, int chunk_x, int chunk
|
|||||||
const int tower_height = 28;
|
const int tower_height = 28;
|
||||||
const int tower_spacing = 32;
|
const int tower_spacing = 32;
|
||||||
const int tower_half_width = 4;
|
const int tower_half_width = 4;
|
||||||
const int gate_spacing = 64;
|
const int ladder_spacing = 96;
|
||||||
for (int dx = 0; dx < CHUNK_SIZE; ++dx) {
|
for (int dx = 0; dx < CHUNK_SIZE; ++dx) {
|
||||||
for (int dz = 0; dz < CHUNK_SIZE; ++dz) {
|
for (int dz = 0; dz < CHUNK_SIZE; ++dz) {
|
||||||
int world_x = chunk_x * CHUNK_SIZE + dx;
|
int world_x = chunk_x * CHUNK_SIZE + dx;
|
||||||
@@ -3605,17 +3605,18 @@ static void generate_chunk_border_wall(worldgen_ctx *ctx, int chunk_x, int chunk
|
|||||||
if (phase < 0) phase += tower_spacing;
|
if (phase < 0) phase += tower_spacing;
|
||||||
int tower_offset = phase;
|
int tower_offset = phase;
|
||||||
if (tower_offset > tower_spacing / 2) tower_offset = tower_spacing - tower_offset;
|
if (tower_offset > tower_spacing / 2) tower_offset = tower_spacing - tower_offset;
|
||||||
int gate_phase = along % gate_spacing;
|
int ladder_phase = along % ladder_spacing;
|
||||||
if (gate_phase < 0) gate_phase += gate_spacing;
|
if (ladder_phase < 0) ladder_phase += ladder_spacing;
|
||||||
int gate_offset = gate_phase - gate_spacing / 2;
|
int ladder_offset = ladder_phase - ladder_spacing / 2;
|
||||||
if (gate_offset < 0) gate_offset = -gate_offset;
|
if (ladder_offset < 0) ladder_offset = -ladder_offset;
|
||||||
int near_corner = (dist_min_x < tower_depth || dist_max_x < tower_depth) &&
|
int near_corner = (dist_min_x < tower_depth || dist_max_x < tower_depth) &&
|
||||||
(dist_min_z < tower_depth || dist_max_z < tower_depth);
|
(dist_min_z < tower_depth || dist_max_z < tower_depth);
|
||||||
|
int ladder_module = !near_corner && ladder_offset <= 1;
|
||||||
|
int ladder_face = !near_corner && ladder_offset == 0 && side_dist == wall_end + 1;
|
||||||
|
int ladder_trim = ladder_module && side_dist == wall_end + 1 && ladder_offset == 1;
|
||||||
int in_tower = side_dist >= tower_outer && side_dist <= tower_inner &&
|
int in_tower = side_dist >= tower_outer && side_dist <= tower_inner &&
|
||||||
(tower_offset <= tower_half_width || near_corner);
|
(tower_offset <= tower_half_width || near_corner);
|
||||||
int in_wall = (side_dist >= wall_start && side_dist <= wall_end) || in_tower;
|
int in_wall = (side_dist >= wall_start && side_dist <= wall_end) || in_tower || ladder_face || ladder_trim;
|
||||||
int in_gateway = !near_corner && gate_offset <= 2 &&
|
|
||||||
side_dist >= tower_outer && side_dist <= tower_inner;
|
|
||||||
int in_exterior_apron = side_dist < wall_start && !in_wall;
|
int in_exterior_apron = side_dist < wall_start && !in_wall;
|
||||||
if (!in_wall && !in_exterior_apron) continue;
|
if (!in_wall && !in_exterior_apron) continue;
|
||||||
|
|
||||||
@@ -3642,49 +3643,83 @@ static void generate_chunk_border_wall(worldgen_ctx *ctx, int chunk_x, int chunk
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int height = in_tower ? tower_height : wall_height;
|
int center_x = world_x;
|
||||||
int top = visible_base + height;
|
int center_z = world_z;
|
||||||
if (top >= CHUNK_HEIGHT) top = CHUNK_HEIGHT - 1;
|
switch (side) {
|
||||||
uint16_t stair_block = BLOCK_STONE_BRICK_STAIRS_E;
|
case 0: center_x = ctx->wall_min_x + wall_center; break;
|
||||||
if (side == 1) stair_block = BLOCK_STONE_BRICK_STAIRS_W;
|
case 1: center_x = ctx->wall_max_x - wall_center; break;
|
||||||
if (side == 2) stair_block = BLOCK_STONE_BRICK_STAIRS_S;
|
case 2: center_z = ctx->wall_min_z + wall_center; break;
|
||||||
if (side == 3) stair_block = BLOCK_STONE_BRICK_STAIRS_N;
|
case 3: center_z = ctx->wall_max_z - wall_center; break;
|
||||||
int stair_rel = -1000;
|
|
||||||
if (in_tower && tower_offset == 2 && side_dist >= tower_outer + 1 && side_dist <= tower_inner - 1) {
|
|
||||||
stair_rel = 2 + (side_dist - (tower_outer + 1));
|
|
||||||
}
|
}
|
||||||
|
int smoothed_base = 0;
|
||||||
|
int weight_sum = 0;
|
||||||
|
const int sample_offsets[5] = {-32, -16, 0, 16, 32};
|
||||||
|
const int sample_weights[5] = {1, 2, 4, 2, 1};
|
||||||
|
for (int i = 0; i < 5; ++i) {
|
||||||
|
int sx = center_x;
|
||||||
|
int sz = center_z;
|
||||||
|
if (side < 2) {
|
||||||
|
sz += sample_offsets[i];
|
||||||
|
} else {
|
||||||
|
sx += sample_offsets[i];
|
||||||
|
}
|
||||||
|
if (sx < ctx->wall_min_x) sx = ctx->wall_min_x;
|
||||||
|
if (sx > ctx->wall_max_x) sx = ctx->wall_max_x;
|
||||||
|
if (sz < ctx->wall_min_z) sz = ctx->wall_min_z;
|
||||||
|
if (sz > ctx->wall_max_z) sz = ctx->wall_max_z;
|
||||||
|
column_data sample = get_column_data(ctx, sx, sz);
|
||||||
|
int sample_base = sample.height;
|
||||||
|
if (sample.has_water && sample.water_surface > sample_base) sample_base = sample.water_surface;
|
||||||
|
smoothed_base += sample_base * sample_weights[i];
|
||||||
|
weight_sum += sample_weights[i];
|
||||||
|
}
|
||||||
|
smoothed_base /= weight_sum;
|
||||||
|
if (visible_base > smoothed_base + 8) {
|
||||||
|
smoothed_base += (visible_base - smoothed_base - 8 + 3) / 4;
|
||||||
|
} else if (visible_base < smoothed_base - 16) {
|
||||||
|
smoothed_base -= (smoothed_base - visible_base - 16 + 4) / 5;
|
||||||
|
}
|
||||||
|
if (smoothed_base < 1) smoothed_base = 1;
|
||||||
|
if (smoothed_base > CHUNK_HEIGHT - 2) smoothed_base = CHUNK_HEIGHT - 2;
|
||||||
|
|
||||||
|
int height = in_tower ? tower_height : wall_height;
|
||||||
|
int top = smoothed_base + height;
|
||||||
|
if (top >= CHUNK_HEIGHT) top = CHUNK_HEIGHT - 1;
|
||||||
|
uint16_t ladder_block = BLOCK_LADDER_E;
|
||||||
|
if (side == 1) ladder_block = BLOCK_LADDER_W;
|
||||||
|
if (side == 2) ladder_block = BLOCK_LADDER_S;
|
||||||
|
if (side == 3) ladder_block = BLOCK_LADDER_N;
|
||||||
|
|
||||||
for (int y = data.height + 1; y < CHUNK_HEIGHT; ++y) {
|
for (int y = data.height + 1; y < CHUNK_HEIGHT; ++y) {
|
||||||
out->blocks[y][dx][dz] = BLOCK_AIR;
|
out->blocks[y][dx][dz] = BLOCK_AIR;
|
||||||
}
|
}
|
||||||
out->heightmap[dx][dz] = (uint16_t)data.height;
|
out->heightmap[dx][dz] = (uint16_t)data.height;
|
||||||
|
|
||||||
int start = data.height - 3;
|
int start = data.height - 4;
|
||||||
|
if (smoothed_base - 4 < start) start = smoothed_base - 4;
|
||||||
if (start < 1) start = 1;
|
if (start < 1) start = 1;
|
||||||
for (int y = start; y <= top; ++y) {
|
for (int y = start; y <= top; ++y) {
|
||||||
int rel_y = y - visible_base;
|
int rel_y = y - smoothed_base;
|
||||||
uint16_t block = BLOCK_SMOOTH_STONE;
|
uint16_t block = BLOCK_SMOOTH_STONE;
|
||||||
int in_center_corridor = side_dist >= wall_center - 1 && side_dist <= wall_center + 1 &&
|
int in_center_corridor = side_dist >= wall_center - 1 && side_dist <= wall_center + 1 &&
|
||||||
rel_y >= 2 && rel_y <= 4 && !in_gateway;
|
rel_y >= 2 && rel_y <= 4;
|
||||||
if (in_gateway && rel_y >= 1 && rel_y <= 5) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (stair_rel >= 0 && rel_y == stair_rel) {
|
|
||||||
set_block_with_height(out, dx, dz, y, stair_block);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (stair_rel >= 0 && rel_y > stair_rel && rel_y <= stair_rel + 3) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (in_center_corridor) {
|
if (in_center_corridor) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (rel_y < 0) {
|
||||||
|
block = (rel_y == -1 || rel_y == -4) ? BLOCK_STONE_BRICKS : BLOCK_STONE;
|
||||||
|
}
|
||||||
if (rel_y <= 2 || rel_y % 6 == 0 || rel_y == height - 1) {
|
if (rel_y <= 2 || rel_y % 6 == 0 || rel_y == height - 1) {
|
||||||
block = BLOCK_STONE_BRICKS;
|
block = BLOCK_STONE_BRICKS;
|
||||||
}
|
}
|
||||||
if (side_dist >= wall_center - 1 && side_dist <= wall_center + 1 && rel_y == height) {
|
if (side_dist >= wall_center - 1 && side_dist <= wall_center + 1 && rel_y == height) {
|
||||||
block = BLOCK_STONE_BRICKS;
|
block = BLOCK_STONE_BRICKS;
|
||||||
}
|
}
|
||||||
|
if (ladder_face && rel_y >= 2 && rel_y <= height - 1) {
|
||||||
|
block = ladder_block;
|
||||||
|
} else if (ladder_trim && rel_y >= 2 && rel_y <= height - 1 && rel_y % 3 != 1) {
|
||||||
|
block = (rel_y % 6 == 0) ? BLOCK_BLACKSTONE : BLOCK_STONE_BRICKS;
|
||||||
|
}
|
||||||
if (in_tower && side_dist == tower_outer && rel_y >= 9 && rel_y <= 17 &&
|
if (in_tower && side_dist == tower_outer && rel_y >= 9 && rel_y <= 17 &&
|
||||||
(tower_offset == 0 || (rel_y == 13 && tower_offset <= 3))) {
|
(tower_offset == 0 || (rel_y == 13 && tower_offset <= 3))) {
|
||||||
block = BLOCK_BLACKSTONE;
|
block = BLOCK_BLACKSTONE;
|
||||||
|
|||||||
Reference in New Issue
Block a user