载入中...
搜索中...
未找到
MotionSchemaInternal.h
浏览该文件的文档.
1#pragma once
2#include <array>
3#include <span>
4#include <map>
5#include <memory>
9
10namespace eve::animation { class AnimClip; }
11namespace eve::animation::detail {
15 std::vector<int> offsets;
16 std::vector<float> weights;
17 std::vector<MotionFeatureSource> sources;
18 std::vector<MotionFeatureKind> kinds;
19 std::vector<MotionFeatureQuery> queries;
20 std::array<float, 3> weightSums{};
21 int dimension = 0;
22 std::unique_ptr<AnimCurveLibrary> curves;
23 std::map<const AnimClip*, std::string> curveSources;
24};
25inline std::array<float, 3> schemaRotate(const std::array<float, 3>& p, const TransformTRS& q, bool inverse = false) {
26 TransformTRS r = q, v;
27 r.px = r.py = r.pz = 0.f;
28 r.sx = r.sy = r.sz = 1.f;
29 if (inverse) { r.qx = -r.qx; r.qy = -r.qy; r.qz = -r.qz; }
30 v.px = p[0]; v.py = p[1]; v.pz = p[2];
31 const auto result = mulTRS(r, v);
32 return {result.px, result.py, result.pz};
33}
34inline std::array<float, 3> schemaDifference(const TransformTRS& a, const TransformTRS& b, const TransformTRS& root) {
36 return schemaRotate({a.px - b.px, a.py - b.py, a.pz - b.pz}, root, true);
37}
39inline void schemaEncode(std::span<float> output, const MotionFeatureChannel& channel, std::array<float, 3> value, float lengthScale) {
40 if (channel.kind == MotionFeatureKind::Velocity && channel.normalizeVelocity) {
41 const float divisor = std::max(.01f, std::sqrt(value[0]*value[0] + value[1]*value[1] + value[2]*value[2]));
42 for (float& component : value) component /= divisor;
43 } else if (channel.kind == MotionFeatureKind::Position || channel.kind == MotionFeatureKind::Velocity)
44 for (float& component : value) component *= lengthScale;
45 int index = 0;
46 for (int axis = 0; axis < 3; ++axis) if (channel.axes & (1 << axis)) output[index++] = value[axis];
47}
48inline std::array<float, 3> schemaHeading(const TransformTRS& bone, const TransformTRS& root, int axis) {
49 std::array<float, 3> direction{}; direction[axis] = 1.f;
52}
53} // namespace eve::animation::detail
double value
int root
Definition AnimSmr.cpp:119
std::string output
glm::vec4 p[6]
std::array< double, 10 > q
double r
float v
std::uint32_t bone
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
RoadLaneDirection direction
uint32_t index
std::array< float, 3 > schemaDifference(const TransformTRS &a, const TransformTRS &b, const TransformTRS &root)
TransformTRS mulTRS(const TransformTRS &parent, const TransformTRS &local)
Mul trs.
std::array< float, 3 > schemaHeading(const TransformTRS &bone, const TransformTRS &root, int axis)
std::array< float, 3 > schemaRotate(const std::array< float, 3 > &p, const TransformTRS &q, bool inverse=false)
void schemaEncode(std::span< float > output, const MotionFeatureChannel &channel, std::array< float, 3 > value, float lengthScale)
Schema encode.
Owning configuration for one ordered motion feature channel.
Owning ordered feature layout; copied atomically by a database.
Local TRS used by skeletal animation (quaternion xyzw).
Definition AnimMath.h:9
std::vector< MotionFeatureSource > sources
std::vector< MotionFeatureQuery > queries
std::unique_ptr< AnimCurveLibrary > curves
std::map< const AnimClip *, std::string > curveSources
std::vector< MotionFeatureKind > kinds