diff --git a/CMakeLists.txt b/CMakeLists.txt index 7739ede..d516876 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ find_package(SDL2 REQUIRED COMPONENTS SDL2::SDL2-static SDL2::SDL2main CONFIG) find_package(OpenAL REQUIRED CONFIG) find_library(physfs REQUIRED NAMES physfs-static PATHS "${CMAKE_PREFIX_PATH}/lib") + # Determine dependencies set(STATIC_LIBS vmq diff --git a/src/animation/ease.hpp b/src/animation/ease.hpp new file mode 100644 index 0000000..73875c6 --- /dev/null +++ b/src/animation/ease.hpp @@ -0,0 +1,418 @@ +/* + * Copyright (C) 2020 Christopher J. Howard + * + * This file is part of Antkeeper source code. + * + * Antkeeper source code is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Antkeeper source code is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Antkeeper source code. If not, see . + */ + +/* + * Easing Functions (Equations) + * + * Copyright (C) 2001 Robert Penner + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the author nor the names of contributors may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ANTKEEPER_EASE_HPP +#define ANTKEEPER_EASE_HPP + +#include +#include +#include + +/** + * Container for templated easing functions. + * + * All easing functions require the following operators to be defined: + * + * value_type operator+(const value_type&, const value_type&); + * value_type operator-(const value_type&, const value_type&); + * value_type operator*(const value_type&, scalar_type) const; + * + * @tparam T Value type. + * @tparam S Scalar type. + */ +template +struct ease +{ + typedef T value_type; + typedef S scalar_type; + + /// Linearly interpolates between @p x and @p y. + static T linear(const T& x, const T& y, S a); + + /// Logarithmically interpolates between @p x and @p y. + static T log(const T& x, const T& y, S a); + + static T in_sine(const T& x, const T& y, S a); + static T out_sine(const T& x, const T& y, S a); + static T in_out_sine(const T& x, const T& y, S a); + + static T in_quad(const T& x, const T& y, S a); + static T out_quad(const T& x, const T& y, S a); + static T in_out_quad(const T& x, const T& y, S a); + + static T in_cubic(const T& x, const T& y, S a); + static T out_cubic(const T& x, const T& y, S a); + static T in_out_cubic(const T& x, const T& y, S a); + + static T in_quart(const T& x, const T& y, S a); + static T out_quart(const T& x, const T& y, S a); + static T in_out_quart(const T& x, const T& y, S a); + + static T in_quint(const T& x, const T& y, S a); + static T out_quint(const T& x, const T& y, S a); + static T in_out_quint(const T& x, const T& y, S a); + + static T in_expo(const T& x, const T& y, S a); + static T out_expo(const T& x, const T& y, S a); + static T in_out_expo(const T& x, const T& y, S a); + + static T in_circ(const T& x, const T& y, S a); + static T out_circ(const T& x, const T& y, S a); + static T in_out_circ(const T& x, const T& y, S a); + + static T in_back(const T& x, const T& y, S a); + static T out_back(const T& x, const T& y, S a); + static T in_out_back(const T& x, const T& y, S a); + + static T in_elastic(const T& x, const T& y, S a); + static T out_elastic(const T& x, const T& y, S a); + static T in_out_elastic(const T& x, const T& y, S a); + + static T in_bounce(const T& x, const T& y, S a); + static T out_bounce(const T& x, const T& y, S a); + static T in_out_bounce(const T& x, const T& y, S a); +}; + +template +inline T ease::linear(const T& x, const T& y, S a) +{ + return (y - x) * a + x; +} + +template +inline T ease::log(const T& x, const T& y, S a) +{ + //return std::exp(linear(std::log(x), std::log(y), a)); + return x * std::pow(y / x, a); +} + +template +T ease::in_sine(const T& x, const T& y, S a) +{ + return linear(y, x, std::cos(a * vmq::half_pi)); +} + +template +T ease::out_sine(const T& x, const T& y, S a) +{ + return linear(x, y, std::sin(a * vmq::half_pi)); +} + +template +T ease::in_out_sine(const T& x, const T& y, S a) +{ + return linear(x, y, -(std::cos(a * vmq::pi) - S(1)) * S(0.5)); +} + +template +T ease::in_quad(const T& x, const T& y, S a) +{ + return linear(x, y, a * a); +} + +template +T ease::out_quad(const T& x, const T& y, S a) +{ + return linear(x, y, (S(2) - a) * a); +} + +template +T ease::in_out_quad(const T& x, const T& y, S a) +{ + return linear(x, y, (a < S(0.5)) ? S(2) * a * a : -(S(2) * a * a - S(4) * a + S(1))); +} + +template +T ease::in_cubic(const T& x, const T& y, S a) +{ + return linear(x, y, a * a * a); +} + +template +T ease::out_cubic(const T& x, const T& y, S a) +{ + return linear(x, y, a * ((a - S(3)) * a + S(3))); +} + +template +T ease::in_out_cubic(const T& x, const T& y, S a) +{ + return linear(x, y, (a < S(0.5)) ? S(4) * a * a * a : S(4) * a * a * a - S(12) * a * a + S(12) * a - 3); +} + +template +T ease::in_quart(const T& x, const T& y, S a) +{ + return linear(x, y, a * a * a * a); +} + +template +T ease::out_quart(const T& x, const T& y, S a) +{ + return linear(x, y, a * (a * ((S(4) - a) * a - S(6)) + S(4))); +} + +template +T ease::in_out_quart(const T& x, const T& y, S a) +{ + return linear(x, y, (a < S(0.5)) ? S(8) * a * a * a * a : a * (a * ((S(32) - S(8) * a) * a - S(48)) + S(32)) - S(7)); +} + +template +T ease::in_quint(const T& x, const T& y, S a) +{ + return linear(x, y, a * a * a * a * a); +} + +template +T ease::out_quint(const T& x, const T& y, S a) +{ + return linear(x, y, a * (a * (a * ((a - S(5)) * a + S(10)) - S(10)) + S(5))); +} + +template +T ease::in_out_quint(const T& x, const T& y, S a) +{ + if (a < S(0.5)) + { + return linear(x, y, S(16) * a * a * a * a * a); + } + else + { + a = S(2) * (S(1) - a); + return linear(x, y, S(0.5) * (S(2) - a * a * a * a * a)); + } +} + +template +T ease::in_expo(const T& x, const T& y, S a) +{ + return (a == S(0)) ? x : linear(x, y, std::pow(S(1024), a - S(1))); +} + +template +T ease::out_expo(const T& x, const T& y, S a) +{ + return (a == S(1)) ? y : linear(y, x, std::pow(S(2), S(-10) * a)); +} + +template +T ease::in_out_expo(const T& x, const T& y, S a) +{ + if (a == S(0)) + { + return x; + } + else if (a == S(1)) + { + return y; + } + + return linear(x, y, (a < S(0.5)) ? std::pow(S(2), S(20) * a - S(11)) : S(1) - std::pow(S(2), S(9) - S(20) * a)); +} + +template +T ease::in_circ(const T& x, const T& y, S a) +{ + return linear(y, x, std::sqrt(S(1) - a * a)); +} + +template +T ease::out_circ(const T& x, const T& y, S a) +{ + return linear(x, y, std::sqrt(-(a - S(2)) * a)); +} + +template +T ease::in_out_circ(const T& x, const T& y, S a) +{ + if (a < S(0.5)) + { + return linear(x, y, S(0.5) - S(0.5) * std::sqrt(S(1) - S(4) * a * a)); + } + else + { + return linear(x, y, S(0.5) * (std::sqrt(S(-4) * (a - S(2)) * a - S(3)) + S(1))); + } +} + +template +T ease::in_back(const T& x, const T& y, S a) +{ + const S c = S(1.70158); + return linear(x, y, a * a * (a * c + a - c)); +} + +template +T ease::out_back(const T& x, const T& y, S a) +{ + const S c = S(1.70158); + a -= S(1); + return linear(x, y, a * a * (a * c + a + c) + S(1)); +} + +template +T ease::in_out_back(const T& x, const T& y, S a) +{ + const S c = S(1.70158) * S(1.525f); + + if (a < S(0.5)) + { + return linear(x, y, a * a * (a * (S(4) * c + S(4)) - S(2) * c)); + } + else + { + S b = S(1) - S(2) * a; + return linear(x, y, b * b * (a * c + a - c * S(0.5) - S(1)) + S(1)); + } +} + +template +T ease::in_elastic(const T& x, const T& y, S a) +{ + if (a == S(0)) + { + return x; + } + else if (a == S(1)) + { + return y; + } + + return linear(x, y, -std::pow(S(1024), a - S(1)) * std::sin(S(20.944) * (a - S(1.075)))); +} + +template +T ease::out_elastic(const T& x, const T& y, S a) +{ + if (a == S(0)) + { + return x; + } + else if (a == S(1)) + { + return y; + } + + return linear(x, y, std::pow(S(2), S(-10) * a) * std::sin(S(20.944) * (a - S(0.075))) + S(1)); +} + +template +T ease::in_out_elastic(const T& x, const T& y, S a) +{ + if (a == S(0)) + { + return x; + } + else if (a == S(1)) + { + return y; + } + + if (a < S(0.5)) + { + return linear(x, y, std::pow(S(2), S(20) * a - S(11)) * std::sin(S(15.5334) - S(27.5293) * a)); + + } + else + { + return linear(y, x, std::pow(2, S(9) - S(20) * a) * std::sin(S(15.5334) - S(27.5293) * a)); + } +} + +template +T ease::in_bounce(const T& x, const T& y, S a) +{ + return linear(x, y, S(1) - ease::out_bounce(S(0), S(1), S(1) - a)); +} + +template +T ease::out_bounce(const T& x, const T& y, S a) +{ + const S n = S(7.5625); + const S d = S(2.75); + + if (a < S(1) / d) + { + a = n * a * a; + } + else if (a < S(2) / d) + { + a -= S(1.5) / d; + a = n * a * a + S(0.75); + } + else if (a < S(2.5) / d) + { + a -= S(2.25) / d; + a = n * a * a + S(0.9375); + } + else + { + a -= S(2.625) / d; + a = n * a * a + S(0.984375); + } + + return linear(x, y, a); +} + +template +T ease::in_out_bounce(const T& x, const T& y, S a) +{ + if (a < S(0.5)) + { + return linear(x, y, (S(1) - ease::out_bounce(S(0), S(1), S(1) - S(2) * a)) * S(0.5)); + } + else + { + return linear(x, y, (S(1) + ease::out_bounce(S(0), S(1), S(2) * a - S(1))) * S(0.5)); + } +} + +#endif // ANTKEEPER_EASE_HPP diff --git a/src/animation/easings.hpp b/src/animation/easings.hpp deleted file mode 100644 index ce8653c..0000000 --- a/src/animation/easings.hpp +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright (C) 2020 Christopher J. Howard - * - * This file is part of Antkeeper source code. - * - * Antkeeper source code is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Antkeeper source code is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Antkeeper source code. If not, see . - */ - -/* - * Easing Functions (Equations) - * - * Copyright (C) 2001 Robert Penner - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of the author nor the names of contributors may be used to - * endorse or promote products derived from this software without specific - * prior written permission. - - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ANTKEEPER_EASINGS_HPP -#define ANTKEEPER_EASINGS_HPP - -#include -#include - -template -inline T ease_linear(const T& x, const T& y, S a) -{ - return (y - x) * a + x; -} - -template -T ease_in_sine(const T& x, const T& y, S a) -{ - return -(y - x) * std::cos(a * vmq::half_pi) + (y - x) + x; -} - -template -T ease_out_sine(const T& x, const T& y, S a) -{ - return (y - x) * std::sin(a * vmq::half_pi) + x; -} - -template -T ease_in_out_sine(const T& x, const T& y, S a) -{ - return -(y - x) * S(0.5) * (std::cos(vmq::pi * a) - S(1.0)) + x; -} - -template -T ease_in_quad(const T& x, const T& y, S a) -{ - return (y - x) * a * a + x; -} - -template -T ease_out_quad(const T& x, const T& y, S a) -{ - return -(y - x) * a * (a - S(2.0)) + x; -} - -template -T ease_in_out_quad(const T& x, const T& y, S a) -{ - a *= S(2.0); - if (a < S(1.0)) - { - return (y - x) * S(0.5) * a * a + x; - } - - a -= S(1.0); - return -(y - x) * S(0.5) * (a * (a - S(2.0)) - S(1.0)) + x; -} - -template -T ease_in_cubic(const T& x, const T& y, S a) -{ - return (y - x) * a * a * a + x; -} - -template -T ease_out_cubic(const T& x, const T& y, S a) -{ - a -= S(1.0); - return (y - x) * (a * a * a + S(1.0)) + x; -} - -template -T ease_in_out_cubic(const T& x, const T& y, S a) -{ - a *= S(2.0); - if (a < S(1.0)) - { - return (y - x) * S(0.5) * a * a * a + x; - } - - a -= S(2.0); - return (y - x) * S(0.5) * (a * a * a + S(2.0)) + x; -} - -template -T ease_in_quart(const T& x, const T& y, S a) -{ - return (y - x) * a * a * a * a + x; -} - -template -T ease_out_quart(const T& x, const T& y, S a) -{ - a -= S(1.0); - return -(y - x) * (a * a * a * a - S(1.0)) + x; -} - -template -T ease_in_out_quart(const T& x, const T& y, S a) -{ - a *= S(2.0); - if (a < S(1.0)) - { - return (y - x) * S(0.5) * a * a * a * a + x; - } - - a -= S(2.0); - return -(y - x) * S(0.5) * (a * a * a * a - S(2.0)) + x; -} - -template -T ease_in_quint(const T& x, const T& y, S a) -{ - return (y - x) * a * a * a * a * a + x; -} - -template -T ease_out_quint(const T& x, const T& y, S a) -{ - a -= S(1.0); - return (y - x) * (a * a * a * a * a + S(1.0)) + x; -} - -template -T ease_in_out_quint(const T& x, const T& y, S a) -{ - a *= S(2.0); - if (a < S(1.0)) - { - return (y - x) * S(0.5) * a * a * a * a * a + x; - } - - a -= S(2.0); - return (y - x) * S(0.5) * (a * a * a * a * a + S(2.0)) + x; -} - -template -T ease_in_expo(const T& x, const T& y, S a) -{ - if (a == S(0.0)) - { - return x; - } - - return (y - x) * std::pow(S(2.0), S(10.0) * (a - S(1.0))) + x; -} - -template -T ease_out_expo(const T& x, const T& y, S a) -{ - if (a == S(1.0)) - { - return y; - } - - return (y - x) * (-std::pow(S(2.0), -S(10.0) * a) + S(1.0)) + x; -} - -template -T ease_in_out_expo(const T& x, const T& y, S a) -{ - if (a == S(0.0)) - { - return x; - } - else if (a == S(1.0)) - { - return y; - } - - a *= S(2.0); - if (a < S(1.0)) - { - return (y - x) * S(0.5) * std::pow(S(2.0), S(10.0) * (a - S(1.0))) + x; - } - - a -= S(1.0); - return (y - x) * S(0.5) * (-std::pow(S(2.0), -S(10.0) * a) + S(2.0)) + x; -} - -template -T ease_in_circ(const T& x, const T& y, S a) -{ - return -(y - x) * (std::sqrt(S(1.0) - a * a) - S(1.0)) + x; -} - -template -T ease_out_circ(const T& x, const T& y, S a) -{ - a -= S(1.0); - return (y - x) * std::sqrt(S(1.0) - a * a) + x; -} - -template -T ease_in_out_circ(const T& x, const T& y, S a) -{ - a *= S(2.0); - if (a < S(1.0)) - { - return -(y - x) * S(0.5) * (std::sqrt(S(1.0) - a * a) - S(1.0)) + x; - } - - a -= S(2.0); - return (y - x) * S(0.5) * (std::sqrt(S(1.0) - a * a) + S(1.0)) + x; -} - -template -T ease_in_back(const T& x, const T& y, S a) -{ - const S s = S(1.70158); - return (y - x) * a * a * ((s + S(1.0)) * a - s) + x; -} - -template -T ease_out_back(const T& x, const T& y, S a) -{ - const S s = S(1.70158); - a -= S(1.0); - return (y - x) * (a * a * ((s + S(1.0)) * a + s) + S(1.0)) + x; -} - -template -T ease_in_out_back(const T& x, const T& y, S a) -{ - const S s = S(1.70158) * S(1.525f); - - a *= S(2.0); - if (a < S(1.0)) - { - return (y - x) * S(0.5) * (a * a * ((s + S(1.0)) * a - s)) + x; - } - - a -= S(2.0); - return (y - x) * S(0.5) * (a * a * ((s + S(1.0)) * a + s) + S(2.0)) + x; -} - -#endif // ANTKEEPER_EASINGS_HPP diff --git a/src/frame-scheduler.cpp b/src/animation/frame-scheduler.cpp similarity index 100% rename from src/frame-scheduler.cpp rename to src/animation/frame-scheduler.cpp diff --git a/src/frame-scheduler.hpp b/src/animation/frame-scheduler.hpp similarity index 100% rename from src/frame-scheduler.hpp rename to src/animation/frame-scheduler.hpp diff --git a/src/application.cpp b/src/application.cpp index c9ea6d2..e395ee3 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -20,9 +20,7 @@ #include "application.hpp" #include "configuration.hpp" #include "state/application-states.hpp" -#include "filesystem.hpp" #include "math.hpp" -#include "timestamp.hpp" // STL #include @@ -79,7 +77,7 @@ #include "animation/animation.hpp" #include "animation/animator.hpp" #include "animation/screen-transition.hpp" -#include "animation/easings.hpp" +#include "animation/ease.hpp" // Scene #include "scene/billboard.hpp" @@ -106,6 +104,10 @@ // Entity components #include "entity/components/cavity-component.hpp" +// Utilities +#include "utility/paths.hpp" +#include "utility/timestamp.hpp" + using namespace vmq::operators; application::application(int argc, char** argv): @@ -703,13 +705,13 @@ application::application(int argc, char** argv): if (this->active_scene == &this->overworld_scene) { this->active_scene = &this->underworld_scene; - this->radial_transition_inner->transition(0.5f, false, ease_in_quad); + this->radial_transition_inner->transition(0.5f, false, ease::in_quad); auto switch_cameras = [this]() { this->overworld_camera.set_active(false); this->underworld_camera.set_active(true); - this->fade_transition->transition(0.25f, true, ease_out_quad); + this->fade_transition->transition(0.25f, true, ease::out_quad); }; float t = timeline.get_position(); @@ -718,13 +720,13 @@ application::application(int argc, char** argv): else { this->active_scene = &this->overworld_scene; - this->fade_transition->transition(0.25f, false, ease_out_quad); + this->fade_transition->transition(0.25f, false, ease::out_quad); auto switch_cameras = [this]() { this->overworld_camera.set_active(true); this->underworld_camera.set_active(false); - this->radial_transition_inner->transition(0.5f, true, ease_out_quad); + this->radial_transition_inner->transition(0.5f, true, ease::out_quad); }; float t = timeline.get_position(); diff --git a/src/application.hpp b/src/application.hpp index ab827b5..bc263e5 100644 --- a/src/application.hpp +++ b/src/application.hpp @@ -61,13 +61,13 @@ #include "scene/model-instance.hpp" // Animation +#include "animation/frame-scheduler.hpp" #include "animation/timeline.hpp" #include "animation/tween.hpp" #include "animation/animation.hpp" // Misc #include "state/fsm.hpp" -#include "frame-scheduler.hpp" #include "pheromone-matrix.hpp" #include "orbit-cam.hpp" diff --git a/src/debug/logger.cpp b/src/debug/logger.cpp index 23bfbbe..d8d10f0 100644 --- a/src/debug/logger.cpp +++ b/src/debug/logger.cpp @@ -18,7 +18,7 @@ */ #include "logger.hpp" -#include "timestamp.hpp" +#include "utility/timestamp.hpp" #include logger::logger(): diff --git a/src/entity/components/chamber-component.hpp b/src/entity/components/chamber-component.hpp index a6e90cd..8b539ef 100644 --- a/src/entity/components/chamber-component.hpp +++ b/src/entity/components/chamber-component.hpp @@ -29,6 +29,10 @@ struct chamber_component { entt::entity nest; float depth; + float outer_radius; + float inner_radius; + float inner_sector_angle; + float tile_radius; std::unordered_set> tiles; } diff --git a/src/entity/components/nest-component.hpp b/src/entity/components/nest-component.hpp index 183d5dd..d997e93 100644 --- a/src/entity/components/nest-component.hpp +++ b/src/entity/components/nest-component.hpp @@ -20,14 +20,20 @@ #ifndef ANTKEEPER_ECS_NEST_COMPONENT_HPP #define ANTKEEPER_ECS_NEST_COMPONENT_HPP +#include +#include + namespace ecs { struct nest_component { - int bla; + std::vector chambers; + float helix_radius; + float helix_pitch; + float helix_chirality; + float helix_turns; }; } // namespace ecs #endif // ANTKEEPER_ECS_NEST_COMPONENT_HPP - diff --git a/src/marching-cubes.cpp b/src/geometry/marching-cubes.cpp similarity index 100% rename from src/marching-cubes.cpp rename to src/geometry/marching-cubes.cpp diff --git a/src/marching-cubes.hpp b/src/geometry/marching-cubes.hpp similarity index 100% rename from src/marching-cubes.hpp rename to src/geometry/marching-cubes.hpp diff --git a/src/morton.cpp b/src/geometry/morton.cpp similarity index 100% rename from src/morton.cpp rename to src/geometry/morton.cpp diff --git a/src/morton.hpp b/src/geometry/morton.hpp similarity index 100% rename from src/morton.hpp rename to src/geometry/morton.hpp diff --git a/src/octree.hpp b/src/geometry/octree.hpp similarity index 100% rename from src/octree.hpp rename to src/geometry/octree.hpp diff --git a/src/sdf.hpp b/src/geometry/sdf.hpp similarity index 100% rename from src/sdf.hpp rename to src/geometry/sdf.hpp diff --git a/src/nest.cpp b/src/nest.cpp index 34fd8f8..fbacac1 100644 --- a/src/nest.cpp +++ b/src/nest.cpp @@ -18,18 +18,8 @@ */ #include "nest.hpp" -#include "animation/easings.hpp" -#include "marching-cubes.hpp" -#include "geometry/mesh-functions.hpp" -#include "sdf.hpp" -#include -#include -#include -#include - +#include "animation/ease.hpp" #include "math.hpp" -#include -#include nest::nest() { @@ -73,7 +63,7 @@ float nest::get_shaft_angle(const shaft& shaft, float depth) const { float shaft_length = shaft.depth[1] - shaft.depth[0]; float depth_factor = (depth - shaft.depth[0]) / shaft_length; - float pitch = ease_linear(shaft.pitch[0], shaft.pitch[1], depth_factor); + float pitch = ease::linear(shaft.pitch[0], shaft.pitch[1], depth_factor); return shaft.rotation + (depth / pitch) * shaft.chirality * vmq::two_pi; } @@ -87,10 +77,10 @@ float3 nest::get_shaft_position(const shaft& shaft, float depth) const float shaft_length = shaft.depth[1] - shaft.depth[0]; float depth_factor = (depth - shaft.depth[0]) / shaft_length; - float pitch = ease_linear(shaft.pitch[0], shaft.pitch[1], depth_factor); - float radius = ease_out_expo(shaft.radius[0], shaft.radius[1], depth_factor); - float translation_x = ease_linear(shaft.translation[0][0], shaft.translation[1][0], depth_factor); - float translation_z = ease_linear(shaft.translation[0][1], shaft.translation[1][1], depth_factor); + float pitch = ease::linear(shaft.pitch[0], shaft.pitch[1], depth_factor); + float radius = ease::out_expo(shaft.radius[0], shaft.radius[1], depth_factor); + float translation_x = ease::linear(shaft.translation[0][0], shaft.translation[1][0], depth_factor); + float translation_z = ease::linear(shaft.translation[0][1], shaft.translation[1][1], depth_factor); float angle = shaft.rotation + (depth / pitch) * shaft.chirality * vmq::two_pi; float3 position; diff --git a/src/state/play-state.cpp b/src/state/play-state.cpp index 9a66e4d..23407b9 100644 --- a/src/state/play-state.cpp +++ b/src/state/play-state.cpp @@ -41,7 +41,7 @@ #include "math.hpp" #include "geometry/mesh-accelerator.hpp" #include "behavior/ebt.hpp" -#include "animation/easings.hpp" +#include "animation/ease.hpp" #include using namespace vmq::operators; @@ -249,7 +249,7 @@ void enter_play_state(application* app) orbit_cam->update(0.0f); // Start fade in - app->get_fade_transition()->transition(1.0f, true, ease_in_quad); + app->get_fade_transition()->transition(1.0f, true, ease::in_quad); logger->pop_task(EXIT_SUCCESS); } diff --git a/src/state/splash-state.cpp b/src/state/splash-state.cpp index 70300a9..c55c51b 100644 --- a/src/state/splash-state.cpp +++ b/src/state/splash-state.cpp @@ -24,7 +24,7 @@ #include "renderer/material-property.hpp" #include "animation/animation.hpp" #include "animation/animator.hpp" -#include "animation/easings.hpp" +#include "animation/ease.hpp" #include "animation/screen-transition.hpp" #include "renderer/passes/sky-pass.hpp" @@ -48,12 +48,12 @@ void enter_splash_state(application* app) const float splash_fade_out_duration = 0.5f; // Start fade in - app->get_fade_transition()->transition(splash_fade_in_duration, true, ease_in_quad); + app->get_fade_transition()->transition(splash_fade_in_duration, true, ease::in_quad); // Crate fade out function auto fade_out = [app, splash_fade_out_duration]() { - app->get_fade_transition()->transition(splash_fade_out_duration, false, ease_out_quad); + app->get_fade_transition()->transition(splash_fade_out_duration, false, ease::out_quad); }; // Create change state function diff --git a/src/systems/control-system.cpp b/src/systems/control-system.cpp index 6a312e4..939f0f0 100644 --- a/src/systems/control-system.cpp +++ b/src/systems/control-system.cpp @@ -22,26 +22,12 @@ #include "orbit-cam.hpp" #include "scene/camera.hpp" #include "geometry/intersection.hpp" -#include "animation/easings.hpp" +#include "animation/ease.hpp" #include "nest.hpp" #include using namespace vmq::operators; -template -static inline T lerp(const T& x, const T& y, float a) -{ - return x * (1.0f - a) + y * a; -} - -template -static inline T log_lerp(const T& x, const T& y, float a) -{ - T log_x = std::log(x); - T log_y = std::log(y); - return std::exp(lerp(log_x, log_y, a)); -} - control_system::control_system(): timestep(0.0f), zoom(0.0f), @@ -112,15 +98,15 @@ void control_system::update(float dt) zoom -= zoom_speed * dt * zoom_out_control.get_current_value(); zoom = std::max(0.0f, std::min(1.0f, zoom)); - float focal_distance = log_lerp(near_focal_distance, far_focal_distance, 1.0f - zoom); + float focal_distance = ease::log(near_focal_distance, far_focal_distance, 1.0f - zoom); - float fov = log_lerp(near_fov, far_fov, 1.0f - zoom); + float fov = ease::log(near_fov, far_fov, 1.0f - zoom); //float elevation_factor = (orbit_cam->get_target_elevation() - min_elevation) / max_elevation; - //fov = log_lerp(near_fov, far_fov, elevation_factor); - float clip_near = log_lerp(near_clip_near, far_clip_near, 1.0f - zoom); - float clip_far = log_lerp(near_clip_far, far_clip_far, 1.0f - zoom); - float movement_speed = log_lerp(near_movement_speed * dt, far_movement_speed * dt, 1.0f - zoom); + //fov = ease::log(near_fov, far_fov, elevation_factor); + float clip_near = ease::log(near_clip_near, far_clip_near, 1.0f - zoom); + float clip_far = ease::log(near_clip_far, far_clip_far, 1.0f - zoom); + float movement_speed = ease::log(near_movement_speed * dt, far_movement_speed * dt, 1.0f - zoom); orbit_cam->set_target_focal_distance(focal_distance); orbit_cam->get_camera()->set_perspective(fov, orbit_cam->get_camera()->get_aspect_ratio(), clip_near, clip_far); diff --git a/src/systems/subterrain-system.cpp b/src/systems/subterrain-system.cpp index 298d44b..8963cd8 100644 --- a/src/systems/subterrain-system.cpp +++ b/src/systems/subterrain-system.cpp @@ -28,7 +28,7 @@ #include "rasterizer/drawing-mode.hpp" #include "rasterizer/vertex-buffer.hpp" #include "resources/resource-manager.hpp" -#include "marching-cubes.hpp" +#include "geometry/marching-cubes.hpp" #include "geometry/intersection.hpp" #include "scene/scene.hpp" #include "scene/model-instance.hpp" diff --git a/src/filesystem.cpp b/src/utility/paths.cpp similarity index 99% rename from src/filesystem.cpp rename to src/utility/paths.cpp index 5a0536b..9af1d97 100644 --- a/src/filesystem.cpp +++ b/src/utility/paths.cpp @@ -17,7 +17,7 @@ * along with Antkeeper source code. If not, see . */ -#include "filesystem.hpp" +#include "paths.hpp" #include #include #include diff --git a/src/filesystem.hpp b/src/utility/paths.hpp similarity index 94% rename from src/filesystem.hpp rename to src/utility/paths.hpp index 498c20d..c0e80d3 100644 --- a/src/filesystem.hpp +++ b/src/utility/paths.hpp @@ -17,8 +17,8 @@ * along with Antkeeper source code. If not, see . */ -#ifndef ANTKEEPER_FILESYSTEM_HPP -#define ANTKEEPER_FILESYSTEM_HPP +#ifndef ANTKEEPER_PATHS_HPP +#define ANTKEEPER_PATHS_HPP #include @@ -57,5 +57,5 @@ bool path_exists(const std::string& path); /// Creates a directory bool create_directory(const std::string& path); -#endif // ANTKEEPER_FILESYSTEM_HPP +#endif // ANTKEEPER_PATHS_HPP diff --git a/src/timestamp.cpp b/src/utility/timestamp.cpp similarity index 100% rename from src/timestamp.cpp rename to src/utility/timestamp.cpp diff --git a/src/timestamp.hpp b/src/utility/timestamp.hpp similarity index 100% rename from src/timestamp.hpp rename to src/utility/timestamp.hpp