Mercurial > projects > chipmunkd
view trunk/chipmunkd/chipmunk_types.d @ 23:4ceef5833c8c
updated to chipmunk 5.3.3
author | Extrawurst |
---|---|
date | Fri, 10 Dec 2010 02:10:27 +0100 |
parents | 131331ebb599 |
children |
line wrap: on
line source
// written in the D programming language module chipmunkd.chipmunk_types; import std.string; //#ifdef __APPLE__ // #import "TargetConditionals.h" //#endif // //#ifndef CP_USE_DOUBLES // // Use single precision floats on the iPhone. // #if TARGET_OS_IPHONE // #define CP_USE_DOUBLES 0 // #else // // use doubles by default for higher precision // #define CP_USE_DOUBLES 1 // #endif //#endif // version(CP_USE_DOUBLES){ alias double cpFloat; //TODO: // #define cpfsqrt sqrt // #define cpfsin sin // #define cpfcos cos // #define cpfacos acos // #define cpfatan2 atan2 // #define cpfmod fmod // #define cpfexp exp // #define cpfpow pow // #define cpffloor floor // #define cpfceil ceil }else{ extern (C) nothrow { float sqrtf(float); float sinf(float); float cosf(float); float acosf(float); float atan2f(float,float); float fmodf(float,float); float expf(float); float powf(float,float); float floorf(float); float ceilf(float); } alias float cpFloat; alias sqrtf cpfsqrt; alias sinf cpfsin; alias cosf cpfcos; alias acosf cpfacos; alias atan2f cpfatan2; alias fmodf cpfmod; alias expf cpfexp; alias powf cpfpow; alias floorf cpffloor; alias ceilf cpfceil; } static cpFloat cpfmax(cpFloat a, cpFloat b) { return (a > b) ? a : b; } static cpFloat cpfmin(cpFloat a, cpFloat b) { return (a < b) ? a : b; } static cpFloat cpfabs(cpFloat n) { return (n < 0) ? -n : n; } static cpFloat cpfclamp(cpFloat f, cpFloat min, cpFloat max) { return cpfmin(cpfmax(f, min), max); } static cpFloat cpflerp(cpFloat f1, cpFloat f2, cpFloat t) { return f1*(1.0f - t) + f2*t; } static cpFloat cpflerpconst(cpFloat f1, cpFloat f2, cpFloat d) { return f1 + cpfclamp(f2 - f1, -d, d); } //#if TARGET_OS_IPHONE // // CGPoints are structurally the same, and allow // // easy interoperability with other iPhone libraries // #import <CoreGraphics/CGGeometry.h> // typedef CGPoint cpVect; //#else struct cpVect { cpFloat x = 0; cpFloat y=0; //TODO: basic operators string toString() const { return .format("(%s,%s)",x,y); } } //#endif alias uint cpHashValue; // Oh C, how we love to define our own boolean types to get compiler compatibility //#ifdef CP_BOOL_TYPE // typedef CP_BOOL_TYPE cpBool; //#else alias bool cpBool; //#endif //#ifndef cpTrue enum cpTrue = true; //#endif //#ifndef cpFalse enum cpFalse = false; //#endif //#ifdef CP_DATA_POINTER_TYPE // typedef CP_DATA_POINTER_TYPE cpDataPointer; //#else alias void * cpDataPointer; //#endif //#ifdef CP_COLLISION_TYPE_TYPE // typedef CP_COLLISION_TYPE_TYPE cpCollisionType; //#else alias uint cpCollisionType; //#endif //#ifdef CP_GROUP_TYPE // typedef CP_GROUP_TYPE cpGroup; //#else alias uint cpGroup; //#endif //#ifdef CP_LAYERS_TYPE // typedef CP_GROUP_TYPE cpLayers; //#else alias uint cpLayers; //#endif //#ifdef CP_TIMESTAMP_TYPE // typedef CP_TIMESTAMP_TYPE cpTimestamp; //#else alias uint cpTimestamp; //#endif //#ifndef CP_NO_GROUP enum CP_NO_GROUP = 0; //#endif //#ifndef CP_ALL_LAYERS enum CP_ALL_LAYERS = ~0; //#endif