vn/code/vn_animation_curve.h

67 lines
1.6 KiB
C
Raw Normal View History

2023-06-17 17:00:55 +00:00
/* date = May 7th 2023 0:37 pm */
#ifndef VN_ANIMATION_CURVE_H
#define VN_ANIMATION_CURVE_H
2023-08-22 03:19:51 +00:00
////////////////////////////////
//~ sixten: Animation Curve Types
2023-06-17 17:00:55 +00:00
struct animation_curve_key
{
u64 Value;
};
struct animation_curve_entry
{
animation_curve_key Key;
u32 LastFrameTouched;
r32 Value;
animation_curve_entry *Next;
animation_curve_entry *Prev;
};
struct animation_curve_bucket
{
animation_curve_entry *First;
animation_curve_entry *Last;
};
struct animation_curve_state
{
arena *Arena;
2023-06-17 17:00:55 +00:00
u32 CurrentFrame;
r32 dtForFrame;
// sixten: Hash map
animation_curve_bucket Buckets[256];
// sixten: Free list
animation_curve_entry *FirstFreeEntry;
animation_curve_entry *LastFreeEntry;
};
2023-08-22 03:19:51 +00:00
////////////////////////////////
//~ sixten: Animation Curve Functions
inline b32 AreEqual(animation_curve_key A, animation_curve_key B)
{
b32 Result = (A.Value == B.Value);
return(Result);
}
static void AC_SetState(animation_curve_state *State);
static animation_curve_key AC_GenerateKeyFromString(string String);
static void AC_Init(animation_curve_state *State);
static animation_curve_entry *AC_GetEntryByKey(animation_curve_key Key, r32 Initial = 0);
static r32 AC_GetValue(string Name, r32 Initial);
static void AC_SetValue(string Name, r32 Value);
static r32 AC_AnimateValueDirect(r32 Target, r32 Duration, r32 *Value);
static r32 AC_AnimateValue(r32 Target, r32 Initial, r32 Duration, string Name);
static r32 AC_AnimateValueF(r32 Target, r32 Initial, r32 Duration, char *Format, ...);
static void AC_NewFrame(animation_curve_state *State, r32 dtForFrame);
2023-06-19 17:12:26 +00:00
2023-06-17 17:00:55 +00:00
#endif //VN_ANIMATION_CURVE_H