@box2d/debug-draw
Version:
Debug drawing helper for @box2d
175 lines • 5.79 kB
TypeScript
import type { b2JointUserData } from "..";
import { b2Draw } from "../common/b2_draw";
import { XY } from "../common/b2_math";
import type { b2Body } from "./b2_body";
import { b2SolverData } from "./b2_time_step";
export declare enum b2JointType {
e_unknownJoint = 0,
e_revoluteJoint = 1,
e_prismaticJoint = 2,
e_distanceJoint = 3,
e_pulleyJoint = 4,
e_mouseJoint = 5,
e_gearJoint = 6,
e_wheelJoint = 7,
e_weldJoint = 8,
e_frictionJoint = 9,
e_motorJoint = 10,
e_areaJoint = 11
}
/**
* A joint edge is used to connect bodies and joints together
* in a joint graph where each body is a node and each joint
* is an edge. A joint edge belongs to a doubly linked list
* maintained in each attached body. Each joint has two joint
* nodes, one for each attached body.
*/
export declare class b2JointEdge {
/** Provides quick access to the other body attached. */
readonly other: b2Body;
/** The joint */
readonly joint: b2Joint;
/** The previous joint edge in the body's joint list */
prev: b2JointEdge | null;
/** The next joint edge in the body's joint list */
next: b2JointEdge | null;
constructor(joint: b2Joint, other: b2Body);
}
/**
* Joint definitions are used to construct joints.
*/
export interface b2IJointDef {
/** The joint type is set automatically for concrete joint types. */
type: b2JointType;
/** Use this to attach application specific data to your joints. */
userData: b2JointUserData;
/** The first attached body. */
bodyA: b2Body;
/** The second attached body. */
bodyB: b2Body;
/** Set this flag to true if the attached bodies should collide. */
collideConnected?: boolean;
}
/**
* Joint definitions are used to construct joints.
*/
export declare abstract class b2JointDef implements b2IJointDef {
/** The joint type is set automatically for concrete joint types. */
readonly type: b2JointType;
/** Use this to attach application specific data to your joints. */
readonly userData: b2JointUserData;
/** The first attached body. */
bodyA: b2Body;
/** The second attached body. */
bodyB: b2Body;
/** Set this flag to true if the attached bodies should collide. */
collideConnected: boolean;
constructor(type: b2JointType);
}
/**
* Utility to compute linear stiffness values from frequency and damping ratio
*/
export declare function b2LinearStiffness(def: {
stiffness: number;
damping: number;
}, frequencyHertz: number, dampingRatio: number, bodyA: b2Body, bodyB: b2Body): void;
/**
* Utility to compute rotational stiffness values frequency and damping ratio
*/
export declare function b2AngularStiffness(def: {
stiffness: number;
damping: number;
}, frequencyHertz: number, dampingRatio: number, bodyA: b2Body, bodyB: b2Body): void;
/**
* The base joint class. Joints are used to constraint two bodies together in
* various fashions. Some joints also feature limits and motors.
*/
export declare abstract class b2Joint {
protected readonly m_type: b2JointType;
/** @internal protected */
m_prev: b2Joint | null;
/** @internal protected */
m_next: b2Joint | null;
/** @internal protected */
readonly m_edgeA: b2JointEdge;
/** @internal protected */
readonly m_edgeB: b2JointEdge;
/** @internal protected */
m_bodyA: b2Body;
/** @internal protected */
m_bodyB: b2Body;
/** @internal protected */
m_islandFlag: boolean;
/** @internal protected */
m_collideConnected: boolean;
protected readonly m_userData: b2JointUserData;
protected constructor(def: b2IJointDef);
/**
* Get the type of the concrete joint.
*/
GetType(): b2JointType;
/**
* Get the first body attached to this joint.
*/
GetBodyA(): b2Body;
/**
* Get the second body attached to this joint.
*/
GetBodyB(): b2Body;
/**
* Get the anchor point on bodyA in world coordinates.
*/
abstract GetAnchorA<T extends XY>(out: T): T;
/**
* Get the anchor point on bodyB in world coordinates.
*/
abstract GetAnchorB<T extends XY>(out: T): T;
/**
* Get the reaction force on bodyB at the joint anchor in Newtons.
*/
abstract GetReactionForce<T extends XY>(inv_dt: number, out: T): T;
/**
* Get the reaction torque on bodyB in N*m.
*/
abstract GetReactionTorque(inv_dt: number): number;
/**
* Get the next joint the world joint list.
*/
GetNext(): b2Joint | null;
/**
* Get the user data reference.
*/
GetUserData(): b2JointUserData;
/**
* Set the user data. Use this to store your application specific data.
* This is a merge operation. Only specified keys will be overridden.
*/
SetUserData(data: b2JointUserData): void;
/**
* Short-cut function to determine if either body is enabled.
*/
IsEnabled(): boolean;
/**
* Get collide connected.
* Note: modifying the collide connect flag won't work correctly because
* the flag is only checked when fixture AABBs begin to overlap.
*/
GetCollideConnected(): boolean;
/**
* Shift the origin for any points stored in world coordinates.
*/
ShiftOrigin(_newOrigin: XY): void;
/** @internal protected */
abstract InitVelocityConstraints(data: b2SolverData): void;
/** @internal protected */
abstract SolveVelocityConstraints(data: b2SolverData): void;
/**
* This returns true if the position errors are within tolerance.
*
* @internal protected
*/
abstract SolvePositionConstraints(data: b2SolverData): boolean;
/** Debug draw this joint */
Draw(draw: b2Draw): void;
}
//# sourceMappingURL=b2_joint.d.ts.map