Chipmunk2D Pro API Reference  7.0.0
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 
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 
void cpShapeDestroy(cpShape *shape)
Destroy a shape.
cpVect point
The point of impact.
Definition: cpShape.h:44
Definition: chipmunk_private.h:641
void cpShapeSetSurfaceVelocity(cpShape *shape, cpVect surfaceVelocity)
Set the surface velocity of this shape.
Fast collision filtering type that is used to determine if two objects collide before calling collisi...
Definition: cpShape.h:52
void * cpDataPointer
Type used for user data pointers.
Definition: chipmunk_types.h:216
cpBitmask mask
A bitmask of user definable category types that this object object collides with. ...
Definition: cpShape.h:61
cpFloat cpShapePointQuery(const cpShape *shape, cpVect p, cpPointQueryInfo *out)
Perform a nearest point query.
struct cpSegmentQueryInfo cpSegmentQueryInfo
Segment query info struct.
cpFloat cpShapeGetDensity(cpShape *shape)
Get the density of the shape if you are having Chipmunk calculate mass properties for you...
static cpShapeFilter cpShapeFilterNew(cpGroup group, cpBitmask categories, cpBitmask mask)
Create a new collision filter.
Definition: cpShape.h:71
cpBB cpShapeUpdate(cpShape *shape, cpTransform transform)
Update, cache and return the bounding box of a shape with an explicit transformation.
cpFloat cpShapeGetArea(cpShape *shape)
Get the calculated area of this shape.
static const cpShapeFilter CP_SHAPE_FILTER_NONE
Collision filter value for a shape that does not collide with anything.
Definition: cpShape.h:67
Definition: chipmunk_private.h:80
cpFloat cpShapeGetMoment(cpShape *shape)
Get the calculated moment of inertia for this shape.
Definition: chipmunk_private.h:256
unsigned char cpBool
Chipmunk's boolean type.
Definition: chipmunk_types.h:199
Definition: chipmunk_private.h:288
cpSpace * cpShapeGetSpace(const cpShape *shape)
The cpSpace this body is added to.
void cpShapeSetMass(cpShape *shape, cpFloat mass)
Set the mass of this shape to have Chipmunk calculate mass properties for you.
cpBody * cpShapeGetBody(const cpShape *shape)
The cpBody this shape is connected to.
const cpShape * shape
The shape that was hit, or NULL if no collision occured.
Definition: cpShape.h:42
uintptr_t cpCollisionType
Type used for cpSpace.collision_type.
Definition: chipmunk_types.h:223
cpVect normal
The normal of the surface hit.
Definition: cpShape.h:46
void cpShapeSetSensor(cpShape *shape, cpBool sensor)
Set if the shape is a sensor or not.
double cpFloat
Chipmunk's floating point type.
Definition: chipmunk_types.h:83
static const cpShapeFilter CP_SHAPE_FILTER_ALL
Collision filter value for a shape that will collide with anything except CP_SHAPE_FILTER_NONE.
Definition: cpShape.h:65
unsigned int cpBitmask
Type used for cpShapeFilter category and mask.
Definition: chipmunk_types.h:237
void cpShapeSetElasticity(cpShape *shape, cpFloat elasticity)
Set the elasticity of this shape.
struct cpShapeFilter cpShapeFilter
Fast collision filtering type that is used to determine if two objects collide before calling collisi...
cpVect cpShapeGetCenterOfGravity(cpShape *shape)
Get the centroid of this shape.
cpBB cpShapeCacheBB(cpShape *shape)
Update, cache and return the bounding box of a shape based on the body it's attached to...
cpFloat distance
The distance to the point. The distance is negative if the point is inside the shape.
Definition: cpShape.h:33
Definition: chipmunk_types.h:271
cpVect gradient
The gradient of the signed distance function.
Definition: cpShape.h:36
Segment query info struct.
Definition: cpShape.h:40
cpVect point
The closest point on the shape's surface. (in world space coordinates)
Definition: cpShape.h:31
cpBool cpShapeGetSensor(const cpShape *shape)
Get if the shape is set to be a sensor or not.
cpCollisionType cpShapeGetCollisionType(const cpShape *shape)
Set the collision type of this shape.
cpBitmask categories
A bitmask of user definable categories that this object belongs to.
Definition: cpShape.h:58
cpGroup group
Two objects with the same non-zero group value do not collide.
Definition: cpShape.h:55
void cpShapeSetUserData(cpShape *shape, cpDataPointer userData)
Set the user definable data pointer of this shape.
void cpShapeSetDensity(cpShape *shape, cpFloat density)
Set the density of this shape to have Chipmunk calculate mass properties for you. ...
cpDataPointer cpShapeGetUserData(const cpShape *shape)
Get the user definable data pointer of this shape.
cpFloat alpha
The normalized distance along the query segment in the range [0, 1].
Definition: cpShape.h:48
cpFloat cpShapeGetMass(cpShape *shape)
Get the mass of the shape if you are having Chipmunk calculate mass properties for you...
A struct that wraps up the important collision data for an arbiter.
Definition: cpArbiter.h:81
uintptr_t cpGroup
Type used for cpShape.group.
Definition: chipmunk_types.h:230
cpFloat cpShapeGetElasticity(const cpShape *shape)
Get the elasticity of this shape.
cpVect cpShapeGetSurfaceVelocity(const cpShape *shape)
Get the surface velocity of this shape.
Point query info struct.
Definition: cpShape.h:27
void cpShapeSetFriction(cpShape *shape, cpFloat friction)
Set the friction of this shape.
cpFloat cpShapeGetFriction(const cpShape *shape)
Get the friction of this shape.
const cpShape * shape
The nearest shape, NULL if no shape was within range.
Definition: cpShape.h:29
cpBool cpShapeSegmentQuery(const cpShape *shape, cpVect a, cpVect b, cpFloat radius, cpSegmentQueryInfo *info)
Perform a segment query against a shape. info must be a pointer to a valid cpSegmentQueryInfo structu...
Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top)
Definition: cpBB.h:33
void cpShapeSetBody(cpShape *shape, cpBody *body)
Set the cpBody this shape is connected to.
#define CP_NO_GROUP
Value for cpShape.group signifying that a shape is in no group.
Definition: chipmunk_types.h:249
#define CP_ALL_CATEGORIES
Value for cpShape.layers signifying that a shape is in every layer.
Definition: chipmunk_types.h:254
cpContactPointSet cpShapesCollide(const cpShape *a, const cpShape *b)
Return contact information about two shapes.
void cpShapeSetFilter(cpShape *shape, cpShapeFilter filter)
Set the collision filtering parameters of this shape.
cpShapeFilter cpShapeGetFilter(const cpShape *shape)
Get the collision filtering parameters of this shape.
Column major affine transform.
Definition: chipmunk_types.h:278
void cpShapeSetCollisionType(cpShape *shape, cpCollisionType collisionType)
Get the collision type of this shape.
Definition: chipmunk_private.h:281
cpBB cpShapeGetBB(const cpShape *shape)
Get the bounding box that contains the shape given it's current position and angle.
void cpShapeFree(cpShape *shape)
Destroy and Free a shape.
struct cpPointQueryInfo cpPointQueryInfo
Point query info struct.