/**
 * physics.ts — 2D physics simulation for animation (ragdoll, cloth).
 *
 * Verlet integration with constraints for realistic body/cloth simulation.
 */
import type { RigPose } from "./rig/rigTypes";
export interface Vec2 {
    x: number;
    y: number;
}
export interface PhysicsParticle {
    pos: Vec2;
    prev: Vec2;
    acc: Vec2;
    mass: number;
    pinned: boolean;
}
export interface DistanceConstraint {
    a: number;
    b: number;
    restLength: number;
    stiffness: number;
}
export interface PhysicsConfig {
    gravity: Vec2;
    damping: number;
    iterations: number;
    timestep: number;
}
export interface RagdollConfig {
    size: number;
    gravity?: Vec2;
    damping?: number;
}
export interface ClothConfig {
    width: number;
    height: number;
    cols: number;
    rows: number;
    pinTop?: boolean;
    stiffness?: number;
    gravity?: Vec2;
    damping?: number;
}
export interface ClothSimulation {
    particles: PhysicsParticle[];
    constraints: DistanceConstraint[];
    cols: number;
    rows: number;
}
export interface RagdollSimulation {
    particles: PhysicsParticle[];
    constraints: DistanceConstraint[];
    boneMap: Record<string, number>;
}
/** Create a ragdoll simulation from a rig pose. */
export declare function createRagdoll(cfg: RagdollConfig): RagdollSimulation;
/** Step the ragdoll simulation forward by one frame. */
export declare function stepRagdoll(sim: RagdollSimulation, config?: Partial<PhysicsConfig>): void;
/** Extract a RigPose from the current ragdoll particle positions. */
export declare function ragdollToPose(sim: RagdollSimulation): RigPose;
/** Apply a force impulse to a ragdoll particle. */
export declare function applyImpulse(sim: RagdollSimulation, boneName: string, force: Vec2): void;
/** Create a cloth simulation grid. */
export declare function createCloth(cfg: ClothConfig): ClothSimulation;
/** Step the cloth simulation forward by one frame. */
export declare function stepCloth(sim: ClothSimulation, config?: Partial<PhysicsConfig>): void;
/** Get cloth vertex positions as a flat array [x0,y0, x1,y1, ...]. */
export declare function clothVertices(sim: ClothSimulation): number[];
/** Pin or unpin a cloth particle by grid position. */
export declare function pinClothParticle(sim: ClothSimulation, col: number, row: number, pinned: boolean): void;
export type Ragdoll = RagdollSimulation;
export type Cloth = ClothSimulation;
