struct

CP::Arbiter

Inherits Struct / Value / Object

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.

Instance methods

bodies

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.

Source
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.

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.

Source
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.

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.

Source
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.

Source
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.

Source
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.

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.

Source
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.

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.

Source
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.

Source
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.

Source
contact_point_set

Return a contact set from an arbiter.

Source
contact_point_set=(contact_point_set : ContactPointSet)

Replace the contact point set for an arbiter.

This can be a very powerful feature, but use it with caution!

Source
count

Get the number of contact points for this arbiter.

Source
data

The user data pointer associated with this pair of colliding objects.

Source
data=(data)
Source
depth(i : Int) : Float64

Get the depth of the i-th contact point.

Source
first_contact?

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.

Source
friction

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.

Source
friction=(friction : Number)
Source
ignore

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.

Source
normal

Get the normal of the collision.

Source
point_a(i : Int) : Vect

Get the position of the i-th contact point on the surface of the first shape.

Source
point_b(i : Int) : Vect

Get the position of the i-th contact point on the surface of the second shape.

Source
removal?

Returns true during a separate() callback if the callback was invoked due to an object removal.

Source
restitution

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.

Source
restitution=(restitution : Number)
Source
shapes

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.

Source
surface_velocity

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.

Source
surface_velocity=(vr : Vect)
Source
total_impulse

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.

Source
total_ke

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.

Source