载入中...
搜索中...
未找到
FootIKSolver.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5namespace eve::animation {
6class AnimPose;
7class AnimSkeleton;
8
11
14public:
16 virtual ~FootIKGroundProvider() = default;
18 virtual FootIKGroundQueryStatus queryGround(float originX, float originY, float originZ, float maxDistance,
19 float& hitX, float& hitY, float& hitZ, float& normalX,
20 float& normalY, float& normalZ) const = 0;
21};
22
24struct FootIKDebugFoot { bool configured=false,contact=false,locked=false,toeConfigured=false; float x=0.f,y=0.f,z=0.f,nx=0.f,ny=1.f,nz=0.f,toeX=0.f,toeY=0.f,toeZ=0.f; };
27
33public:
35 explicit FootIKSolver(AnimSkeleton* skeleton);
39 FootIKSolver(const FootIKSolver&) = default;
43 void setSkeleton(AnimSkeleton* skeleton);
49 AnimSkeleton* getSkeleton() const { return skeleton_; }
51 void setPelvisBone(int bone);
53 void configureLeftLeg(int hip, int knee, int foot, float soleOffset = 0.f);
55 void configureRightLeg(int hip, int knee, int foot, float soleOffset = 0.f);
57 void configureLeftToe(int toe, float soleOffset = 0.f);
59 void configureRightToe(int toe, float soleOffset = 0.f);
65 void setGroundProvider(const FootIKGroundProvider* provider) { groundProvider_ = provider; }
71 const FootIKGroundProvider* getGroundProvider() const { return groundProvider_; }
73 void setGroundQuery(float startHeight, float distance);
75 void setLeftContact(bool hit, float x, float y, float z, float nx, float ny, float nz,
76 float weight = 1.f);
78 void setRightContact(bool hit, float x, float y, float z, float nx, float ny, float nz,
79 float weight = 1.f);
81 void setMaxPelvisOffset(float distance);
83 void setMinGroundNormalY(float value);
85 void setPositionResponse(float value);
87 void setRotationResponse(float value);
89 void setContactGraceTime(float seconds);
91 void setFootLockEnabled(bool enabled);
93 void setFootLockThresholds(float enterWeight, float exitWeight);
95 bool isLeftFootLocked() const { return left_.locked; }
97 bool isRightFootLocked() const { return right_.locked; }
99 void reset();
101 void apply(AnimPose* pose, float dt);
103 FootIKDebugSnapshot debugSnapshot() const;
104
105private:
106 struct Contact { float x=0.f,y=0.f,z=0.f,nx=0.f,ny=1.f,nz=0.f,weight=0.f; };
107 struct Leg {
108 int hip=-1,knee=-1,foot=-1,toe=-1;
109 float soleOffset=0.f,toeSoleOffset=0.f,missingTime=0.f;
110 Contact target,smooth,toeTarget,toeSmooth,lockedContact;
111 bool configured=false,toeConfigured=false,initialized=false,toeInitialized=false,locked=false;
112 };
113 void configure(Leg& leg,int hip,int knee,int foot,float soleOffset);
114 void contact(Leg& leg,bool hit,float x,float y,float z,float nx,float ny,float nz,float weight);
115 void configureToe(Leg& leg,int toe,float soleOffset);
116 void queryGround(Leg& leg,const AnimPose& pose,float dt);
117 void updateLock(Leg& leg);
118 void interpolate(Leg& leg,float dt);
119 float pelvisOffset(const Leg& leg,const AnimPose& pose) const;
120 void solve(const Leg& leg,AnimPose& pose,float rotationWeight) const;
121
122 AnimSkeleton* skeleton_=nullptr;
123 int pelvisBone_=-1;
124 Leg left_,right_;
125 float maxPelvisOffset_=0.35f,minGroundNormalY_=0.35f;
126 float positionResponse_=18.f,rotationResponse_=14.f;
127 const FootIKGroundProvider* groundProvider_=nullptr;
128 float groundStartHeight_=0.5f,groundQueryDistance_=1.5f,contactGraceTime_=0.08f;
129 float lockEnterWeight_=0.8f,lockExitWeight_=0.2f;
130 bool footLockEnabled_=false;
131};
132} // namespace eve::animation
LogicalId target
double value
bool locked
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
eve::EntitySpatialPose pose
float nx
float nz
float ny
#define EVENGINE_API_WORLD
Definition Export.h:109
std::uint32_t bone
float distance
bool hit
Evaluated local (and optional world) pose for an AnimSkeleton. Script type: AnimPose.
Definition AnimPose.h:17
3D bone hierarchy + bind-pose local TRS for skeletal animation. Independent of ik::Skeleton3D (FABRIK...
Physics-neutral downward ground-query provider for Foot IK.
virtual FootIKGroundQueryStatus queryGround(float originX, float originY, float originZ, float maxDistance, float &hitX, float &hitY, float &hitZ, float &normalX, float &normalY, float &normalZ) const =0
Query ground below an origin and return model-space contact data.
virtual ~FootIKGroundProvider()=default
Releases FootIKGroundProvider resources.
Paired-foot IK with contact smoothing and pelvis compensation.
const FootIKGroundProvider * getGroundProvider() const
Return the borrowed ground provider, or null. @ownership Borrowed; ownership remains with the caller....
bool isLeftFootLocked() const
Return whether the left foot is currently locked.
~FootIKSolver()
Foot ik solver.
FootIKSolver & operator=(const FootIKSolver &)=default
Operator =.
bool isRightFootLocked() const
Return whether the right foot is currently locked.
FootIKSolver(const FootIKSolver &)=default
Foot ik solver.
AnimSkeleton * getSkeleton() const
Return the borrowed skeleton, or null. @ownership Borrowed; ownership remains with the animation sour...
void setGroundProvider(const FootIKGroundProvider *provider)
Set an optional automatic ground-query provider. @ownership Borrowed; ownership remains with the call...
FootIKGroundQueryStatus
Result of a Foot IK ground query.
bool enabled
Immutable model-space state for one foot in a tooling snapshot.
Owning renderer-neutral paired-foot tooling snapshot.