Add simple animation controller.

This commit is contained in:
Bartosz Taudul 2018-08-17 22:23:04 +02:00
parent 12f2080387
commit 841f18885e
3 changed files with 52 additions and 0 deletions

View File

@ -133,6 +133,7 @@
<ClInclude Include="..\..\..\nfd\nfd.h" /> <ClInclude Include="..\..\..\nfd\nfd.h" />
<ClInclude Include="..\..\..\nfd\nfd_common.h" /> <ClInclude Include="..\..\..\nfd\nfd_common.h" />
<ClInclude Include="..\..\..\server\TracyBadVersion.hpp" /> <ClInclude Include="..\..\..\server\TracyBadVersion.hpp" />
<ClInclude Include="..\..\..\server\TracyBuzzAnim.hpp" />
<ClInclude Include="..\..\..\server\TracyCharUtil.hpp" /> <ClInclude Include="..\..\..\server\TracyCharUtil.hpp" />
<ClInclude Include="..\..\..\server\TracyDecayValue.hpp" /> <ClInclude Include="..\..\..\server\TracyDecayValue.hpp" />
<ClInclude Include="..\..\..\server\TracyEvent.hpp" /> <ClInclude Include="..\..\..\server\TracyEvent.hpp" />

View File

@ -218,6 +218,9 @@
<ClInclude Include="..\..\src\imgui_freetype.h"> <ClInclude Include="..\..\src\imgui_freetype.h">
<Filter>src</Filter> <Filter>src</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\server\TracyBuzzAnim.hpp">
<Filter>server</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Natvis Include="DebugVis.natvis" /> <Natvis Include="DebugVis.natvis" />

48
server/TracyBuzzAnim.hpp Normal file
View File

@ -0,0 +1,48 @@
#ifndef __TRACYBUZZANIM_HPP__
#define __TRACYBUZZANIM_HPP__
#include <assert.h>
namespace tracy
{
template<typename T>
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