00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef CHIPMUNK_HEADER
00023 #define CHIPMUNK_HEADER
00024
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028
00029 #ifndef CP_ALLOW_PRIVATE_ACCESS
00030 #define CP_ALLOW_PRIVATE_ACCESS 0
00031 #endif
00032
00033 #if CP_ALLOW_PRIVATE_ACCESS == 1
00034 #define CP_PRIVATE(symbol) symbol
00035 #else
00036 #define CP_PRIVATE(symbol) symbol##_private
00037 #endif
00038
00039 void cpMessage(const char *condition, const char *file, int line, int isError, int isHardError, const char *message, ...);
00040 #ifdef NDEBUG
00041 #define cpAssertWarn(condition, ...)
00042 #else
00043 #define cpAssertWarn(condition, ...) if(!(condition)) cpMessage(#condition, __FILE__, __LINE__, 0, 0, __VA_ARGS__)
00044 #endif
00045
00046 #ifdef NDEBUG
00047 #define cpAssertSoft(condition, ...)
00048 #else
00049 #define cpAssertSoft(condition, ...) if(!(condition)) cpMessage(#condition, __FILE__, __LINE__, 1, 0, __VA_ARGS__)
00050 #endif
00051
00052
00053 #define cpAssertHard(condition, ...) if(!(condition)) cpMessage(#condition, __FILE__, __LINE__, 1, 1, __VA_ARGS__)
00054
00055
00056 #include "chipmunk_types.h"
00057
00060
00062 #ifndef CP_BUFFER_BYTES
00063 #define CP_BUFFER_BYTES (32*1024)
00064 #endif
00065
00066 #ifndef cpcalloc
00067
00068 #define cpcalloc calloc
00069 #endif
00070
00071 #ifndef cprealloc
00072
00073 #define cprealloc realloc
00074 #endif
00075
00076 #ifndef cpfree
00077
00078 #define cpfree free
00079 #endif
00080
00081 typedef struct cpArray cpArray;
00082 typedef struct cpHashSet cpHashSet;
00083
00084 typedef struct cpBody cpBody;
00085 typedef struct cpShape cpShape;
00086 typedef struct cpConstraint cpConstraint;
00087
00088 typedef struct cpCollisionHandler cpCollisionHandler;
00089 typedef struct cpArbiter cpArbiter;
00090
00091 typedef struct cpSpace cpSpace;
00092
00093 #include "cpVect.h"
00094 #include "cpBB.h"
00095 #include "cpSpatialIndex.h"
00096
00097 #include "cpBody.h"
00098 #include "cpShape.h"
00099 #include "cpPolyShape.h"
00100
00101 #include "cpArbiter.h"
00102 #include "constraints/cpConstraint.h"
00103
00104 #include "cpSpace.h"
00105
00106
00107 #define CP_VERSION_MAJOR 6
00108 #define CP_VERSION_MINOR 0
00109 #define CP_VERSION_RELEASE 3
00110
00112 extern const char *cpVersionString;
00113
00115 void cpInitChipmunk(void);
00116
00119 cpFloat cpMomentForCircle(cpFloat m, cpFloat r1, cpFloat r2, cpVect offset);
00120
00123 cpFloat cpAreaForCircle(cpFloat r1, cpFloat r2);
00124
00127 cpFloat cpMomentForSegment(cpFloat m, cpVect a, cpVect b);
00128
00130 cpFloat cpAreaForSegment(cpVect a, cpVect b, cpFloat r);
00131
00133 cpFloat cpMomentForPoly(cpFloat m, int numVerts, const cpVect *verts, cpVect offset);
00134
00137 cpFloat cpAreaForPoly(const int numVerts, const cpVect *verts);
00138
00140 cpVect cpCentroidForPoly(const int numVerts, const cpVect *verts);
00141
00143 void cpRecenterPoly(const int numVerts, cpVect *verts);
00144
00146 cpFloat cpMomentForBox(cpFloat m, cpFloat width, cpFloat height);
00147
00149 cpFloat cpMomentForBox2(cpFloat m, cpBB box);
00150
00152
00153 #ifdef __cplusplus
00154 }
00155
00156 static inline cpVect operator *(const cpVect v, const cpFloat s){return cpvmult(v, s);}
00157 static inline cpVect operator +(const cpVect v1, const cpVect v2){return cpvadd(v1, v2);}
00158 static inline cpVect operator -(const cpVect v1, const cpVect v2){return cpvsub(v1, v2);}
00159 static inline cpBool operator ==(const cpVect v1, const cpVect v2){return cpveql(v1, v2);}
00160 static inline cpVect operator -(const cpVect v){return cpvneg(v);}
00161
00162 #endif
00163 #endif