Browse Source

Revise and expand easing functions, and reorganize some source file locations

master
C. J. Howard 1 year ago
parent
commit
f44df4b7cc
25 changed files with 465 additions and 342 deletions
  1. +1
    -0
      CMakeLists.txt
  2. +418
    -0
      src/animation/ease.hpp
  3. +0
    -284
      src/animation/easings.hpp
  4. +0
    -0
      src/animation/frame-scheduler.cpp
  5. +0
    -0
      src/animation/frame-scheduler.hpp
  6. +9
    -7
      src/application.cpp
  7. +1
    -1
      src/application.hpp
  8. +1
    -1
      src/debug/logger.cpp
  9. +4
    -0
      src/entity/components/chamber-component.hpp
  10. +8
    -2
      src/entity/components/nest-component.hpp
  11. +0
    -0
      src/geometry/marching-cubes.cpp
  12. +0
    -0
      src/geometry/marching-cubes.hpp
  13. +0
    -0
      src/geometry/morton.cpp
  14. +0
    -0
      src/geometry/morton.hpp
  15. +0
    -0
      src/geometry/octree.hpp
  16. +0
    -0
      src/geometry/sdf.hpp
  17. +6
    -16
      src/nest.cpp
  18. +2
    -2
      src/state/play-state.cpp
  19. +3
    -3
      src/state/splash-state.cpp
  20. +7
    -21
      src/systems/control-system.cpp
  21. +1
    -1
      src/systems/subterrain-system.cpp
  22. +1
    -1
      src/utility/paths.cpp
  23. +3
    -3
      src/utility/paths.hpp
  24. +0
    -0
      src/utility/timestamp.cpp
  25. +0
    -0
      src/utility/timestamp.hpp

+ 1
- 0
CMakeLists.txt View File

@ -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

