1 module chipmunk.cpShape;
2 
3 import chipmunk.chipmunk;
4 import chipmunk.chipmunk_types;
5 import chipmunk.chipmunk_structs;
6 import chipmunk.cpBB;
7 import chipmunk.cpArbiter;
8 
9 extern (C):
10 
11 static const cpShapeFilter CP_SHAPE_FILTER_ALL = {CP_NO_GROUP, CP_ALL_CATEGORIES, CP_ALL_CATEGORIES};
12 
13 /// Collision filter value for a shape that does not collide with anything.
14 static const cpShapeFilter CP_SHAPE_FILTER_NONE = {CP_NO_GROUP, ~CP_ALL_CATEGORIES, ~CP_ALL_CATEGORIES};
15 
16 struct cpPointQueryInfo
17 {
18     const(cpShape)* shape;
19     cpVect point;
20     cpFloat distance;
21     cpVect gradient;
22 }
23 
24 struct cpSegmentQueryInfo
25 {
26     const(cpShape)* shape;
27     cpVect point;
28     cpVect normal;
29     cpFloat alpha;
30 }
31 
32 struct cpShapeFilter
33 {
34     cpGroup group;
35     cpBitmask categories;
36     cpBitmask mask;
37 }
38 
39 // inlined in chipmunk header
40 static cpShapeFilter
41 cpShapeFilterNew(cpGroup group, cpBitmask categories, cpBitmask mask)
42 {
43 	cpShapeFilter filter = {group, categories, mask};
44 	return filter;
45 }
46 
47 void cpShapeDestroy (cpShape* shape);
48 void cpShapeFree (cpShape* shape);
49 cpBB cpShapeCacheBB (cpShape* shape);
50 cpBB cpShapeUpdate (cpShape* shape, cpTransform transform);
51 cpFloat cpShapePointQuery (const(cpShape)* shape, cpVect p, cpPointQueryInfo* out_);
52 cpBool cpShapeSegmentQuery (const(cpShape)* shape, cpVect a, cpVect b, cpFloat radius, cpSegmentQueryInfo* info);
53 cpContactPointSet cpShapesCollide (const(cpShape)* a, const(cpShape)* b);
54 cpSpace* cpShapeGetSpace (const(cpShape)* shape);
55 cpBody* cpShapeGetBody (const(cpShape)* shape);
56 void cpShapeSetBody (cpShape* shape, cpBody* body_);
57 cpFloat cpShapeGetMass (cpShape* shape);
58 void cpShapeSetMass (cpShape* shape, cpFloat mass);
59 cpFloat cpShapeGetDensity (cpShape* shape);
60 void cpShapeSetDensity (cpShape* shape, cpFloat density);
61 cpFloat cpShapeGetMoment (cpShape* shape);
62 cpFloat cpShapeGetArea (cpShape* shape);
63 cpVect cpShapeGetCenterOfGravity (cpShape* shape);
64 cpBB cpShapeGetBB (const(cpShape)* shape);
65 cpBool cpShapeGetSensor (const(cpShape)* shape);
66 void cpShapeSetSensor (cpShape* shape, cpBool sensor);
67 cpFloat cpShapeGetElasticity (const(cpShape)* shape);
68 void cpShapeSetElasticity (cpShape* shape, cpFloat elasticity);
69 cpFloat cpShapeGetFriction (const(cpShape)* shape);
70 void cpShapeSetFriction (cpShape* shape, cpFloat friction);
71 cpVect cpShapeGetSurfaceVelocity (const(cpShape)* shape);
72 void cpShapeSetSurfaceVelocity (cpShape* shape, cpVect surfaceVelocity);
73 cpDataPointer cpShapeGetUserData (const(cpShape)* shape);
74 void cpShapeSetUserData (cpShape* shape, cpDataPointer userData);
75 cpCollisionType cpShapeGetCollisionType (const(cpShape)* shape);
76 void cpShapeSetCollisionType (cpShape* shape, cpCollisionType collisionType);
77 cpShapeFilter cpShapeGetFilter (const(cpShape)* shape);
78 void cpShapeSetFilter (cpShape* shape, cpShapeFilter filter);
79 cpCircleShape* cpCircleShapeAlloc ();
80 cpCircleShape* cpCircleShapeInit (cpCircleShape* circle, cpBody* body_, cpFloat radius, cpVect offset);
81 cpShape* cpCircleShapeNew (cpBody* body_, cpFloat radius, cpVect offset);
82 cpVect cpCircleShapeGetOffset (const(cpShape)* shape);
83 cpFloat cpCircleShapeGetRadius (const(cpShape)* shape);
84 cpSegmentShape* cpSegmentShapeAlloc ();
85 cpSegmentShape* cpSegmentShapeInit (cpSegmentShape* seg, cpBody* body_, cpVect a, cpVect b, cpFloat radius);
86 cpShape* cpSegmentShapeNew (cpBody* body_, cpVect a, cpVect b, cpFloat radius);
87 void cpSegmentShapeSetNeighbors (cpShape* shape, cpVect prev, cpVect next);
88 cpVect cpSegmentShapeGetA (const(cpShape)* shape);
89 cpVect cpSegmentShapeGetB (const(cpShape)* shape);
90 cpVect cpSegmentShapeGetNormal (const(cpShape)* shape);
91 cpFloat cpSegmentShapeGetRadius (const(cpShape)* shape);