NodeRepulseForceBVH

class NodeRepulseForceBVH(val body: Body) : Force(source)

Represents a repulsive force applied on nodes of a Body using a bounding volume hierarchy (BVH) for optimization.

This force calculates mutual repulsion between nodes within a specified search radius to prevent overlap or maintain specific spatial relationships. The force magnitude decreases smoothly as the distance between nodes approaches the search radius, determined by a smoothstep function.

Constructors

Link copied to clipboard
constructor(body: Body)

Creates a NodeRepulseForceBVH for the specified body.

Properties

Link copied to clipboard
val body: Body

The Body instance on which the repulsive force acts. This serves as the context for the force calculations.

Link copied to clipboard
lateinit var bvh: BVHNode2D

A bounding volume hierarchy data structure used to efficiently detect pairs of intersecting nodes.

Link copied to clipboard

The radius used to search for neighboring nodes to apply repulsion. Default is 10.0.

Link copied to clipboard

The strength of the repulsive force. Default is 1.0.

Functions

Link copied to clipboard
open suspend override fun apply(body: Body, dt: Double)
Link copied to clipboard
open suspend override fun initializeFrame(body: Body)