Constraint#
-
struct nvConstraint#
Constraint base struct.
-
enum nvConstraintType#
Constraint types.
Values:
-
enumerator nvConstraintType_DISTANCEJOINT#
Distance joint constraint type. See nvDistanceJoint.
-
enumerator nvConstraintType_HINGEJOINT#
Hinge joint constraint type. See nvHingeJoint.
-
enumerator nvConstraintType_DISTANCEJOINT#
Spring Constraint#
-
struct nvSpring#
Spring constraint definition.
A spring constraint is a damped spring with rest length, stiffness and damping value.
Public Members
-
nv_float length#
Resting length of the spring.
-
nv_float stiffness#
Stiffness (strength) of the spring.
-
nv_float damping#
Damping of the spring.
-
nv_float target_vel#
Target relative velocity.
-
nv_float damping_bias#
Damping bias.
-
nv_float mass#
Constraint effective mass.
-
nv_float jc#
Accumulated constraint impulse.
-
nv_float length#
-
nvConstraint *nvSpring_new(nvBody *a, nvBody *b, nvVector2 anchor_a, nvVector2 anchor_b, nv_float length, nv_float stiffness, nv_float damping)#
Create a new spring constraint.
Leave one of the body parameters as :code:
NULL
to link the body to world. Don’t forget to change the anchor point to be in world space as well.- Parameters:
a – First body
b – Second body
anchor_a – Local anchor point on body A
anchor_b – Local anchor point on body B
length – Length of the spring
stiffness – Stiffness (strength) of the spring
damping – Damping of the spring
- Returns:
Distance Joint Constraint#
-
struct nvDistanceJoint#
Distance joint constraint definition.
A distance joint constraints the distance of two points on the two bodies to be constant. This acts like as if the two bodies are linked with a solid bar. TODO: lower upper limit
-
nvConstraint *nvDistanceJoint_new(nvBody *a, nvBody *b, nvVector2 anchor_a, nvVector2 anchor_b, nv_float length)#
Create a new distance joint constraint.
Leave one of the body parameters as :code:
NULL
to link the body to world. Don’t forget to change the anchor point to be in world space as well.- Parameters:
a – First body
b – Second body
anchor_a – Local anchor point on body A
anchor_b – Local anchor point on body B
length – Length of the joint
- Returns:
Hinge Joint Constraint#
-
struct nvHingeJoint#
Hinge joint constraint definition.
A hinge joint, also known as revolute join, allows the bodies to rotate around a common axis. Ensuring the relative orientation of the bodies remains fixed.
Public Members
-
bool enable_limits#
Enable angular limits or not.
-
nv_float upper_limit#
Upper angle limit.
-
nv_float lower_limit#
Lower angle limit.
-
nv_float angle#
Angle of the constraint.
-
nv_float upper_impulse#
Accumulated upper limit impulse.
-
nv_float lower_impulse#
Accumulated lower limit impulse.
-
nv_float reference_angle#
Reference angle for the constrain.
-
nv_float axial_mass#
Axial effective mass.
-
nv_float bias#
Distance constraint position correction bias.
-
nv_float mass#
Distance constraint effective mass.
-
nv_float jc#
Accumulated distance constraint impulse.
-
bool enable_limits#
-
nvConstraint *nvHingeJoint_new(nvBody *a, nvBody *b, nvVector2 anchor)#
Create a new hinge joint constraint.
Leave one of the body parameters as :code:
NULL
to link the body to world. Don’t forget to change the anchor point to be in world space as well.- Parameters:
a – First body
b – Second body
anchor_a – Anchor point in world space.
- Returns: