Packages
Procedural terrain generator: fractal noise, hydraulic erosion and rivers (Rust NIF)
Current section
Files
Jump to
Current section
Files
terrain_generator
Cargo.toml
Cargo.toml
[workspace]
members = [".", "native/terrain_generator_nif", "native/terrain_generator_ffi"]
# **The GUI is its own workspace** (gui/Cargo.toml, gui/Cargo.lock). The
# libraries' graph stays at their ~50 crates instead of eframe's ~440. The
# Hex package, which must ship every member of this workspace for Cargo to
# build the NIF, carries no GUI source. And an eframe release can never move
# the libraries' lockfile.
exclude = ["gui"]
[workspace.package]
# Minimum supported Rust version for every crate here.
# Currently set by rustler 0.38, which the Elixir NIF depends on.
rust-version = "1.91"
[package]
name = "terrain-generator"
version = "0.3.1"
edition = "2021"
rust-version.workspace = true
license = "Apache-2.0"
authors = ["Fabio Ticconi <fabio.ticconi@gmail.com>"]
description = "Procedural terrain generator: fractal noise, hydraulic erosion and river extraction"
repository = "https://github.com/fabio-t/terrain-generator"
keywords = ["terrain", "procedural", "heightmap", "erosion", "noise"]
categories = ["game-development", "simulation"]
# Anchored with `/`: these follow .gitignore rules, so a bare "README.md"
# also matches every README under deps/ once `mix deps.get` has run.
include = [
"/src/**",
"/Cargo.toml",
"/README.md",
"/LICENSE",
]
[dependencies]
# **Exact pin.** `noise` computes the base heightmap, so its output is part of
# ours: a patch release that changes one bit changes every stored seed's map.
# With "0.9", a library user's `cargo update` could pull such a release in
# without this crate changing. Pinned, a `noise` upgrade reaches users only in
# a release of ours, which tests/determinism.rs has checked and the CHANGELOG
# describes.
#
# The cost: Cargo allows one 0.9.x per dependency graph, so a user who needs
# another 0.9 patch for their own code cannot build alongside us until we
# move the pin. 0.9.0 is the latest release, so nobody is affected today.
noise = "=0.9.0"
png = { version = "0.18", optional = true }
clap = { version = "4", features = ["derive"], optional = true }
[dev-dependencies]
# decoding written layers back in the integration tests
png = "0.18"
[features]
default = ["cli"]
# PNG file output (Terrain::save_png); to_rgb works without it.
png = ["dep:png"]
# The terrain-generator command-line binary.
cli = ["dep:clap", "png"]
[[bin]]
name = "terrain-generator"
required-features = ["cli"]
[profile.release]
opt-level = 3
# **Tests run optimised code where it matters, and nowhere else.** The test
# suites generate and erode whole maps, which unoptimised is the slow part:
# 26 s of the run. Optimising this crate and `noise` (the per-cell sampler)
# takes it to 5 s for 2 s more compile. Measured cold, `cargo test
# --workspace` on 4 cores, after the GUI left the workspace:
#
# compile run
# default (everything opt-level 0) 11 s 26 s
# this crate 1, noise 3 13 s 5 s
# every crate 1 18 s 4 s
# this crate 1, every dependency 3 42 s 4 s
#
# Warm (a CI run off `main`'s cache), only the run differs: 26 s before,
# 5 s with this.
#
# The blanket `package."*"` override is what islandur uses, but there the
# dependencies are the hot path. Here only `noise` is: optimising clap, png
# and rustler as well triples the compile and saves a second of run.
# Debug assertions and overflow checks stay on: opt-level does not touch them.
[profile.dev.package.terrain-generator]
opt-level = 1
[profile.dev.package.noise]
opt-level = 3