b2d.shape

Namespace: b2d.shape Language: Lua Type: Defold Lua File: script_box2d_shape_v2.cpp Source: engine/gamesys/src/gamesys/scripts/box2d/v2/script_box2d_shape_v2.cpp

Constants for functional shape tables used with b2d.body.create_fixture and returned from b2d.fixture.get_shape.

API

b2d.shape.are_contact_events_enabled

Type: FUNCTION Check if contact events are enabled for a shape.

Parameters

Returns

b2d.shape.are_hit_events_enabled

Type: FUNCTION Check if hit events are enabled for a shape.

Parameters

Returns

b2d.shape.are_pre_solve_events_enabled

Type: FUNCTION Check if pre-solve events are enabled for a shape.

Parameters

Returns

b2d.shape.are_sensor_events_enabled

Type: FUNCTION Check if sensor events are enabled for a shape.

Parameters

Returns

b2d.shape.enable_contact_events

Type: FUNCTION Enable or disable contact events for a shape.

Parameters

b2d.shape.enable_hit_events

Type: FUNCTION Enable or disable hit events for a shape.

Parameters

b2d.shape.enable_pre_solve_events

Type: FUNCTION Enable or disable pre-solve events for a shape.

Parameters

b2d.shape.enable_sensor_events

Type: FUNCTION Enable or disable sensor events for a shape.

Parameters

b2d.shape.get_body

Type: FUNCTION Get the body owning a shape.

Parameters

Returns

b2d.shape.get_closest_point

Type: FUNCTION Get the closest point on a shape.

Parameters

Returns

b2d.shape.get_contact_capacity

Type: FUNCTION Get shape contact capacity.

Parameters

Returns

b2d.shape.get_contact_data

Type: FUNCTION Get touching contact data for a shape.

Parameters

Returns

b2d.shape.get_mass_data

Type: FUNCTION Get mass data for a shape.

Parameters

Returns

b2d.shape.get_material

Type: FUNCTION Get shape material id.

Parameters

Returns

b2d.shape.get_sensor_capacity

Type: FUNCTION Get sensor overlap capacity.

Parameters

Returns

b2d.shape.get_sensor_overlaps

Type: FUNCTION Get sensor overlaps.

Parameters

Returns

b2d.shape.get_shape

Type: FUNCTION Get a shape’s geometry.

Parameters

Returns

b2d.shape.get_world

Type: FUNCTION Get the world owning a shape.

Parameters

Returns

b2d.shape.is_valid

Type: FUNCTION Validate a shape handle.

Parameters

Returns

b2d.shape.ray_cast

Type: FUNCTION Ray cast a shape directly.

Parameters

Returns

b2d.shape.set_material

Type: FUNCTION Set shape material id.

Parameters

b2d.shape.set_shape

Type: FUNCTION This updates the shape geometry using the same table format as b2d.body.create_shape and b2d.shape.get_shape. The body mass is not updated unless update_mass is true.

Parameters

Examples

local body = b2d.get_body("#collisionobject")

-- Move a circle shape relative to the body origin.
local circle = b2d.shape.get_shape(body, 1)
circle.center = vmath.vector3(24, 0, 0)
b2d.shape.set_shape(body, 1, circle, true)

-- Replace a segment shape's local endpoints.
b2d.shape.set_shape(body, 2, {
    type = b2d.shape.SHAPE_TYPE_SEGMENT,
    v1 = vmath.vector3(-32, 0, 0),
    v2 = vmath.vector3( 32, 0, 0),
})

-- Update a box shape using the polygon box convenience format.
b2d.shape.set_shape(body, 3, {
    type = b2d.shape.SHAPE_TYPE_BOX,
    hx = 16,
    hy = 8,
    center = vmath.vector3(0, 20, 0),
    angle = math.rad(30),
}, true)

b2d.shape.SHAPE_TYPE_BOX

Type: CONSTANT Uses the polygon enum value, but indicates the hx/hy box convenience format.

b2d.shape.SHAPE_TYPE_BOX

Type: CONSTANT Uses the polygon enum value, but indicates the hx/hy box convenience format.

b2d.shape.SHAPE_TYPE_CAPSULE

Type: CONSTANT Capsule shape type.

b2d.shape.SHAPE_TYPE_CHAIN

Type: CONSTANT Chain shape type.

b2d.shape.SHAPE_TYPE_CIRCLE

Type: CONSTANT Circle shape type.

b2d.shape.SHAPE_TYPE_CIRCLE

Type: CONSTANT Circle shape type.

b2d.shape.SHAPE_TYPE_EDGE

Type: CONSTANT Edge shape type.

b2d.shape.SHAPE_TYPE_EDGE

Type: CONSTANT Compatibility alias for b2d.shape.SHAPE_TYPE_SEGMENT.

b2d.shape.SHAPE_TYPE_GRID

Type: CONSTANT Grid shape type.

b2d.shape.SHAPE_TYPE_POLYGON

Type: CONSTANT Polygon shape type.

b2d.shape.SHAPE_TYPE_POLYGON

Type: CONSTANT Polygon shape type.

b2d.shape.SHAPE_TYPE_SEGMENT

Type: CONSTANT Segment shape type.

b2Shape

Type: TYPEDEF Box2D shape

Parameters