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.
Type: FUNCTION Check if contact events are enabled for a shape.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
enabled (boolean) - true if contact events are enabledType: FUNCTION Check if hit events are enabled for a shape.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
enabled (boolean) - true if hit events are enabledType: FUNCTION Check if pre-solve events are enabled for a shape.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
enabled (boolean) - true if pre-solve events are enabledType: FUNCTION Check if sensor events are enabled for a shape.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
enabled (boolean) - true if sensor events are enabledType: FUNCTION Enable or disable contact events for a shape.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexenable (boolean) - true to enable contact eventsType: FUNCTION Enable or disable hit events for a shape.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexenable (boolean) - true to enable hit eventsType: FUNCTION Enable or disable pre-solve events for a shape.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexenable (boolean) - true to enable pre-solve eventsType: FUNCTION Enable or disable sensor events for a shape.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexenable (boolean) - true to enable sensor eventsType: FUNCTION Get the body owning a shape.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
body (b2Body) - owning bodyType: FUNCTION Get the closest point on a shape.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indextarget (vector3) - world target pointReturns
point (vector3) - closest world point on the shapeType: FUNCTION Get shape contact capacity.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
capacity (number) - maximum contact data countType: FUNCTION Get touching contact data for a shape.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
contacts (table) - array of contact tablesType: FUNCTION Get mass data for a shape.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
data (table) - table with mass, center, and inertiaType: FUNCTION Get shape material id.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
material (number) - shape material idType: FUNCTION Get sensor overlap capacity.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
capacity (number) - maximum sensor overlap countType: FUNCTION Get sensor overlaps.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
overlaps (table) - array of shape info tablesType: FUNCTION Get a shape’s geometry.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
shape (table) - shape table with numeric type from b2d.shape.SHAPE_TYPE_*Type: FUNCTION Get the world owning a shape.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
world (b2World) - owning worldType: FUNCTION Validate a shape handle.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexReturns
valid (boolean) - true if the shape handle still refers to a live Box2D shapeType: FUNCTION Ray cast a shape directly.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexorigin (vector3) - world ray origintranslation (vector3) - world ray translationmax_fraction (number) - optional maximum translation fraction, defaults to 1Returns
hit (table) - hit table with point, normal, fraction, and iterations, or nilType: FUNCTION Set shape material id.
Parameters
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexmaterial (number) - shape material idType: 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
shape_id (b2Shape) - shape handle from a shape info table, or pass body, shape_indexdefinition (table) - shape table with numeric type from b2d.shape.SHAPE_TYPE_*update_mass (boolean) - true to reset body mass from shapesExamples
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)
Type: CONSTANT Uses the polygon enum value, but indicates the hx/hy box convenience format.
Type: CONSTANT Uses the polygon enum value, but indicates the hx/hy box convenience format.
Type: CONSTANT Capsule shape type.
Type: CONSTANT Chain shape type.
Type: CONSTANT Circle shape type.
Type: CONSTANT Circle shape type.
Type: CONSTANT Edge shape type.
Type: CONSTANT Compatibility alias for b2d.shape.SHAPE_TYPE_SEGMENT.
Type: CONSTANT Grid shape type.
Type: CONSTANT Polygon shape type.
Type: CONSTANT Polygon shape type.
Type: CONSTANT Segment shape type.
Type: TYPEDEF Box2D shape
Parameters
value (userdata)