Base type for all Nape joints and constraints

Static variables

@:value(false)staticzpp_internalAlloc:Bool = false

@private

Constructor

new()

Variables

active:Bool

Whether this constraint is active or not.

Setting a constraint to be no longer active is a useful way of temporarigly disabling a constraint without having to remove it from a Space.

breakUnderError:Bool

Whether constraint will break once maxError is reached.

This property effects both stiff and non-stiff constraints.

breakUnderForce:Bool

Whether constraint will break once maxForce is reached.

This property effects both stiff and non-stiff constraints, though for the same reasons as those of maxForce, does not make much sense to be used in stiff constraints.

read onlycbTypes:CbTypeList

Set of CbTypes for this constraints for callbacks.

This value cannot at present be set, but can be modified.

compound:Null<Compound>

Compound this Constraints belong to.

If this constraint is in a Space or another Compound and you change its compound, then it will be removed from that Space or Compound.

damping:Float

Damping ratio of elastic properties of constraint.

This property only has an effect when constraint is not stiff.

This value corresponds to in the ideal situation, the damping ratio of the constraints oscillations with 1 corresponding to a total dampening, and values greater than one being over-dampening.

This value must be zero or positive.

@:value(true)debugDraw:Bool = true

Set to disable debug drawing/

When true, this Constraint will not be drawn during debug draw operations unless specifically given as argument to Debug draw() method.

frequency:Float

Frequency of elastic properties of constraint.

This property only has an effect when constraint is not stiff.

This value corresponds to in an ideal situation, the number of spring like oscillations the constraint will make per second.

This value must be strictly positive (0 not allowed).

ignore:Bool

Whether interactions between related Bodys will be ignored.

If true, then the Bodys related to this constraint will not be permitted to interact in anyway, including callbacks.

read onlyisSleeping:Bool

Whether this constraint is sleeping or not.

This property is only defined if the constraint is inside of a Space and is active, otherwise an error will be thrown should you access this property.

This value is immutable, In Nape you do not ever need to manually wake up a Constraint. It will always be done automatically without error.

To manually put a Constraint to sleep is against the very nature of Nape API and so is excluded from the core of Nape. If you really want to do this you should make use of the nape-hacks module.

maxError:Float

The maximum amount of error this constraint is allowed to use.

For stiff constraints, this value only serves to work in conjunction with breakUnderError to permit breaking of the constraint.

For non-stiff constraints, this value will also effect how the constraint behaves when breakUnderError is false by restricting the amount of error that will be resolved; this will not work for stiff constraints.

maxForce:Float

The maximum amount of force this constraint is allowed to use.

This value, whilst still used in a stiff constraint will not work as you might hope for; since a stiff constraint resolves positional error without using impulses, the maxForce will not have any effect on how positional errors are resolved.

This value must be zero or positive.

removeOnBreak:Bool

Whether constraint will be removed when it breaks.

If true, then when constraint is broken it will be removed from the Space. Otherwise it will simple be made inactive.

space:Null<Space>

Space this constraint is inside of.

Whether this constraint is directly in a Space, or part of a Compound which is inside of a space, this value will be equal to that Space.

If this constraint is inside of a Compound, then you cannot modify its Space as the constraint belongs to that Compound.

stiff:Bool

Whether constraint is stiff, or elastic.

A stiff constraint has its positional error resolved directly as with contact penetrations. This is generally a more stable way of solving positional errors but has a side-effect that for example changing the pivot point on a constraint used for mouse control will not cause the objects to swing as the positional error is solved without effecting the velocity of the object which may not be wanted.

If false, then the positional error of the constraint will be resolved in an elastic way using changes in velocity.

read onlyuserData:Dynamic<Dynamic>

Dynamic object for user to store additional data.

This object cannot be set, only its dynamically created properties may be set. In AS3 the type of this property is &#42

This object will be lazily constructed so that until accessed for the first time, will be null internally.

zpp_inner:ZPP_Constraint

@private

Methods

bodyImpulse(body:Body):Vec3

Compute impulse that was applied to the given Body.

This impulse is the actual (mass weighted) change in velocity that occured due to this constraint.

Parameters:

body

The Body to compute impulse for.

Returns:

The impulse that was applied to the body in the previous step.

Throws:

#

If Body is not related to the Constraint.

copy():Constraint

Produce copy of constraint.

All constraint properties except for internal impulse cache and userData field will be copied.

Returns:

The copied Constraint.

impulse():MatMN

Return the constraint-space impulse applied in previous step.

Returns:

A new MatMN representing the constraint space impulse.

@:keeptoString():String

@private

visitBodies(lambda:Body ‑> Void):Void

Apply given function to all Bodys linked to the constraint.

If a body is duplicated in a constraint then it will only be visited once.

Parameters:

lambda

The function to apply to each Body.

Throws:

#

If lambda is null.