#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "STRINGS.h" typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef int8_t s8; typedef int16_t s16; typedef int32_t s32; typedef int64_t s64; typedef float f32; typedef double f64; #define PI (GLM_PI) #define TAU (PI * 2) using namespace glm; // fuck you #define MIN(x, min) (x < min ? min : x) #define MAX(x, max) (x > max ? max : x) #define CLAMP(x, min, max) (MIN(MAX(x, max), min)) static inline const char* enum_to_string(const char* arr[], s32 count, s32 index) { return (index >= 0 && index < count) ? arr[index] : "undefined"; } static inline s32 string_to_enum(const char* str, const char* const* arr, s32 n) { for (s32 i=0; i static inline s32 map_next_id_get(const std::map& map) { s32 id = 0; for (const auto& [key, _] : map) if (key != id) break; else ++id; return id; } template static inline void map_swap(Map& map, const Key& key1, const Key& key2) { auto it1 = map.find(key1); auto it2 = map.find(key2); if (it1 == map.end() || it2 == map.end()) return; using std::swap; swap(it1->second, it2->second); } #define DEFINE_ENUM_TO_STRING_FN(fn_name, arr, count) \ static inline const char* fn_name(s32 index) { \ return enum_to_string(arr, count, index); \ } #define DEFINE_STRING_TO_ENUM_FN(fn_name, enum_type, str_array, count) \ static inline enum_type fn_name(const char* str) { \ return (enum_type)string_to_enum(str, str_array, count); \ }