Reference TShape
Declared in Codebot.Physics.pas on line 242
TShape is a shape attached to a body, which collides with other shapes
TShape = record
public
Ref: cpShape;
class operator Implicit(const Value: TShape): cpShape; inline;
class operator Implicit(const Value: cpShape): TShape; inline;
class operator Equal(const A, B: TShape): Boolean; inline;
class operator NotEqual(const A, B: TShape): Boolean; inline;
{ Remove the shape from its space and free it. If the space is locked, such
as in a collision callback, this happens after the current step. }
procedure Free;
{ True if this refers to nothing }
function IsNil: Boolean; inline;
{ The shape as a circle, a polygon, or a segment }
function AsCircle: TCircle; inline;
function AsPolygon: TPolygon; inline;
function AsSegment: TSegment; inline;
{ Find the closest point on the surface of the shape to P. The result is the
distance to the point, which is negative if P is inside the shape. }
function PointQuery(const P: TVec2; out Info: cpPointQueryInfoStruct): Float;
{ Test if a segment from A to B with a radius hits the shape }
function SegmentQuery(const A, B: TVec2; Radius: Float; out Info: cpSegmentQueryInfoStruct): Boolean;
{ Return contact information about this shape and another }
function Collide(Shape: TShape): cpContactPointSetStruct;
{ Update, cache, and return the bounding box using the body transform }
function CacheBB: cpBB;
{ Update, cache, and return the bounding box using an explicit transform }
function Update(const Transform: TMatrix2x3): cpBB;
{ The next shape sibling for its body }
property Next: TShape read GetNext;
{ The kind of the shape }
property Kind: TShapeKind read GetKind;
{ Mass and density are mutually exclusive. It's best to set the density and
allow the physics engine to determine the mass based on the area of the
shape }
property Mass: Float read GetMass write SetMass;
{ The density of the shape, which gives it mass from its area }
property Density: Float read GetDensity write SetDensity;
{ The moment of inertia of the shape }
property Moment: Float read GetMoment;
{ The area of the shape }
property Area: Float read GetArea;
{ The center of gravity of the shape }
property CenterOfGravity: TVec2 read GetCenterOfGravity;
{ The bounding box of the shape }
property BoundingBox: cpBB read GetBoundingBox;
{ When a shape is set as a sensor it does not cause changes to physics, but
it can be used with cpCollisionHandler beginFunc and separateFunc to
detect collisions }
property Sensor: Boolean read GetSensor write SetSensor;
{ The bounciness of a shape is determined by multiplying the elasticity of
two shapes. A product of 0 gives no bounce while 1 represents a perfect
bounce }
property Elasticity: Float read GetElasticity write SetElasticity;
{ Friction adds dampening to a shape. A value of 0 is frictionless. Total
friction is a product of two shapes. }
property Friction: Float read GetFriction write SetFriction;
{ Surface velocity is used in the calculation of moving shape friction, such
as a conveyor belt }
property SurfaceVelocity: TVec2 read GetSurfaceVelocity write SetSurfaceVelocity;
{ User definable data associated with the shape }
property UserData: Pointer read GetUserData write SetUserData;
{ Collision filtering explained
Shapes in the same group do not collide with each other. This overrides
the categories and mask properties below.
By default a shape belongs to the nil group and is eligible to collide
with everything. Shapes will only collide if one belongs to a dynamic
body, they are in different groups, and the bits of the categories of each
shape and the mask of the other are non zero when bitwise `and`ed
together. }
property Filter: cpShapeFilter read GetFilter write SetFilter;
{ Shapes in the same group do not collide with each other }
property Group: Pointer read GetGroup write SetGroup;
{ Bitmask defining which categories a shape belongs. Note: defaults to all
or $FFFFFFFF }
property Category: TBitmask read GetCategory write SetCategory;
{ Bitmask defining which categories of other shapes it is allowed to
collide. Note: defaults to all or $FFFFFFFF }
property Mask: TBitmask read GetMask write SetMask;
{ See: cpSpaceAddCollisionHandler for more information }
property CollisionType: TCollisionType read GetCollisionType write SetCollisionType;
end;See also
Float in Codebot.System.pas
TMatrix2x3 in Codebot.Geometry.pas
TVec2 in Codebot.Geometry.pas