@box2d/debug-draw
Version:
Debug drawing helper for @box2d
300 lines • 11.4 kB
TypeScript
import { b2Vec2, b2Transform, XY } from "../common/b2_math";
import { b2AABB } from "../collision/b2_collision";
import { b2Shape } from "../collision/b2_shape";
import { b2Contact } from "./b2_contact";
import { b2Joint } from "./b2_joint";
import { b2AreaJoint, b2IAreaJointDef } from "./b2_area_joint";
import { b2DistanceJoint, b2IDistanceJointDef } from "./b2_distance_joint";
import { b2FrictionJoint, b2IFrictionJointDef } from "./b2_friction_joint";
import { b2GearJoint, b2IGearJointDef } from "./b2_gear_joint";
import { b2MotorJoint, b2IMotorJointDef } from "./b2_motor_joint";
import { b2MouseJoint, b2IMouseJointDef } from "./b2_mouse_joint";
import { b2PrismaticJoint, b2IPrismaticJointDef } from "./b2_prismatic_joint";
import { b2PulleyJoint, b2IPulleyJointDef } from "./b2_pulley_joint";
import { b2RevoluteJoint, b2IRevoluteJointDef } from "./b2_revolute_joint";
import { b2WeldJoint, b2IWeldJointDef } from "./b2_weld_joint";
import { b2WheelJoint, b2IWheelJointDef } from "./b2_wheel_joint";
import { b2Body, b2BodyDef } from "./b2_body";
import { b2ContactManager } from "./b2_contact_manager";
import { b2Fixture } from "./b2_fixture";
import { b2Profile, b2TimeStep, b2StepConfig } from "./b2_time_step";
import { b2ContactFilter, b2ContactListener, b2DestructionListener, b2QueryCallback, b2RayCastCallback } from "./b2_world_callbacks";
import { b2Readonly } from "../common/b2_readonly";
/**
* The world class manages all physics entities, dynamic simulation,
* and asynchronous queries.
*/
export declare class b2World {
/** @internal */
readonly m_contactManager: b2ContactManager;
private m_bodyList;
private m_jointList;
private m_bodyCount;
private m_jointCount;
private readonly m_gravity;
private m_allowSleep;
private m_destructionListener;
/**
* This is used to compute the time step ratio to
* support a variable time step.
*/
private m_inv_dt0;
/** @internal */
m_newContacts: boolean;
private m_locked;
private m_clearForces;
private m_warmStarting;
private m_continuousPhysics;
private m_subStepping;
private m_stepComplete;
private readonly m_profile;
private readonly m_island;
private readonly s_stack;
private constructor();
/**
* Construct a world object.
*
* @param gravity The world gravity vector.
*/
static Create(gravity: XY): b2World;
/**
* Register a destruction listener. The listener is owned by you and must
* remain in scope.
*/
SetDestructionListener(listener: b2DestructionListener | null): void;
/**
* Get the current destruction listener
*/
GetDestructionListener(): b2DestructionListener | null;
/**
* Register a contact filter to provide specific control over collision.
* Otherwise the default filter is used (b2_defaultFilter). The listener is
* owned by you and must remain in scope.
*/
SetContactFilter(filter: b2ContactFilter): void;
/**
* Register a contact event listener. The listener is owned by you and must
* remain in scope.
*/
SetContactListener(listener: b2ContactListener): void;
/**
* Create a rigid body given a definition. No reference to the definition
* is retained.
*
* @warning This function is locked during callbacks.
*/
CreateBody(def?: b2BodyDef): b2Body;
/**
* Destroy a rigid body given a definition. No reference to the definition
* is retained. This function is locked during callbacks.
*
* @warning This automatically deletes all associated shapes and joints.
* @warning This function is locked during callbacks.
*/
DestroyBody(b: b2Body): void;
private static Joint_Create;
/**
* 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.
*/
CreateJoint(def: b2IAreaJointDef): b2AreaJoint;
CreateJoint(def: b2IDistanceJointDef): b2DistanceJoint;
CreateJoint(def: b2IFrictionJointDef): b2FrictionJoint;
CreateJoint(def: b2IGearJointDef): b2GearJoint;
CreateJoint(def: b2IMotorJointDef): b2MotorJoint;
CreateJoint(def: b2IMouseJointDef): b2MouseJoint;
CreateJoint(def: b2IPrismaticJointDef): b2PrismaticJoint;
CreateJoint(def: b2IPulleyJointDef): b2PulleyJoint;
CreateJoint(def: b2IRevoluteJointDef): b2RevoluteJoint;
CreateJoint(def: b2IWeldJointDef): b2WeldJoint;
CreateJoint(def: b2IWheelJointDef): b2WheelJoint;
/**
* Destroy a joint. This may cause the connected bodies to begin colliding.
*
* @warning This function is locked during callbacks.
*/
DestroyJoint(j: b2Joint): void;
private static Step_s_step;
private static Step_s_stepTimer;
private static Step_s_timer;
/**
* Take a time step. This performs collision detection, integration,
* and constraint solution.
*
* @param dt The amount of time to simulate, this should not vary.
* @param iterations Config for the solvers.
*/
Step(dt: number, iterations: b2StepConfig): void;
/**
* Manually clear the force buffer on all bodies. By default, forces are cleared automatically
* after each call to Step. The default behavior is modified by calling SetAutoClearForces.
* The purpose of this function is to support sub-stepping. Sub-stepping is often used to maintain
* a fixed sized time step under a variable frame-rate.
* When you perform sub-stepping you will disable auto clearing of forces and instead call
* ClearForces after all sub-steps are complete in one pass of your game loop.
*
* @see SetAutoClearForces
*/
ClearForces(): void;
/**
* Query the world for all fixtures that potentially overlap the
* provided AABB.
*
* @param aabb The query box.
* @param callback A user implemented callback class or function.
*/
QueryAABB(aabb: b2AABB, callback: b2QueryCallback): void;
QueryAllAABB(aabb: b2AABB, out?: b2Fixture[]): b2Fixture[];
/**
* Query the world for all fixtures that potentially overlap the
* provided point.
*
* @param point The query point.
* @param callback A user implemented callback class or function.
*/
QueryPointAABB(point: XY, callback: b2QueryCallback): void;
QueryAllPointAABB(point: XY, out?: b2Fixture[]): b2Fixture[];
private static QueryFixtureShape_s_aabb;
QueryFixtureShape(shape: b2Shape, index: number, transform: b2Readonly<b2Transform>, callback: b2QueryCallback): void;
QueryAllFixtureShape(shape: b2Shape, index: number, transform: b2Readonly<b2Transform>, out?: b2Fixture[]): b2Fixture[];
QueryFixturePoint(point: XY, callback: b2QueryCallback): void;
QueryAllFixturePoint(point: XY, out?: b2Fixture[]): b2Fixture[];
private static RayCast_s_input;
private static RayCast_s_output;
private static RayCast_s_point;
/**
* 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.
*
* @param point1 The ray starting point
* @param point2 The ray ending point
* @param callback A user implemented callback class or function.
*/
RayCast(point1: XY, point2: XY, callback: b2RayCastCallback): void;
RayCastOne(point1: XY, point2: XY): b2Fixture | null;
RayCastAll(point1: XY, point2: XY, out?: b2Fixture[]): b2Fixture[];
/**
* 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 The head of the world body list.
*/
GetBodyList(): b2Body | null;
/**
* 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 The head of the world joint list.
*/
GetJointList(): b2Joint | null;
/**
* 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 The head of the world contact list.
* @warning contacts are created and destroyed in the middle of a time step.
* Use b2ContactListener to avoid missing contacts.
*/
GetContactList(): b2Contact | null;
/**
* Enable/disable sleep.
*/
SetAllowSleeping(flag: boolean): void;
GetAllowSleeping(): boolean;
/**
* Enable/disable warm starting. For testing.
*/
SetWarmStarting(flag: boolean): void;
GetWarmStarting(): boolean;
/**
* Enable/disable continuous physics. For testing.
*/
SetContinuousPhysics(flag: boolean): void;
GetContinuousPhysics(): boolean;
/**
* Enable/disable single stepped continuous physics. For testing.
*/
SetSubStepping(flag: boolean): void;
GetSubStepping(): boolean;
/**
* Get the number of broad-phase proxies.
*/
GetProxyCount(): number;
/**
* Get the number of bodies.
*/
GetBodyCount(): number;
/**
* Get the number of joints.
*/
GetJointCount(): number;
/**
* Get the number of contacts (each may have 0 or more contact points).
*/
GetContactCount(): number;
/**
* Get the height of the dynamic tree.
*/
GetTreeHeight(): number;
/**
* Get the balance of the dynamic tree.
*/
GetTreeBalance(): number;
/**
* Get the quality metric of the dynamic tree. The smaller the better.
* The minimum is 1.
*/
GetTreeQuality(): number;
/**
* Change the global gravity vector.
*/
SetGravity(gravity: XY): void;
/**
* Get the global gravity vector.
*/
GetGravity(): b2Readonly<b2Vec2>;
/**
* Is the world locked (in the middle of a time step).
*/
IsLocked(): boolean;
/**
* Set flag to control automatic clearing of forces after each time step.
*/
SetAutoClearForces(flag: boolean): void;
/**
* Get the flag that controls automatic clearing of forces after each time step.
*/
GetAutoClearForces(): boolean;
/**
* Shift the world origin. Useful for large worlds.
* The body shift formula is: position -= newOrigin
*
* @param newOrigin The new origin with respect to the old origin
*/
ShiftOrigin(newOrigin: XY): void;
/**
* Get the contact manager for testing.
*/
GetContactManager(): b2ContactManager;
/**
* Get the current profile.
*/
GetProfile(): b2Profile;
/** Find islands, integrate and solve constraints, solve position constraints */
private Solve;
private static SolveTOI_s_subStep;
private static SolveTOI_s_backup;
private static SolveTOI_s_backup1;
private static SolveTOI_s_backup2;
private static SolveTOI_s_toi_input;
private static SolveTOI_s_toi_output;
/**
* Find TOI contacts and solve them.
* @internal
*/
SolveTOI(step: b2TimeStep): void;
}
//# sourceMappingURL=b2_world.d.ts.map