+ 418
- 0
src/animation/ease.hpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
/*
* 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 <vmq/vmq.hpp>
#include <cmath>
#include <type_traits>
/**
* 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 <typename T, typename S = float>
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 <typename T, typename S>
inline T ease<T, S>::linear(const T& x, const T& y, S a)
{
return (y - x) * a + x;
}
template <typename T, typename S>
inline T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::in_sine(const T& x, const T& y, S a)
{
return linear(y, x, std::cos(a * vmq::half_pi<S>));
}
template <typename T, typename S>
T ease<T, S>::out_sine(const T& x, const T& y, S a)
{
return linear(x, y, std::sin(a * vmq::half_pi<S>));
}
template <typename T, typename S>
T ease<T, S>::in_out_sine(const T& x, const T& y, S a)
{
return linear(x, y, -(std::cos(a * vmq::pi<S>) - S(1)) * S(0.5));
}
template <typename T, typename S>
T ease<T, S>::in_quad(const T& x, const T& y, S a)
{
return linear(x, y, a * a);
}
template <typename T, typename S>
T ease<T, S>::out_quad(const T& x, const T& y, S a)
{
return linear(x, y, (S(2) - a) * a);
}
template <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::in_cubic(const T& x, const T& y, S a)
{
return linear(x, y, a * a * a);
}
template <typename T, typename S>
T ease<T, S>::out_cubic(const T& x, const T& y, S a)
{
return linear(x, y, a * ((a - S(3)) * a + S(3)));
}
template <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::in_quart(const T& x, const T& y, S a)
{
return linear(x, y, a * a * a * a);
}
template <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::in_quint(const T& x, const T& y, S a)
{
return linear(x, y, a * a * a * a * a);
}
template <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::in_circ(const T& x, const T& y, S a)
{
return linear(y, x, std::sqrt(S(1) - a * a));
}
template <typename T, typename S>
T ease<T, S>::out_circ(const T& x, const T& y, S a)
{
return linear(x, y, std::sqrt(-(a - S(2)) * a));
}
template <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::in_bounce(const T& x, const T& y, S a)
{
return linear(x, y, S(1) - ease<S, S>::out_bounce(S(0), S(1), S(1) - a));
}
template <typename T, typename S>
T ease<T, S>::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 <typename T, typename S>
T ease<T, S>::in_out_bounce(const T& x, const T& y, S a)
{
if (a < S(0.5))
{
return linear(x, y, (S(1) - ease<S, S>::out_bounce(S(0), S(1), S(1) - S(2) * a)) * S(0.5));
}
else
{
return linear(x, y, (S(1) + ease<S, S>::out_bounce(S(0), S(1), S(2) * a - S(1))) * S(0.5));
}
}
#endif // ANTKEEPER_EASE_HPP

+ 0
- 284
src/animation/easings.hpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
/*
* 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 <vmq/vmq.hpp>
#include <cmath>
template <typename T, typename S>
inline T ease_linear(const T& x, const T& y, S a)
{
return (y - x) * a + x;
}
template <typename T, typename S>
T ease_in_sine(const T& x, const T& y, S a)
{
return -(y - x) * std::cos(a * vmq::half_pi<S>) + (y - x) + x;
}
template <typename T, typename S>
T ease_out_sine(const T& x, const T& y, S a)
{
return (y - x) * std::sin(a * vmq::half_pi<S>) + x;
}
template <typename T, typename S>
T ease_in_out_sine(const T& x, const T& y, S a)
{
return -(y - x) * S(0.5) * (std::cos(vmq::pi<S> * a) - S(1.0)) + x;
}
template <typename T, typename S>
T ease_in_quad(const T& x, const T& y, S a)
{
return (y - x) * a * a + x;
}
template <typename T, typename S>
T ease_out_quad(const T& x, const T& y, S a)
{
return -(y - x) * a * (a - S(2.0)) + x;
}
template <typename T, typename S>
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 <typename T, typename S>
T ease_in_cubic(const T& x, const T& y, S a)
{
return (y - x) * a * a * a + x;
}
template <typename T, typename S>
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 <typename T, typename S>
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 <typename T, typename S>
T ease_in_quart(const T& x, const T& y, S a)
{
return (y - x) * a * a * a * a + x;
}
template <typename T, typename S>
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 <typename T, typename S>
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 <typename T, typename S>
T ease_in_quint(const T& x, const T& y, S a)
{
return (y - x) * a * a * a * a * a + x;
}
template <typename T, typename S>
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 <typename T, typename S>
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 <typename T, typename S>
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 <typename T, typename S>
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 <typename T, typename S>
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 <typename T, typename S>
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 <typename T, typename S>
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 <typename T, typename S>
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 <typename T, typename S>
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 <typename T, typename S>
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 <typename T, typename S>
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

src/frame-scheduler.cpp → src/animation/frame-scheduler.cpp View File


src/frame-scheduler.hpp → src/animation/frame-scheduler.hpp View File


+ 9
- 7
src/application.cpp View File

@ -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 <cstdlib>
@ -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<float, double>);
this->radial_transition_inner->transition(0.5f, false, ease<float, double>::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<float, double>);
this->fade_transition->transition(0.25f, true, ease<float, double>::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<float, double>);
this->fade_transition->transition(0.25f, false, ease<float, double>::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<float, double>);
this->radial_transition_inner->transition(0.5f, true, ease<float, double>::out_quad);
};
float t = timeline.get_position();

+ 1
- 1
src/application.hpp View File

@ -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"

+ 1
- 1
src/debug/logger.cpp View File

@ -18,7 +18,7 @@
*/
#include "logger.hpp"
#include "timestamp.hpp"
#include "utility/timestamp.hpp"
#include <iostream>
logger::logger():

+ 4
- 0
src/entity/components/chamber-component.hpp View File

@ -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<std::array<int, 2>> tiles;
}

+ 8
- 2
src/entity/components/nest-component.hpp View File

@ -20,14 +20,20 @@
#ifndef ANTKEEPER_ECS_NEST_COMPONENT_HPP
#define ANTKEEPER_ECS_NEST_COMPONENT_HPP
#include <vector>
#include <entt/entt.hpp>
namespace ecs {
struct nest_component
{
int bla;
std::vector<entt::entity> chambers;
float helix_radius;
float helix_pitch;
float helix_chirality;
float helix_turns;
};
} // namespace ecs
#endif // ANTKEEPER_ECS_NEST_COMPONENT_HPP

