diff options
| author | KonAki <konaki@anokonaki.org> | 2026-10-13 10:28:17 +0800 |
|---|---|---|
| committer | KonAki <konaki@anokonaki.org> | 2026-10-13 10:28:17 +0800 |
| commit | d3432fcc288a53dff9eb219c8857ca48c5981323 (patch) | |
| tree | fba5cc730c91d2c674efe6d71dd20e9d6bf7d0d8 /kon/koncollide.h | |
| parent | a2dc5ca4c659e2d0a9527cd0910bc76b65e6d09f (diff) | |
headers: extern C guards and C++ safe vector and rect constructors
Diffstat (limited to 'kon/koncollide.h')
| -rw-r--r-- | kon/koncollide.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/kon/koncollide.h b/kon/koncollide.h index d312533..2edcff5 100644 --- a/kon/koncollide.h +++ b/kon/koncollide.h @@ -30,6 +30,10 @@ #include "konmath.h" +#ifdef __cplusplus +extern "C" { +#endif + /*** definition ***/ /* 2d shapes. x, y is the top left corner of a box and the centre of a circle. nothing here cares which way y points, @@ -37,8 +41,15 @@ typedef struct kon_box2 { float x, y, w, h; } kon_box2_t; typedef struct kon_circle2 { float x, y, r; } kon_circle2_t; +#ifdef __cplusplus +static inline kon_box2_t kon_makeBox2_(float x, float y, float w, float h) { kon_box2_t b; b.x = x; b.y = y; b.w = w; b.h = h; return b; } +static inline kon_circle2_t kon_makeCircle2_(float x, float y, float r) { kon_circle2_t c; c.x = x; c.y = y; c.r = r; return c; } +#define KON_BOX2(x, y, w, h) kon_makeBox2_((float)(x), (float)(y), (float)(w), (float)(h)) +#define KON_CIRCLE2(x, y, r) kon_makeCircle2_((float)(x), (float)(y), (float)(r)) +#else #define KON_BOX2(x, y, w, h) ((kon_box2_t){(float)(x), (float)(y), (float)(w), (float)(h)}) #define KON_CIRCLE2(x, y, r) ((kon_circle2_t){(float)(x), (float)(y), (float)(r)}) +#endif /* what a ray or a sweep found. time is how far along it was (0 to 1 for a sweep, a distance for a ray when dir is a unit vector), normal points back out of the thing that was hit, point is where it happened */ @@ -262,4 +273,8 @@ static inline int kon_rayCircle(kon_vec2_t origin, kon_vec2_t dir, float maxTime return 1; } + +#ifdef __cplusplus +} +#endif #endif /* KONCOLLIDE_H */ |
