Files
MetaCrate/crates/libremetaverse/src/foliage_catalog.rs
Chili Palmer b71386dc31
Some checks failed
API and SemVer surface / api-surface (push) Failing after 13m11s
Native code generation / deterministic (push) Failing after 2m9s
Documentation / documentation (push) Failing after 1m39s
Imaging and meshing gate / native (push) Failing after 2m58s
Release platform and feature matrix / audit (push) Successful in 44s
Native Rust workspace compile / compile (push) Failing after 55s
Dependency and supply-chain audit / audit (push) Failing after 9m14s
Release platform and feature matrix / matrix (false, linux-stable-minimal, x86_64-unknown-linux-gnu, stable) (push) Failing after 9m22s
Release platform and feature matrix / matrix (false, windows-stable-portable, x86_64-pc-windows-gnu, stable) (push) Has been cancelled
Release platform and feature matrix / matrix (true, linux-msrv-portable, x86_64-unknown-linux-gnu, 1.96.0) (push) Has been cancelled
Release platform and feature matrix / matrix (true, linux-stable-default, x86_64-unknown-linux-gnu, stable) (push) Has been cancelled
Release platform and feature matrix / matrix (true, linux-stable-features, x86_64-unknown-linux-gnu, stable) (push) Has been cancelled
Release platform and feature matrix / matrix (true, linux-stable-release-surface, x86_64-unknown-linux-gnu, stable) (push) Has been cancelled
Release platform and feature matrix / matrix (false, macos-stable-portable, x86_64-apple-darwin, stable) (push) Has been cancelled
Audit release licenses and provenance (#104)
2026-08-12 02:12:49 +00:00

472 lines
24 KiB
Rust

// @generated by libremetaverse-codegen; DO NOT EDIT.
// Regenerate: cargo run -p libremetaverse-codegen -- generate
// Generator: foliage
// Source: codegen/inputs/trees.xml sha256=f54e626b00bd2c4fec9f59a574a45860f209e4440bbb02b81d27050b9df8ffba license=CC-BY-SA-3.0
// Source: codegen/inputs/grass.xml sha256=90015f9768afe3cfee761d04239bf9e284b2739b095b7ab8331966fa1fbfcb4e license=CC-BY-SA-3.0
#![allow(clippy::missing_errors_doc, clippy::must_use_candidate, clippy::too_many_lines)]
use std::sync::OnceLock;
#[derive(Clone, Debug, PartialEq)]
pub struct TreeDefinition {
name: String,
species_id: i32,
texture_id: libremetaverse_types::UUID,
droop: f32,
twist: f32,
branches: f32,
depth: i32,
scale_step: f32,
trunk_depth: f32,
branch_length: f32,
trunk_length: f32,
leaf_scale: f32,
billboard_scale: f32,
billboard_ratio: f32,
trunk_aspect: f32,
branch_aspect: f32,
leaf_rotate: f32,
noise_mag: f32,
noise_scale: f32,
taper: f32,
repeat_z: i32,
}
impl TreeDefinition {
pub fn name(&self) -> String {
self.name.clone()
}
pub fn set_name(&mut self, value: String) {
self.name = value;
}
pub fn species_id(&self) -> i32 {
self.species_id
}
pub fn set_species_id(&mut self, value: i32) {
self.species_id = value;
}
pub fn texture_id(&self) -> libremetaverse_types::UUID {
self.texture_id
}
pub fn set_texture_id(&mut self, value: libremetaverse_types::UUID) {
self.texture_id = value;
}
pub fn droop(&self) -> f32 {
self.droop
}
pub fn set_droop(&mut self, value: f32) {
self.droop = value;
}
pub fn twist(&self) -> f32 {
self.twist
}
pub fn set_twist(&mut self, value: f32) {
self.twist = value;
}
pub fn branches(&self) -> f32 {
self.branches
}
pub fn set_branches(&mut self, value: f32) {
self.branches = value;
}
pub fn scale_step(&self) -> f32 {
self.scale_step
}
pub fn set_scale_step(&mut self, value: f32) {
self.scale_step = value;
}
pub fn trunk_depth(&self) -> f32 {
self.trunk_depth
}
pub fn set_trunk_depth(&mut self, value: f32) {
self.trunk_depth = value;
}
pub fn branch_length(&self) -> f32 {
self.branch_length
}
pub fn set_branch_length(&mut self, value: f32) {
self.branch_length = value;
}
pub fn trunk_length(&self) -> f32 {
self.trunk_length
}
pub fn set_trunk_length(&mut self, value: f32) {
self.trunk_length = value;
}
pub fn leaf_scale(&self) -> f32 {
self.leaf_scale
}
pub fn set_leaf_scale(&mut self, value: f32) {
self.leaf_scale = value;
}
pub fn billboard_scale(&self) -> f32 {
self.billboard_scale
}
pub fn set_billboard_scale(&mut self, value: f32) {
self.billboard_scale = value;
}
pub fn billboard_ratio(&self) -> f32 {
self.billboard_ratio
}
pub fn set_billboard_ratio(&mut self, value: f32) {
self.billboard_ratio = value;
}
pub fn trunk_aspect(&self) -> f32 {
self.trunk_aspect
}
pub fn set_trunk_aspect(&mut self, value: f32) {
self.trunk_aspect = value;
}
pub fn branch_aspect(&self) -> f32 {
self.branch_aspect
}
pub fn set_branch_aspect(&mut self, value: f32) {
self.branch_aspect = value;
}
pub fn leaf_rotate(&self) -> f32 {
self.leaf_rotate
}
pub fn set_leaf_rotate(&mut self, value: f32) {
self.leaf_rotate = value;
}
pub fn noise_mag(&self) -> f32 {
self.noise_mag
}
pub fn set_noise_mag(&mut self, value: f32) {
self.noise_mag = value;
}
pub fn noise_scale(&self) -> f32 {
self.noise_scale
}
pub fn set_noise_scale(&mut self, value: f32) {
self.noise_scale = value;
}
pub fn taper(&self) -> f32 {
self.taper
}
pub fn set_taper(&mut self, value: f32) {
self.taper = value;
}
pub fn depth(&self) -> i32 {
self.depth
}
pub fn set_depth(&mut self, value: i32) {
self.depth = value;
}
pub fn repeat_z(&self) -> i32 {
self.repeat_z
}
pub fn set_repeat_z(&mut self, value: i32) {
self.repeat_z = value;
}
}
fn generated_trees() -> &'static [TreeDefinition] {
static TREES: OnceLock<Vec<TreeDefinition>> = OnceLock::new();
TREES
.get_or_init(|| {
vec![
TreeDefinition { name : "Pine 1".to_owned(), species_id : 0, texture_id :
libremetaverse_types::UUID::parse("0187babf-6c0d-5891-ebed-4ecab1426683"
.to_owned()).expect("validated tree UUID"), droop : 60.0_f32, twist :
5.0_f32, branches : 5.0_f32, depth : 1, scale_step : 0.7_f32, trunk_depth
: 6.0_f32, branch_length : 8.0_f32, trunk_length : 11.5_f32, leaf_scale :
22.0_f32, billboard_scale : 39.5_f32, billboard_ratio : 1.1_f32,
trunk_aspect : 0.1_f32, branch_aspect : 0.05_f32, leaf_rotate : 20.0_f32,
noise_mag : 0.5_f32, noise_scale : 2.5_f32, taper : 0.8_f32, repeat_z : 3
}, TreeDefinition { name : "Oak".to_owned(), species_id : 1, texture_id :
libremetaverse_types::UUID::parse("8a515889-eac9-fb55-8eba-d2dc09eb32c8"
.to_owned()).expect("validated tree UUID"), droop : 35.0_f32, twist :
3.0_f32, branches : 4.0_f32, depth : 3, scale_step : 0.7_f32, trunk_depth
: 0.0_f32, branch_length : 3.0_f32, trunk_length : 3.8_f32, leaf_scale :
7.0_f32, billboard_scale : 10.25_f32, billboard_ratio : 1.0_f32,
trunk_aspect : 0.15_f32, branch_aspect : 0.07_f32, leaf_rotate : 0.0_f32,
noise_mag : 1.2_f32, noise_scale : 4.0_f32, taper : 0.3_f32, repeat_z : 4
}, TreeDefinition { name : "Tropical Bush 1".to_owned(), species_id : 2,
texture_id :
libremetaverse_types::UUID::parse("5bc11cd6-2f40-071e-a8da-0903394204f9"
.to_owned()).expect("validated tree UUID"), droop : 10.0_f32, twist :
0.0_f32, branches : 6.0_f32, depth : 1, scale_step : 0.5_f32, trunk_depth
: 1.0_f32, branch_length : 0.5_f32, trunk_length : 0.15_f32, leaf_scale :
7.5_f32, billboard_scale : 5.0_f32, billboard_ratio : 1.25_f32,
trunk_aspect : 1.0_f32, branch_aspect : 0.08_f32, leaf_rotate : 0.0_f32,
noise_mag : 1.0_f32, noise_scale : 1.0_f32, taper : 0.2_f32, repeat_z : 1
}, TreeDefinition { name : "Palm 1".to_owned(), species_id : 3,
texture_id :
libremetaverse_types::UUID::parse("ca4e8c27-473c-eb1c-2f5d-50ee3f07d85c"
.to_owned()).expect("validated tree UUID"), droop : 0.0_f32, twist :
0.0_f32, branches : 3.0_f32, depth : 1, scale_step : 0.5_f32, trunk_depth
: 0.0_f32, branch_length : 0.7_f32, trunk_length : 9.0_f32, leaf_scale :
10.0_f32, billboard_scale : 13.25_f32, billboard_ratio : 1.0_f32,
trunk_aspect : 0.035_f32, branch_aspect : 0.03_f32, leaf_rotate :
0.0_f32, noise_mag : 0.2_f32, noise_scale : 6.0_f32, taper : 0.7_f32,
repeat_z : 10 }, TreeDefinition { name : "Dogwood".to_owned(), species_id
: 4, texture_id :
libremetaverse_types::UUID::parse("64367bd1-697e-b3e6-0b65-3f862a577366"
.to_owned()).expect("validated tree UUID"), droop : 30.0_f32, twist :
0.0_f32, branches : 3.0_f32, depth : 2, scale_step : 0.7_f32, trunk_depth
: 1.0_f32, branch_length : 2.75_f32, trunk_length : 4.0_f32, leaf_scale :
5.5_f32, billboard_scale : 10.0_f32, billboard_ratio : 1.0_f32,
trunk_aspect : 0.06_f32, branch_aspect : 0.05_f32, leaf_rotate : 0.0_f32,
noise_mag : 1.5_f32, noise_scale : 2.0_f32, taper : 0.8_f32, repeat_z : 3
}, TreeDefinition { name : "Tropical Bush 2".to_owned(), species_id : 5,
texture_id :
libremetaverse_types::UUID::parse("cdd9a9fc-6d0b-f90d-8416-c72b6019bca8"
.to_owned()).expect("validated tree UUID"), droop : 10.0_f32, twist :
0.0_f32, branches : 3.0_f32, depth : 1, scale_step : 0.5_f32, trunk_depth
: 1.0_f32, branch_length : 0.5_f32, trunk_length : 0.15_f32, leaf_scale :
6.0_f32, billboard_scale : 4.5_f32, billboard_ratio : 0.9_f32,
trunk_aspect : 1.0_f32, branch_aspect : 0.08_f32, leaf_rotate : 0.0_f32,
noise_mag : 1.0_f32, noise_scale : 1.0_f32, taper : 0.2_f32, repeat_z : 1
}, TreeDefinition { name : "Palm 2".to_owned(), species_id : 6,
texture_id :
libremetaverse_types::UUID::parse("2d784476-d0db-9979-0cff-9408745a7cf3"
.to_owned()).expect("validated tree UUID"), droop : 0.0_f32, twist :
0.0_f32, branches : 3.0_f32, depth : 1, scale_step : 0.5_f32, trunk_depth
: 0.0_f32, branch_length : 0.7_f32, trunk_length : 10.0_f32, leaf_scale :
7.5_f32, billboard_scale : 13.5_f32, billboard_ratio : 1.0_f32,
trunk_aspect : 0.035_f32, branch_aspect : 0.03_f32, leaf_rotate :
0.0_f32, noise_mag : 0.2_f32, noise_scale : 6.0_f32, taper : 0.6_f32,
repeat_z : 12 }, TreeDefinition { name : "Cypress 1".to_owned(),
species_id : 7, texture_id :
libremetaverse_types::UUID::parse("fb2ae204-3fd1-df33-594f-c9f882830e66"
.to_owned()).expect("validated tree UUID"), droop : 30.0_f32, twist :
0.0_f32, branches : 3.0_f32, depth : 4, scale_step : 0.5_f32, trunk_depth
: 0.0_f32, branch_length : 10.0_f32, trunk_length : 10.0_f32, leaf_scale
: 70.0_f32, billboard_scale : 22.5_f32, billboard_ratio : 1.0_f32,
trunk_aspect : 0.05_f32, branch_aspect : 0.03_f32, leaf_rotate : 0.0_f32,
noise_mag : 1.2_f32, noise_scale : 1.0_f32, taper : 0.5_f32, repeat_z : 6
}, TreeDefinition { name : "Cypress 2".to_owned(), species_id : 8,
texture_id :
libremetaverse_types::UUID::parse("30047cec-269d-408e-0c30-b2603b887268"
.to_owned()).expect("validated tree UUID"), droop : 30.0_f32, twist :
0.0_f32, branches : 3.0_f32, depth : 4, scale_step : 0.6_f32, trunk_depth
: 3.0_f32, branch_length : 7.5_f32, trunk_length : 10.0_f32, leaf_scale :
35.0_f32, billboard_scale : 25.0_f32, billboard_ratio : 0.8_f32,
trunk_aspect : 0.05_f32, branch_aspect : 0.04_f32, leaf_rotate : 0.0_f32,
noise_mag : 1.2_f32, noise_scale : 1.0_f32, taper : 0.5_f32, repeat_z : 5
}, TreeDefinition { name : "Pine 2".to_owned(), species_id : 9,
texture_id :
libremetaverse_types::UUID::parse("d691a01c-13b7-578d-57c0-5caef0b4e7e1"
.to_owned()).expect("validated tree UUID"), droop : 50.0_f32, twist :
7.5_f32, branches : 4.0_f32, depth : 2, scale_step : 0.7_f32, trunk_depth
: 6.0_f32, branch_length : 6.0_f32, trunk_length : 10.0_f32, leaf_scale :
15.5_f32, billboard_scale : 33.0_f32, billboard_ratio : 1.35_f32,
trunk_aspect : 0.1_f32, branch_aspect : 0.08_f32, leaf_rotate : 5.0_f32,
noise_mag : 0.5_f32, noise_scale : 2.5_f32, taper : 0.7_f32, repeat_z : 3
}, TreeDefinition { name : "Plumeria".to_owned(), species_id : 10,
texture_id :
libremetaverse_types::UUID::parse("6de37e4e-7029-61f5-54b8-f5e63f983f58"
.to_owned()).expect("validated tree UUID"), droop : 8.0_f32, twist :
7.0_f32, branches : 3.0_f32, depth : 2, scale_step : 0.6_f32, trunk_depth
: 0.0_f32, branch_length : 3.0_f32, trunk_length : 0.1_f32, leaf_scale :
20.0_f32, billboard_scale : 10.0_f32, billboard_ratio : 1.35_f32,
trunk_aspect : 0.1_f32, branch_aspect : 0.075_f32, leaf_rotate : 0.0_f32,
noise_mag : 0.0_f32, noise_scale : 0.0_f32, taper : 0.85_f32, repeat_z :
2 }, TreeDefinition { name : "Winter Pine 1".to_owned(), species_id : 11,
texture_id :
libremetaverse_types::UUID::parse("10d2a01a-0818-84b9-4b96-c2eb63256519"
.to_owned()).expect("validated tree UUID"), droop : 90.0_f32, twist :
2.5_f32, branches : 6.0_f32, depth : 1, scale_step : 0.66_f32,
trunk_depth : 8.0_f32, branch_length : 0.0_f32, trunk_length : 4.0_f32,
leaf_scale : 6.75_f32, billboard_scale : 12.5_f32, billboard_ratio :
0.6_f32, trunk_aspect : 0.1_f32, branch_aspect : 0.05_f32, leaf_rotate :
0.0_f32, noise_mag : 0.0_f32, noise_scale : 2.5_f32, taper : 0.85_f32,
repeat_z : 2 }, TreeDefinition { name : "Winter Aspen".to_owned(),
species_id : 12, texture_id :
libremetaverse_types::UUID::parse("7c0cf89b-44b1-1ce2-dd74-07102a98ac2a"
.to_owned()).expect("validated tree UUID"), droop : 85.0_f32, twist :
3.0_f32, branches : 5.0_f32, depth : 1, scale_step : 0.6_f32, trunk_depth
: 8.0_f32, branch_length : 3.0_f32, trunk_length : 4.5_f32, leaf_scale :
8.0_f32, billboard_scale : 12.0_f32, billboard_ratio : 0.675_f32,
trunk_aspect : 0.06_f32, branch_aspect : 0.05_f32, leaf_rotate : 0.0_f32,
noise_mag : 0.75_f32, noise_scale : 2.5_f32, taper : 0.8_f32, repeat_z :
2 }, TreeDefinition { name : "Winter Pine 2".to_owned(), species_id : 13,
texture_id :
libremetaverse_types::UUID::parse("67931331-0c02-4876-1255-28770896c6a2"
.to_owned()).expect("validated tree UUID"), droop : 140.0_f32, twist :
5.0_f32, branches : 6.0_f32, depth : 1, scale_step : 0.6_f32, trunk_depth
: 7.0_f32, branch_length : 0.0_f32, trunk_length : 3.0_f32, leaf_scale :
5.0_f32, billboard_scale : 7.5_f32, billboard_ratio : 0.5_f32,
trunk_aspect : 0.1_f32, branch_aspect : 0.05_f32, leaf_rotate : 0.0_f32,
noise_mag : 0.75_f32, noise_scale : 2.5_f32, taper : 0.5_f32, repeat_z :
2 }, TreeDefinition { name : "Eucalyptus".to_owned(), species_id : 14,
texture_id :
libremetaverse_types::UUID::parse("a6162133-724b-54df-a12f-51cd070ad6f3"
.to_owned()).expect("validated tree UUID"), droop : 20.0_f32, twist :
5.0_f32, branches : 3.6_f32, depth : 4, scale_step : 0.6_f32, trunk_depth
: 0.0_f32, branch_length : 12.0_f32, trunk_length : 8.0_f32, leaf_scale :
33.0_f32, billboard_scale : 24.0_f32, billboard_ratio : 1.3_f32,
trunk_aspect : 0.15_f32, branch_aspect : 0.08_f32, leaf_rotate : 0.0_f32,
noise_mag : 0.0_f32, noise_scale : 0.0_f32, taper : 0.675_f32, repeat_z :
3 }, TreeDefinition { name : "Fern".to_owned(), species_id : 15,
texture_id :
libremetaverse_types::UUID::parse("8872f2b8-31db-42d8-580a-b3e4a91262de"
.to_owned()).expect("validated tree UUID"), droop : 12.0_f32, twist :
0.0_f32, branches : 7.0_f32, depth : 1, scale_step : 0.5_f32, trunk_depth
: 0.1_f32, branch_length : 0.01_f32, trunk_length : 0.0_f32, leaf_scale :
4.0_f32, billboard_scale : 3.5_f32, billboard_ratio : 0.85_f32,
trunk_aspect : 1.0_f32, branch_aspect : 0.08_f32, leaf_rotate : 0.0_f32,
noise_mag : 1.0_f32, noise_scale : 1.0_f32, taper : 0.2_f32, repeat_z : 1
}, TreeDefinition { name : "Eelgrass".to_owned(), species_id : 16,
texture_id :
libremetaverse_types::UUID::parse("96b4de31-f4fa-337d-ec78-451e3609769e"
.to_owned()).expect("validated tree UUID"), droop : 0.0_f32, twist :
0.0_f32, branches : 5.0_f32, depth : 1, scale_step : 0.5_f32, trunk_depth
: 1.0_f32, branch_length : 0.5_f32, trunk_length : 0.15_f32, leaf_scale :
5.0_f32, billboard_scale : 3.0_f32, billboard_ratio : 1.0_f32,
trunk_aspect : 1.0_f32, branch_aspect : 0.08_f32, leaf_rotate : 0.0_f32,
noise_mag : 1.0_f32, noise_scale : 1.0_f32, taper : 0.2_f32, repeat_z : 1
}, TreeDefinition { name : "Sea Sword".to_owned(), species_id : 17,
texture_id :
libremetaverse_types::UUID::parse("5894e2e7-ab8d-edfa-e61c-18cf16854ba3"
.to_owned()).expect("validated tree UUID"), droop : 0.0_f32, twist :
0.0_f32, branches : 6.0_f32, depth : 1, scale_step : 0.7_f32, trunk_depth
: 1.0_f32, branch_length : 0.0_f32, trunk_length : 0.0_f32, leaf_scale :
2.0_f32, billboard_scale : 2.0_f32, billboard_ratio : 1.0_f32,
trunk_aspect : 1.0_f32, branch_aspect : 1.0_f32, leaf_rotate : 0.0_f32,
noise_mag : 0.5_f32, noise_scale : 0.0_f32, taper : 0.0_f32, repeat_z : 1
}, TreeDefinition { name : "Kelp 1".to_owned(), species_id : 18,
texture_id :
libremetaverse_types::UUID::parse("2caf1179-7861-6ff3-4b7d-46e17780bdfa"
.to_owned()).expect("validated tree UUID"), droop : - 15.0_f32, twist :
0.0_f32, branches : 1.0_f32, depth : 1, scale_step : 1.0_f32, trunk_depth
: 3.0_f32, branch_length : 2.5_f32, trunk_length : 0.75_f32, leaf_scale :
1.85_f32, billboard_scale : 4.9_f32, billboard_ratio : 1.0_f32,
trunk_aspect : 0.04_f32, branch_aspect : 0.05_f32, leaf_rotate : 0.0_f32,
noise_mag : 1.0_f32, noise_scale : 2.0_f32, taper : 0.8_f32, repeat_z : 2
}, TreeDefinition { name : "Beach Grass 1".to_owned(), species_id : 19,
texture_id :
libremetaverse_types::UUID::parse("18fb888b-e8f1-dce7-7da7-321d651ea6b0"
.to_owned()).expect("validated tree UUID"), droop : 0.0_f32, twist :
0.0_f32, branches : 4.0_f32, depth : 1, scale_step : 0.7_f32, trunk_depth
: 1.0_f32, branch_length : 0.0_f32, trunk_length : 0.0_f32, leaf_scale :
4.0_f32, billboard_scale : 2.5_f32, billboard_ratio : 1.2_f32,
trunk_aspect : 1.0_f32, branch_aspect : 1.0_f32, leaf_rotate : 0.0_f32,
noise_mag : 0.5_f32, noise_scale : 0.0_f32, taper : 0.0_f32, repeat_z : 1
}, TreeDefinition { name : "Kelp 2".to_owned(), species_id : 20,
texture_id :
libremetaverse_types::UUID::parse("2a4880b6-b7a3-690a-2049-bfbe38eafb9f"
.to_owned()).expect("validated tree UUID"), droop : - 15.0_f32, twist :
0.0_f32, branches : 1.0_f32, depth : 1, scale_step : 1.0_f32, trunk_depth
: 3.0_f32, branch_length : 2.5_f32, trunk_length : 1.35_f32, leaf_scale :
2.0_f32, billboard_scale : 4.9_f32, billboard_ratio : 1.0_f32,
trunk_aspect : 0.025_f32, branch_aspect : 0.05_f32, leaf_rotate :
0.0_f32, noise_mag : 1.0_f32, noise_scale : 2.0_f32, taper : 0.8_f32,
repeat_z : 2 },
]
})
.as_slice()
}
pub struct TreeDefinitions;
impl TreeDefinitions {
pub fn all() -> Vec<TreeDefinition> {
generated_trees().to_vec()
}
pub fn get(species: crate::Tree) -> Result<TreeDefinition, crate::Error> {
generated_trees().get(species as usize).cloned().ok_or(crate::Error::Argument)
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct GrassDefinition {
name: String,
species_id: i32,
texture_id: libremetaverse_types::UUID,
blade_size_x: f32,
blade_size_y: f32,
}
impl GrassDefinition {
pub fn name(&self) -> String {
self.name.clone()
}
pub fn set_name(&mut self, value: String) {
self.name = value;
}
pub fn species_id(&self) -> i32 {
self.species_id
}
pub fn set_species_id(&mut self, value: i32) {
self.species_id = value;
}
pub fn texture_id(&self) -> libremetaverse_types::UUID {
self.texture_id
}
pub fn set_texture_id(&mut self, value: libremetaverse_types::UUID) {
self.texture_id = value;
}
pub fn blade_size_x(&self) -> f32 {
self.blade_size_x
}
pub fn set_blade_size_x(&mut self, value: f32) {
self.blade_size_x = value;
}
pub fn blade_size_y(&self) -> f32 {
self.blade_size_y
}
pub fn set_blade_size_y(&mut self, value: f32) {
self.blade_size_y = value;
}
}
fn generated_grasses() -> &'static [GrassDefinition] {
static GRASSES: OnceLock<Vec<GrassDefinition>> = OnceLock::new();
GRASSES
.get_or_init(|| {
vec![
GrassDefinition { name : "Grass 0".to_owned(), species_id : 0, texture_id
:
libremetaverse_types::UUID::parse("6c4727b8-ac79-ba44-3b81-f9aa887b47eb"
.to_owned()).expect("validated grass UUID"), blade_size_x : 1.35_f32,
blade_size_y : 1.35_f32 }, GrassDefinition { name : "Grass 1".to_owned(),
species_id : 1, texture_id :
libremetaverse_types::UUID::parse("79504bf5-c3ec-0763-6563-d843de66d0a1"
.to_owned()).expect("validated grass UUID"), blade_size_x : 1.0_f32,
blade_size_y : 0.66_f32 }, GrassDefinition { name : "Grass 2".to_owned(),
species_id : 2, texture_id :
libremetaverse_types::UUID::parse("6c4727b8-ac79-ba44-3b81-f9aa887b47eb"
.to_owned()).expect("validated grass UUID"), blade_size_x : 1.8_f32,
blade_size_y : 1.8_f32 }, GrassDefinition { name : "Grass 3".to_owned(),
species_id : 3, texture_id :
libremetaverse_types::UUID::parse("99bd60a2-3250-efc9-2e39-2fbcadefbecc"
.to_owned()).expect("validated grass UUID"), blade_size_x : 1.0_f32,
blade_size_y : 1.0_f32 }, GrassDefinition { name : "Grass 4".to_owned(),
species_id : 4, texture_id :
libremetaverse_types::UUID::parse("7a2b3a4a-53c2-53ac-5716-aac7d743c020"
.to_owned()).expect("validated grass UUID"), blade_size_x : 2.25_f32,
blade_size_y : 2.25_f32 }, GrassDefinition { name : "undergrowth_1"
.to_owned(), species_id : 5, texture_id :
libremetaverse_types::UUID::parse("8f458549-173b-23ff-d4ff-bfaa5ea2371b"
.to_owned()).expect("validated grass UUID"), blade_size_x : 2.0_f32,
blade_size_y : 2.0_f32 },
]
})
.as_slice()
}
pub struct GrassDefinitions;
impl GrassDefinitions {
pub fn all() -> Vec<GrassDefinition> {
generated_grasses().to_vec()
}
pub fn get(species: crate::Grass) -> Result<GrassDefinition, crate::Error> {
grass_by_id(species as u8)
}
}
pub(crate) fn grass_by_id(species: u8) -> Result<GrassDefinition, crate::Error> {
generated_grasses().get(usize::from(species)).cloned().ok_or(crate::Error::Argument)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn golden_foliage_shape_and_values() {
let trees = TreeDefinitions::all();
assert_eq!(trees.len(), 21);
assert_eq!(trees[0].name(), "Pine 1");
assert_eq!(trees[0].species_id(), crate ::Tree::Pine1 as i32);
assert_eq!(trees[20].name(), "Kelp 2");
assert_eq!(TreeDefinitions::get(crate ::Tree::Oak).unwrap(), trees[1]);
let grass = GrassDefinitions::all();
assert_eq!(grass.len(), 6);
assert_eq!(grass[5].name(), "undergrowth_1");
assert_eq!(
GrassDefinitions::get(crate ::Grass::Undergrowth1).unwrap(), grass[5]
);
}
}