X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=libs%2Fcgmath%2Fcgmmisc.inl;h=2ef8a11b3ae9d010eb5a83c78dcfeb541951c6e0;hb=ff52b8546c5982313bb47b7bf8aed33fef21e77d;hp=fafaf4a4c5fe4de6c77de3fd340053e33b57494b;hpb=103b67f9f1e041dc5f6ffbb59004ebe846e3f3f9;p=deeprace diff --git a/libs/cgmath/cgmmisc.inl b/libs/cgmath/cgmmisc.inl index fafaf4a..2ef8a11 100644 --- a/libs/cgmath/cgmmisc.inl +++ b/libs/cgmath/cgmmisc.inl @@ -8,17 +8,17 @@ */ #include -static inline float cgm_deg_to_rad(float deg) +static CGM_INLINE float cgm_deg_to_rad(float deg) { return M_PI * deg / 180.0f; } -static inline float cgm_rad_to_deg(float rad) +static CGM_INLINE float cgm_rad_to_deg(float rad) { return 180.0f * rad / M_PI; } -static inline float cgm_smoothstep(float a, float b, float x) +static CGM_INLINE float cgm_smoothstep(float a, float b, float x) { if(x < a) return 0.0f; if(x >= b) return 1.0f; @@ -27,18 +27,18 @@ static inline float cgm_smoothstep(float a, float b, float x) return x * x * (3.0f - 2.0f * x); } -static inline float cgm_lerp(float a, float b, float t) +static CGM_INLINE float cgm_lerp(float a, float b, float t) { return a + (b - a) * t; } -static inline float cgm_logerp(float a, float b, float t) +static CGM_INLINE float cgm_logerp(float a, float b, float t) { if(a == 0.0f) return 0.0f; return a * pow(b / a, t); } -static inline float cgm_bezier(float a, float b, float c, float d, float t) +static CGM_INLINE float cgm_bezier(float a, float b, float c, float d, float t) { float omt, omt3, t3, f; t3 = t * t * t; @@ -49,7 +49,7 @@ static inline float cgm_bezier(float a, float b, float c, float d, float t) return (a * omt3) + (b * f * omt) + (c * f * t) + (d * t3); } -static inline float cgm_bspline(float a, float b, float c, float d, float t) +static CGM_INLINE float cgm_bspline(float a, float b, float c, float d, float t) { static const float mat[] = { -1, 3, -3, 1, @@ -67,7 +67,7 @@ static inline float cgm_bspline(float a, float b, float c, float d, float t) return cgm_wdot(&tmp, &qfact); } -static inline float cgm_spline(float a, float b, float c, float d, float t) +static CGM_INLINE float cgm_spline(float a, float b, float c, float d, float t) { static const float mat[] = { -1, 2, -1, 0, @@ -85,7 +85,7 @@ static inline float cgm_spline(float a, float b, float c, float d, float t) return cgm_wdot(&tmp, &qfact); } -static inline void cgm_discrand(cgm_vec3 *pt, float rad) +static CGM_INLINE void cgm_discrand(cgm_vec3 *pt, float rad) { float theta = 2.0f * M_PI * (float)rand() / RAND_MAX; float r = sqrt((float)rand() / RAND_MAX) * rad; @@ -94,7 +94,7 @@ static inline void cgm_discrand(cgm_vec3 *pt, float rad) pt->z = 0.0f; } -static inline void cgm_sphrand(cgm_vec3 *pt, float rad) +static CGM_INLINE void cgm_sphrand(cgm_vec3 *pt, float rad) { float u, v, theta, phi; @@ -109,7 +109,7 @@ static inline void cgm_sphrand(cgm_vec3 *pt, float rad) pt->z = cos(phi) * rad; } -static inline void cgm_unproject(cgm_vec3 *res, const cgm_vec3 *norm_scrpos, +static CGM_INLINE void cgm_unproject(cgm_vec3 *res, const cgm_vec3 *norm_scrpos, const float *inv_viewproj) { cgm_vec4 pos; @@ -126,7 +126,7 @@ static inline void cgm_unproject(cgm_vec3 *res, const cgm_vec3 *norm_scrpos, res->z = pos.z / pos.w; } -static inline void cgm_glu_unproject(float winx, float winy, float winz, +static CGM_INLINE void cgm_glu_unproject(float winx, float winy, float winz, const float *view, const float *proj, const int *vp, float *objx, float *objy, float *objz) { @@ -147,7 +147,7 @@ static inline void cgm_glu_unproject(float winx, float winy, float winz, *objz = res.z; } -static inline void cgm_pick_ray(cgm_ray *ray, float nx, float ny, +static CGM_INLINE void cgm_pick_ray(cgm_ray *ray, float nx, float ny, const float *viewmat, const float *projmat) { cgm_vec3 npos, farpt; @@ -166,14 +166,14 @@ static inline void cgm_pick_ray(cgm_ray *ray, float nx, float ny, ray->dir.z = farpt.z - ray->origin.z; } -static inline void cgm_raypos(cgm_vec3 *p, const cgm_ray *ray, float t) +static CGM_INLINE void cgm_raypos(cgm_vec3 *p, const cgm_ray *ray, float t) { p->x = ray->origin.x + ray->dir.x * t; p->y = ray->origin.y + ray->dir.y * t; p->z = ray->origin.z + ray->dir.z * t; } -static inline void cgm_bary(cgm_vec3 *bary, const cgm_vec3 *a, +static CGM_INLINE void cgm_bary(cgm_vec3 *bary, const cgm_vec3 *a, const cgm_vec3 *b, const cgm_vec3 *c, const cgm_vec3 *pt) { float d00, d01, d11, d20, d21, denom; @@ -195,13 +195,13 @@ static inline void cgm_bary(cgm_vec3 *bary, const cgm_vec3 *a, bary->x = 1.0f - bary->y - bary->z; } -static inline void cgm_uvec_to_sph(float *theta, float *phi, const cgm_vec3 *v) +static CGM_INLINE void cgm_uvec_to_sph(float *theta, float *phi, const cgm_vec3 *v) { *theta = atan2(v->z, v->x); *phi = acos(v->y); } -static inline void cgm_sph_to_uvec(cgm_vec3 *v, float theta, float phi) +static CGM_INLINE void cgm_sph_to_uvec(cgm_vec3 *v, float theta, float phi) { v->x = sin(theta) * cos(phi); v->y = sin(phi);