Meshing and lighting per section

This commit is contained in:
2026-11-07 11:41:21 -03:00
parent 71cbf901a5
commit b726ce9695
21 changed files with 736 additions and 544 deletions
+13
View File
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import type { TintColor } from "./worldgen/biome_colors.ts";
import { ID_MASK } from "./constants.ts";
import type { ItemStack } from "./inventory.ts";
import type { BlockPart, BlockVariant } from "./block_models.ts";
@@ -101,6 +102,18 @@ export function block_light_emission(block: BlockRegistry | undefined): number {
return block?.light_emission ?? 0;
}
// every block's light opacity and emission by numeric id, for lighting a lot of blocks at once. blocks is the blocks
// registry, with its gaps
export function light_tables(blocks: readonly (BlockRegistry | undefined)[]) {
const opacity = new Uint8Array(ID_MASK + 1);
const emission = new Uint8Array(ID_MASK + 1);
blocks.forEach((block, nid) => {
opacity[nid] = block_light_opacity(block);
emission[nid] = block_light_emission(block);
});
return { opacity, emission };
}
export interface BlockRegistry {
id: string;
// what players see, like "Iron Ore". made from the id when not set, see display_name in common/utils.ts