10template<
typename Object,
typename TargetType,
typename InitializeFunc,
typename UpdateFunc,
typename Getter>
12 const TargetType& end,
14 InitializeFunc&& initialize_func,
15 UpdateFunc&& update_func,
25 initialize_func = std::forward<InitializeFunc>(initialize_func),
26 update_func = std::forward<UpdateFunc>(update_func),
27 getter = std::forward<Getter>(getter),
28 ease_func = ease_func,
29 interpolate = interpolate,
30 start_required =
true,
38 if(sentinel.expired())
57 if(duration == duration_t::zero())
59 auto old_object = getter(
object, self);
60 bool request_on_step = old_object != end;
61 update_func(
object, end, self);
80 auto old_object = getter(
object, self);
81 begin = initialize_func(
object, sentinel, self);
82 start_required =
false;
83 auto updated_object = getter(
object, self);
84 if(old_object != updated_object)
101 const float progress = float(
elapsed.count()) / float(duration.count());
102 const auto next = interpolate(begin, end, progress, ease_func);
104 if(prev != next || next == end)
106 update_func(
object, next, self);
const btCollisionObject * object
float linear(float progress)
Provides a sequence-based action management system for controlling and scheduling actions.
hpp::sentinel sentinel_t
Alias for a sentinel object used for lifecycle management.
state_t
Represents the state of a sequence action.
@ running
The action is running.
@ finished
The action has finished.
@ paused
The action is paused.
std::function< float(float)> ease_t
Represents an easing function for interpolation.
auto lerp(const T &start, const T &end, float progress, const ease_t &ease_func=ease::linear) -> T
Linearly interpolates between two values based on progress.
std::function< T(const T &, const T &, float, const ease_t &)> interpolate_t
Represents a function for interpolating values.
auto create_action_updater(Object *object, const TargetType &end, const sentinel_t &sentinel, InitializeFunc &&initialize_func, UpdateFunc &&update_func, Getter &&getter, const ease_t &ease_func=ease::linear, const interpolate_t< TargetType > &interpolate=lerp< TargetType >)
std::chrono::nanoseconds duration_t
Represents a duration in nanoseconds.
Represents an action within the sequence management system. Contains lifecycle events and management ...
static auto get_duration(const seq_action &self) -> duration_t
Gets the total duration of a given action.
static void update_elapsed(seq_action &self, duration_t update_time)
Updates the elapsed time of a given action.
static auto get_state(const seq_action &action) -> state_t
Gets the current state of a given action.
static auto is_stop_and_finished_requested(const seq_action &action) -> bool
Checks if the action is requested to stop and finish.
static auto get_elapsed(const seq_action &self) -> duration_t
Gets the elapsed time of a given action.