From b3d0a9b0be79076869b31a30110f0f446cb224e5 Mon Sep 17 00:00:00 2001 From: "C. J. Howard" Date: Tue, 18 Jun 2024 21:09:49 -0700 Subject: [PATCH] Remove timeline class. --- src/engine/animation/timeline.cpp | 96 ------------------ src/engine/animation/timeline.hpp | 116 ---------------------- src/game/game.cpp | 16 --- src/game/game.hpp | 8 -- src/game/states/collection-menu-state.hpp | 1 - src/game/states/graphics-menu-state.cpp | 1 - 6 files changed, 238 deletions(-) delete mode 100644 src/engine/animation/timeline.cpp delete mode 100644 src/engine/animation/timeline.hpp diff --git a/src/engine/animation/timeline.cpp b/src/engine/animation/timeline.cpp deleted file mode 100644 index b24d13b1..00000000 --- a/src/engine/animation/timeline.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// SPDX-FileCopyrightText: 2023 C. J. Howard -// SPDX-License-Identifier: GPL-3.0-or-later - -#include - -auto cue_compare = [](const typename timeline::cue& a, const typename timeline::cue& b) -{ - return std::get<0>(a) < std::get<0>(b); -}; - -timeline::timeline(): - cues(cue_compare), - position(0.0f), - autoremove(false) -{} - -void timeline::advance(float dt) -{ - auto lower_bound = cues.lower_bound({position, nullptr}); - auto upper_bound = cues.upper_bound({position + dt, nullptr}); - - for (auto iterator = lower_bound; iterator != upper_bound; ++iterator) - { - std::get<1>(*iterator)(); - } - - if (autoremove && lower_bound != upper_bound) - { - cues.erase(lower_bound, upper_bound); - } - - position += dt; -} - -void timeline::seek(float t) -{ - position = t; -} - -void timeline::add_cue(const cue& c) -{ - cues.emplace(c); -} - -void timeline::remove_cue(const cue& c) -{ - cues.erase(c); -} - -void timeline::remove_cues(float start, float end) -{ - auto lower_bound = cues.lower_bound({start, nullptr}); - auto upper_bound = cues.upper_bound({end, nullptr}); - cues.erase(lower_bound, upper_bound); -} - -void timeline::add_sequence(const sequence& s) -{ - for (const cue& c: s) - { - add_cue(c); - } -} - -void timeline::remove_sequence(const sequence& s) -{ - for (const cue& c: s) - { - remove_cue(c); - } -} - -void timeline::clear() -{ - cues.clear(); -} - -void timeline::set_autoremove(bool enabled) -{ - autoremove = enabled; -} - -typename timeline::sequence timeline::get_cues(float start, float end) const -{ - sequence s; - - auto lower_bound = cues.lower_bound({start, nullptr}); - auto upper_bound = cues.upper_bound({end, nullptr}); - for (auto iterator = lower_bound; iterator != upper_bound; ++iterator) - { - s.push_back(*iterator); - } - - return s; -} - diff --git a/src/engine/animation/timeline.hpp b/src/engine/animation/timeline.hpp deleted file mode 100644 index 9a1d2a25..00000000 --- a/src/engine/animation/timeline.hpp +++ /dev/null @@ -1,116 +0,0 @@ -// SPDX-FileCopyrightText: 2023 C. J. Howard -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef ANTKEEPER_TIMELINE_HPP -#define ANTKEEPER_TIMELINE_HPP - -#include -#include -#include - -/** - * Timeline which executes cues (scheduled functions) when advanced over their respective positions in time. - */ -class timeline -{ -public: - /// Scheduled function consisting of a time and function object. - typedef std::tuple> cue; - - /// List of cues. - typedef std::list sequence; - - /** - * Creates a timeline. - */ - timeline(); - - /** - * Advances the timeline position (t) by @p dt, triggering any cues scheduled between `t` and `dt`. If autoremove is enabled, triggered cues will be removed. - * - * @param dt Delta time by which the timeline position will be advanced. - */ - void advance(float dt); - - /** - * Sets the timeline position to @p t. - * - * @param t Position in time to which the timeline position will be set. - */ - void seek(float t); - - /** - * Adds a cue to the timeline. - * - * @param c Cue to add. - */ - void add_cue(const cue& c); - - /** - * Removes a cue from the timeline. If there are multiple identical cues (same time and function), they will all be removed. - * - * @param c Cue to remove. - */ - void remove_cue(const cue& c); - - /** - * Removes all cues on `[start, end)`. - * - * @param start Starting position in time (inclusive). - * @param end Ending position in time (non-inclusive). - */ - void remove_cues(float start, float end); - - /** - * Adds a sequence of cues to the timeline. - * - * @param s Sequence of cues to add. - */ - void add_sequence(const sequence& s); - - /** - * Removes a sequence of cues from the timeline. - * - * @param s Sequence of cues to remove. - */ - void remove_sequence(const sequence& s); - - /** - * Removes all cues from the timeline. - */ - void clear(); - - /** - * If enabled, cues will be automatically removed from the timeline when they are triggered. - * - * @param enabled Whether to enable autoremove. - */ - void set_autoremove(bool enabled); - - /** - * Returns the current position in time on the timeline. - */ - float get_position() const; - - /** - * Returns all the cues on `[start, end)`. - * - * @param start Starting position in time (inclusive). - * @param end Ending position in time (non-inclusive). - * @return All cues on `[start, end)`. - */ - sequence get_cues(float start, float end) const; - -private: - std::multiset> cues; - float position; - bool autoremove; -}; - -inline float timeline::get_position() const -{ - return position; -} - -#endif // ANTKEEPER_TIMELINE_HPP - diff --git a/src/game/game.cpp b/src/game/game.cpp index 68635f3e..4799887a 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -715,10 +714,6 @@ void game::setup_scenes() void game::setup_animation() { - // Setup timeline system - timeline = std::make_unique<::timeline>(); - timeline->set_autoremove(true); - // Setup animator animator = std::make_unique<::animator>(); } @@ -797,14 +792,6 @@ void game::setup_ui() fade_transition->get_material()->set_variable("color", fade_transition_color); fade_transition->get_billboard()->set_translation({0, 0, 98}); - // Create inner radial transition - radial_transition_inner = std::make_unique(); - radial_transition_inner->get_material()->set_shader_template(resource_manager->load("radial-transition-inner.glsl")); - - // Create outer radial transition - radial_transition_outer = std::make_unique(); - radial_transition_outer->get_material()->set_shader_template(resource_manager->load("radial-transition-outer.glsl")); - // Menu BG animations { auto menu_bg_frame_callback = [menu_bg_tint]([[maybe_unused]] int channel, const float& opacity) @@ -1241,9 +1228,6 @@ void game::fixed_update(::frame_scheduler::duration_type fixed_update_time, ::fr function_queue.pop(); } - // Advance timeline - //timeline->advance(dt); - // Update entity systems animation_system->update(t, dt); diff --git a/src/game/game.hpp b/src/game/game.hpp index f16e68af..466f6032 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -53,7 +53,6 @@ class animator; class resource_manager; class screen_transition; -class timeline; class shell; class shell_buffer; @@ -355,16 +354,9 @@ class game scene::collection* active_scene; // Animation - std::unique_ptr timeline; std::unique_ptr animator; - std::unique_ptr> radial_transition_in; - std::unique_ptr> radial_transition_out; std::unique_ptr fade_transition; std::shared_ptr fade_transition_color; - std::unique_ptr radial_transition_inner; - std::unique_ptr radial_transition_outer; - std::unique_ptr> equip_tool_animation; - std::unique_ptr> unequip_tool_animation; // Sound std::unique_ptr sound_system; diff --git a/src/game/states/collection-menu-state.hpp b/src/game/states/collection-menu-state.hpp index 7cf56a04..09465be3 100644 --- a/src/game/states/collection-menu-state.hpp +++ b/src/game/states/collection-menu-state.hpp @@ -24,7 +24,6 @@ class collection_menu_state: public game_state std::shared_ptr selection_material; scene::billboard selection_billboard; - animation selection_snap_animation; std::shared_ptr box_material; scene::billboard box_billboard; diff --git a/src/game/states/graphics-menu-state.cpp b/src/game/states/graphics-menu-state.cpp index f9d83769..580756d4 100644 --- a/src/game/states/graphics-menu-state.cpp +++ b/src/game/states/graphics-menu-state.cpp @@ -9,7 +9,6 @@ #include "game/fonts.hpp" #include "game/menu.hpp" #include "game/graphics.hpp" -#include #include "game/strings.hpp" #include