World shape for dimension
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
// entities, visuals and changing blocks. it's made of what the loaded mods' worldgen data makes the ground of, and other
|
||||
// blocks picked by what they are (a cutout plant, a translucent cube), not by their ids
|
||||
import { Alea } from "@paulaboks/rng";
|
||||
import { AIR, CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "@/common/constants.ts";
|
||||
import { AIR, CHUNK_AREA, CHUNK_SIZE } from "@/common/constants.ts";
|
||||
import { DEFAULT_SHAPE } from "@/common/world_shape.ts";
|
||||
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
|
||||
import { DEFAULT_MODEL } from "@/common/block_models.ts";
|
||||
import { OctaveNoise2D, OctaveNoise3D, smoothstep } from "@/common/worldgen/noise.ts";
|
||||
@@ -19,6 +20,9 @@ const SEED = "benchmark";
|
||||
// can be meshed, see ClientLevel.can_mesh
|
||||
export const LEVEL_RADIUS = 13;
|
||||
export const SEA_LEVEL = 62;
|
||||
// 0 to 256 with sky light whatever the world's dimension is, so runs compare. y in its chunks counts from 0
|
||||
export const LEVEL_SHAPE = DEFAULT_SHAPE;
|
||||
const TOP = LEVEL_SHAPE.max_y;
|
||||
|
||||
// the lake, and flat ground for the scenes. the terrain eases into each over BLEND blocks
|
||||
export const ZONES = {
|
||||
@@ -143,12 +147,12 @@ export class BenchTerrain {
|
||||
const t = smoothstep(zone.radius, zone.radius + BLEND, Math.hypot(x - zone.x, z - zone.z));
|
||||
height = zone.height + (height - zone.height) * t;
|
||||
}
|
||||
return Math.min(CHUNK_HEIGHT - 32, Math.round(height));
|
||||
return Math.min(TOP - 32, Math.round(height));
|
||||
}
|
||||
|
||||
chunk(chunk_x: number, chunk_z: number): { blocks: Uint32Array; biomes: string[] } {
|
||||
const b = this.#blocks;
|
||||
const blocks = new Uint32Array(CHUNK_AREA * CHUNK_HEIGHT);
|
||||
const blocks = new Uint32Array(LEVEL_SHAPE.volume);
|
||||
const random = new Alea(`${SEED}_${chunk_x}_${chunk_z}`);
|
||||
const x0 = chunk_x * CHUNK_SIZE;
|
||||
const z0 = chunk_z * CHUNK_SIZE;
|
||||
@@ -156,7 +160,7 @@ export class BenchTerrain {
|
||||
const set = (x: number, y: number, z: number, value: number, only_air = false) => {
|
||||
const lx = x - x0;
|
||||
const lz = z - z0;
|
||||
if (lx < 0 || lx >= CHUNK_SIZE || lz < 0 || lz >= CHUNK_SIZE || y < 0 || y >= CHUNK_HEIGHT) return;
|
||||
if (lx < 0 || lx >= CHUNK_SIZE || lz < 0 || lz >= CHUNK_SIZE || y < 0 || y >= TOP) return;
|
||||
const index = y * CHUNK_AREA + lz * CHUNK_SIZE + lx;
|
||||
if (!only_air || blocks[index] === AIR) blocks[index] = value;
|
||||
};
|
||||
|
||||
@@ -40,6 +40,7 @@ import {
|
||||
type BenchBlocks,
|
||||
BenchTerrain,
|
||||
LEVEL_RADIUS,
|
||||
LEVEL_SHAPE,
|
||||
SEA_LEVEL,
|
||||
UPDATE_WALL,
|
||||
ZONES,
|
||||
@@ -145,7 +146,7 @@ export class RenderBenchmark {
|
||||
(_, row) => names.slice(row * GUI_LINE_LENGTH, (row + 1) * GUI_LINE_LENGTH),
|
||||
);
|
||||
|
||||
this.#level = new ClientLevel([], LEVEL_RADIUS);
|
||||
this.#level = new ClientLevel([], LEVEL_SHAPE, LEVEL_RADIUS);
|
||||
this.#level.time = TIMES_OF_DAY.noon;
|
||||
this.#level.max_meshes_in_flight = this.#level.workers.size * MESHES_PER_WORKER;
|
||||
this.#system = system_info(this.#level.workers.size);
|
||||
|
||||
Reference in New Issue
Block a user