Compare commits

...
Author SHA1 Message Date
Erimel 7cf14188e6 make foot plant and toe snap less agressive 2026-11-19 16:15:57 -05:00
Erimel 292da8d91f upper waist as default 2026-11-19 16:14:11 -05:00
5 changed files with 43 additions and 24 deletions

No files matched your search

@@ -74,14 +74,14 @@ export function PersonFrontIcon({
<circle
className="body-part-circle"
cx="82"
cy="140"
cy="155"
r={CIRCLE_RADIUS}
id={BodyPart[BodyPart.UPPER_WAIST]}
/>
<circle
className="body-part-circle"
cx="82"
cy="155"
cy="169"
r={CIRCLE_RADIUS}
id={BodyPart[BodyPart.LOWER_WAIST]}
/>
+7 -7
View File
@@ -75,7 +75,7 @@ const ASSIGNABLE_PARTS = new Set(ALL_ASSIGNABLE_PARTS);
type SetupRegionName =
| 'legs'
| 'chest'
| 'upperChest'
| 'hip'
| 'feet'
| 'upperArms'
@@ -96,12 +96,12 @@ const SETUP_REGIONS: {
needs: SetupRegionName[];
}[] = [
{ id: 'legs', parts: [...LEGS_PARTS], needs: [] },
{ id: 'chest', parts: [BodyPart.UPPER_CHEST], needs: [] },
{ id: 'hip', parts: [BodyPart.HIP], needs: ['chest'] },
{ id: 'upperChest', parts: [BodyPart.UPPER_CHEST], needs: [] },
{ id: 'hip', parts: [BodyPart.HIP], needs: ['upperChest'] },
// one spine point at a time, each halving the largest remaining gap
{ id: 'lowerWaist', parts: [BodyPart.LOWER_WAIST], needs: ['hip'] },
{ id: 'lowerChest', parts: [BodyPart.LOWER_CHEST], needs: ['lowerWaist'] },
{ id: 'upperWaist', parts: [BodyPart.UPPER_WAIST], needs: ['lowerChest'] },
{ id: 'upperWaist', parts: [BodyPart.UPPER_WAIST], needs: ['hip'] },
{ id: 'lowerChest', parts: [BodyPart.LOWER_CHEST], needs: ['upperWaist'] },
{ id: 'lowerWaist', parts: [BodyPart.LOWER_WAIST], needs: ['lowerChest'] },
{
id: 'feet',
parts: [BodyPart.LEFT_FOOT, BodyPart.RIGHT_FOOT],
@@ -110,7 +110,7 @@ const SETUP_REGIONS: {
{
id: 'upperArms',
parts: [BodyPart.LEFT_UPPER_ARM, BodyPart.RIGHT_UPPER_ARM],
needs: ['legs', 'chest'],
needs: ['legs', 'upperChest'],
},
{
id: 'lowerArms',
@@ -1,23 +1,36 @@
package dev.slimevr.skeleton.fkprocessors
import com.jme3.math.FastMath
import dev.slimevr.skeleton.ComputedSkeleton
import dev.slimevr.skeleton.InputSkeleton
import dev.slimevr.skeleton.Skeleton
import dev.slimevr.skeleton.SkeletonFkProcessor
import io.github.axisangles.ktmath.Quaternion
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import kotlin.math.abs
// The max height to plant feet by
const val ROTATION_CORRECTION_VERTICAL = 0.1f
private const val ROTATION_CORRECTION_VERTICAL = 0.1f
private const val ANKLE_DOWN_MIN = 0.35f
private const val ANKLE_DOWN_MAX = 0.63f
fun computeFootPlantRatio(
ankleHeight: Float,
floorLevel: Float,
ankleLocalPosition: Vector3,
): Float {
val ankleHeightAboveFloor = ankleHeight - floorLevel
val ratioOfRangeFromFloor = (ankleHeightAboveFloor / ROTATION_CORRECTION_VERTICAL).coerceIn(0f, 1f)
// Ratio of range *to* floor
return 1f - ratioOfRangeFromFloor
val rangeToFloorRatio = 1f - ratioOfRangeFromFloor
// Lessen the ratio as the ankle doesn't point down
val ankleDownDirection = abs(ankleLocalPosition.unit().y.coerceAtMost(0f))
val ankleDownRatio = FastMath.remapClamped(ankleDownDirection, ANKLE_DOWN_MIN, ANKLE_DOWN_MAX, 0f, 1f)
return rangeToFloorRatio * ankleDownRatio
}
fun correctFootAttitude(
@@ -27,21 +40,26 @@ fun correctFootAttitude(
): Quaternion = rotation.interpQ(rotation.eulerHeading(), correctionRatio)
class FootPlantFkProcessor(val skeleton: Skeleton) : SkeletonFkProcessor {
val bodyParts: Array<BodyPart> = arrayOf(BodyPart.LEFT_FOOT, BodyPart.RIGHT_FOOT)
val bodyParts = arrayOf(
BodyPart.LEFT_LOWER_LEG to BodyPart.LEFT_FOOT,
BodyPart.RIGHT_LOWER_LEG to BodyPart.RIGHT_FOOT,
)
override fun process(mutableInputSkeleton: InputSkeleton, fk: ComputedSkeleton, floorLevel: Float) {
if (!skeleton.effectiveFootPlant) return
for (bodyPart in bodyParts) {
val input = mutableInputSkeleton[bodyPart] ?: continue
for ((anklePart, footPart) in bodyParts) {
val input = mutableInputSkeleton[footPart] ?: continue
if (input.isRotationActive) continue
val output = fk[bodyPart] ?: continue
mutableInputSkeleton[bodyPart] = input.copy(
val foot = fk[footPart] ?: continue
val ankle = fk[anklePart] ?: continue
mutableInputSkeleton[footPart] = input.copy(
rotation = correctFootAttitude(
input.rotation,
computeFootPlantRatio(
output.headPosition.y,
foot.headPosition.y,
floorLevel,
ankle.localTailPosition,
),
),
)
@@ -10,10 +10,10 @@ import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import kotlin.math.abs
const val TOE_SNAP_RANGE_MULTIPLIER = 2f
const val MAX_TOE_SNAP_RATIO = 0.8f
const val ANKLE_DOWN_MIN = 0.65f
const val ANKLE_DOWN_MAX = 0.85f
private const val TOE_SNAP_RANGE_MULTIPLIER = 1.64f
private const val MAX_TOE_SNAP_RATIO = 0.8f
private const val ANKLE_DOWN_MIN = 0.75f
private const val ANKLE_DOWN_MAX = 0.94f
fun computeToeSnapRatio(
ankleHeight: Float,
@@ -65,6 +65,7 @@ class ToeSnapFkProcessor(val skeleton: Skeleton) : SkeletonFkProcessor {
if (input.isRotationActive) continue
val length = input.offset.len()
if (length <= 0f) continue
val ankle = fk[anklePart] ?: continue
val foot = fk[footPart] ?: continue
mutableInputSkeleton[footPart] = input.copy(
@@ -43,7 +43,7 @@ private val SPINE_SOURCE_RELIABILITY = arrayOf(
SpineSource.UPPER_CHEST to Reliability(-11.5f, -20f), // Itself
// To
SpineSource.LOWER_CHEST to Reliability(-6f, -15f, 0f),
SpineSource.UPPER_WAIST to Reliability(1.5f, 4f, 0.4f),
SpineSource.UPPER_WAIST to Reliability(1.5f, 4f, 0.44f),
SpineSource.LOWER_WAIST to Reliability(2f, 5f, 0.4f),
SpineSource.HIP to Reliability(4f, 6.25f, 0.4f),
SpineSource.UPPER_LEGS to Reliability(4f, 5f),
@@ -53,7 +53,7 @@ private val SPINE_SOURCE_RELIABILITY = arrayOf(
SpineSource.UPPER_CHEST to Reliability(-18f, 40f),
SpineSource.LOWER_CHEST to Reliability(30f), // Itself
// To
SpineSource.UPPER_WAIST to Reliability(1.5f, 10f, 0.4f),
SpineSource.UPPER_WAIST to Reliability(1.5f, 10f, 0.44f),
SpineSource.LOWER_WAIST to Reliability(2f, 8f, 0.4f),
SpineSource.HIP to Reliability(4f, 7.25f, 0.4f),
SpineSource.UPPER_LEGS to Reliability(4f, 6f),