java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.NonCopyable
com.github.stephengold.joltjni.Constraint
- All Implemented Interfaces:
ConstConstraint,ConstJoltPhysicsObject,RefTarget,AutoCloseable,Comparable<JoltPhysicsObject>
- Direct Known Subclasses:
TwoBodyConstraint,VehicleConstraint
The abstract base class for physics constraints.
-
Method Summary
Modifier and TypeMethodDescriptionintReturn the constraint's priority when solving.Generate settings to reconstruct the constraint.booleanTest whether the constraint is enabled.intReturn the override for the number of position iterations used in the solver.intReturn the override for the number of velocity iterations used in the solver.intCount the active references to the nativeConstraint.Return the constraint's subtype.getType()Return the constraint's type.booleanisActive()Test whether the constraint is active.voidnotifyShapeChanged(int bodyId, Vec3Arg deltaCom) Notify the constraint that the shape of the specified body has changed and its center of mass has shifted bydeltaCom.voidrestoreState(StateRecorder recorder) Restore the state of the constraint prior to replay.voidsaveState(StateRecorder recorder) Save the state of the constraint, for possible replay.voidsetConstraintPriority(int level) Alter the constraint's priority when solving.voidMark the nativeConstraintas embedded.voidsetEnabled(boolean setting) Enable or disable the constraint.voidsetNumPositionStepsOverride(int setting) Alter the override for the number of position iterations used in the solver.voidsetNumVelocityStepsOverride(int setting) Alter the override for the number of velocity iterations used in the solver.protected final voidsetVirtualAddressAsCoOwner(long constraintVa) Assign a native object (assuming there's none already assigned) and designate the JVM object as a co-owner.toRef()Create a counted reference to the nativeConstraint.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, vaMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, targetVa
-
Method Details
-
notifyShapeChanged
Notify the constraint that the shape of the specified body has changed and its center of mass has shifted bydeltaCom.- Parameters:
bodyId- the ID of the body that changeddeltaCom- the offset of the shift (not null, unaffected)
-
restoreState
Restore the state of the constraint prior to replay.- Parameters:
recorder- to read state from (not null)
-
setConstraintPriority
public void setConstraintPriority(int level) Alter the constraint's priority when solving.- Parameters:
level- the desired priority level
-
setEnabled
public void setEnabled(boolean setting) Enable or disable the constraint.- Parameters:
setting-trueto enable orfalseto disable
-
setNumPositionStepsOverride
public void setNumPositionStepsOverride(int setting) Alter the override for the number of position iterations used in the solver.- Parameters:
setting- the number of iterations, or 0 to use the default inPhysicsSettings
-
setNumVelocityStepsOverride
public void setNumVelocityStepsOverride(int setting) Alter the override for the number of velocity iterations used in the solver.- Parameters:
setting- the number of iterations, or 0 to use the default inPhysicsSettings
-
setVirtualAddressAsCoOwner
protected final void setVirtualAddressAsCoOwner(long constraintVa) Assign a native object (assuming there's none already assigned) and designate the JVM object as a co-owner.- Parameters:
constraintVa- the virtual address of the native object to assign (not zero)
-
getConstraintPriority
public int getConstraintPriority()Return the constraint's priority when solving. The constraint is unaffected.- Specified by:
getConstraintPriorityin interfaceConstConstraint- Returns:
- the priority level
-
getConstraintSettings
Generate settings to reconstruct the constraint. The constraint is unaffected.- Specified by:
getConstraintSettingsin interfaceConstConstraint- Returns:
- a new counted reference to a new settings object
-
getEnabled
public boolean getEnabled()Test whether the constraint is enabled. The constraint is unaffected.- Specified by:
getEnabledin interfaceConstConstraint- Returns:
trueif enabled, otherwisefalse
-
getNumPositionStepsOverride
public int getNumPositionStepsOverride()Return the override for the number of position iterations used in the solver. The constraint is unaffected.- Specified by:
getNumPositionStepsOverridein interfaceConstConstraint- Returns:
- the number of iterations, or 0 to use the default in
PhysicsSettings
-
getNumVelocityStepsOverride
public int getNumVelocityStepsOverride()Return the override for the number of velocity iterations used in the solver. The constraint is unaffected.- Specified by:
getNumVelocityStepsOverridein interfaceConstConstraint- Returns:
- the number of iterations, or 0 to use the default in
PhysicsSettings
-
getSubType
Return the constraint's subtype. The constraint is unaffected.- Specified by:
getSubTypein interfaceConstConstraint- Returns:
- an enum value (not null)
-
getType
Return the constraint's type. The constraint is unaffected.- Specified by:
getTypein interfaceConstConstraint- Returns:
- an enum value (not null)
-
isActive
public boolean isActive()Test whether the constraint is active. The constraint is unaffected.- Specified by:
isActivein interfaceConstConstraint- Returns:
trueif active, otherwisefalse
-
saveState
Save the state of the constraint, for possible replay. The constraint is unaffected.- Specified by:
saveStatein interfaceConstConstraint- Parameters:
recorder- the recorder to write to (not null)
-
getRefCount
public int getRefCount()Count the active references to the nativeConstraint. The constraint is unaffected.- Specified by:
getRefCountin interfaceRefTarget- Returns:
- the count (≥0)
-
setEmbedded
public void setEmbedded()Mark the nativeConstraintas embedded.- Specified by:
setEmbeddedin interfaceRefTarget
-
toRef
Create a counted reference to the nativeConstraint.
-