Munk2D Documentation  8.x.x
Loading...
Searching...
No Matches
cpArbiter.h
1/* Copyright (c) 2025 Victor Blomqvist
2 * Copyright (c) 2007-2024 Scott Lembcke and Howling Moon Software
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21*/
22
29
30#define CP_MAX_CONTACTS_PER_ARBITER 2
31
35CP_EXPORT void cpArbiterSetRestitution(cpArbiter *arb, cpFloat restitution);
39CP_EXPORT void cpArbiterSetFriction(cpArbiter *arb, cpFloat friction);
40
41// Get the relative surface velocity of the two shapes in contact.
42CP_EXPORT cpVect cpArbiterGetSurfaceVelocity(cpArbiter *arb);
43
44// Override the relative surface velocity of the two shapes in contact.
45// By default this is calculated to be the difference of the two surface velocities clamped to the tangent plane.
46CP_EXPORT void cpArbiterSetSurfaceVelocity(cpArbiter *arb, cpVect vr);
47
52CP_EXPORT void cpArbiterSetUserData(cpArbiter *arb, cpDataPointer userData);
53
59CP_EXPORT cpFloat cpArbiterTotalKE(const cpArbiter *arb);
60
68CP_EXPORT void cpArbiterSetProcessCollision(cpArbiter *arb, cpBool processCollision);
69
70
74CP_EXPORT void cpArbiterGetShapes(const cpArbiter *arb, cpShape **a, cpShape **b);
75
77#define CP_ARBITER_GET_SHAPES(__arb__, __a__, __b__) cpShape *__a__, *__b__; cpArbiterGetShapes(__arb__, &__a__, &__b__);
78
82CP_EXPORT void cpArbiterGetBodies(const cpArbiter *arb, cpBody **a, cpBody **b);
83
85#define CP_ARBITER_GET_BODIES(__arb__, __a__, __b__) cpBody *__a__, *__b__; cpArbiterGetBodies(__arb__, &__a__, &__b__);
86
90 int count;
91
94
96 struct {
98 cpVect pointA, pointB;
102 } points[CP_MAX_CONTACTS_PER_ARBITER];
103};
104
107
111
115CP_EXPORT cpBool cpArbiterIsRemoval(const cpArbiter *arb);
116
118CP_EXPORT int cpArbiterGetCount(const cpArbiter *arb);
120CP_EXPORT cpVect cpArbiterGetNormal(const cpArbiter *arb);
122CP_EXPORT cpVect cpArbiterGetPointA(const cpArbiter *arb, int i);
124CP_EXPORT cpVect cpArbiterGetPointB(const cpArbiter *arb, int i);
126CP_EXPORT cpFloat cpArbiterGetDepth(const cpArbiter *arb, int i);
127
void * cpDataPointer
Type used for user data pointers.
Definition chipmunk_types.h:196
unsigned char cpBool
Chipmunk's boolean type.
Definition chipmunk_types.h:179
double cpFloat
Chipmunk's floating point type.
Definition chipmunk_types.h:68
CP_EXPORT cpVect cpArbiterGetPointA(const cpArbiter *arb, int i)
Get the position of the ith contact point on the surface of the first shape.
CP_EXPORT int cpArbiterGetCount(const cpArbiter *arb)
Get the number of contact points for this arbiter.
CP_EXPORT void cpArbiterSetContactPointSet(cpArbiter *arb, cpContactPointSet *set)
Replace the contact point set for an arbiter.
CP_EXPORT cpFloat cpArbiterGetFriction(const cpArbiter *arb)
Get the friction coefficient that will be applied to the pair of colliding objects.
CP_EXPORT cpContactPointSet cpArbiterGetContactPointSet(const cpArbiter *arb)
Return a contact set from an arbiter.
CP_EXPORT void cpArbiterGetShapes(const cpArbiter *arb, cpShape **a, cpShape **b)
Return the colliding shapes involved for this arbiter.
CP_EXPORT cpBool cpArbiterGetProcessCollision(const cpArbiter *arb)
Return if the collision was set to be ignored by cpArbiterSetProcessCollision earlier.
CP_EXPORT cpVect cpArbiterGetPointB(const cpArbiter *arb, int i)
Get the position of the ith contact point on the surface of the second shape.
CP_EXPORT cpFloat cpArbiterGetRestitution(const cpArbiter *arb)
Get the restitution (elasticity) that will be applied to the pair of colliding objects.
CP_EXPORT void cpArbiterSetProcessCollision(cpArbiter *arb, cpBool processCollision)
Set processCollision to false to not process the collision.
CP_EXPORT cpFloat cpArbiterGetDepth(const cpArbiter *arb, int i)
Get the depth of the ith contact point.
CP_EXPORT cpVect cpArbiterTotalImpulse(const cpArbiter *arb)
Calculate the total impulse including the friction that was applied by this arbiter.
CP_EXPORT cpDataPointer cpArbiterGetUserData(const cpArbiter *arb)
Get the user data pointer associated with this pair of colliding objects.
CP_EXPORT cpFloat cpArbiterTotalKE(const cpArbiter *arb)
Calculate the amount of energy lost in a collision including static, but not dynamic friction.
CP_EXPORT void cpArbiterSetFriction(cpArbiter *arb, cpFloat friction)
Override the friction coefficient that will be applied to the pair of colliding objects.
CP_EXPORT cpBool cpArbiterIsRemoval(const cpArbiter *arb)
Returns true if the separate callback is due to a shape being removed from the space.
CP_EXPORT cpBool cpArbiterIsFirstContact(const cpArbiter *arb)
Returns true if this is the first step a pair of objects started colliding.
CP_EXPORT void cpArbiterGetBodies(const cpArbiter *arb, cpBody **a, cpBody **b)
Return the colliding bodies involved for this arbiter.
CP_EXPORT void cpArbiterSetRestitution(cpArbiter *arb, cpFloat restitution)
Override the restitution (elasticity) that will be applied to the pair of colliding objects.
CP_EXPORT cpVect cpArbiterGetNormal(const cpArbiter *arb)
Get the normal of the collision.
CP_EXPORT void cpArbiterSetUserData(cpArbiter *arb, cpDataPointer userData)
Set a user data point associated with this pair of colliding objects.
Definition chipmunk_structs.h:124
Definition chipmunk_structs.h:36
A struct that wraps up the important collision data for an arbiter.
Definition cpArbiter.h:88
int count
The number of contact points in the set.
Definition cpArbiter.h:90
cpVect normal
The normal of the collision.
Definition cpArbiter.h:93
cpVect pointA
The position of the contact on the surface of each shape.
Definition cpArbiter.h:98
struct cpContactPointSet::@1 points[2]
The array of contact points.
cpFloat distance
Penetration distance of the two shapes.
Definition cpArbiter.h:101
Definition chipmunk_structs.h:178
Definition chipmunk_types.h:251