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
impl Node
Sourcepub fn from_name(metadata_name: &str) -> Result<Self, FastNoiseError>
pub fn from_name(metadata_name: &str) -> Result<Self, FastNoiseError>
Sourcepub fn from_encoded_node_tree(
encoded_node_tree: &str,
) -> Result<Self, FastNoiseError>
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.
pub fn get_simd_level(&self) -> u32
Sourcepub fn set<V>(
&mut self,
member_name: &str,
value: V,
) -> Result<(), FastNoiseError>where
V: MemberValue + Debug,
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.
Sourcepub 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
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_outhas enough space to holdx_size * y_sizevalues. - The internal state of the node must be correctly configured before calling this method.
Sourcepub 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
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_outhas enough space to holdx_size * y_size * z_sizevalues. - The internal state of the node must be correctly configured before calling this method.
Sourcepub 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
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_outhas enough space to holdx_size * y_size * z_size * w_sizevalues. - The internal state of the node must be correctly configured before calling this method.
Sourcepub 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
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, andy_pos_arrayall have the same length. - The internal state of the node must be correctly configured before calling this method.
Sourcepub 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
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, andz_pos_arrayall have the same length. - The internal state of the node must be correctly configured before calling this method.
Sourcepub 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
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, andw_pos_arrayall have the same length. - The internal state of the node must be correctly configured before calling this method.
Sourcepub unsafe fn gen_tileable_2d_unchecked(
&self,
noise_out: &mut [f32],
x_size: i32,
y_size: i32,
frequency: f32,
seed: i32,
) -> OutputMinMax
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_outhas enough space to holdx_size * y_sizevalues. - The internal state of the node must be correctly configured before calling this method.
Sourcepub unsafe fn gen_single_2d_unchecked(&self, x: f32, y: f32, seed: i32) -> f32
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.