src/marching-cubes.cpp → src/geometry/marching-cubes.cpp View File


src/marching-cubes.hpp → src/geometry/marching-cubes.hpp View File


src/morton.cpp → src/geometry/morton.cpp View File


src/morton.hpp → src/geometry/morton.hpp View File


src/octree.hpp → src/geometry/octree.hpp View File


src/sdf.hpp → src/geometry/sdf.hpp View File


+ 6
- 16
src/nest.cpp View File

@ -18,18 +18,8 @@
*/
#include "nest.hpp"
#include "animation/easings.hpp"
#include "marching-cubes.hpp"
#include "geometry/mesh-functions.hpp"
#include "sdf.hpp"
#include <functional>
#include <iostream>
#include <map>
#include <vector>
#include "animation/ease.hpp"
#include "math.hpp"
#include <functional>
#include <limits>
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<float>::linear(shaft.pitch[0], shaft.pitch[1], depth_factor);
return shaft.rotation + (depth / pitch) * shaft.chirality * vmq::two_pi<float>;
}
@ -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<float>::linear(shaft.pitch[0], shaft.pitch[1], depth_factor);
float radius = ease<float>::out_expo(shaft.radius[0], shaft.radius[1], depth_factor);
float translation_x = ease<float>::linear(shaft.translation[0][0], shaft.translation[1][0], depth_factor);
float translation_z = ease<float>::linear(shaft.translation[0][1], shaft.translation[1][1], depth_factor);
float angle = shaft.rotation + (depth / pitch) * shaft.chirality * vmq::two_pi<float>;
float3 position;

+ 2
- 2
src/state/play-state.cpp View File

@ -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 <iostream>
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<float, double>);
app->get_fade_transition()->transition(1.0f, true, ease<float>::in_quad);
logger->pop_task(EXIT_SUCCESS);
}

+ 3
- 3
src/state/splash-state.cpp View File

@ -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<float, double>);
app->get_fade_transition()->transition(splash_fade_in_duration, true, ease<float>::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<float, double>);
app->get_fade_transition()->transition(splash_fade_out_duration, false, ease<float>::out_quad);
};
// Create change state function

+ 7
- 21
src/systems/control-system.cpp View File

@ -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 <vmq/vmq.hpp>
using namespace vmq::operators;
template <class T>
static inline T lerp(const T& x, const T& y, float a)
{
return x * (1.0f - a) + y * a;
}
template <class T>
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<float>(0.0f, std::min<float>(1.0f, zoom));
float focal_distance = log_lerp(near_focal_distance, far_focal_distance, 1.0f - zoom);
float focal_distance = ease<float>::log(near_focal_distance, far_focal_distance, 1.0f - zoom);
float fov = log_lerp(near_fov, far_fov, 1.0f - zoom);
float fov = ease<float>::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<float>::log(near_fov, far_fov, elevation_factor);
float clip_near = ease<float>::log(near_clip_near, far_clip_near, 1.0f - zoom);
float clip_far = ease<float>::log(near_clip_far, far_clip_far, 1.0f - zoom);
float movement_speed = ease<float>::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);

+ 1
- 1
src/systems/subterrain-system.cpp View File

@ -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"

src/filesystem.cpp → src/utility/paths.cpp View File

@ -17,7 +17,7 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "filesystem.hpp"
#include "paths.hpp"
#include <cstdlib>
#include <limits.h>
#include <stdexcept>

src/filesystem.hpp → src/utility/paths.hpp View File

@ -17,8 +17,8 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_FILESYSTEM_HPP
#define ANTKEEPER_FILESYSTEM_HPP
#ifndef ANTKEEPER_PATHS_HPP
#define ANTKEEPER_PATHS_HPP
#include <string>
@ -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

src/timestamp.cpp → src/utility/timestamp.cpp View File


src/timestamp.hpp → src/utility/timestamp.hpp View File


Loading…
Cancel
Save