b2d.world

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

Query and cast functions for the Defold-owned Box2D v2 world.

API

b2d.world.cast_mover

Type: FUNCTION The capsule table has center1, center2, and radius fields. The return value is the fraction of translation that can be traveled before collision, or 1 if there is no hit.

Parameters

Returns

b2d.world.cast_ray

Type: FUNCTION Cast a ray.

Parameters

Returns

b2d.world.cast_ray

Type: FUNCTION The translation is the ray displacement from origin. Result order is not guaranteed by Box2D.

Parameters

Returns

b2d.world.cast_ray_closest

Type: FUNCTION Cast a ray and return the closest hit.

Parameters

Returns

b2d.world.cast_ray_closest

Type: FUNCTION The translation is the ray displacement from origin.

Parameters

Returns

b2d.world.cast_shape

Type: FUNCTION Uses Box2D v2 time-of-impact for fixture child shapes that support distance proxies. Grid fixture children are skipped.

Parameters

Returns

b2d.world.cast_shape

Type: FUNCTION The shape table uses the same circle, capsule, segment, polygon, and box formats as b2d.body.create_shape. The translation is the shape displacement.

Parameters

Returns

b2d.world.collide_mover

Type: FUNCTION The capsule table has center1, center2, and radius fields. Plane result tables include shape, normal, offset, and hit.

Parameters

Returns

b2d.world.enable_continuous

Type: FUNCTION Enable or disable continuous collision.

Parameters

b2d.world.enable_sleeping

Type: FUNCTION Enable or disable world sleeping.

Parameters

b2d.world.enable_speculative

Type: FUNCTION Enable or disable speculative collision.

Parameters

b2d.world.enable_warm_starting

Type: FUNCTION Enable or disable warm starting.

Parameters

b2d.world.explode

Type: FUNCTION The definition table requires position, radius, falloff, and impulse_per_length. It may also include mask_bits.

Parameters

b2d.world.get_awake_body_count

Type: FUNCTION Get the number of awake bodies.

Parameters

Returns

b2d.world.get_counters

Type: FUNCTION The returned table contains body_count, shape_count, contact_count, joint_count, island_count, stack_used, static_tree_height, tree_height, byte_count, task_count, and color_counts.

Parameters

Returns

b2d.world.get_gravity

Type: FUNCTION Get world gravity.

Parameters

Returns

b2d.world.get_hit_event_threshold

Type: FUNCTION Get the hit event threshold.

Parameters

Returns

b2d.world.get_maximum_linear_speed

Type: FUNCTION Get the maximum linear speed.

Parameters

Returns

b2d.world.get_profile

Type: FUNCTION The returned table contains Box2D timing fields including step, pairs, collide, solve, merge_islands, prepare_stages, solve_constraints, prepare_constraints, integrate_velocities, warm_start, solve_impulses, integrate_positions, relax_impulses, apply_restitution, store_impulses, split_islands, transforms, hit_events, refit, bullets, sleep_islands, and sensors.

Parameters

Returns

b2d.world.get_restitution_threshold

Type: FUNCTION Get the restitution threshold.

Parameters

Returns

b2d.world.is_continuous_enabled

Type: FUNCTION Get whether continuous collision is enabled.

Parameters

Returns

b2d.world.is_locked

Type: FUNCTION The world is locked during callbacks and some simulation phases. Functions marked as locked during callbacks cannot be called while this returns true.

Parameters

Returns

b2d.world.is_sleeping_enabled

Type: FUNCTION Get whether world sleeping is enabled.

Parameters

Returns

b2d.world.is_valid

Type: FUNCTION Check whether a world handle is valid.

Parameters

Returns

b2d.world.is_warm_starting_enabled

Type: FUNCTION Get whether warm starting is enabled.

Parameters

Returns

b2d.world.overlap_aabb

Type: FUNCTION Overlap an AABB.

Parameters

Returns

b2d.world.overlap_aabb

Type: FUNCTION The AABB table has lower and upper vector3 fields.

Parameters

Returns

b2d.world.overlap_shape

Type: FUNCTION Overlap a shape.

Parameters

Returns

b2d.world.overlap_shape

Type: FUNCTION The shape table uses the same circle, capsule, segment, polygon, and box formats as b2d.body.create_shape.

Parameters

Returns

b2d.world.rebuild_static_tree

Type: FUNCTION Rebuild the static broad-phase tree.

Parameters

b2d.world.set_contact_tuning

Type: FUNCTION Set contact solver tuning.

Parameters

b2d.world.set_gravity

Type: FUNCTION Set world gravity.

Parameters

b2d.world.set_hit_event_threshold

Type: FUNCTION Set the hit event threshold.

Parameters

b2d.world.set_joint_tuning

Type: FUNCTION Set joint solver tuning.

Parameters

b2d.world.set_maximum_linear_speed

Type: FUNCTION Set the maximum linear speed.

Parameters

b2d.world.set_restitution_threshold

Type: FUNCTION Collisions below this relative speed use inelastic collision response.

Parameters