Node

Struct Node 

Source
pub struct Node { /* private fields */ }
Expand description

Represents a node in the FastNoise2 C++ library.

This struct interfaces with the library, which uses metadata to dynamically manage node names and parameters. For details on available metadata, see the library documentation.

§Safety

Generating noise with this structure is not safe for various reasons. One of them is the fact that nodes such as FractalFBm need a Source member to generate noise. With the metadata-based API, it’s not possible to enforce this, which will result in a crash if not specified.

Refer to the specific method documentation for safety details.

You can use SafeNode to get rid of unsafe blocks in exchange for easy node updating.

Implementations§

Source§

impl Node

Source

pub fn from_name(metadata_name: &str) -> Result<Self, FastNoiseError>

Creates a Node instance using a metadata name.

§Errors

Returns an error if the metadata name is not found in the FastNoise2 metadata system.

Source

pub fn from_encoded_node_tree( encoded_node_tree: &str, ) -> Result<Self, FastNoiseError>

Creates a Node instance from an encoded node tree.

§Errors

Returns an error if the encoded node tree is invalid or if creation fails.

Source

pub fn get_simd_level(&self) -> u32

Source

pub fn set<V>( &mut self, member_name: &str, value: V, ) -> Result<(), FastNoiseError>
where V: MemberValue + Debug,

Sets a value for a member.

The member_name is looked up in the metadata, and the value is applied based on its type. The type of value must match the member’s expected type as defined in the metadata.

§Errors

Returns an error if the member name is not found which includes a list of valid member names. Also returns an error if value’s type does not match the expected type for the member. The error provides the expected and actual types to assist in debugging.

Source

pub unsafe fn gen_uniform_grid_2d_unchecked( &self, noise_out: &mut [f32], x_start: i32, y_start: i32, x_size: i32, y_size: i32, frequency: f32, seed: i32, ) -> OutputMinMax

§Safety
  • The caller must ensure that noise_out has enough space to hold x_size * y_size values.
  • The internal state of the node must be correctly configured before calling this method.
Source

pub unsafe fn gen_uniform_grid_3d_unchecked( &self, noise_out: &mut [f32], x_start: i32, y_start: i32, z_start: i32, x_size: i32, y_size: i32, z_size: i32, frequency: f32, seed: i32, ) -> OutputMinMax

§Safety
  • The caller must ensure that noise_out has enough space to hold x_size * y_size * z_size values.
  • The internal state of the node must be correctly configured before calling this method.
Source

pub unsafe fn gen_uniform_grid_4d_unchecked( &self, noise_out: &mut [f32], x_start: i32, y_start: i32, z_start: i32, w_start: i32, x_size: i32, y_size: i32, z_size: i32, w_size: i32, frequency: f32, seed: i32, ) -> OutputMinMax

§Safety
  • The caller must ensure that noise_out has enough space to hold x_size * y_size * z_size * w_size values.
  • The internal state of the node must be correctly configured before calling this method.
Source

pub unsafe fn gen_position_array_2d_unchecked( &self, noise_out: &mut [f32], x_pos_array: &[f32], y_pos_array: &[f32], x_offset: f32, y_offset: f32, seed: i32, ) -> OutputMinMax

§Safety
  • The caller must ensure that noise_out, x_pos_array, and y_pos_array all have the same length.
  • The internal state of the node must be correctly configured before calling this method.
Source

pub unsafe fn gen_position_array_3d_unchecked( &self, noise_out: &mut [f32], x_pos_array: &[f32], y_pos_array: &[f32], z_pos_array: &[f32], x_offset: f32, y_offset: f32, z_offset: f32, seed: i32, ) -> OutputMinMax

§Safety
  • The caller must ensure that noise_out, x_pos_array, y_pos_array, and z_pos_array all have the same length.
  • The internal state of the node must be correctly configured before calling this method.
Source

pub unsafe fn gen_position_array_4d_unchecked( &self, noise_out: &mut [f32], x_pos_array: &[f32], y_pos_array: &[f32], z_pos_array: &[f32], w_pos_array: &[f32], x_offset: f32, y_offset: f32, z_offset: f32, w_offset: f32, seed: i32, ) -> OutputMinMax

§Safety
  • The caller must ensure that noise_out, x_pos_array, y_pos_array, z_pos_array, and w_pos_array all have the same length.
  • The internal state of the node must be correctly configured before calling this method.
Source

pub unsafe fn gen_tileable_2d_unchecked( &self, noise_out: &mut [f32], x_size: i32, y_size: i32, frequency: f32, seed: i32, ) -> OutputMinMax

§Safety
  • The caller must ensure that noise_out has enough space to hold x_size * y_size values.
  • The internal state of the node must be correctly configured before calling this method.
Source

pub unsafe fn gen_single_2d_unchecked(&self, x: f32, y: f32, seed: i32) -> f32

§Safety
  • The internal state of the node must be correctly configured before calling this method.
Source

pub unsafe fn gen_single_3d_unchecked( &self, x: f32, y: f32, z: f32, seed: i32, ) -> f32

§Safety
  • The internal state of the node must be correctly configured before calling this method.
Source

pub unsafe fn gen_single_4d_unchecked( &self, x: f32, y: f32, z: f32, w: f32, seed: i32, ) -> f32

§Safety
  • The internal state of the node must be correctly configured before calling this method.

Trait Implementations§

Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Node

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl !Send for Node

§

impl !Sync for Node

§

impl Unpin for Node

§

impl UnwindSafe for Node

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.

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.

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.