mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
Implement skeleton constraint toggles (#1290)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user