Skip to content

Commit

Permalink
Move Tween library into a new experimental directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mogemimi committed Aug 25, 2018
1 parent fcef973 commit f68e14f
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 48 deletions.
3 changes: 3 additions & 0 deletions build/pomdog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ source_group(Experimental\\Graphics REGULAR_EXPRESSION "(include/Pomdog|sr
source_group(Experimental\\Image REGULAR_EXPRESSION "(include/Pomdog|src)/Experimental/Image/*")
source_group(Experimental\\MagicaVoxel REGULAR_EXPRESSION "(include/Pomdog|src)/Experimental/MagicaVoxel/*")
source_group(Experimental\\TexturePacker REGULAR_EXPRESSION "(include/Pomdog|src)/Experimental/TexturePacker/*")
source_group(Experimental\\Tween REGULAR_EXPRESSION "(include/Pomdog|src)/Experimental/Tween/*")
source_group(InputSystem REGULAR_EXPRESSION src/InputSystem/*)
source_group(InputSystem.DirectInput REGULAR_EXPRESSION src/InputSystem.DirectInput/*)
source_group(InputSystem.IOKit REGULAR_EXPRESSION src/InputSystem.IOKit/*)
Expand Down Expand Up @@ -368,6 +369,7 @@ set(POMDOG_SOURCES_EXPERIMENTAL
${POMDOG_DIR}/include/Pomdog/Experimental/TexturePacker/TextureAtlasGenerator.hpp
${POMDOG_DIR}/include/Pomdog/Experimental/TexturePacker/TextureAtlasLoader.hpp
${POMDOG_DIR}/include/Pomdog/Experimental/TexturePacker/TextureRegion.hpp
${POMDOG_DIR}/include/Pomdog/Experimental/Tween/EasingHelper.hpp
${POMDOG_DIR}/src/Experimental/Graphics/LineBatch.cpp
${POMDOG_DIR}/src/Experimental/Graphics/PolygonBatch.cpp
${POMDOG_DIR}/src/Experimental/Graphics/PolygonShapeBuilder.cpp
Expand All @@ -383,6 +385,7 @@ set(POMDOG_SOURCES_EXPERIMENTAL
${POMDOG_DIR}/src/Experimental/MagicaVoxel/VoxModelExporter.cpp
${POMDOG_DIR}/src/Experimental/TexturePacker/TextureAtlasGenerator.cpp
${POMDOG_DIR}/src/Experimental/TexturePacker/TextureAtlasLoader.cpp
${POMDOG_DIR}/src/Experimental/Tween/EasingHelper.cpp
)

set(POMDOG_SOURCES_GL4
Expand Down
4 changes: 0 additions & 4 deletions build/pomdog_experimental/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ source_group(Particle2D\\detail REGULAR_EXPRESSION Pomdog.Experimental/Par
source_group(Skeletal2D REGULAR_EXPRESSION Pomdog.Experimental/Skeletal2D/*)
source_group(Skeletal2D\\detail REGULAR_EXPRESSION Pomdog.Experimental/Skeletal2D/detail/*)
source_group(Spine REGULAR_EXPRESSION Pomdog.Experimental/Spine/*)
source_group(Tween REGULAR_EXPRESSION Pomdog.Experimental/Tween/*)
source_group(Rendering REGULAR_EXPRESSION Pomdog.Experimental/Rendering/*)
source_group(Rendering\\Commands REGULAR_EXPRESSION Pomdog.Experimental/Rendering/Commands/*)
source_group(Rendering\\Processors REGULAR_EXPRESSION Pomdog.Experimental/Rendering/Processors/*)
Expand Down Expand Up @@ -219,9 +218,6 @@ add_library(pomdog_experimental STATIC
${POMDOG_EXPERIMENTAL_DIR}/Spine/SpriteAnimationLoader.cpp
${POMDOG_EXPERIMENTAL_DIR}/Spine/SpriteAnimationLoader.hpp

${POMDOG_EXPERIMENTAL_DIR}/Tween/EasingHelper.cpp
${POMDOG_EXPERIMENTAL_DIR}/Tween/EasingHelper.hpp

${POMDOG_EXPERIMENTAL_DIR}/Rendering/RenderCommand.hpp
${POMDOG_EXPERIMENTAL_DIR}/Rendering/RenderCommandProcessor.hpp
${POMDOG_EXPERIMENTAL_DIR}/Rendering/Renderer.cpp
Expand Down
2 changes: 0 additions & 2 deletions experimental/Pomdog.Experimental/Experimental.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@
#include "Spine/SkinnedMeshLoader.hpp"
#include "Spine/SpriteAnimationLoader.hpp"

#include "Tween/EasingHelper.hpp"

#include "Rendering/RenderCommand.hpp"
#include "Rendering/Renderer.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

#pragma once

#include "Pomdog/Basic/Export.hpp"
#include "Pomdog/Math/MathHelper.hpp"
#include "Pomdog/Utility/Assert.hpp"
#include <type_traits>
#include <cmath>
#include <type_traits>

namespace Pomdog {
namespace Detail {
namespace Easings {

template <typename T, T(*Function)(T)>
class Ease {
template <typename T, T (*Function)(T)>
class POMDOG_EXPORT Ease final {
public:
static_assert(Function != nullptr);
static_assert(std::is_floating_point<T>::value,
"You can only use floating-point types");

Expand All @@ -37,34 +39,34 @@ class Ease {
};

template <typename T>
T Quadratic(T time);
T POMDOG_EXPORT Quadratic(T time) noexcept;

template <typename T>
T Cubic(T time);
T POMDOG_EXPORT Cubic(T time) noexcept;

template <typename T>
T Quartic(T time);
T POMDOG_EXPORT Quartic(T time) noexcept;

template <typename T>
T Quintic(T time);
T POMDOG_EXPORT Quintic(T time) noexcept;

template <typename T>
T Sine(T time);
T POMDOG_EXPORT Sine(T time) noexcept;

template <typename T>
T Exponential(T time);
T POMDOG_EXPORT Exponential(T time) noexcept;

template <typename T>
T Circle(T time);
T POMDOG_EXPORT Circle(T time) noexcept;

template <typename T>
T Elastic(T time);
T POMDOG_EXPORT Elastic(T time) noexcept;

template <typename T>
T Bounce(T time);
T POMDOG_EXPORT Bounce(T time) noexcept;

template <typename T>
T Back(T time);
T POMDOG_EXPORT Back(T time) noexcept;

template <typename T>
using EaseBack = Ease<T, Back<T>>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) 2013-2018 mogemimi. Distributed under the MIT license.

#include "Pomdog.Experimental/Tween/EasingHelper.hpp"
#include "Pomdog/Experimental/Tween/EasingHelper.hpp"

namespace Pomdog {
namespace Detail {
namespace Easings {

template <typename T>
T Quadratic(T time)
T Quadratic(T time) noexcept
{
static_assert(std::is_floating_point<T>::value,
"You can only use floating-point types");
Expand All @@ -17,7 +17,7 @@ T Quadratic(T time)
}

template <typename T>
T Cubic(T time)
T Cubic(T time) noexcept
{
static_assert(std::is_floating_point<T>::value,
"You can only use floating-point types");
Expand All @@ -27,7 +27,7 @@ T Cubic(T time)
}

template <typename T>
T Quartic(T time)
T Quartic(T time) noexcept
{
static_assert(std::is_floating_point<T>::value,
"You can only use floating-point types");
Expand All @@ -37,7 +37,7 @@ T Quartic(T time)
}

template <typename T>
T Quintic(T time)
T Quintic(T time) noexcept
{
static_assert(std::is_floating_point<T>::value,
"You can only use floating-point types");
Expand All @@ -47,7 +47,7 @@ T Quintic(T time)
}

template <typename T>
T Sine(T time)
T Sine(T time) noexcept
{
static_assert(std::is_floating_point<T>::value,
"You can only use floating-point types");
Expand All @@ -57,7 +57,7 @@ T Sine(T time)
}

template <typename T>
T Exponential(T time)
T Exponential(T time) noexcept
{
static_assert(std::is_floating_point<T>::value,
"You can only use floating-point types");
Expand All @@ -67,7 +67,7 @@ T Exponential(T time)
}

template <typename T>
T Circle(T time)
T Circle(T time) noexcept
{
static_assert(std::is_floating_point<T>::value,
"You can only use floating-point types");
Expand All @@ -77,7 +77,7 @@ T Circle(T time)
}

template <typename T>
T Elastic(T time)
T Elastic(T time) noexcept
{
static_assert(std::is_floating_point<T>::value,
"You can only use floating-point types");
Expand All @@ -86,37 +86,38 @@ T Elastic(T time)
constexpr auto period = T(0.3);
constexpr auto s = period / 4;
const auto postFix = std::pow(2, 10 * (time - 1));
return (time <= 0 || time >= 1) ? time
: - (postFix * std::sin(((time - 1) - s) * Math::TwoPi<T> / period));
return (time <= 0 || time >= 1)
? time
: -(postFix * std::sin(((time - 1) - s) * Math::TwoPi<T> / period));
}

template <typename T>
T Bounce(T time)
T Bounce(T time) noexcept
{
static_assert(std::is_floating_point<T>::value,
"You can only use floating-point types");

// Bounce easing
time = 1 - time;

if (time < 1/2.75) {
if (time < 1 / 2.75) {
return 1 - (7.5625 * time * time);
}
else if (time < 2/2.75) {
auto t = time - 1.5/2.75;
else if (time < 2 / 2.75) {
auto t = time - 1.5 / 2.75;
return 1 - (7.5625 * t * t + 0.75);
}
else if (time < 2.5/2.75) {
auto t = time - 2.25/2.75;
else if (time < 2.5 / 2.75) {
auto t = time - 2.25 / 2.75;
return 1 - (7.5625 * t * t + 0.9375);
}

auto postFix = time -= 2.625/2.75;
auto postFix = time -= 2.625 / 2.75;
return 1 - (7.5625 * postFix * time + 0.984375);
}

template <typename T>
T Back(T time)
T Back(T time) noexcept
{
static_assert(std::is_floating_point<T>::value,
"You can only use floating-point types");
Expand All @@ -127,16 +128,16 @@ T Back(T time)
}

// NOTE: explicit instantiations
template float Quadratic<float>(float time);
template float Cubic(float time);
template float Quartic(float time);
template float Quintic(float time);
template float Sine(float time);
template float Exponential(float time);
template float Circle(float time);
template float Elastic(float time);
template float Bounce(float time);
template float Back(float time);
template float Quadratic<float>(float time) noexcept;
template float Cubic(float time) noexcept;
template float Quartic(float time) noexcept;
template float Quintic(float time) noexcept;
template float Sine(float time) noexcept;
template float Exponential(float time) noexcept;
template float Circle(float time) noexcept;
template float Elastic(float time) noexcept;
template float Bounce(float time) noexcept;
template float Back(float time) noexcept;

} // namespace Easings
} // namespace Detail
Expand Down

0 comments on commit f68e14f

Please sign in to comment.