struct CP::Arbiter

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

Instance Method Summary

Instance Method Detail

def bodies : Tuple(Body, Body) #

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.


[View source]
def 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.


[View source]
def 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.


[View source]
def 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.


[View source]
def 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.


[View source]
def 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.


[View source]
def 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.


[View source]
def 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.


[View source]
def 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.


[View source]
def contact_point_set : ContactPointSet #

Return a contact set from an arbiter.


[View source]
def 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!


[View source]
def count : Int32 #

Get the number of contact points for this arbiter.


[View source]
def data : Pointer(Void) #

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


[View source]
def data=(data) #

[View source]
def depth(i : Int) : Float64 #

Get the depth of the i-th contact point.


[View source]
def first_contact? : Bool #

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.


[View source]
def friction : Float64 #

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.


[View source]
def friction=(friction : Number) #

[View source]
def ignore : Bool #

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.


[View source]
def normal : Vect #

Get the normal of the collision.


[View source]
def point_a(i : Int) : Vect #

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


[View source]
def point_b(i : Int) : Vect #

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


[View source]
def removal? : Bool #

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


[View source]
def restitution : Float64 #

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.


[View source]
def restitution=(restitution : Number) #

[View source]
def shapes : Tuple(Shape, Shape) #

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.


[View source]
def surface_velocity : Vect #

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.


[View source]
def surface_velocity=(vr : Vect) #

[View source]
def total_impulse : Vect #

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.


[View source]
def total_ke : Float64 #

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.


[View source]