Expose mutable Animation Clips (#13067)
# Objective - Be able to edit animation inside the editor and save them once modified. This will allow bevy to modify animation assets with code. - Fixes #13052 ## Solution - Expose the previously const getters of the Animation curves ---
This commit is contained in:
parent
ddc9599d5e
commit
83f1184ea3
@ -255,6 +255,12 @@ impl AnimationClip {
|
|||||||
&self.curves
|
&self.curves
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
/// Get mutable references of [`VariableCurve`]s for each animation target. Indexed by the [`AnimationTargetId`].
|
||||||
|
pub fn curves_mut(&mut self) -> &mut AnimationCurves {
|
||||||
|
&mut self.curves
|
||||||
|
}
|
||||||
|
|
||||||
/// Gets the curves for a single animation target.
|
/// Gets the curves for a single animation target.
|
||||||
///
|
///
|
||||||
/// Returns `None` if this clip doesn't animate the target.
|
/// Returns `None` if this clip doesn't animate the target.
|
||||||
@ -266,12 +272,29 @@ impl AnimationClip {
|
|||||||
self.curves.get(&target_id)
|
self.curves.get(&target_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Gets mutable references of the curves for a single animation target.
|
||||||
|
///
|
||||||
|
/// Returns `None` if this clip doesn't animate the target.
|
||||||
|
#[inline]
|
||||||
|
pub fn curves_for_target_mut(
|
||||||
|
&mut self,
|
||||||
|
target_id: AnimationTargetId,
|
||||||
|
) -> Option<&'_ mut Vec<VariableCurve>> {
|
||||||
|
self.curves.get_mut(&target_id)
|
||||||
|
}
|
||||||
|
|
||||||
/// Duration of the clip, represented in seconds.
|
/// Duration of the clip, represented in seconds.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn duration(&self) -> f32 {
|
pub fn duration(&self) -> f32 {
|
||||||
self.duration
|
self.duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the duration of the clip in seconds.
|
||||||
|
#[inline]
|
||||||
|
pub fn set_duration(&mut self, duration_sec: f32) {
|
||||||
|
self.duration = duration_sec;
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds a [`VariableCurve`] to an [`AnimationTarget`] named by an
|
/// Adds a [`VariableCurve`] to an [`AnimationTarget`] named by an
|
||||||
/// [`AnimationTargetId`].
|
/// [`AnimationTargetId`].
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user