From 841f18885e029191dc16bbb5e42831c71f345f30 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 17 Aug 2018 22:23:04 +0200 Subject: [PATCH] Add simple animation controller. --- profiler/build/win32/Tracy.vcxproj | 1 + profiler/build/win32/Tracy.vcxproj.filters | 3 ++ server/TracyBuzzAnim.hpp | 48 ++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 server/TracyBuzzAnim.hpp diff --git a/profiler/build/win32/Tracy.vcxproj b/profiler/build/win32/Tracy.vcxproj index fcd0117e..59a8ee14 100644 --- a/profiler/build/win32/Tracy.vcxproj +++ b/profiler/build/win32/Tracy.vcxproj @@ -133,6 +133,7 @@ + diff --git a/profiler/build/win32/Tracy.vcxproj.filters b/profiler/build/win32/Tracy.vcxproj.filters index a7aee634..ea38f165 100644 --- a/profiler/build/win32/Tracy.vcxproj.filters +++ b/profiler/build/win32/Tracy.vcxproj.filters @@ -218,6 +218,9 @@ src + + server + diff --git a/server/TracyBuzzAnim.hpp b/server/TracyBuzzAnim.hpp new file mode 100644 index 00000000..fa3151d3 --- /dev/null +++ b/server/TracyBuzzAnim.hpp @@ -0,0 +1,48 @@ +#ifndef __TRACYBUZZANIM_HPP__ +#define __TRACYBUZZANIM_HPP__ + +#include + +namespace tracy +{ + +template +class BuzzAnim +{ +public: + bool Match( const T& comp ) const + { + return active && comp == id; + } + + float Time() const + { + assert( active ); + return time; + } + + void Enable( const T& val, float len ) + { + active = true; + time = len; + id = val; + } + + void Update( float dt ) + { + if( active ) + { + time -= dt; + if( time <= 0 ) active = false; + } + } + +private: + bool active = false; + float time; + T id; +}; + +} + +#endif