typedef & PascalCase for ALL structs and enums

This commit is contained in:
2024-09-23 14:43:16 -03:00
parent e093a6d492
commit 73bf92e706
43 changed files with 795 additions and 793 deletions

View File

@ -80,54 +80,54 @@ TWN_API TWN_API bool strends(const char *str, const char *suffix);
/* */
/* 32-bit color data */
typedef struct color {
typedef struct Color {
_Alignas(4)
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
} t_color;
} Color;
/* a rectangle with the origin at the upper left (integer) */
typedef struct rect {
typedef struct Recti {
_Alignas(16)
int32_t x;
int32_t y;
int32_t w;
int32_t h;
} t_rect;
} Recti;
/* a rectangle with the origin at the upper left (floating point) */
typedef struct frect {
typedef struct Rect {
_Alignas(16)
float x;
float y;
float w;
float h;
} t_frect;
} Rect;
/* calculates the overlap of two rectangles and places it in result. */
/* result may be NULL. if this is the case, it will simply be ignored. */
/* returns true if the rectangles are indeed intersecting. */
TWN_API bool overlap_rect(const t_rect *a, const t_rect *b, t_rect *result);
TWN_API bool overlap_frect(const t_frect *a, const t_frect *b, t_frect *result);
TWN_API bool overlap_rect(const Recti *a, const Recti *b, Recti *result);
TWN_API bool overlap_frect(const Rect *a, const Rect *b, Rect *result);
/* returns true if two rectangles are intersecting */
TWN_API bool intersect_rect(const t_rect *a, const t_rect *b);
TWN_API bool intersect_frect(const t_frect *a, const t_frect *b);
TWN_API bool intersect_rect(const Recti *a, const Recti *b);
TWN_API bool intersect_frect(const Rect *a, const Rect *b);
/* TODO: generics and specials (see m_to_fvec2() for an example)*/
TWN_API t_frect to_frect(t_rect rect);
/* TODO: generics and specials (see m_vec2_from() for an example)*/
TWN_API Rect to_frect(Recti rect);
TWN_API t_fvec2 frect_center(t_frect rect);
TWN_API Vec2 frect_center(Rect rect);
typedef struct matrix4 {
t_fvec4 row[4];
} t_matrix4;
typedef struct Matrix4 {
Vec4 row[4];
} Matrix4;
/* decrements an lvalue (which should be an int), stopping at 0 */
@ -162,9 +162,9 @@ static inline float fast_sqrt(float x)
}
static inline t_fvec2 fast_cossine(float a) {
static inline Vec2 fast_cossine(float a) {
const float s = sinf(a);
return (t_fvec2){
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
};