import { b2Vec2, XY } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
import { b2AABB, b2RayCastInput } from "./b2_collision";
/**
 * A node in the dynamic tree. The client does not interact with this directly.
 */
export declare class b2TreeNode<T> {
    readonly id: number;
    /** Enlarged AABB */
    readonly aabb: b2AABB;
    userData: T | null;
    parent: b2TreeNode<T> | null;
    child1: b2TreeNode<T> | null;
    child2: b2TreeNode<T> | null;
    height: number;
    moved: boolean;
    constructor();
    Reset(): void;
    IsLeaf(): boolean;
    GetArea(): number;
    /** Compute the height of a sub-tree. */
    ComputeHeight(): number;
    GetMaxBalance(): number;
    ShiftOrigin(newOrigin: XY): void;
}
/**
 * A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt.
 * A dynamic tree arranges data in a binary tree to accelerate
 * queries such as volume queries and ray casts. Leafs are proxies
 * with an AABB. In the tree we expand the proxy AABB by b2_fatAABBFactor
 * so that the proxy AABB is bigger than the client object. This allows the client
 * object to move by small amounts without triggering a tree update.
 *
 * Nodes are pooled
 */
export declare class b2DynamicTree<T> {
    private m_root;
    private m_freeList;
    /**
     * Query an AABB for overlapping proxies. The callback class
     * is called for each proxy that overlaps the supplied AABB.
     */
    Query(aabb: b2AABB, callback: (node: b2TreeNode<T>) => boolean): void;
    QueryPoint(point: XY, callback: (node: b2TreeNode<T>) => boolean): void;
    /**
     * Ray-cast against the proxies in the tree. This relies on the callback
     * to perform a exact ray-cast in the case were the proxy contains a shape.
     * The callback also performs the any collision filtering. This has performance
     * roughly equal to k * log(n), where k is the number of collisions and n is the
     * number of proxies in the tree.
     * @param input the ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
     * @param callback a callback class that is called for each proxy that is hit by the ray.
     */
    RayCast(input: b2RayCastInput, callback: (input: b2RayCastInput, node: b2TreeNode<T>) => number): void;
    /** Allocate a node from the pool. Grow the pool if necessary. */
    private AllocateNode;
    /** Return a node to the pool. */
    private FreeNode;
    /**
     * Create a proxy. Provide a tight fitting AABB and a userData pointer.
     * Create a proxy in the tree as a leaf node. We return the index
     * of the node instead of a pointer so that we can grow
     * the node pool.
     */
    CreateProxy(aabb: b2AABB, userData: T): b2TreeNode<T>;
    /** Destroy a proxy. This asserts if the id is invalid. */
    DestroyProxy(node: b2TreeNode<T>): void;
    /**
     * Move a proxy with a swepted AABB. If the proxy has moved outside of its fattened AABB,
     * the function returns immediately.
     * @return true if the proxy was re-inserted.
     */
    MoveProxy(node: b2TreeNode<T>, aabb: b2AABB, displacement: b2Readonly<b2Vec2>): boolean;
    private InsertLeaf;
    private RemoveLeaf;
    /**
     * Perform a left or right rotation if node A is imbalanced.
     * Returns the new root index.
     */
    private Balance;
    /**
     * Compute the height of the binary tree in O(N) time. Should not be
     * called often.
     */
    GetHeight(): number;
    /** Get the ratio of the sum of the node areas to the root area. */
    GetAreaRatio(): number;
    /**
     * Get the maximum balance of an node in the tree. The balance is the difference
     * in height of the two children of a node.
     */
    GetMaxBalance(): number;
    /**
     * Shift the world origin. Useful for large worlds.
     * The shift formula is: position -= newOrigin
     * @param newOrigin the new origin with respect to the old origin
     */
    ShiftOrigin(newOrigin: XY): void;
}
//# sourceMappingURL=b2_dynamic_tree.d.ts.map