Chipmunk2D Pro API Reference  7.0.0
 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 void cpShapeDestroy(cpShape *shape);
80 void cpShapeFree(cpShape *shape);
81 
85 cpBB cpShapeUpdate(cpShape *shape, cpTransform transform);
86 
90 
92 cpBool cpShapeSegmentQuery(const cpShape *shape, cpVect a, cpVect b, cpFloat radius, cpSegmentQueryInfo *info);
93 
96 
98 cpSpace* cpShapeGetSpace(const cpShape *shape);
99 
101 cpBody* cpShapeGetBody(const cpShape *shape);
104 void cpShapeSetBody(cpShape *shape, cpBody *body);
105 
109 void cpShapeSetMass(cpShape *shape, cpFloat mass);
110 
114 void cpShapeSetDensity(cpShape *shape, cpFloat density);
115 
122 
124 cpBB cpShapeGetBB(const cpShape *shape);
125 
127 cpBool cpShapeGetSensor(const cpShape *shape);
129 void cpShapeSetSensor(cpShape *shape, cpBool sensor);
130 
132 cpFloat cpShapeGetElasticity(const cpShape *shape);
134 void cpShapeSetElasticity(cpShape *shape, cpFloat elasticity);
135 
137 cpFloat cpShapeGetFriction(const cpShape *shape);
139 void cpShapeSetFriction(cpShape *shape, cpFloat friction);
140 
144 void cpShapeSetSurfaceVelocity(cpShape *shape, cpVect surfaceVelocity);
145 
149 void cpShapeSetUserData(cpShape *shape, cpDataPointer userData);
150 
154 void cpShapeSetCollisionType(cpShape *shape, cpCollisionType collisionType);
155 
159 void cpShapeSetFilter(cpShape *shape, cpShapeFilter filter);
160 
161 
164 
166 cpCircleShape* cpCircleShapeAlloc(void);
168 cpCircleShape* cpCircleShapeInit(cpCircleShape *circle, cpBody *body, cpFloat radius, cpVect offset);
170 cpShape* cpCircleShapeNew(cpBody *body, cpFloat radius, cpVect offset);
171 
173 cpVect cpCircleShapeGetOffset(const cpShape *shape);
175 cpFloat cpCircleShapeGetRadius(const cpShape *shape);
176 
179 
181 cpSegmentShape* cpSegmentShapeAlloc(void);
183 cpSegmentShape* cpSegmentShapeInit(cpSegmentShape *seg, cpBody *body, cpVect a, cpVect b, cpFloat radius);
185 cpShape* cpSegmentShapeNew(cpBody *body, cpVect a, cpVect b, cpFloat radius);
186 
188 void cpSegmentShapeSetNeighbors(cpShape *shape, cpVect prev, cpVect next);
189 
191 cpVect cpSegmentShapeGetA(const cpShape *shape);
193 cpVect cpSegmentShapeGetB(const cpShape *shape);
195 cpVect cpSegmentShapeGetNormal(const cpShape *shape);
197 cpFloat cpSegmentShapeGetRadius(const cpShape *shape);
198