7#include <hpp/variant.hpp>
18 auto clp =
clip.get();
29 auto clp =
clip.get();
32 progress = math::clamp(progress, 0.0f, 1.0f);
33 elapsed = clp->duration * progress;
42 std::vector<std::pair<asset_handle<animation_clip>,
float>>
blend_clips{};
54 auto normalized_blend_time =
static_cast<float>(
elapsed.count() /
duration.count());
55 normalized_blend_time = std::clamp(normalized_blend_time, 0.0f, 1.0f);
56 return normalized_blend_time;
74 hpp::variant<hpp::monostate, blend_over_time, blend_over_param>
state{};
103 bool phase_sync =
false,
106 void clear(
size_t layer_idx);
108 void set_blend_space(
size_t layer_idx,
const std::shared_ptr<blend_space_def>& blend_space,
bool loop =
true);
157 struct animation_layer_state
159 auto is_valid() const ->
bool
161 return state.clip || state.blend_space;
165 animation_state state{};
166 std::vector<float> parameters;
169 struct animation_layer
171 auto get_final_pose() const -> const animation_pose*
173 auto final_pose = ¤t_state.pose;
175 if(target_state.is_valid())
177 final_pose = &blend_pose;
183 animation_layer_state current_state{};
184 animation_layer_state target_state{};
187 animation_pose blend_pose{};
188 blend_state blending_state{};
191 auto get_layer(
size_t index) -> animation_layer&;
193 void sample_animation(
const animation_clip* anim_clip,
196 animation_pose&
pose)
const noexcept;
197 auto compute_blend_factor(
const animation_layer&
layer,
float normalized_blend_time)
noexcept -> float;
198 void update_state(
seconds_t delta_time, animation_state& state);
199 auto get_blend_progress(
const animation_layer&
layer)
const -> float;
202 std::vector<animation_layer> layers_;
Class responsible for playing animations on a skeletal mesh.
auto play() -> bool
Starts or resumes the animation playback.
void pause()
Pauses the animation playback.
animation_clip::seconds_t seconds_t
void clear(size_t layer_idx)
void set_blend_space(size_t layer_idx, const std::shared_ptr< blend_space_def > &blend_space, bool loop=true)
void stop()
Stops the animation playback and resets the time.
std::function< void(const animation_pose::node_desc &desc, const math::transform &abs, const animation_pose::root_motion_result &motion_result)> update_callback_t
auto is_playing() const -> bool
Returns whether the animation is currently playing.
void blend_to(size_t layer_idx, const asset_handle< animation_clip > &clip, seconds_t duration=seconds_t(0.3), bool loop=true, bool phase_sync=false, const blend_easing_t &easing=math::linearInterpolation< float >)
Blends to the animation over the specified time with the specified easing.
void set_blend_space_parameters(size_t layer_idx, const std::vector< float > ¶ms)
void resume()
Resumes the animation playback.
auto update_time(seconds_t delta_time, bool force=false) -> bool
Updates the animation player, advancing the animation time and applying transformations.
void update_poses(const animation_pose &ref_pose, animation_retargeting_mode retargeting_mode, const update_callback_t &set_transform_callback)
auto is_paused() const -> bool
Returns whether the animation is currently paused.
std::function< float(float)> blend_easing_t
animation_retargeting_mode
Animation retargeting mode for bone matching.
Thread-safe handle to an asset.
animation_channel::seconds_t seconds_t
void set_progress(float progress)
animation_clip::seconds_t elapsed
std::vector< std::pair< asset_handle< animation_clip >, float > > blend_clips
auto get_progress() const -> float
std::vector< animation_pose > blend_poses
asset_handle< animation_clip > clip
std::shared_ptr< blend_space_def > blend_space
auto get_progress() const -> float
animation_clip::seconds_t elapsed
animation_clip::seconds_t duration
auto get_progress() const -> float
hpp::variant< hpp::monostate, blend_over_time, blend_over_param > state