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);
156 struct animation_layer_state
158 auto is_valid() const ->
bool
160 return state.clip || state.blend_space;
164 animation_state state{};
165 std::vector<float> parameters;
168 struct animation_layer
170 auto get_final_pose() const -> const animation_pose*
172 auto final_pose = ¤t_state.pose;
174 if(target_state.is_valid())
176 final_pose = &blend_pose;
182 animation_layer_state current_state{};
183 animation_layer_state target_state{};
186 animation_pose blend_pose{};
187 blend_state blending_state{};
190 auto get_layer(
size_t index) -> animation_layer&;
192 void sample_animation(
const animation_clip* anim_clip,
194 animation_pose& pose)
const noexcept;
195 auto compute_blend_factor(
const animation_layer&
layer,
float normalized_blend_time)
noexcept -> float;
196 void update_state(
seconds_t delta_time, animation_state& state);
197 auto get_blend_progress(
const animation_layer&
layer)
const -> float;
198 auto update_pose(animation_layer_state&
layer)
201 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, 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
Represents a handle to an asset, providing access and management functions.
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