[Feature] Add foot IK with analytic two-bone solver - #1143
Open
miogds wants to merge 1 commit into
Open
Conversation
Clips are authored against a flat ground plane; on real terrain feet float or sink. Foot IK (opt-in per entity, default off) samples the ground beneath each configured ankle every frame and adjusts the hip and knee with a closed-form two-bone solver so the foot lands on it. - TwoBoneIK: Holden-style analytic solver — law-of-cosines bend plus aim rotation, axes expressed in each joint's local frame. Composition order is aim-then-bend in local post-multiplication (equivalent to bend-then-aim in world space); the wrong order is invisible whenever hint, chain, and target are coplanar, so tests cover the non-coplanar case. Unreachable targets clamp to full extension; straight chains take the bend plane from a hint. - FootIK: chains described by hip/knee/ankle joint paths (setFootIKChains), resolved once against the skeleton. The ankle's authored height above the clip's ground plane is preserved above the real terrain; corrections beyond 0.5 m are treated as non-ground and ignored. A collinear pose bend (straight leg) falls back to the chain's configurable bendDirection. - Ground sampling defaults to a downward scene ray pick (octree picking) that rejects hits on the character itself or its descendants; games can override per entity with setFootIKGroundQuery (heightfield, navmesh, physics). - Runs after root motion and transitions, before pose composition. Leg joints are assumed unit-scale. Docs: docs/API/UsingFootIK.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Next link in the animation chain after inertialized transitions (#1125) and root motion (#1135): foot IK. Clips are authored against a flat ground plane; on real terrain feet float or sink. With foot IK enabled — opt-in per entity, default off, zero cost when disabled — the ground beneath each configured ankle is sampled every frame and the hip and knee are adjusted with a closed-form two-bone solver so the foot lands on it.
API
bendDirection.setFootIKGroundQuery(heightfield, navmesh, physics — anything).How-to guide:
docs/API/UsingFootIK.md. Single commit cherry-picked onto current develop (7d54789).Testing
AnimationFootIKTests(10 tests, all passing):setFootIKGroundQueryinjection, exercising the override path end to endRoot motion, inertialization, compiled-sampler, and policy suites still pass on this base. SwiftFormat lint clean.