Skip to main content

CesScatterLayer

Struct CesScatterLayer 

Source
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: GString

Display 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: bool

LIVE on/off toggle: a disabled layer draws nothing but keeps its cached GPU placement, so re-enabling is instant (compact-only update).

§density: f32

Fraction 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: f32

Base 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: f32

LIVE 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: f32

LIVE 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: i64

LOD 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: i64

Candidates 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: i64

Hard 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: i64

Seed 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

Source

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().

Source

pub fn get_layer_name(&self) -> GString

Source

pub fn set_layer_name(&mut self, v: GString)

Source

pub fn get_enabled(&self) -> bool

Source

pub fn set_enabled(&mut self, v: bool)

Source

pub fn get_density(&self) -> f32

Source

pub fn set_density(&mut self, v: f32)

Source

pub fn get_scale(&self) -> f32

Source

pub fn set_scale(&mut self, v: f32)

Source

pub fn get_min_height(&self) -> f32

Source

pub fn set_min_height(&mut self, v: f32)

Source

pub fn get_max_height(&self) -> f32

Source

pub fn set_max_height(&mut self, v: f32)

Source

pub fn get_mesh(&self) -> Option<Gd<Mesh>>

Source

pub fn set_mesh(&mut self, mesh: Option<Gd<Mesh>>)

Source

pub fn get_lod_level(&self) -> i64

Source

pub fn set_lod_level(&mut self, v: i64)

Source

pub fn get_instances_per_cell(&self) -> i64

Source

pub fn set_instances_per_cell(&mut self, v: i64)

Source

pub fn get_max_instances(&self) -> i64

Source

pub fn set_max_instances(&mut self, v: i64)

Source

pub fn get_seed(&self) -> i64

Source

pub fn set_seed(&mut self, v: i64)

Trait Implementations§

Source§

impl Bounds for CesScatterLayer

Source§

type Memory = <<CesScatterLayer as GodotClass>::Base as Bounds>::Memory

Defines the memory strategy of the static type.
Source§

type Declarer = DeclUser

Whether this class is a core Godot class provided by the engine, or declared by the user as a Rust struct.
Source§

impl GodotClass for CesScatterLayer

Source§

type Base = Resource

The immediate superclass of T. This is always a Godot engine class.
Source§

fn class_id() -> ClassId

Globally unique class ID, linked to the name under which the class is registered in Godot. Read more
§

const INIT_LEVEL: InitLevel = <Self::Base as GodotClass>::INIT_LEVEL

Initialization level, during which this class should be initialized with Godot. Read more
§

fn inherits<Base>() -> bool
where Base: GodotClass,

Returns whether Self inherits from Base. Read more
Source§

impl Inherits<Object> for CesScatterLayer

§

const IS_SAME_CLASS: bool = false

True iff Self == Base. Read more
Source§

impl Inherits<RefCounted> for CesScatterLayer

§

const IS_SAME_CLASS: bool = false

True iff Self == Base. Read more
Source§

impl Inherits<Resource> for CesScatterLayer

§

const IS_SAME_CLASS: bool = false

True iff Self == Base. Read more
Source§

impl WithBaseField for CesScatterLayer

Source§

fn to_gd(&self) -> Gd<CesScatterLayer>

Returns the Gd pointer containing this object. Read more
§

fn base(&self) -> BaseRef<'_, Self>

Returns a shared reference guard, suitable for calling &self engine methods on this object. Read more
§

fn base_mut(&mut self) -> BaseMut<'_, Self>

Returns an exclusive reference guard, suitable for calling &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,

Defers the given closure to run during idle time. Read more
§

fn run_deferred_gd<F>(&mut self, gd_function: F)
where F: FnOnce(Gd<Self>) + 'static,

Defers the given closure to run during idle time. Read more
Source§

impl WithSignals for CesScatterLayer

Source§

type SignalCollection<'c, C: WithSignals> = __godot_Signals_CesScatterLayer<'c, C>

The associated struct listing all signals of this class. Read more
Source§

impl WithUserSignals for CesScatterLayer

Source§

fn signals(&mut self) -> Self::SignalCollection<'_, Self>

Access user-defined signals of the current object self. Read more
Source§

impl GodotDefault for CesScatterLayer

Source§

impl ImplementsGodotApi for CesScatterLayer

Source§

impl ImplementsGodotExports for CesScatterLayer

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Inherits<T> for T
where T: GodotClass,

§

const IS_SAME_CLASS: bool = true

True iff Self == Base. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> NewGd for T
where T: GodotDefault<Memory = MemRefCounted> + Bounds,

§

fn new_gd() -> Gd<T>

Return a new, ref-counted Gd containing a default-constructed instance. Read more
§

impl<C> ObjectToOwned<C> for C
where C: WithBaseField,

§

fn object_to_owned(&self) -> Gd<C>

Converts the object reference to an owned Gd<T>.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> UniformObjectDeref<DeclUser> for T
where T: WithBaseField,

§

type TargetRef<'a> = GdRef<'a, T>

§

type TargetMut<'a> = GdMut<'a, T>

§

fn object_as_ref<'a>( gd: &'a Gd<T>, ) -> <T as UniformObjectDeref<DeclUser>>::TargetRef<'a>

§

fn object_as_mut<'a>( gd: &'a mut Gd<T>, ) -> <T as UniformObjectDeref<DeclUser>>::TargetMut<'a>