Chipmunk2D Pro API Reference  7.0.1
 All Classes Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
cpShape.h
1 /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to deal
5  * in the Software without restriction, including without limitation the rights
6  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7  * copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19  * SOFTWARE.
20  */
21 
25 
27 typedef struct cpPointQueryInfo {
29  const cpShape *shape;
38 
40 typedef struct cpSegmentQueryInfo {
42  const cpShape *shape;
50 
52 typedef struct cpShapeFilter {
63 
65 static const cpShapeFilter CP_SHAPE_FILTER_ALL = {CP_NO_GROUP, CP_ALL_CATEGORIES, CP_ALL_CATEGORIES};
68 
70 static inline cpShapeFilter
71 cpShapeFilterNew(cpGroup group, cpBitmask categories, cpBitmask mask)
72 {
73  cpShapeFilter filter = {group, categories, mask};
74  return filter;
75 }
76 
78 CP_EXPORT void cpShapeDestroy(cpShape *shape);
80 CP_EXPORT void cpShapeFree(cpShape *shape);
81 
83 CP_EXPORT cpBB cpShapeCacheBB(cpShape *shape);
85 CP_EXPORT cpBB cpShapeUpdate(cpShape *shape, cpTransform transform);
86 
89 CP_EXPORT cpFloat cpShapePointQuery(const cpShape *shape, cpVect p, cpPointQueryInfo *out);
90 
92 CP_EXPORT cpBool cpShapeSegmentQuery(const cpShape *shape, cpVect a, cpVect b, cpFloat radius, cpSegmentQueryInfo *info);
93 
95 CP_EXPORT cpContactPointSet cpShapesCollide(const cpShape *a, const cpShape *b);
96 
98 CP_EXPORT cpSpace* cpShapeGetSpace(const cpShape *shape);
99 
101 CP_EXPORT cpBody* cpShapeGetBody(const cpShape *shape);
104 CP_EXPORT void cpShapeSetBody(cpShape *shape, cpBody *body);
105 
109 CP_EXPORT void cpShapeSetMass(cpShape *shape, cpFloat mass);
110 
112 CP_EXPORT cpFloat cpShapeGetDensity(cpShape *shape);
114 CP_EXPORT void cpShapeSetDensity(cpShape *shape, cpFloat density);
115 
117 CP_EXPORT cpFloat cpShapeGetMoment(cpShape *shape);
119 CP_EXPORT cpFloat cpShapeGetArea(cpShape *shape);
121 CP_EXPORT cpVect cpShapeGetCenterOfGravity(cpShape *shape);
122 
124 CP_EXPORT cpBB cpShapeGetBB(const cpShape *shape);
125 
127 CP_EXPORT cpBool cpShapeGetSensor(const cpShape *shape);
129 CP_EXPORT void cpShapeSetSensor(cpShape *shape, cpBool sensor);
130 
132 CP_EXPORT cpFloat cpShapeGetElasticity(const cpShape *shape);
134 CP_EXPORT void cpShapeSetElasticity(cpShape *shape, cpFloat elasticity);
135 
137 CP_EXPORT cpFloat cpShapeGetFriction(const cpShape *shape);
139 CP_EXPORT void cpShapeSetFriction(cpShape *shape, cpFloat friction);
140 
142 CP_EXPORT cpVect cpShapeGetSurfaceVelocity(const cpShape *shape);
144 CP_EXPORT void cpShapeSetSurfaceVelocity(cpShape *shape, cpVect surfaceVelocity);
145 
147 CP_EXPORT cpDataPointer cpShapeGetUserData(const cpShape *shape);
149 CP_EXPORT void cpShapeSetUserData(cpShape *shape, cpDataPointer userData);
150 
152 CP_EXPORT cpCollisionType cpShapeGetCollisionType(const cpShape *shape);
154 CP_EXPORT void cpShapeSetCollisionType(cpShape *shape, cpCollisionType collisionType);
155 
157 CP_EXPORT cpShapeFilter cpShapeGetFilter(const cpShape *shape);
159 CP_EXPORT void cpShapeSetFilter(cpShape *shape, cpShapeFilter filter);
160 
161 
164 
166 CP_EXPORT cpCircleShape* cpCircleShapeAlloc(void);
168 CP_EXPORT cpCircleShape* cpCircleShapeInit(cpCircleShape *circle, cpBody *body, cpFloat radius, cpVect offset);
170 CP_EXPORT cpShape* cpCircleShapeNew(cpBody *body, cpFloat radius, cpVect offset);
171 
173 CP_EXPORT cpVect cpCircleShapeGetOffset(const cpShape *shape);
175 CP_EXPORT cpFloat cpCircleShapeGetRadius(const cpShape *shape);
176 
179 
181 CP_EXPORT cpSegmentShape* cpSegmentShapeAlloc(void);
183 CP_EXPORT cpSegmentShape* cpSegmentShapeInit(cpSegmentShape *seg, cpBody *body, cpVect a, cpVect b, cpFloat radius);
185 CP_EXPORT cpShape* cpSegmentShapeNew(cpBody *body, cpVect a, cpVect b, cpFloat radius);
186 
188 CP_EXPORT void cpSegmentShapeSetNeighbors(cpShape *shape, cpVect prev, cpVect next);
189 
191 CP_EXPORT cpVect cpSegmentShapeGetA(const cpShape *shape);
193 CP_EXPORT cpVect cpSegmentShapeGetB(const cpShape *shape);
195 CP_EXPORT cpVect cpSegmentShapeGetNormal(const cpShape *shape);
197 CP_EXPORT cpFloat cpSegmentShapeGetRadius(const cpShape *shape);
198