Implement skeleton constraint toggles (#1290)

This commit is contained in:
Butterscotch!
2025-01-29 08:56:36 -05:00
committed by GitHub
parent eb08cb5aa1
commit d389b5acec
2 changed files with 7 additions and 4 deletions

View File

@@ -67,7 +67,7 @@ class Bone(val boneType: BoneType, val rotationConstraint: Constraint) {
* this bone and all of its children while
* enforcing rotation constraints.
*/
fun updateWithConstraints() {
fun updateWithConstraints(correctConstraints: Boolean) {
val initialRot = getGlobalRotation()
val newRot = rotationConstraint.applyConstraint(initialRot, this)
setRotationRaw(newRot)
@@ -82,7 +82,8 @@ class Bone(val boneType: BoneType, val rotationConstraint: Constraint) {
val deltaRot = newRot * initialRot.inv()
val angle = deltaRot.angleR()
if (angle > Constraint.ANGLE_THRESHOLD &&
if (correctConstraints &&
angle > Constraint.ANGLE_THRESHOLD &&
(attachedTracker?.filteringHandler?.getFilteringImpact() ?: 1f) < Constraint.FILTER_IMPACT_THRESHOLD &&
(parent?.attachedTracker?.filteringHandler?.getFilteringImpact() ?: 0f) < Constraint.FILTER_IMPACT_THRESHOLD
) {
@@ -92,7 +93,7 @@ class Bone(val boneType: BoneType, val rotationConstraint: Constraint) {
// Recursively apply constraints and update children.
for (child in children) {
child.updateWithConstraints()
child.updateWithConstraints(correctConstraints)
}
}

View File

@@ -511,7 +511,9 @@ class HumanSkeleton(
updateTransforms()
updateBones()
headBone.updateWithConstraints()
if (enforceConstraints) {
headBone.updateWithConstraints(correctConstraints)
}
updateComputedTrackers()
// Don't run post-processing if the tracking is paused