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.
Type: FUNCTION The return value is the fraction of translation that can be traveled before collision, or 1 if there is no hit.
Parameters
world (b2World) - worldcapsule (b2d.mover_capsule) - mover capsuletranslation (vector3) - capsule displacementfilter (b2d.query_filter) (optional) - optional query filterReturns
fraction (number) - travel fraction before collisionType: FUNCTION Cast a ray.
Parameters
world (b2World) - world from b2d.get_world or b2d.body.get_worldorigin (vector3) - world ray origintranslation (vector3) - world ray translationfilter (b2d.query_filter) (optional) - optional query filtermax_results (integer) (optional) - optional maximum result countReturns
hits (b2d.fixture_cast_hit[]) - ray-cast hitsstats (b2d.tree_stats) - broad-phase query statisticsType: FUNCTION The translation is the ray displacement from origin. Result order is not guaranteed by Box2D.
Parameters
world (b2World) - worldorigin (vector3) - ray start positiontranslation (vector3) - ray displacementfilter (b2d.query_filter) (optional) - optional query filtermax_results (integer) (optional) - optional maximum result count. Omit or pass 0 for unlimited results.Returns
hits (b2d.shape_cast_hit[]) - ray-cast hitsstats (b2d.tree_stats) - broad-phase query statisticsType: FUNCTION Cast a ray and return the closest hit.
Parameters
world (b2World) - world from b2d.get_world or b2d.body.get_worldorigin (vector3) - world ray origintranslation (vector3) - world ray translationfilter (b2d.query_filter) (optional) - optional query filterReturns
hit (b2d.fixture_cast_hit |
nil) - closest hit, or nil |
Type: FUNCTION The translation is the ray displacement from origin.
Parameters
world (b2World) - worldorigin (vector3) - ray start positiontranslation (vector3) - ray displacementfilter (b2d.query_filter) (optional) - optional query filterReturns
hit (b2d.shape_cast_hit |
nil) - closest hit, or nil |
Type: FUNCTION Uses Box2D v2 time-of-impact for fixture child shapes that support distance proxies. Grid fixture children are skipped.
Parameters
world (b2World) - world from b2d.get_world or b2d.body.get_worldshape (b2d.shape.definition) - query shapetranslation (vector3) - world shape translationfilter (b2d.query_filter) (optional) - optional query filtermax_results (integer) (optional) - optional maximum result countReturns
hits (b2d.fixture_cast_hit[]) - shape-cast hitsstats (b2d.tree_stats) - broad-phase query statisticsType: FUNCTION The translation is the shape displacement.
Parameters
world (b2World) - worldshape (b2d.shape.definition) - cast shapetranslation (vector3) - shape displacementfilter (b2d.query_filter) (optional) - optional query filtermax_results (integer) (optional) - optional maximum result count. Omit or pass 0 for unlimited results.Returns
hits (b2d.shape_cast_hit[]) - shape-cast hitsstats (b2d.tree_stats) - broad-phase query statisticsType: FUNCTION Collide a mover capsule against the world.
Parameters
world (b2World) - worldcapsule (b2d.mover_capsule) - mover capsulefilter (b2d.query_filter) (optional) - optional query filtermax_results (integer) (optional) - optional maximum result count. Omit or pass 0 for unlimited results.Returns
planes (b2d.mover_plane[]) - collision planesType: FUNCTION Enable or disable continuous collision.
Parameters
world (b2World) - worldenable (boolean) - true to enable continuous collisionType: FUNCTION Enable or disable world sleeping.
Parameters
world (b2World) - worldenable (boolean) - true to allow sleepingType: FUNCTION Enable or disable speculative collision.
Parameters
world (b2World) - worldenable (boolean) - true to enable speculative collisionType: FUNCTION Enable or disable warm starting.
Parameters
world (b2World) - worldenable (boolean) - true to enable warm startingType: FUNCTION Apply an explosion impulse.
Parameters
world (b2World) - worlddefinition (b2d.explosion_definition) - explosion definitionType: FUNCTION Get the number of awake bodies.
Parameters
world (b2World) - worldReturns
count (integer) - awake body countType: FUNCTION Get world counters.
Parameters
world (b2World) - worldReturns
counters (b2d.world_counters) - world countersType: FUNCTION Get world gravity.
Parameters
world (b2World) - worldReturns
gravity (vector3) - gravity vectorType: FUNCTION Get the hit event threshold.
Parameters
world (b2World) - worldReturns
threshold (number) - hit event threshold in project units per secondType: FUNCTION Get the maximum linear speed.
Parameters
world (b2World) - worldReturns
speed (number) - maximum linear speed in project units per secondType: FUNCTION Get world profiling data.
Parameters
world (b2World) - worldReturns
profile (b2d.world_profile) - world profiling dataType: FUNCTION Get the restitution threshold.
Parameters
world (b2World) - worldReturns
threshold (number) - restitution threshold in project units per secondType: FUNCTION Get whether continuous collision is enabled.
Parameters
world (b2World) - worldReturns
enabled (boolean) - true if continuous collision is enabledType: 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
world (b2World) - worldReturns
locked (boolean) - true if the world is lockedType: FUNCTION Get whether world sleeping is enabled.
Parameters
world (b2World) - worldReturns
enabled (boolean) - true if sleeping is enabledType: FUNCTION Check whether a world handle is valid.
Parameters
world (b2World) - worldReturns
valid (boolean) - true if the world handle is validType: FUNCTION Get whether warm starting is enabled.
Parameters
world (b2World) - worldReturns
enabled (boolean) - true if warm starting is enabledType: FUNCTION Overlap an AABB.
Parameters
world (b2World) - world from b2d.get_world or b2d.body.get_worldaabb (b2d.aabb) - query boundsfilter (b2d.query_filter) (optional) - optional query filtermax_results (integer) (optional) - optional maximum result countReturns
fixtures (b2d.fixture_info[]) - overlapping fixturesstats (b2d.tree_stats) - broad-phase query statisticsType: FUNCTION Find shapes overlapping an AABB.
Parameters
world (b2World) - worldaabb (b2d.aabb) - query boundsfilter (b2d.query_filter) (optional) - optional query filtermax_results (integer) (optional) - optional maximum result count. Omit or pass 0 for unlimited results.Returns
hits (b2d.shape_info[]) - overlapping shapesstats (b2d.tree_stats) - broad-phase query statisticsType: FUNCTION Overlap a shape.
Parameters
world (b2World) - world from b2d.get_world or b2d.body.get_worldshape (b2d.shape.definition) - query shapefilter (b2d.query_filter) (optional) - optional query filtermax_results (integer) (optional) - optional maximum result countReturns
fixtures (b2d.fixture_info[]) - overlapping fixturesstats (b2d.tree_stats) - broad-phase query statisticsType: FUNCTION Find shapes overlapping a shape proxy.
Parameters
world (b2World) - worldshape (b2d.shape.definition) - query shapefilter (b2d.query_filter) (optional) - optional query filtermax_results (integer) (optional) - optional maximum result count. Omit or pass 0 for unlimited results.Returns
hits (b2d.shape_info[]) - overlapping shapesstats (b2d.tree_stats) - broad-phase query statisticsType: FUNCTION Rebuild the static broad-phase tree.
Parameters
world (b2World) - worldType: FUNCTION Set contact solver tuning.
Parameters
world (b2World) - worldhertz (number) - contact stiffness frequency in hertzdamping_ratio (number) - contact damping ratiopushout (number) - pushout velocity in project units per secondType: FUNCTION Set world gravity.
Parameters
world (b2World) - worldgravity (vector3) - gravity vectorType: FUNCTION Set the hit event threshold.
Parameters
world (b2World) - worldthreshold (number) - hit event threshold in project units per secondType: FUNCTION Set joint solver tuning.
Parameters
world (b2World) - worldhertz (number) - joint stiffness frequency in hertzdamping_ratio (number) - joint damping ratioType: FUNCTION Set the maximum linear speed.
Parameters
world (b2World) - worldspeed (number) - maximum linear speed in project units per secondType: FUNCTION Collisions below this relative speed use inelastic collision response.
Parameters
world (b2World) - worldthreshold (number) - restitution threshold in project units per second