use nightshade::prelude::*;
pub fn set_morph_weight(world: &mut World, entity: Entity, index: u32, weight: f32) {
if let Some(weights) = world.get_mut::<nightshade::ecs::morph::components::MorphWeights>(entity)
{
weights.set_weight(index as usize, weight);
}
}
pub fn morph_weight(world: &World, entity: Entity, index: u32) -> f32 {
world
.get::<nightshade::ecs::morph::components::MorphWeights>(entity)
.map(|weights| weights.get_weight(index as usize))
.unwrap_or(0.0)
}
pub fn morph_target_count(world: &World, entity: Entity) -> usize {
world
.get::<nightshade::ecs::morph::components::MorphWeights>(entity)
.map(|weights| weights.weight_count())
.unwrap_or(0)
}
pub fn set_morph_weights(world: &mut World, entity: Entity, weights: &[f32]) {
if let Some(component) =
world.get_mut::<nightshade::ecs::morph::components::MorphWeights>(entity)
{
for (index, value) in weights.iter().enumerate() {
component.set_weight(index, *value);
}
}
}