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
148 lines
6.4 KiB
Rust
148 lines
6.4 KiB
Rust
// @generated by libremetaverse-codegen; DO NOT EDIT.
|
|
// Regenerate: cargo run -p libremetaverse-codegen -- generate
|
|
// Generator: attentions
|
|
// Source: codegen/inputs/attentions.xml sha256=bdbc4ca02dd3bde78b86e796f7eb4ada0000e47be9a127e35d2b77f3010a20af license=CC-BY-SA-3.0
|
|
// Source: codegen/inputs/attentionsN.xml sha256=80055e12a04d05ef5bb16e8c542cd6c218735f8c72f7e48317b8a34282d1ac5b license=CC-BY-SA-3.0
|
|
|
|
#![allow(
|
|
clippy::missing_errors_doc,
|
|
clippy::must_use_candidate,
|
|
clippy::should_implement_trait
|
|
)]
|
|
use std::sync::OnceLock;
|
|
#[derive(Clone, Debug, Default, PartialEq)]
|
|
pub struct AttentionData {
|
|
priority: f32,
|
|
timeout: f32,
|
|
}
|
|
impl AttentionData {
|
|
pub fn priority(&self) -> f32 {
|
|
self.priority
|
|
}
|
|
pub fn set_priority(&mut self, value: f32) {
|
|
self.priority = value;
|
|
}
|
|
pub fn timeout(&self) -> f32 {
|
|
self.timeout
|
|
}
|
|
pub fn set_timeout(&mut self, value: f32) {
|
|
self.timeout = value;
|
|
}
|
|
}
|
|
#[derive(Clone, Debug, Default, PartialEq)]
|
|
pub struct AttentionSet {
|
|
name: String,
|
|
entries: Vec<AttentionData>,
|
|
}
|
|
impl AttentionSet {
|
|
pub fn get(&self, type_: crate::LookAtType) -> Result<AttentionData, crate::Error> {
|
|
self.entries.get(type_ as usize).cloned().ok_or(crate::Error::IndexOutOfRange)
|
|
}
|
|
pub fn entries(&self) -> Vec<AttentionData> {
|
|
self.entries.clone()
|
|
}
|
|
pub fn set_entries(&mut self, value: Vec<AttentionData>) {
|
|
self.entries = value;
|
|
}
|
|
pub fn name(&self) -> String {
|
|
self.name.clone()
|
|
}
|
|
pub fn set_name(&mut self, value: String) {
|
|
self.name = value;
|
|
}
|
|
}
|
|
fn default_sets() -> &'static [AttentionSet] {
|
|
static SETS: OnceLock<Vec<AttentionSet>> = OnceLock::new();
|
|
SETS.get_or_init(|| {
|
|
vec![
|
|
AttentionSet { name : "Masculine".to_owned(), entries :
|
|
vec![AttentionData { priority : 0.0_f32, timeout : 0.0_f32 },
|
|
AttentionData { priority : 1.0_f32, timeout : 3.0_f32 }, AttentionData {
|
|
priority : 3.0_f32, timeout : 4.0_f32 }, AttentionData { priority :
|
|
2.0_f32, timeout : 2.0_f32 }, AttentionData { priority : 3.0_f32, timeout
|
|
: 4.0_f32 }, AttentionData { priority : 4.0_f32, timeout : 1.0_f32 },
|
|
AttentionData { priority : 0.0_f32, timeout : - 1.0_f32 }, AttentionData
|
|
{ priority : 6.0_f32, timeout : - 1.0_f32 }, AttentionData { priority :
|
|
6.0_f32, timeout : - 1.0_f32 }, AttentionData { priority : 7.0_f32,
|
|
timeout : - 1.0_f32 }, AttentionData { priority : 0.0_f32, timeout :
|
|
0.0_f32 }] }, AttentionSet { name : "Feminine".to_owned(), entries :
|
|
vec![AttentionData { priority : 0.0_f32, timeout : 0.0_f32 },
|
|
AttentionData { priority : 1.0_f32, timeout : 3.0_f32 }, AttentionData {
|
|
priority : 3.0_f32, timeout : 4.0_f32 }, AttentionData { priority :
|
|
2.0_f32, timeout : 2.0_f32 }, AttentionData { priority : 3.0_f32, timeout
|
|
: 4.0_f32 }, AttentionData { priority : 4.0_f32, timeout : 1.0_f32 },
|
|
AttentionData { priority : 0.0_f32, timeout : - 1.0_f32 }, AttentionData
|
|
{ priority : 6.0_f32, timeout : - 1.0_f32 }, AttentionData { priority :
|
|
6.0_f32, timeout : - 1.0_f32 }, AttentionData { priority : 7.0_f32,
|
|
timeout : - 1.0_f32 }, AttentionData { priority : 0.0_f32, timeout :
|
|
0.0_f32 }] }
|
|
]
|
|
})
|
|
.as_slice()
|
|
}
|
|
fn updated_sets() -> &'static [AttentionSet] {
|
|
static SETS: OnceLock<Vec<AttentionSet>> = OnceLock::new();
|
|
SETS.get_or_init(|| {
|
|
vec![
|
|
AttentionSet { name : "Masculine".to_owned(), entries :
|
|
vec![AttentionData { priority : 0.0_f32, timeout : 0.0_f32 },
|
|
AttentionData { priority : 1.0_f32, timeout : 3.0_f32 }, AttentionData {
|
|
priority : 3.0_f32, timeout : 4.0_f32 }, AttentionData { priority :
|
|
2.0_f32, timeout : 2.0_f32 }, AttentionData { priority : 3.0_f32, timeout
|
|
: 3.0_f32 }, AttentionData { priority : 4.0_f32, timeout : 1.0_f32 },
|
|
AttentionData { priority : 5.0_f32, timeout : 3.0_f32 }, AttentionData {
|
|
priority : 3.5_f32, timeout : - 1.0_f32 }, AttentionData { priority :
|
|
3.5_f32, timeout : 20.0_f32 }, AttentionData { priority : 7.0_f32,
|
|
timeout : - 1.0_f32 }, AttentionData { priority : 0.0_f32, timeout :
|
|
0.0_f32 }] }, AttentionSet { name : "Feminine".to_owned(), entries :
|
|
vec![AttentionData { priority : 0.0_f32, timeout : 0.0_f32 },
|
|
AttentionData { priority : 1.0_f32, timeout : 3.0_f32 }, AttentionData {
|
|
priority : 3.0_f32, timeout : 4.0_f32 }, AttentionData { priority :
|
|
2.0_f32, timeout : 2.0_f32 }, AttentionData { priority : 3.0_f32, timeout
|
|
: 6.0_f32 }, AttentionData { priority : 4.0_f32, timeout : 1.0_f32 },
|
|
AttentionData { priority : 5.0_f32, timeout : 6.0_f32 }, AttentionData {
|
|
priority : 2.5_f32, timeout : - 1.0_f32 }, AttentionData { priority :
|
|
2.5_f32, timeout : 10.0_f32 }, AttentionData { priority : 7.0_f32,
|
|
timeout : - 1.0_f32 }, AttentionData { priority : 0.0_f32, timeout :
|
|
0.0_f32 }] }
|
|
]
|
|
})
|
|
.as_slice()
|
|
}
|
|
pub struct LindenAttentions;
|
|
impl LindenAttentions {
|
|
pub fn default() -> Vec<AttentionSet> {
|
|
default_sets().to_vec()
|
|
}
|
|
pub fn updated() -> Vec<AttentionSet> {
|
|
updated_sets().to_vec()
|
|
}
|
|
pub fn default_masculine() -> AttentionSet {
|
|
default_sets()[0].clone()
|
|
}
|
|
pub fn default_feminine() -> AttentionSet {
|
|
default_sets()[1].clone()
|
|
}
|
|
pub fn updated_masculine() -> AttentionSet {
|
|
updated_sets()[0].clone()
|
|
}
|
|
pub fn updated_feminine() -> AttentionSet {
|
|
updated_sets()[1].clone()
|
|
}
|
|
}
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
#[test]
|
|
fn generated_attention_shape() {
|
|
assert_eq!(default_sets().len(), 2);
|
|
assert_eq!(updated_sets().len(), 2);
|
|
assert!(
|
|
default_sets().iter().chain(updated_sets()).all(| set | set.entries.len() ==
|
|
11)
|
|
);
|
|
assert_eq!(default_sets() [0].name, "Masculine");
|
|
assert_eq!(default_sets() [1].name, "Feminine");
|
|
}
|
|
}
|