twn_util: separate internal c-only features from public header
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
#include "twn_rendering_c.h"
|
||||
#include "twn_engine_context_c.h"
|
||||
#include "twn_util.h"
|
||||
#include "twn_util_c.h"
|
||||
#include "twn_textures_c.h"
|
||||
|
||||
#include <stb_ds.h>
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "twn_textures_c.h"
|
||||
#include "twn_config.h"
|
||||
#include "twn_util.h"
|
||||
#include "twn_util_c.h"
|
||||
#include "twn_engine_context_c.h"
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
@ -1,7 +1,37 @@
|
||||
#ifndef TWN_UTIL_C_H
|
||||
#define TWN_UTIL_C_H
|
||||
|
||||
#include "twn_types.h"
|
||||
|
||||
/* note: you must free the returned string */
|
||||
char *expand_asterisk(const char *mask, const char *to);
|
||||
|
||||
/* http://www.azillionmonkeys.com/qed/sqroot.html */
|
||||
static inline float fast_sqrt(float x)
|
||||
{
|
||||
union {
|
||||
float f;
|
||||
uint32_t u;
|
||||
} pun = {.f = x};
|
||||
|
||||
pun.u += 127 << 23;
|
||||
pun.u >>= 1;
|
||||
|
||||
return pun.f;
|
||||
}
|
||||
|
||||
|
||||
static inline Vec2 fast_cossine(float a) {
|
||||
const float s = sinf(a);
|
||||
return (Vec2){
|
||||
.x = fast_sqrt(1.0f - s * s) * (a >= (float)M_PI_2 && a < (float)(M_PI + M_PI_2) ? -1 : 1),
|
||||
.y = s
|
||||
};
|
||||
}
|
||||
|
||||
static inline bool is_power_of_two(int x)
|
||||
{
|
||||
return (x != 0) && ((x & (x - 1)) == 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user