Skip to content

Commit

Permalink
Implement skeleton constraint toggles (#1290)
Browse files Browse the repository at this point in the history
  • Loading branch information
ButterscotchV authored Jan 29, 2025
1 parent eb08cb5 commit d389b5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
) {
Expand All @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d389b5a

Please sign in to comment.