Options
All
  • Public
  • Public/Protected
  • All
Menu

The world class manages all physics entities, dynamic simulation, and asynchronous queries.

Hierarchy

  • b2World

Index

Constructors

  • Creates a new world.

    Parameters

    • gravity: b2Vec2

      The world gravity vector.

    • doSleep: boolean

      Improvie performance by not simulating inactive bodies.

    Returns b2World

Properties

e_locked: number

Locked

e_newFixture: number

New Fixture

Methods

  • ClearForces(): void
  • Call this after you are done with time steps to clear the forces. You normally call this after each call to Step, unless you are performing sub-steps.

    Returns void

  • Create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies to cease colliding.

    warning

    This function is locked during callbacks.

    Parameters

    Returns b2Joint

    New created joint.

  • Destroy a rigid body given a definition. No reference to the definition is retained. This function is locked during callbacks.

    warning

    This function is locked during callbacks.

    Parameters

    Returns void

  • Destroy a controller given the controller instance.

    warning

    This function is locked during callbacks.

    Parameters

    Returns void

  • DrawDebugData(): void
  • GetBodyCount(): number
  • Get the world body list. With the returned body, use b2Body::GetNext to get the next body in the world list. A NULL body indicates the end of the list.

    Returns b2Body

    The head of the world body list.

  • GetContactCount(): number
  • Get the number of contacts (each may have 0 or more contact points).

    Returns number

    Number of contacts.

  • Get the world contact list. With the returned contact, use b2Contact::GetNext to get the next contact in the world list. A NULL contact indicates the end of the list.

    Returns b2Contact

    The head of the world contact list.

  • The world provides a single static ground body with no collision shapes. You can use this to simplify the creation of joints and static shapes.

    Returns b2Body

    The ground body.

  • GetJointCount(): number
  • Get the world joint list. With the returned joint, use b2Joint::GetNext to get the next joint in the world list. A NULL joint indicates the end of the list.

    Returns b2Joint

    The head of the world joint list.

  • GetProxyCount(): number
  • IsLocked(): boolean
  • Is the world locked (in the middle of a time step).

    Returns boolean

    True if the world is locked and in the middle of a time step, otherwise false.

  • Query the world for all fixtures that potentially overlap the provided AABB.

    Parameters

    • callback: (fixutre: b2Fixture) => boolean

      A user implemented callback class. It should match signature function Callback(fixture:b2Fixture):Boolean. Return true to continue to the next fixture.

    • aabb: b2AABB

      The query bounding box.

    Returns void

  • Query the world for all fixtures that contain a point.

    note

    This provides a feature specific to this port.

    Parameters

    • callback: (fixture: b2Fixture) => boolean

      A user implemented callback class. It should match signature function Callback(fixture:b2Fixture):Boolean. Return true to continue to the next fixture.

    • p: b2Vec2

      The query point.

    Returns void

  • Query the world for all fixtures that precisely overlap the provided transformed shape.

    note

    This provides a feature specific to this port.

    Parameters

    • callback: (fixture: b2Fixture) => boolean

      A user implemented callback class. It should match signature function Callback(fixture:b2Fixture):Boolean. Return true to continue to the next fixture.

    • shape: b2Shape

      The query shape.

    • Optional transform: b2Transform

      Optional transform, default = null.

    Returns void

  • Ray-cast the world for all fixtures in the path of the ray. Your callback Controls whether you get the closest point, any point, or n-points The ray-cast ignores shapes that contain the starting point.

    Parameters

    • callback: (fixture: b2Fixture, point: b2Vec2, normal: b2Vec2, fraction: number) => number

      A callback function which must be of signature: function Callback( fixture:b2Fixture, // The fixture hit by the ray point:b2Vec2, // The point of initial intersection normal:b2Vec2, // The normal vector at the point of intersection fraction:Number // The fractional length along the ray of the intersection ):Number Callback should return the new length of the ray as a fraction of the original length. By returning 0, you immediately terminate. By returning 1, you continue wiht the original ray. By returning the current fraction, you proceed to find the closest point.

    • point1: b2Vec2

      The ray starting point.

    • point2: b2Vec2

      The ray ending point.

    Returns void

  • Ray-cast the world for all fixture in the path of the ray.

    Parameters

    • point1: b2Vec2

      The ray starting point.

    • point2: b2Vec2

      The ray ending point.

    Returns b2Fixture[]

    Array of all the fixtures intersected by the ray.

  • Ray-cast the world for the first fixture in the path of the ray.

    Parameters

    • point1: b2Vec2

      The ray starting point.

    • point2: b2Vec2

      The ray ending point.

    Returns b2Fixture

    First fixture intersected by the ray.

  • Use the given object as a broadphase. The old broadphase will not be cleanly emptied.

    warning

    This function is locked during callbacks.

    Parameters

    Returns void

  • Register a contact filter to provide specific control over collision. Otherwise the default filter is used (b2_defaultFilter).

    Parameters

    Returns void

  • SetContinuousPhysics(flag: boolean): void
  • Enable/disable continuous physics. For testing.

    Parameters

    • flag: boolean

      True for continuous physics, otherwise false.

    Returns void

  • Register a routine for debug drawing. The debug draw functions are called inside the b2World::Step method, so make sure your renderer is ready to consume draw commands when you call Step().

    Parameters

    Returns void

  • SetGravity(gravity: b2Vec2): void
  • SetWarmStarting(flag: boolean): void
  • Enable/disable warm starting. For testing.

    Parameters

    • flag: boolean

      True for warm starting, otherwise false.

    Returns void

  • Step(dt: number, velocityIterations: number, positionIterations: number): void
  • Take a time step. This performs collision detection, integration, and constraint solution.

    Parameters

    • dt: number

      The amout of time to simulate, this should not vary.

    • velocityIterations: number

      For the velocity constraint solver.

    • positionIterations: number

      For the position constraint solver.

    Returns void

  • Validate(): void

Generated using TypeDoc