载入中...
搜索中...
未找到
OrientationWarping.cpp
浏览该文件的文档.
37void setWorldRotation(AnimPose& pose, const AnimSkeleton& skeleton, int bone, float qx, float qy, float qz, float qw) {
47 multiplyQuat(-parentWorld.qx, -parentWorld.qy, -parentWorld.qz, parentWorld.qw, qx, qy, qz, qw, lx, ly, lz, lw);
57 multiplyQuat(0.f, std::sin(half), 0.f, std::cos(half), world.qx, world.qy, world.qz, world.qw, qx, qy, qz, qw);
61bool validBoneList(const AnimSkeleton& skeleton, int root, std::span<const int> bones, int maxCount) {
89eve::Result<void> OrientationWarping::configure(AnimSkeleton& skeleton, int rootBone, std::span<const int> spineBones,
91 if (rootBone < 0 || rootBone >= skeleton.getBoneCount()) return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "root bone must belong to the skeleton",
94 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "spine bones must be unique valid indices distinct from the root",
97 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "ik bones must be unique valid indices distinct from the root",
101 if (spine == ik) return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "a bone cannot be both spine and ik",
113 if (!std::isfinite(alpha) || alpha < 0.f || alpha > 1.f) return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "distributed alpha must be finite in [0,1]",
123 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "angle threshold must be finite in (0, pi]",
133 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "rotation interp speed must be finite in [0,100]",
143 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "minimum root-motion speed must be finite in [0,100]",
159eve::Result<void> OrientationWarping::apply(AnimPose& pose, float locomotionX, float locomotionZ, float animatedX,
161 if (!impl_->skeleton) return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "configure a skeleton before applying orientation warp",
163 if (pose.getBoneCount() != impl_->skeleton->getBoneCount()) return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "pose bone count must match the skeleton",
165 if (!std::isfinite(dt) || dt < 0.f || dt > 1.f) return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "dt must be finite in [0,1]",
168 if (!std::isfinite(value)) return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "locomotion and animated velocities must be finite",
173 if (!std::isfinite(value)) return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "pose locals must be finite",
230int OrientationWarping::getSpineBoneCount() const { return static_cast<int>(impl_->spineBones.size()); }
231int OrientationWarping::getIkBoneCount() const { return static_cast<int>(impl_->ikBones.size()); }
Stable, structured diagnostics shared by engine modules.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
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...
Definition AnimSkeleton.h:16
eve::Result< void > setDistributedAlpha(float alpha)
Set how much of the warp is distributed onto the spine chain.
Definition OrientationWarping.cpp:112
~OrientationWarping()
Release owned interpolation state; the borrowed skeleton is not accessed.
AnimSkeleton * getSkeleton() const
Borrowed skeleton from the last successful configure, or null. @ownership Borrowed; ownership remains...
Definition OrientationWarping.cpp:228
void reset()
Clear smoothed yaw so the next apply starts from zero.
Definition OrientationWarping.cpp:154
float getRotationInterpSpeed() const
Definition OrientationWarping.cpp:139
float getAngleThreshold() const
Definition OrientationWarping.cpp:129
eve::Result< void > apply(AnimPose &pose, float locomotionX, float locomotionZ, float animatedX, float animatedZ, float dt)
Warp a local pose so animated planar velocity aligns with locomotion velocity.
Definition OrientationWarping.cpp:159
float getDistributedAlpha() const
Definition OrientationWarping.cpp:119
float getAppliedAngle() const
Smoothed yaw last applied to a pose, radians, positive from +Z toward +X.
Definition OrientationWarping.cpp:226
eve::Result< void > setAngleThreshold(float radians)
Set the inclusive planar-angle magnitude that disables warping.
Definition OrientationWarping.cpp:121
eve::Result< void > setMinRootMotionSpeed(float metresPerSecond)
Set the planar speed below which either direction is treated as stationary.
Definition OrientationWarping.cpp:141
eve::Result< void > setRotationInterpSpeed(float speed)
Set how quickly the applied yaw approaches the target, matching Unreal FInterpTo.
Definition OrientationWarping.cpp:131
void setEnabled(bool enabled)
Enable or disable pose mutation. Disabled apply calls still recompute the target.
Definition OrientationWarping.cpp:151
eve::Result< void > configure(AnimSkeleton &skeleton, int rootBone, std::span< const int > spineBones={}, std::span< const int > ikBones={})
Atomically bind a skeleton and bone lists used by later apply calls.
Definition OrientationWarping.cpp:89
OrientationWarping()
Construct an unconfigured warper with no borrowed skeleton.
Definition OrientationWarping.cpp:86
float getTargetAngle() const
Unsmoothed target yaw from the last successful apply, radians.
Definition OrientationWarping.cpp:227
float getMinRootMotionSpeed() const
Definition OrientationWarping.cpp:149
Definition Animation.cpp:58
void multiplyQuat(float ax, float ay, float az, float aw, float bx, float by, float bz, float bw, float &ox, float &oy, float &oz, float &ow)
Hamilton product a * b for unit quaternions (xyzw).
Definition AnimMath.h:94
@ InvalidArgument
@ NoOp
@ Applied
Definition Container.h:602
std::vector< int > ikBones
Definition OrientationWarping.cpp:76
float interpSpeed
Definition OrientationWarping.cpp:79
AnimSkeleton * skeleton
Definition OrientationWarping.cpp:73
float targetAngle
Definition OrientationWarping.cpp:82
float appliedAngle
Definition OrientationWarping.cpp:81
float distributedAlpha
Definition OrientationWarping.cpp:77
float minSpeed
Definition OrientationWarping.cpp:80
float angleThreshold
Definition OrientationWarping.cpp:78
std::vector< int > spineBones
Definition OrientationWarping.cpp:75