mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-21 17:41:28 -08:00
Fix upper legs twist math
This commit is contained in:
1 parent
d0fa419131
commit
9942e843ff
3 files changed
+9
-9
No files matched your search
@@ -120,7 +120,7 @@ data class SkeletonRatiosConfig(
|
||||
val predictionStrength: Float = 0.30f,
|
||||
val spineCurvature: Float = 0.75f,
|
||||
val imputeSpineFromUpperToLower: Float = DEFAULT_SPINE_UPPER_LOWER,
|
||||
val interpolateUpperLegsTwistWithLowerLegs: Float = 0.8f,
|
||||
val interpolateUpperLegsTwistWithLowerLegs: Float = 0.85f,
|
||||
val skatingCorrectionStrength: Float = 0.5f,
|
||||
)
|
||||
|
||||
|
||||
+6
-6
@@ -4,6 +4,7 @@ import dev.slimevr.config.Settings
|
||||
import dev.slimevr.skeleton.InputSkeleton
|
||||
import dev.slimevr.skeleton.SkeletonInputProcessor
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import solarxr_protocol.datatypes.BodyPart
|
||||
|
||||
/**
|
||||
@@ -15,19 +16,18 @@ import solarxr_protocol.datatypes.BodyPart
|
||||
* @return the rotated Quaternion
|
||||
*/
|
||||
private fun alignRoll(from: Quaternion, to: Quaternion): Quaternion {
|
||||
val r = to.inv() * from
|
||||
val c = Quaternion(r.w, 0f, -r.y, 0f)
|
||||
return (to * r * c).unit()
|
||||
val local = to.localAbout(from)
|
||||
val roll = local.project(Vector3.POS_Y).unit()
|
||||
return roll.globalAbout(from)
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles rotating the upper legs' roll to match the lower legs' roll.
|
||||
*/
|
||||
class UpperLegsRollAlignInputProcessor(val settings: Settings) : SkeletonInputProcessor {
|
||||
class UpperLegsTwistInputProcessor(val settings: Settings) : SkeletonInputProcessor {
|
||||
/**
|
||||
* First value is the BodyPart to be aligned.
|
||||
*
|
||||
* Second value is a source BodyPart
|
||||
* Second value is the source BodyPart.
|
||||
*/
|
||||
private val bodyPartToSources = arrayOf(
|
||||
BodyPart.LEFT_UPPER_LEG to BodyPart.LEFT_LOWER_LEG,
|
||||
@@ -19,7 +19,7 @@ import dev.slimevr.skeleton.inputprocessors.HeadPositionFallbackInputProcessor
|
||||
import dev.slimevr.skeleton.inputprocessors.NeckInputProcessor
|
||||
import dev.slimevr.skeleton.inputprocessors.SpineInputProcessor
|
||||
import dev.slimevr.skeleton.inputprocessors.ToesInputProcessor
|
||||
import dev.slimevr.skeleton.inputprocessors.UpperLegsRollAlignInputProcessor
|
||||
import dev.slimevr.skeleton.inputprocessors.UpperLegsTwistInputProcessor
|
||||
import dev.slimevr.skeleton.targetprocessors.FloorClipTargetProcessor
|
||||
import dev.slimevr.skeleton.targetprocessors.PositionalTargetProcessor
|
||||
import dev.slimevr.skeleton.targetprocessors.SkatingCorrectionTargetProcessor
|
||||
@@ -285,7 +285,7 @@ class Skeleton(
|
||||
FingersInputProcessor(),
|
||||
ToesInputProcessor(),
|
||||
ConstraintInputProcessor(settings),
|
||||
UpperLegsRollAlignInputProcessor(settings),
|
||||
UpperLegsTwistInputProcessor(settings),
|
||||
),
|
||||
// Run on the result of FK and persist
|
||||
fkComputedProcessors = listOf(
|
||||
|
||||
Reference in new issue
Block a user