abstract class CP::Shape

Overview

Defines the shape of a rigid body.

Direct Known Subclasses

Defined in:

chipmunk/shape.cr

Instance Method Summary

Instance Method Detail

def area : Float64 #

Get the calculated area of this shape.


[View source]
def bb : BB #

Get the bounding box that contains the shape given its current position and angle.

Only guaranteed to be valid after #cache_bb or Space#step is called. Moving a body that a shape is connected to does not update its bounding box. For shapes used for queries that aren't attached to bodies, you can also use #update.


[View source]
def body : Body | Nil #

The Body this shape is added to.


[View source]
def body=(body : Body | Nil) #

Set the Body this shape is added to.

Can only be used if the shape is not currently added to a space.


[View source]
def cache_bb : BB #

Update, cache and return the bounding box of a shape based on the body it's attached to.


[View source]
def center_of_gravity : Vect #

Get the centroid of this shape.


[View source]
def collide(b : Shape) : ContactPointSet #

Return contact information about two shapes.


[View source]
def collision_type : CollisionType #

User defined collision type for the shape.

See Space#add_collision_handler for more information.


[View source]
def collision_type=(collision_type : Int) #

[View source]
def density : Float64 #

Get the density of the shape if you are having Chipmunk calculate mass properties for you.


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

Set the density of this shape to have Chipmunk calculate mass properties for you.


[View source]
def elasticity : Float64 #

The elasticity of this shape.

A value of 0.0 gives no bounce, while a value of 1.0 will give a 'perfect' bounce. However due to inaccuracies in the simulation using 1.0 or greater is not recommended.


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

[View source]
def filter : ShapeFilter #

The collision filtering parameters of this shape.


[View source]
def filter=(filter : ShapeFilter) #

[View source]
def friction : Float64 #

The friction of this shape.

Chipmunk uses the Coulomb friction model, a value of 0.0 is frictionless. A value over 1.0 is also perfectly fine.


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

[View source]
def mass : Float64 #

Get the mass of the shape if you are having Chipmunk calculate mass properties for you.


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

Set the mass of this shape to have Chipmunk calculate mass properties for you.


[View source]
def moment : Float64 #

Get the calculated moment of inertia for this shape.


[View source]
def point_query(p : Vect) : PointQueryInfo #

Perform a nearest point query. It finds the closest point on the surface of shape to a specific point.


[View source]
def segment_query(a : Vect, b : Vect, radius : Number = 0) : SegmentQueryInfo | Nil #

Perform a segment query against a shape: check if the line segment from start to end intersects the shape.


[View source]
def sensor=(sensor : Bool) #

[View source]
def sensor? : Bool #

Is the shape set to be a sensor or not?

Sensors only call collision callbacks, and never generate real collisions.


[View source]
def space : Space | Nil #

The Space this shape is added to.


[View source]
def surface_velocity : Vect #

The surface velocity of this shape.

Useful for creating conveyor belts or players that move around. This value is only used when calculating friction, not resolving the collision.


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

[View source]
def update(transform : Transform) : BB #

Update, cache and return the bounding box of a shape with an explicit transformation.

Useful if you have a shape without a body and want to use it for querying.


[View source]