diff --git a/build/pomdog/CMakeLists.txt b/build/pomdog/CMakeLists.txt index a43785f49..3b985f925 100644 --- a/build/pomdog/CMakeLists.txt +++ b/build/pomdog/CMakeLists.txt @@ -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/*) @@ -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 @@ -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 diff --git a/build/pomdog_experimental/CMakeLists.txt b/build/pomdog_experimental/CMakeLists.txt index e3fa49fc2..368396e17 100644 --- a/build/pomdog_experimental/CMakeLists.txt +++ b/build/pomdog_experimental/CMakeLists.txt @@ -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/*) @@ -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 diff --git a/experimental/Pomdog.Experimental/Experimental.hpp b/experimental/Pomdog.Experimental/Experimental.hpp index 10f38a004..98fef50fd 100644 --- a/experimental/Pomdog.Experimental/Experimental.hpp +++ b/experimental/Pomdog.Experimental/Experimental.hpp @@ -91,8 +91,6 @@ #include "Spine/SkinnedMeshLoader.hpp" #include "Spine/SpriteAnimationLoader.hpp" -#include "Tween/EasingHelper.hpp" - #include "Rendering/RenderCommand.hpp" #include "Rendering/Renderer.hpp" diff --git a/experimental/Pomdog.Experimental/Tween/EasingHelper.hpp b/include/Pomdog/Experimental/Tween/EasingHelper.hpp similarity index 81% rename from experimental/Pomdog.Experimental/Tween/EasingHelper.hpp rename to include/Pomdog/Experimental/Tween/EasingHelper.hpp index b0de5e980..d9e213665 100644 --- a/experimental/Pomdog.Experimental/Tween/EasingHelper.hpp +++ b/include/Pomdog/Experimental/Tween/EasingHelper.hpp @@ -2,18 +2,20 @@ #pragma once +#include "Pomdog/Basic/Export.hpp" #include "Pomdog/Math/MathHelper.hpp" #include "Pomdog/Utility/Assert.hpp" -#include #include +#include namespace Pomdog { namespace Detail { namespace Easings { -template -class Ease { +template +class POMDOG_EXPORT Ease final { public: + static_assert(Function != nullptr); static_assert(std::is_floating_point::value, "You can only use floating-point types"); @@ -37,34 +39,34 @@ class Ease { }; template -T Quadratic(T time); +T POMDOG_EXPORT Quadratic(T time) noexcept; template -T Cubic(T time); +T POMDOG_EXPORT Cubic(T time) noexcept; template -T Quartic(T time); +T POMDOG_EXPORT Quartic(T time) noexcept; template -T Quintic(T time); +T POMDOG_EXPORT Quintic(T time) noexcept; template -T Sine(T time); +T POMDOG_EXPORT Sine(T time) noexcept; template -T Exponential(T time); +T POMDOG_EXPORT Exponential(T time) noexcept; template -T Circle(T time); +T POMDOG_EXPORT Circle(T time) noexcept; template -T Elastic(T time); +T POMDOG_EXPORT Elastic(T time) noexcept; template -T Bounce(T time); +T POMDOG_EXPORT Bounce(T time) noexcept; template -T Back(T time); +T POMDOG_EXPORT Back(T time) noexcept; template using EaseBack = Ease>; diff --git a/experimental/Pomdog.Experimental/Tween/EasingHelper.cpp b/src/Experimental/Tween/EasingHelper.cpp similarity index 68% rename from experimental/Pomdog.Experimental/Tween/EasingHelper.cpp rename to src/Experimental/Tween/EasingHelper.cpp index a4b3b7d84..440743a1c 100644 --- a/experimental/Pomdog.Experimental/Tween/EasingHelper.cpp +++ b/src/Experimental/Tween/EasingHelper.cpp @@ -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 -T Quadratic(T time) +T Quadratic(T time) noexcept { static_assert(std::is_floating_point::value, "You can only use floating-point types"); @@ -17,7 +17,7 @@ T Quadratic(T time) } template -T Cubic(T time) +T Cubic(T time) noexcept { static_assert(std::is_floating_point::value, "You can only use floating-point types"); @@ -27,7 +27,7 @@ T Cubic(T time) } template -T Quartic(T time) +T Quartic(T time) noexcept { static_assert(std::is_floating_point::value, "You can only use floating-point types"); @@ -37,7 +37,7 @@ T Quartic(T time) } template -T Quintic(T time) +T Quintic(T time) noexcept { static_assert(std::is_floating_point::value, "You can only use floating-point types"); @@ -47,7 +47,7 @@ T Quintic(T time) } template -T Sine(T time) +T Sine(T time) noexcept { static_assert(std::is_floating_point::value, "You can only use floating-point types"); @@ -57,7 +57,7 @@ T Sine(T time) } template -T Exponential(T time) +T Exponential(T time) noexcept { static_assert(std::is_floating_point::value, "You can only use floating-point types"); @@ -67,7 +67,7 @@ T Exponential(T time) } template -T Circle(T time) +T Circle(T time) noexcept { static_assert(std::is_floating_point::value, "You can only use floating-point types"); @@ -77,7 +77,7 @@ T Circle(T time) } template -T Elastic(T time) +T Elastic(T time) noexcept { static_assert(std::is_floating_point::value, "You can only use floating-point types"); @@ -86,12 +86,13 @@ 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 / period)); + return (time <= 0 || time >= 1) + ? time + : -(postFix * std::sin(((time - 1) - s) * Math::TwoPi / period)); } template -T Bounce(T time) +T Bounce(T time) noexcept { static_assert(std::is_floating_point::value, "You can only use floating-point types"); @@ -99,24 +100,24 @@ T Bounce(T time) // 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 -T Back(T time) +T Back(T time) noexcept { static_assert(std::is_floating_point::value, "You can only use floating-point types"); @@ -127,16 +128,16 @@ T Back(T time) } // NOTE: explicit instantiations -template float Quadratic(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 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