struct CP::Arbiter
- CP::Arbiter
- Struct
- Value
- Object
Overview
The Arbiter object encapsulates a pair of colliding shapes and all of the data about their collision.
They are created when a collision starts, and persist until those shapes are no longer colliding.
Warning: Because arbiters are handled by the space you should never hold on to an arbiter as you don't know when it will be destroyed! Use them within the callback where they are given to you and then forget about them or copy out the information you need from them.
Defined in:
chipmunk/collision.crInstance Method Summary
-
#bodies : Tuple(Body, Body)
Return the colliding bodies involved for this arbiter.
-
#call_wildcard_begin_a(space : Space) : Bool
If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly.
-
#call_wildcard_begin_b(space : Space) : Bool
If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly.
-
#call_wildcard_post_solve_a(space : Space)
If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly.
-
#call_wildcard_post_solve_b(space : Space)
If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly.
-
#call_wildcard_pre_solve_a(space : Space) : Bool
If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly.
-
#call_wildcard_pre_solve_b(space : Space) : Bool
If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly.
-
#call_wildcard_separate_a(space : Space)
If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly.
-
#call_wildcard_separate_b(space : Space)
If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly.
-
#contact_point_set : ContactPointSet
Return a contact set from an arbiter.
-
#contact_point_set=(contact_point_set : ContactPointSet)
Replace the contact point set for an arbiter.
-
#count : Int32
Get the number of contact points for this arbiter.
-
#data : Pointer(Void)
The user data pointer associated with this pair of colliding objects.
- #data=(data)
-
#depth(i : Int) : Float64
Get the depth of the i-th contact point.
-
#first_contact? : Bool
Returns true if this is the first step a pair of objects started colliding.
-
#friction : Float64
The friction coefficient that will be applied to the pair of colliding objects.
- #friction=(friction : Number)
-
#ignore : Bool
Mark a collision pair to be ignored until the two objects separate.
-
#normal : Vect
Get the normal of the collision.
-
#point_a(i : Int) : Vect
Get the position of the i-th contact point on the surface of the first shape.
-
#point_b(i : Int) : Vect
Get the position of the i-th contact point on the surface of the second shape.
-
#removal? : Bool
Returns true during a
separate()
callback if the callback was invoked due to an object removal. -
#restitution : Float64
The restitution (elasticity) that will be applied to the pair of colliding objects.
- #restitution=(restitution : Number)
-
#shapes : Tuple(Shape, Shape)
Return the colliding shapes involved for this arbiter.
-
#surface_velocity : Vect
The relative surface velocity of the two shapes in contact.
- #surface_velocity=(vr : Vect)
-
#total_impulse : Vect
Calculate the total impulse including the friction that was applied by this arbiter.
-
#total_ke : Float64
Calculate the amount of energy lost in a collision including static, but not dynamic friction.
Instance Method Detail
Return the colliding bodies involved for this arbiter.
The order of the collision_type
the bodies are associated with values will match
the order set when the collision handler was registered.
If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly.
You must decide how to handle the wildcard's return value since it may disagree with the other wildcard handler's return value or your own.
If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly.
You must decide how to handle the wildcard's return value since it may disagree with the other wildcard handler's return value or your own.
If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly.
If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly.
If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly.
You must decide how to handle the wildcard's return value since it may disagree with the other wildcard handler's return value or your own.
If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly.
You must decide how to handle the wildcard's return value since it may disagree with the other wildcard handler's return value or your own.
If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly.
If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly.
Replace the contact point set for an arbiter.
This can be a very powerful feature, but use it with caution!
Returns true if this is the first step a pair of objects started colliding.
This can be useful for sound effects for instance. If it's the first
frame for a certain collision, check the energy of the collision in a
post_step()
callback and use that to determine the volume of a sound
effect to play.
The friction coefficient that will be applied to the pair of colliding objects.
Setting the value in a pre_solve()
callback will override the value
calculated by the space. The default calculation multiplies the
friction of the two shapes together.
Mark a collision pair to be ignored until the two objects separate.
Pre-solve and post-solve callbacks will not be called, but the separate callback will be called.
Get the position of the i-th contact point on the surface of the first shape.
Get the position of the i-th contact point on the surface of the second shape.
Returns true during a separate()
callback if the callback was
invoked due to an object removal.
The restitution (elasticity) that will be applied to the pair of colliding objects.
Setting the value in a pre_solve()
callback will override the value
calculated by the space. The default calculation multiplies the
elasticity of the two shapes together.
Return the colliding shapes involved for this arbiter.
The order of their collision_type
values will match
the order set when the collision handler was registered.
The relative surface velocity of the two shapes in contact.
Setting the value in a pre_solve()
callback will override the value
calculated by the space. the default calculation subtracts the
surface velocity of the second shape from the first and then projects
that onto the tangent of the collision. This is so that only
friction is affected by default calculation. Using a custom
calculation, you can make something that responds like a pinball
bumper, or where the surface velocity is dependent on the location
of the contact point.
Calculate the total impulse including the friction that was applied by this arbiter.
This function should only be called from a post-solve, post-step or each_arbiter
callback.
Calculate the amount of energy lost in a collision including static, but not dynamic friction.
This function should only be called from a post-solve, post-step or each_arbiter
callback.