C# Class Nez.Verlet.DistanceConstraint

maintains a specified distance betweeen two Particles. The stiffness adjusts how rigid or springy the constraint will be.
Inheritance: Constraint
Show file Open project: prime31/Nez

Public Properties

Property Type Description
restingDistance float
shouldApproximateCollisionsWithPoints bool
stiffness float
tearSensitivity float
totalPointsToApproximateCollisionsWith int

Public Methods

Method Description
DistanceConstraint ( Particle first, Particle second, float stiffness, float distance = -1 ) : System
create ( Particle a, Particle center, Particle c, float stiffness, float angleInDegrees ) : DistanceConstraint

creates a faux angle constraint by figuring out the required distance from a to c for the given angle

debugRender ( Batcher batcher ) : void
setCollidesWithColliders ( bool collidesWithColliders ) : DistanceConstraint

sets whether this Constraint should collide with standard Colliders

setShouldApproximateCollisionsWithPoints ( bool shouldApproximateCollisionsWithPoints ) : DistanceConstraint

sets whether collisions should be approximated by points. This should be used for Constraints that need to collided on both sides. SAT only works with single sided collisions.

setTearSensitivity ( float tearSensitivity ) : DistanceConstraint

sets the tear sensitivity. if the ratio of the current distance / restingDistance is greater than tearSensitivity the Constaint will be removed

solve ( ) : void

Private Methods

Method Description
approximateCollisionsWithPoints ( int collidesWithLayers ) : void
handleCollisions ( int collidesWithLayers ) : void
preparePolygonForCollisionChecks ( Vector2 &midPoint ) : void

Method Details

DistanceConstraint() public method

public DistanceConstraint ( Particle first, Particle second, float stiffness, float distance = -1 ) : System
first Particle
second Particle
stiffness float
distance float
return System

create() public static method

creates a faux angle constraint by figuring out the required distance from a to c for the given angle
public static create ( Particle a, Particle center, Particle c, float stiffness, float angleInDegrees ) : DistanceConstraint
a Particle The alpha component.
center Particle Center.
c Particle C.
stiffness float Stiffness.
angleInDegrees float Angle in degrees.
return DistanceConstraint

debugRender() public method

public debugRender ( Batcher batcher ) : void
batcher Batcher
return void

setCollidesWithColliders() public method

sets whether this Constraint should collide with standard Colliders
public setCollidesWithColliders ( bool collidesWithColliders ) : DistanceConstraint
collidesWithColliders bool If set to true collides with colliders.
return DistanceConstraint

setShouldApproximateCollisionsWithPoints() public method

sets whether collisions should be approximated by points. This should be used for Constraints that need to collided on both sides. SAT only works with single sided collisions.
public setShouldApproximateCollisionsWithPoints ( bool shouldApproximateCollisionsWithPoints ) : DistanceConstraint
shouldApproximateCollisionsWithPoints bool If set to true should approximate collisions with points.
return DistanceConstraint

setTearSensitivity() public method

sets the tear sensitivity. if the ratio of the current distance / restingDistance is greater than tearSensitivity the Constaint will be removed
public setTearSensitivity ( float tearSensitivity ) : DistanceConstraint
tearSensitivity float Tear sensitivity.
return DistanceConstraint

solve() public method

public solve ( ) : void
return void

Property Details

restingDistance public property

the resting distnace of the Constraint. It will always try to get to this distance.
public float restingDistance
return float

shouldApproximateCollisionsWithPoints public property

sets whether collisions should be approximated by points. This should be used for Constraints that need to collided on both sides. SAT only works with single sided collisions.
public bool shouldApproximateCollisionsWithPoints
return bool

stiffness public property

[0-1]. the stiffness of the Constraint. Lower values are more springy and higher are more rigid.
public float stiffness
return float

tearSensitivity public property

if the ratio of the current distance / restingDistance is greater than tearSensitivity the Constaint will be removed. Values should be above 1 and higher values mean rupture wont occur until the Constaint is stretched further.
public float tearSensitivity
return float

totalPointsToApproximateCollisionsWith public property

if shouldApproximateCollisionsWithPoints is true, this controls how accurate the collisions check will be. Higher numbers mean more collisions checks.
public int totalPointsToApproximateCollisionsWith
return int