Functions for interacting with fixtures attached to Box2D bodies.
Fixtures are addressed functionally by (body, fixture_index) rather than persistent Lua handles.
Version: alpha
| FUNCTIONS | |
|---|---|
| b2d.fixture.get_aabb() | Get fixture AABB for a child shape. |
| b2d.fixture.get_density() | Get fixture density. |
| b2d.fixture.get_filter_data() | Get fixture filter data for a child shape. |
| b2d.fixture.get_friction() | Get fixture friction. |
| b2d.fixture.get_restitution() | Get fixture restitution. |
| b2d.fixture.get_shape() | Get the fixture shape as a functional shape table. |
| b2d.fixture.get_type() | Get the fixture type. |
| b2d.fixture.is_sensor() | Check if a fixture is a sensor. |
| b2d.fixture.refilter() | Refilter a fixture. |
| b2d.fixture.set_density() | Set fixture density. |
| b2d.fixture.set_filter_data() | Set fixture filter data for a child shape. |
| b2d.fixture.set_friction() | Set fixture friction. |
| b2d.fixture.set_restitution() | Set fixture restitution. |
| b2d.fixture.set_sensor() | Set sensor mode for a fixture. |
| b2d.fixture.set_shape() | Set the fixture shape geometry. |
| b2d.fixture.test_point() | Test a point against a fixture. |
b2d.fixture.get_aabb(body:b2Body, fixture_index:integer, child_index:integer)→aabb:b2d.aabb
Get fixture AABB for a child shape.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
child_index |
integer |
1-based child shape index |
RETURNS
aabb |
b2d.aabb |
the fixture AABB |
b2d.fixture.get_density(body:b2Body, fixture_index:integer)→density:number
Get fixture density.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
RETURNS
density |
number |
density in kg/m^2 |
b2d.fixture.get_filter_data(body:b2Body, fixture_index:integer, child_index:integer)→filter:b2d.filter
Get fixture filter data for a child shape.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
child_index |
integer |
1-based child shape index |
RETURNS
filter |
b2d.filter |
the filter data |
b2d.fixture.get_friction(body:b2Body, fixture_index:integer)→friction:number
Get fixture friction.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
RETURNS
friction |
number |
b2d.fixture.get_restitution(body:b2Body, fixture_index:integer)→restitution:number
Get fixture restitution.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
RETURNS
restitution |
number |
b2d.fixture.get_shape(body:b2Body, fixture_index:integer)→shape:b2d.shape.definition
Get the fixture shape as a functional shape table.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
RETURNS
shape |
b2d.shape.definition |
the shape definition, suitable for reuse in b2d.body.create_fixture |
b2d.fixture.get_type(body:b2Body, fixture_index:integer)→type:b2d.shape.SHAPE_TYPE
Get the fixture type.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
RETURNS
type |
b2d.shape.SHAPE_TYPE |
b2d.fixture.is_sensor(body:b2Body, fixture_index:integer)→enabled:boolean
Check if a fixture is a sensor.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
RETURNS
enabled |
boolean |
b2d.fixture.refilter(body:b2Body, fixture_index:integer, touch_proxies:boolean)
Refilter a fixture.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
touch_proxies |
boolean |
if true, touch broad-phase proxies |
b2d.fixture.set_density(body:b2Body, fixture_index:integer, density:number, update_mass:boolean)
Set fixture density.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
density |
number |
density in kg/m^2 |
update_mass |
boolean |
if true, reset body mass data after the change |
b2d.fixture.set_filter_data(body:b2Body, fixture_index:integer, child_index:integer, filter:b2d.filter)
Set fixture filter data for a child shape.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
child_index |
integer |
1-based child shape index |
filter |
b2d.filter |
the filter data |
b2d.fixture.set_friction(body:b2Body, fixture_index:integer, friction:number)
Set fixture friction.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
friction |
number |
b2d.fixture.set_restitution(body:b2Body, fixture_index:integer, restitution:number)
Set fixture restitution.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
restitution |
number |
b2d.fixture.set_sensor(body:b2Body, fixture_index:integer, enabled:boolean)
Set sensor mode for a fixture.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
enabled |
boolean |
b2d.fixture.set_shape(body:b2Body, fixture_index:integer, shape:b2d.shape.definition, update_mass:boolean)
This updates the existing Box2D v2 shape using the same table format as
b2d.body.create_fixture and b2d.fixture.get_shape.
The shape type must match the current fixture shape type. Polygon updates must
keep the same vertex count. Chain shape geometry cannot be updated in-place.
The body mass is not updated unless update_mass is true.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
shape |
b2d.shape.definition |
the shape definition |
update_mass |
boolean |
if true, reset body mass data after the change |
EXAMPLES
local body = b2d.get_body("#collisionobject")
-- Move a circle shape relative to the body origin.
local circle = b2d.fixture.get_shape(body, 1)
circle.center = vmath.vector3(24, 0, 0)
b2d.fixture.set_shape(body, 1, circle, true)
-- Replace an edge shape's local endpoints.
b2d.fixture.set_shape(body, 2, {
type = b2d.shape.SHAPE_TYPE_EDGE,
v1 = vmath.vector3(-32, 0, 0),
v2 = vmath.vector3( 32, 0, 0),
})
-- Update a box shape using the polygon box convenience format.
-- The existing polygon must already have four vertices.
b2d.fixture.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.fixture.test_point(body:b2Body, fixture_index:integer, point:vector3)→hit:boolean
Test a point against a fixture.
PARAMETERS
body |
b2Body |
body |
fixture_index |
integer |
1-based fixture index from b2d.body.get_fixtures |
point |
vector3 |
point in world coordinates |
RETURNS
hit |
boolean |