pub struct CesScatterLayer {
pub layer_name: GString,
pub enabled: bool,
pub density: f32,
pub mesh: Option<Gd<Mesh>>,
pub scale: f32,
pub min_height: f32,
pub max_height: f32,
pub lod_level: i64,
pub instances_per_cell: i64,
pub max_instances: i64,
pub seed: i64,
/* private fields */
}Expand description
One scattered mesh — grass, trees, rocks — spread over the planet.
A Resource: create one per kind of object and put it in the planet’s
scatter_layers array (Celestial). Placement is
GPU-only: candidates sit on a stable world lattice keyed to the terrain, so
instances never move when chunks split or merge, and nothing is read back to the
CPU. Layers are cheap to iterate on — enabled, density, min_height and
max_height re-run only the gather pass, so they respond live while you drag them.
Fields§
§layer_name: GStringDisplay name (e.g. “Grass”, “Oak trees”). Mirrored into
resource_name, so the inspector’s layer array shows it per element —
name your layers instead of hunting through “CesScatterLayer” entries.
enabled: boolLIVE on/off toggle: a disabled layer draws nothing but keeps its cached GPU placement, so re-enabling is instant (compact-only update).
density: f32Fraction of the lattice candidates actually drawn, 0..1 — the thinning knob
(LIVE: only the gather pass re-runs, so it is free to drag). It never adds
instances beyond what lod_level/instances_per_cell place; 1.0 draws them
all. Default 0.5.
mesh: Option<Gd<Mesh>>The mesh every instance of this layer draws. No mesh ⇒ the layer is
INACTIVE: it is skipped entirely (no GPU placement, nothing drawn), which is
also how a layer you are not using costs nothing. For grass, assign
res://addons/celestialsim/grass_blade.tres (regenerable via
CesScatterLayer.make_grass_blade_mesh()).
scale: f32Base scale applied to every instance (on top of a ±20% per-instance jitter), so you can size a mesh without re-authoring it. 1.0 = the mesh’s native size.
min_height: f32LIVE lower bound on normalized terrain height (0..1) where this layer may appear. Default 0.45 = the default sea level, so nothing scatters underwater; drop to 0 to allow it. (Terrain height is normalized: ~0.45 is the shoreline, 1.0 the highest peaks.)
max_height: f32LIVE upper bound on normalized terrain height (0..1). Default 1.0 = no upper limit; lower it to keep this layer off the mountain tops.
lod_level: i64LOD level the candidates are keyed to — the fineness of the stable world
lattice. Higher = denser and shorter-range; the layer only appears on
terrain chunks at depth >= lod_level - 3 (per-slot capacity bound), so
this is the single knob for both density and reach. Instances never move
when chunks split/merge. Rough starting points: ~12 for grass, ~6 for trees.
Editing it re-places every resident chunk. Default 9 (range 0–20).
instances_per_cell: i64Candidates placed per lattice cell (K) — jitters several instances into one
cell instead of one per cell, which breaks up the grid look. Costs GPU memory:
the per-slot candidate pool is K * 64 entries. Changing it rebuilds the GPU
job. Default 4 (range 1–64).
max_instances: i64Hard cap on the instances this layer draws — the size of its MultiMesh pool.
The gather pass stops appending once it is hit (so instances go missing rather
than the frame blowing up), and the buffer is sized for it, so raising it costs
VRAM. Changing it rebuilds the GPU job. Default 100000.
seed: i64Seed of the placement hash: change it to shuffle which candidates exist and where they land, keeping the same density. Re-places every resident chunk.
Implementations§
Source§impl CesScatterLayer
impl CesScatterLayer
Sourcepub fn make_grass_blade_mesh() -> Gd<ArrayMesh>
pub fn make_grass_blade_mesh() -> Gd<ArrayMesh>
Build the procedural grass blade mesh (the source of the committed
addons/celestialsim/grass_blade.tres). Callable from GDScript:
CesScatterLayer.make_grass_blade_mesh().
pub fn get_layer_name(&self) -> GString
pub fn set_layer_name(&mut self, v: GString)
pub fn get_enabled(&self) -> bool
pub fn set_enabled(&mut self, v: bool)
pub fn get_density(&self) -> f32
pub fn set_density(&mut self, v: f32)
pub fn get_scale(&self) -> f32
pub fn set_scale(&mut self, v: f32)
pub fn get_min_height(&self) -> f32
pub fn set_min_height(&mut self, v: f32)
pub fn get_max_height(&self) -> f32
pub fn set_max_height(&mut self, v: f32)
pub fn get_mesh(&self) -> Option<Gd<Mesh>>
pub fn set_mesh(&mut self, mesh: Option<Gd<Mesh>>)
pub fn get_lod_level(&self) -> i64
pub fn set_lod_level(&mut self, v: i64)
pub fn get_instances_per_cell(&self) -> i64
pub fn set_instances_per_cell(&mut self, v: i64)
pub fn get_max_instances(&self) -> i64
pub fn set_max_instances(&mut self, v: i64)
pub fn get_seed(&self) -> i64
pub fn set_seed(&mut self, v: i64)
Trait Implementations§
Source§impl Bounds for CesScatterLayer
impl Bounds for CesScatterLayer
Source§impl GodotClass for CesScatterLayer
impl GodotClass for CesScatterLayer
Source§impl Inherits<Object> for CesScatterLayer
impl Inherits<Object> for CesScatterLayer
§const IS_SAME_CLASS: bool = false
const IS_SAME_CLASS: bool = false
Self == Base. Read moreSource§impl Inherits<RefCounted> for CesScatterLayer
impl Inherits<RefCounted> for CesScatterLayer
§const IS_SAME_CLASS: bool = false
const IS_SAME_CLASS: bool = false
Self == Base. Read moreSource§impl Inherits<Resource> for CesScatterLayer
impl Inherits<Resource> for CesScatterLayer
§const IS_SAME_CLASS: bool = false
const IS_SAME_CLASS: bool = false
Self == Base. Read moreSource§impl WithBaseField for CesScatterLayer
impl WithBaseField for CesScatterLayer
Source§fn to_gd(&self) -> Gd<CesScatterLayer>
fn to_gd(&self) -> Gd<CesScatterLayer>
Gd pointer containing this object. Read more§fn base(&self) -> BaseRef<'_, Self>
fn base(&self) -> BaseRef<'_, Self>
&self engine methods on this object. Read more§fn base_mut(&mut self) -> BaseMut<'_, Self>
fn base_mut(&mut self) -> BaseMut<'_, Self>
&self/&mut self engine methods on this object. Read more§fn run_deferred<F>(&mut self, mut_self_method: F)where
F: FnOnce(&mut Self) + 'static,
fn run_deferred<F>(&mut self, mut_self_method: F)where
F: FnOnce(&mut Self) + 'static,
§fn run_deferred_gd<F>(&mut self, gd_function: F)where
F: FnOnce(Gd<Self>) + 'static,
fn run_deferred_gd<F>(&mut self, gd_function: F)where
F: FnOnce(Gd<Self>) + 'static,
Source§impl WithSignals for CesScatterLayer
impl WithSignals for CesScatterLayer
Source§type SignalCollection<'c, C: WithSignals> = __godot_Signals_CesScatterLayer<'c, C>
type SignalCollection<'c, C: WithSignals> = __godot_Signals_CesScatterLayer<'c, C>
Source§impl WithUserSignals for CesScatterLayer
impl WithUserSignals for CesScatterLayer
impl GodotDefault for CesScatterLayer
impl ImplementsGodotApi for CesScatterLayer
impl ImplementsGodotExports for CesScatterLayer
Auto Trait Implementations§
impl Freeze for CesScatterLayer
impl !RefUnwindSafe for CesScatterLayer
impl !Send for CesScatterLayer
impl !Sync for CesScatterLayer
impl Unpin for CesScatterLayer
impl UnsafeUnpin for CesScatterLayer
impl !UnwindSafe for CesScatterLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Inherits<T> for Twhere
T: GodotClass,
impl<T> Inherits<T> for Twhere
T: GodotClass,
§const IS_SAME_CLASS: bool = true
const IS_SAME_CLASS: bool = true
Self == Base. Read more§impl<T> NewGd for Twhere
T: GodotDefault<Memory = MemRefCounted> + Bounds,
impl<T> NewGd for Twhere
T: GodotDefault<Memory = MemRefCounted> + Bounds,
§impl<C> ObjectToOwned<C> for Cwhere
C: WithBaseField,
impl<C> ObjectToOwned<C> for Cwhere
C: WithBaseField,
§fn object_to_owned(&self) -> Gd<C>
fn object_to_owned(&self) -> Gd<C>
Gd<T>.