Chipmunk2D Pro API Reference  7.0.0
cpArbiter.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 
28 
29 #define CP_MAX_CONTACTS_PER_ARBITER 2
30 
34 void cpArbiterSetRestitution(cpArbiter *arb, cpFloat restitution);
38 void cpArbiterSetFriction(cpArbiter *arb, cpFloat friction);
39 
40 // Get the relative surface velocity of the two shapes in contact.
41 cpVect cpArbiterGetSurfaceVelocity(cpArbiter *arb);
42 
43 // Override the relative surface velocity of the two shapes in contact.
44 // By default this is calculated to be the difference of the two surface velocities clamped to the tangent plane.
45 void cpArbiterSetSurfaceVelocity(cpArbiter *arb, cpVect vr);
46 
51 void cpArbiterSetUserData(cpArbiter *arb, cpDataPointer userData);
52 
59 
63 
67 void cpArbiterGetShapes(const cpArbiter *arb, cpShape **a, cpShape **b);
68 
70 #define CP_ARBITER_GET_SHAPES(__arb__, __a__, __b__) cpShape *__a__, *__b__; cpArbiterGetShapes(__arb__, &__a__, &__b__);
71 
75 void cpArbiterGetBodies(const cpArbiter *arb, cpBody **a, cpBody **b);
76 
78 #define CP_ARBITER_GET_BODIES(__arb__, __a__, __b__) cpBody *__a__, *__b__; cpArbiterGetBodies(__arb__, &__a__, &__b__);
79 
83  int count;
84 
87 
89  struct {
91  cpVect pointA, pointB;
95  } points[CP_MAX_CONTACTS_PER_ARBITER];
96 };
97 
100 
104 
109 
111 int cpArbiterGetCount(const cpArbiter *arb);
115 cpVect cpArbiterGetPointA(const cpArbiter *arb, int i);
117 cpVect cpArbiterGetPointB(const cpArbiter *arb, int i);
119 cpFloat cpArbiterGetDepth(const cpArbiter *arb, int i);
120 
127 
134 
139 
144 
Definition: chipmunk_private.h:641
void * cpDataPointer
Type used for user data pointers.
Definition: chipmunk_types.h:216
cpFloat cpArbiterGetFriction(const cpArbiter *arb)
Get the friction coefficient that will be applied to the pair of colliding objects.
cpBool cpArbiterCallWildcardPreSolveA(cpArbiter *arb, cpSpace *space)
If you want a custom callback to invoke the wildcard callback for the first collision type...
Definition: chipmunk_private.h:80
cpVect normal
The normal of the collision.
Definition: cpArbiter.h:86
Definition: chipmunk_private.h:256
cpVect cpArbiterGetPointB(const cpArbiter *arb, int i)
Get the position of the ith contact point on the surface of the second shape.
unsigned char cpBool
Chipmunk's boolean type.
Definition: chipmunk_types.h:199
cpFloat cpArbiterTotalKE(const cpArbiter *arb)
Calculate the amount of energy lost in a collision including static, but not dynamic friction...
void cpArbiterSetFriction(cpArbiter *arb, cpFloat friction)
Override the friction coefficient that will be applied to the pair of colliding objects.
void cpArbiterCallWildcardPostSolveB(cpArbiter *arb, cpSpace *space)
If you want a custom callback to invoke the wildcard callback for the second collision type...
void cpArbiterCallWildcardSeparateA(cpArbiter *arb, cpSpace *space)
If you want a custom callback to invoke the wildcard callback for the first collision type...
cpContactPointSet cpArbiterGetContactPointSet(const cpArbiter *arb)
Return a contact set from an arbiter.
cpBool cpArbiterCallWildcardBeginA(cpArbiter *arb, cpSpace *space)
If you want a custom callback to invoke the wildcard callback for the first collision type...
void cpArbiterGetShapes(const cpArbiter *arb, cpShape **a, cpShape **b)
Return the colliding shapes involved for this arbiter.
double cpFloat
Chipmunk's floating point type.
Definition: chipmunk_types.h:83
cpBool cpArbiterIsFirstContact(const cpArbiter *arb)
Returns true if this is the first step a pair of objects started colliding.
cpFloat distance
Penetration distance of the two shapes.
Definition: cpArbiter.h:94
cpBool cpArbiterCallWildcardPreSolveB(cpArbiter *arb, cpSpace *space)
If you want a custom callback to invoke the wildcard callback for the second collision type...
cpFloat cpArbiterGetDepth(const cpArbiter *arb, int i)
Get the depth of the ith contact point.
cpVect pointA
The position of the contact on the surface of each shape.
Definition: cpArbiter.h:91
int cpArbiterGetCount(const cpArbiter *arb)
Get the number of contact points for this arbiter.
Definition: chipmunk_types.h:271
int count
The number of contact points in the set.
Definition: cpArbiter.h:83
cpVect cpArbiterGetPointA(const cpArbiter *arb, int i)
Get the position of the ith contact point on the surface of the first shape.
A struct that wraps up the important collision data for an arbiter.
Definition: cpArbiter.h:81
void cpArbiterSetUserData(cpArbiter *arb, cpDataPointer userData)
Set a user data point associated with this pair of colliding objects.
cpBool cpArbiterCallWildcardBeginB(cpArbiter *arb, cpSpace *space)
If you want a custom callback to invoke the wildcard callback for the second collision type...
void cpArbiterSetRestitution(cpArbiter *arb, cpFloat restitution)
Override the restitution (elasticity) that will be applied to the pair of colliding objects...
cpFloat cpArbiterGetRestitution(const cpArbiter *arb)
Get the restitution (elasticity) that will be applied to the pair of colliding objects.
struct cpContactPointSet::@1 points[2]
The array of contact points.
Definition: chipmunk_private.h:185
void cpArbiterCallWildcardSeparateB(cpArbiter *arb, cpSpace *space)
If you want a custom callback to invoke the wildcard callback for the second collision type...
cpVect cpArbiterTotalImpulse(const cpArbiter *arb)
Calculate the total impulse including the friction that was applied by this arbiter.
void cpArbiterSetContactPointSet(cpArbiter *arb, cpContactPointSet *set)
Replace the contact point set for an arbiter.
cpBool cpArbiterIgnore(cpArbiter *arb)
Mark a collision pair to be ignored until the two objects separate.
cpDataPointer cpArbiterGetUserData(const cpArbiter *arb)
Get the user data pointer associated with this pair of colliding objects.
cpBool cpArbiterIsRemoval(const cpArbiter *arb)
Returns true if the separate callback is due to a shape being removed from the space.
void cpArbiterGetBodies(const cpArbiter *arb, cpBody **a, cpBody **b)
Return the colliding bodies involved for this arbiter.
void cpArbiterCallWildcardPostSolveA(cpArbiter *arb, cpSpace *space)
If you want a custom callback to invoke the wildcard callback for the first collision type...
cpVect cpArbiterGetNormal(const cpArbiter *arb)
Get the normal of the collision.