# HG changeset patch # User Matti Hamalainen # Date 1349246355 -10800 # Node ID 72813cece1ba18eeb4bd3b8e485503cdabaf97ab # Parent 1c2ff205fa0e87dc4bd3ac84b3392ee9986f50de Move some lerp functions to the header as static inline functions. diff -r 1c2ff205fa0e -r 72813cece1ba dmlerp.c --- a/dmlerp.c Wed Oct 03 09:29:29 2012 +0300 +++ b/dmlerp.c Wed Oct 03 09:39:15 2012 +0300 @@ -8,22 +8,7 @@ } -DMFloat dmLerpSCurve(DMLerpContext *ctx, const DMFloat step) -{ - const DMFloat n = step / ctx->nsteps; - const DMFloat v = DMM_S_CURVE(n); - return DMM_LERP(v, ctx->start, ctx->end); -} - - -DMFloat dmLerp1(DMLerpContext *ctx, const DMFloat step) -{ - const DMFloat v = step / ctx->nsteps; - return DMM_LERP(v, ctx->start, ctx->end); -} - - -DMFloat dmCatmull_Rom(const DMFloat t, const DMFloat p0, const DMFloat p1, const DMFloat p2, const DMFloat p3) +DMFloat dmCatmullRom(const DMFloat t, const DMFloat p0, const DMFloat p1, const DMFloat p2, const DMFloat p3) { const DMFloat q = t * t; return ( diff -r 1c2ff205fa0e -r 72813cece1ba dmlib.h --- a/dmlib.h Wed Oct 03 09:29:29 2012 +0300 +++ b/dmlib.h Wed Oct 03 09:39:15 2012 +0300 @@ -206,9 +206,49 @@ void dmLerpInit(DMLerpContext *ctx, DMFloat start, DMFloat end, DMFloat nsteps); -DMFloat dmLerpSCurve(DMLerpContext *ctx, const DMFloat step); -DMFloat dmLerp1(DMLerpContext *ctx, const DMFloat step); -DMFloat dmCatmull_Rom(const DMFloat t, const DMFloat p0, const DMFloat p1, const DMFloat p2, const DMFloat p3); +DMFloat dmCatmullRom(const DMFloat t, const DMFloat p0, const DMFloat p1, const DMFloat p2, const DMFloat p3); + + +static inline DMFloat dmClamp10(const DMFloat a) +{ + return (a < 0.0f ? 0.0f : (a > 1.0f ? 1.0f : a)); +} + + +static inline DMFloat dmLerpSCurve(DMLerpContext *ctx, const DMFloat step) +{ + const DMFloat n = step / ctx->nsteps; + const DMFloat v = DMM_S_CURVE(n); + return DMM_LERP(v, ctx->start, ctx->end); +} + + +static inline DMFloat dmLerpSCurveClamp(DMLerpContext *ctx, const DMFloat step) +{ + const DMFloat n = dmClamp10(step / ctx->nsteps); + const DMFloat v = DMM_S_CURVE(n); + return DMM_LERP(v, ctx->start, ctx->end); +} + + +static inline DMFloat dmLerp1(DMLerpContext *ctx, const DMFloat step) +{ + const DMFloat v = step / ctx->nsteps; + return DMM_LERP(v, ctx->start, ctx->end); +} + + +static inline DMFloat dmLerp1Clamp(DMLerpContext *ctx, const DMFloat step) +{ + const DMFloat v = dmClamp10(step / ctx->nsteps); + return DMM_LERP(v, ctx->start, ctx->end); +} + + +static inline DMFloat dmCatmullRomClamp(const DMFloat t, const DMFloat p0, const DMFloat p1, const DMFloat p2, const DMFloat p3) +{ + return dmCatmullRom(dmClamp10(t), p0, p1, p2, p3); +} /* Perlin noise @@ -278,12 +318,6 @@ #endif -static inline DMFloat dmClip10(const DMFloat a) -{ - return (a < 0.0f ? 0.0f : (a > 1.0f ? 1.0f : a)); -} - - /* Global variables */ extern char *dmProgName,