UNPKG

@box2d/debug-draw

Version:

Debug drawing helper for @box2d

230 lines 8.09 kB
import { b2Transform, XY } from "../common/b2_math"; import { b2AABB, b2RayCastInput, b2RayCastOutput } from "../collision/b2_collision"; import { b2TreeNode } from "../collision/b2_dynamic_tree"; import { b2Shape, b2ShapeType, b2MassData } from "../collision/b2_shape"; import type { b2Body } from "./b2_body"; import { b2Readonly } from "../common/b2_readonly"; import { b2BroadPhase } from "../collision/b2_broad_phase"; import type { b2FixtureUserData } from ".."; /** * This holds contact filtering data. */ export interface b2Filter { /** The collision category bits. Normally you would just set one bit. */ categoryBits: number; /** * The collision mask bits. This states the categories that this * shape would accept for collision. */ maskBits: number; /** * Collision groups allow a certain group of objects to never collide (negative) * or always collide (positive). Zero means no collision group. Non-zero group * filtering always wins against the mask bits. */ groupIndex: number; } export declare const b2DefaultFilter: Readonly<b2Filter>; /** * A fixture definition is used to create a fixture. This class defines an * abstract fixture definition. You can reuse fixture definitions safely. */ export interface b2FixtureDef { /** * The shape, this must be set. The shape will be cloned, so you * can create the shape on the stack. */ shape: b2Shape; /** Use this to store application specific fixture data. */ userData?: b2FixtureUserData; /** The friction coefficient, usually in the range [0,1]. */ friction?: number; /** The restitution (elasticity) usually in the range [0,1]. */ restitution?: number; /** * Restitution velocity threshold, usually in m/s. Collisions above this * speed have restitution applied (will bounce). */ restitutionThreshold?: number; /** The density, usually in kg/m^2. */ density?: number; /** * A sensor shape collects contact information but never generates a collision * response. */ isSensor?: boolean; /** Contact filtering data. */ filter?: Partial<b2Filter>; } /** * This proxy is used internally to connect fixtures to the broad-phase. */ export declare class b2FixtureProxy { readonly aabb: b2AABB; readonly fixture: b2Fixture; readonly childIndex: number; readonly treeNode: b2TreeNode<b2FixtureProxy>; constructor(fixture: b2Fixture, broadPhase: b2BroadPhase<b2FixtureProxy>, xf: b2Readonly<b2Transform>, childIndex: number); } /** * A fixture is used to attach a shape to a body for collision detection. A fixture * inherits its transform from its parent. Fixtures hold additional non-geometric data * such as friction, collision filters, etc. * Fixtures are created via b2Body::CreateFixture. * * @warning you cannot reuse fixtures. */ export declare class b2Fixture { /** @internal protected */ m_density: number; /** @internal protected */ m_next: b2Fixture | null; /** @internal protected */ readonly m_body: b2Body; /** @internal protected */ readonly m_shape: b2Shape; /** @internal protected */ m_friction: number; /** @internal protected */ m_restitution: number; /** @internal protected */ m_restitutionThreshold: number; /** @internal protected */ readonly m_proxies: b2FixtureProxy[]; /** @internal protected */ get m_proxyCount(): number; protected readonly m_filter: b2Filter; /** @internal protected */ m_isSensor: boolean; protected readonly m_userData: b2FixtureUserData; /** @internal protected */ constructor(body: b2Body, def: b2FixtureDef); /** * Get the type of the child shape. You can use this to down cast to the concrete shape. * * @returns The shape type. */ GetType(): b2ShapeType; /** * Get the child shape. You can modify the child shape, however you should not change the * number of vertices because this will crash some collision caching mechanisms. * Manipulating the shape may lead to non-physical behavior. */ GetShape(): b2Shape; /** * Set if this fixture is a sensor. */ SetSensor(sensor: boolean): void; /** * Is this fixture a sensor (non-solid)? * * @returns The true if the shape is a sensor. */ IsSensor(): boolean; /** * Set the contact filtering data. This will not update contacts until the next time * step when either parent body is active and awake. * This automatically calls Refilter. */ SetFilterData(filter: Readonly<Partial<b2Filter>>): void; /** * Get the contact filtering data. */ GetFilterData(): Readonly<b2Filter>; /** * Call this if you want to establish collision that was previously disabled by b2ContactFilter::ShouldCollide. */ Refilter(): void; /** * Get the parent body of this fixture. * * @returns The parent body. */ GetBody(): b2Body; /** * Get the next fixture in the parent body's fixture list. * * @returns The next shape. */ GetNext(): b2Fixture | null; /** * Get the user data that was assigned in the fixture definition. Use this to * store your application specific data. */ GetUserData(): b2FixtureUserData; /** * 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: b2FixtureUserData): void; /** * Test a point for containment in this fixture. * * @param p A point in world coordinates. */ TestPoint(p: XY): boolean; /** * Cast a ray against this shape. * * @param output The ray-cast results. * @param input The ray-cast input parameters. */ RayCast(output: b2RayCastOutput, input: b2RayCastInput, childIndex: number): boolean; /** * Get the mass data for this fixture. The mass data is based on the density and * the shape. The rotational inertia is about the shape's origin. This operation * may be expensive. */ GetMassData(massData?: b2MassData): b2MassData; /** * Set the density of this fixture. This will _not_ automatically adjust the mass * of the body. You must call b2Body::ResetMassData to update the body's mass. */ SetDensity(density: number): void; /** * Get the density of this fixture. */ GetDensity(): number; /** * Get the coefficient of friction. */ GetFriction(): number; /** * Set the coefficient of friction. This will _not_ change the friction of * existing contacts. */ SetFriction(friction: number): void; /** * Get the coefficient of restitution. */ GetRestitution(): number; /** * Set the coefficient of restitution. This will _not_ change the restitution of * existing contacts. */ SetRestitution(restitution: number): void; /** Get the restitution velocity threshold. */ GetRestitutionThreshold(): number; /** * Set the restitution threshold. This will _not_ change the restitution threshold of * existing contacts. */ SetRestitutionThreshold(threshold: number): void; /** * Get the fixture's AABB. This AABB may be enlarge and/or stale. * If you need a more accurate AABB, compute it using the shape and * the body transform. */ GetAABB(childIndex: number): Readonly<b2AABB>; /** * These support body activation/deactivation. * * @internal protected */ CreateProxies(broadPhase: b2BroadPhase<b2FixtureProxy>, xf: b2Readonly<b2Transform>): void; /** @internal protected */ DestroyProxies(broadPhase: b2BroadPhase<b2FixtureProxy>): void; /** @internal protected */ Synchronize(broadPhase: b2BroadPhase<b2FixtureProxy>, transform1: b2Readonly<b2Transform>, transform2: b2Readonly<b2Transform>): void; } //# sourceMappingURL=b2_fixture.d.ts.map