struct CP::ShapeFilter

Overview

Fast collision filtering type that is used to determine if two objects collide before calling collision or query callbacks.

Chipmunk has two primary means of ignoring collisions: groups and category masks.

Groups are used to ignore collisions between parts on a complex object. A ragdoll is a good example. When jointing an arm onto the torso, you'll want them to allow them to overlap. Groups allow you to do exactly that. Shapes that have the same group don't generate collisions. So by placing all of the shapes in a ragdoll in the same group, you'll prevent it from colliding against other parts of itself.

Category masks allow you to mark which categories an object belongs to and which categories it collidies with. By default, objects exist in every category and collide with every category.

The type of categories and mask in ShapeFilter is UInt32.

There is one last way of filtering collisions using collision handlers. See the section on callbacks for more information. Collision handlers can be more flexible, but can be slower. Fast collision filtering rejects collisions before running the expensive collision detection code, so using groups or category masks is preferred.

Defined in:

chipmunk/query.cr

Constant Summary

ALL = new(NO_GROUP, ALL_CATEGORIES, ALL_CATEGORIES)

Collision filter value for a shape that will collide with anything except NONE.

ALL_CATEGORIES = ~(Bitmask.new(0))

Value for signifying that a shape is in every category.

NO_GROUP = Group.new(0)

Value signifying that a shape is in no group.

NONE = new(NO_GROUP, ~ALL_CATEGORIES, ~ALL_CATEGORIES)

Collision filter value for a shape that does not collide with anything.

Constructors

Instance Method Summary

Constructor Detail

def self.new(group : Int = NO_GROUP, categories : Int = ALL_CATEGORIES, mask : Int = ALL_CATEGORIES) #

[View source]

Instance Method Detail

def categories : Bitmask #

A bitmask of user definable categories that this object belongs to.

The category/mask combinations of both objects in a collision must agree for a collision to occur.


[View source]
def categories=(categories : Bitmask) #

[View source]
def group : Group #

Two objects with the same non-zero group value do not collide.

This is generally used to group objects in a composite object together to disable self collisions.


[View source]
def group=(group : Group) #

[View source]
def mask : Bitmask #

A bitmask of user definable category types that this object object collides with.

The category/mask combinations of both objects in a collision must agree for a collision to occur.


[View source]
def mask=(mask : Bitmask) #

[View source]