Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.

Commit aeccf4c

Browse files
committed
fixes
1 parent cdcfb0f commit aeccf4c

File tree

4 files changed

+38
-33
lines changed

4 files changed

+38
-33
lines changed

packages/engine/src/avatar/functions/avatarFootHeuristics.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
2323
Ethereal Engine. All Rights Reserved.
2424
*/
2525

26-
import { getState } from '@etherealengine/hyperflux'
2726
import { Euler, Quaternion, Vector3 } from 'three'
2827
import { V_010 } from '../../common/constants/MathConstants'
2928
import { Engine } from '../../ecs/classes/Engine'
30-
import { EngineState } from '../../ecs/classes/EngineState'
3129
import { getComponent } from '../../ecs/functions/ComponentFunctions'
3230
import { UUIDComponent } from '../../scene/components/UUIDComponent'
3331
import { TransformComponent } from '../../transform/components/TransformComponent'
@@ -102,13 +100,10 @@ export const setIkFootTarget = (stepThreshold: number, delta: number) => {
102100
}
103101

104102
//interpolate foot to next step position
105-
ikTransform.position.lerp(nextStep[key].position, getState(EngineState).deltaSeconds * (minSpeed + playerSpeed))
103+
ikTransform.position.lerp(nextStep[key].position, delta * (minSpeed + playerSpeed))
106104
//set foot y to player y until we have step math
107105
ikTransform.position.y = playerTransform.position.y + 0.1
108-
ikTransform.rotation.slerp(
109-
quat.copy(playerTransform.rotation).multiply(offset),
110-
getState(EngineState).deltaSeconds * (minSpeed + playerSpeed)
111-
)
106+
ikTransform.rotation.slerp(quat.copy(playerTransform.rotation).multiply(offset), delta * (minSpeed + playerSpeed))
112107
}
113108

114109
lastPlayerPosition.copy(playerTransform.position)

packages/engine/src/avatar/systems/AvatarAnimationSystem.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,7 @@ const execute = () => {
205205

206206
//right now the only times we want to be using inverse kinematics is when we're in xr mode,
207207
//or when we're running our own leg calculations for mocap
208-
if (
209-
(motionCaptureRigComponent && !MotionCaptureRigComponent.solvingLowerBody[entity]) ||
210-
getOptionalComponent(entity, XRRigComponent)
211-
) {
208+
if (motionCaptureRigComponent || getOptionalComponent(entity, XRRigComponent)) {
212209
hipsForward.set(0, 0, 1)
213210

214211
const uuid = getComponent(entity, UUIDComponent)
@@ -262,8 +259,9 @@ const execute = () => {
262259
)
263260
)
264261
} else {
265-
leftFootTarget.blendWeight.set(1)
266-
rightFootTarget.blendWeight.set(1)
262+
/**todo: fix foot heuristic function causing ik solve issues */
263+
//leftFootTarget.blendWeight.set(1)
264+
//rightFootTarget.blendWeight.set(1)
267265
}
268266

269267
const transform = getComponent(entity, TransformComponent)

packages/engine/src/mocap/MotionCaptureSystem.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import { NormalizedLandmarkList } from '@mediapipe/pose'
4040
import { addDataChannelHandler, removeDataChannelHandler } from '../networking/systems/DataChannelRegistry'
4141

4242
import { getState } from '@etherealengine/hyperflux'
43-
import { VRMHumanBoneList } from '@pixiv/three-vrm'
43+
import { VRMHumanBoneList, VRMHumanBoneName } from '@pixiv/three-vrm'
4444
import {
4545
BufferAttribute,
4646
BufferGeometry,
@@ -151,7 +151,17 @@ const execute = () => {
151151
for (const boneName of VRMHumanBoneList) {
152152
const localbone = rigComponent.localRig[boneName]?.node
153153
if (!localbone) continue
154-
154+
if (!MotionCaptureRigComponent.solvingLowerBody[entity]) {
155+
if (
156+
boneName == VRMHumanBoneName.LeftUpperLeg ||
157+
boneName == VRMHumanBoneName.RightUpperLeg ||
158+
boneName == VRMHumanBoneName.LeftLowerLeg ||
159+
boneName == VRMHumanBoneName.RightLowerLeg ||
160+
boneName == VRMHumanBoneName.LeftFoot ||
161+
boneName == VRMHumanBoneName.RightFoot
162+
)
163+
continue
164+
}
155165
if (
156166
MotionCaptureRigComponent.rig[boneName].x[entity] === 0 &&
157167
MotionCaptureRigComponent.rig[boneName].y[entity] === 0 &&

packages/engine/src/mocap/solveMotionCapturePose.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -236,24 +236,26 @@ export function solveMotionCapturePose(
236236
VRMHumanBoneName.RightUpperLeg,
237237
VRMHumanBoneName.RightLowerLeg
238238
)
239-
solveFoot(
240-
entity,
241-
lowestWorldY,
242-
landmarks[POSE_LANDMARKS_LEFT.LEFT_ANKLE],
243-
landmarks[POSE_LANDMARKS_LEFT.LEFT_HEEL],
244-
landmarks[POSE_LANDMARKS_LEFT.LEFT_FOOT_INDEX],
245-
VRMHumanBoneName.RightUpperLeg,
246-
VRMHumanBoneName.RightFoot
247-
)
248-
solveFoot(
249-
entity,
250-
lowestWorldY,
251-
landmarks[POSE_LANDMARKS_RIGHT.RIGHT_ANKLE],
252-
landmarks[POSE_LANDMARKS_RIGHT.RIGHT_HEEL],
253-
landmarks[POSE_LANDMARKS_RIGHT.RIGHT_FOOT_INDEX],
254-
VRMHumanBoneName.LeftUpperLeg,
255-
VRMHumanBoneName.LeftFoot
256-
)
239+
/**todo: figure out why we get bad foot quaternions when using solveFoot */
240+
//solveFoot(
241+
// entity,
242+
// lowestWorldY,
243+
// landmarks[POSE_LANDMARKS_LEFT.LEFT_ANKLE],
244+
// landmarks[POSE_LANDMARKS_LEFT.LEFT_HEEL],
245+
// landmarks[POSE_LANDMARKS_LEFT.LEFT_FOOT_INDEX],
246+
// VRMHumanBoneName.RightUpperLeg,
247+
// VRMHumanBoneName.RightFoot
248+
//)
249+
//solveFoot(
250+
// entity,
251+
// lowestWorldY,
252+
// landmarks[POSE_LANDMARKS_RIGHT.RIGHT_ANKLE],
253+
// landmarks[POSE_LANDMARKS_RIGHT.RIGHT_HEEL],
254+
// landmarks[POSE_LANDMARKS_RIGHT.RIGHT_FOOT_INDEX],
255+
// VRMHumanBoneName.LeftUpperLeg,
256+
// VRMHumanBoneName.LeftFoot
257+
//)
258+
257259
//check state, if we are still not set to track lower body, update that
258260
if (!MotionCaptureRigComponent.solvingLowerBody[entity]) {
259261
MotionCaptureRigComponent.solvingLowerBody[entity] = 1

0 commit comments

Comments
 (0)