Skip to content

Commit

Permalink
remove prefix from TargetChain
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Jul 26, 2024
1 parent 0e53ce1 commit 23b0fd8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
20 changes: 5 additions & 15 deletions crates/bevy_vrm/src/animations/target_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,18 @@ use bevy::{animation::AnimationTargetId, core::Name};

/// Utility for creating chains of [AnimationTargetId]s.
#[derive(Default, Clone)]
pub struct TargetChain<'a> {
pub names: Vec<String>,
/// Prefix added before each added name, when using [TargetChain::push_target].
pub prefix: &'a str,
}
pub struct TargetChain(Vec<String>);

impl<'a> TargetChain<'a> {
impl TargetChain {
/// Add a name to the list and return the new [AnimationTargetId].
pub fn push_target(&mut self, name: &str) -> AnimationTargetId {
let value = format!("{}{}", self.prefix, name);
self.names.push(value);
pub fn push_target(&mut self, name: String) -> AnimationTargetId {
self.0.push(name);
self.target()
}

/// Get the [AnimationTargetId] for the current list of names.
pub fn target(&self) -> AnimationTargetId {
let names = self
.names
.clone()
.into_iter()
.map(Name::new)
.collect::<Vec<_>>();
let names = self.0.iter().cloned().map(Name::new).collect::<Vec<_>>();
AnimationTargetId::from_names(names.iter())
}
}
2 changes: 1 addition & 1 deletion crates/bevy_vrm/src/animations/vrm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ macro_rules! push_bone {
($map:ident, $chain:ident, $name:ident) => {
$map.insert(
BoneName::$name,
$chain.push_target(&BoneName::$name.to_string()),
$chain.push_target(BoneName::$name.to_string()),
);
};
}
Expand Down

0 comments on commit 23b0fd8

Please sign in to comment.