mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-07 17:21:49 -10:00
Light views of proto chunks: their blocks only
A finished column at the edge of the generated area is lit against its decorated proto neighbours, each copied into a column on the server thread (light_view). The light engine reads only their blocks, yet the copy also rebuilt every section's biomes (64 biome lookups and a palette per section), the scheduled ticks, post-processing marks and structure references. The view now copies the blocks alone; the final column (finish) still gets everything. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
d0ce8fa54e
commit
8e5ab9ec63
1 file changed
+28
-15
@@ -286,23 +286,21 @@ impl VanillaTerrain {
|
||||
self.structure_mobs
|
||||
.spawn_generated(kind, position, yaw, biome, random, group)
|
||||
}
|
||||
/// A proto chunk's blocks, biomes, scheduled ticks and post-processing
|
||||
/// marks as a column.
|
||||
fn column(&self, chunk: &ProtoChunk) -> Chunk {
|
||||
/// Only the generated range of a proto chunk (the Nether is 0..256)
|
||||
/// is copied into a column.
|
||||
fn generated_range(chunk: &ProtoChunk, out: &Chunk) -> (i32, i32) {
|
||||
(
|
||||
chunk.terrain.min_y().max(out.min_y()),
|
||||
(chunk.terrain.min_y() + chunk.terrain.height()).min(out.max_y()),
|
||||
)
|
||||
}
|
||||
/// A proto chunk's blocks alone as a column: what a light job reads of
|
||||
/// its neighbours.
|
||||
fn block_column(&self, chunk: &ProtoChunk) -> Chunk {
|
||||
let pos = chunk.position();
|
||||
let mut out = Chunk::with_layout(pos.x, pos.z, self.layout());
|
||||
let (bx, bz) = (pos.x * 16, pos.z * 16);
|
||||
// Only the generated range (the Nether is 0..256) is copied.
|
||||
let (lo, hi) = (
|
||||
chunk.terrain.min_y().max(out.min_y()),
|
||||
(chunk.terrain.min_y() + chunk.terrain.height()).min(out.max_y()),
|
||||
);
|
||||
out.structure_refs = chunk
|
||||
.structures()
|
||||
.into_iter()
|
||||
.map(|(id, start, _, _)| (Arc::from(id), (start.x, start.z)))
|
||||
.collect();
|
||||
out.structure_starts = chunk.own_starts();
|
||||
let (lo, hi) = Self::generated_range(chunk, &out);
|
||||
let mut values = Box::new([0u32; 4096]);
|
||||
for si in 0..out.sections.len() as i32 {
|
||||
let base = out.min_y() + si * 16;
|
||||
@@ -332,6 +330,21 @@ impl VanillaTerrain {
|
||||
Section::from_blocks(&values);
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
/// A proto chunk's blocks, biomes, scheduled ticks and post-processing
|
||||
/// marks as a column.
|
||||
fn column(&self, chunk: &ProtoChunk) -> Chunk {
|
||||
let mut out = self.block_column(chunk);
|
||||
let pos = chunk.position();
|
||||
let (bx, bz) = (pos.x * 16, pos.z * 16);
|
||||
let (lo, hi) = Self::generated_range(chunk, &out);
|
||||
out.structure_refs = chunk
|
||||
.structures()
|
||||
.into_iter()
|
||||
.map(|(id, start, _, _)| (Arc::from(id), (start.x, start.z)))
|
||||
.collect();
|
||||
out.structure_starts = chunk.own_starts();
|
||||
// Ticks the features scheduled (leaves reshaped at a tree's edge,
|
||||
// fluids of lakes and springs) run once the chunk is live, as
|
||||
// LevelChunk takes over ProtoChunk's ticks.
|
||||
@@ -783,7 +796,7 @@ impl ChunkGenerator for VanillaTerrain {
|
||||
}
|
||||
fn light_view(&self, proto: &Proto) -> Option<Chunk> {
|
||||
match proto.downcast_ref::<VanillaProto>() {
|
||||
Some(VanillaProto::Ready(chunk)) => Some(self.column(chunk)),
|
||||
Some(VanillaProto::Ready(chunk)) => Some(self.block_column(chunk)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user