载入中...
搜索中...
未找到
AnimPose.cpp
浏览该文件的文档.
2#include <array>
5
6#include "common/Exception.h"
7
8#if defined(__SSE2__) || defined(_M_X64) || defined(_M_IX86_FP)
9#include <immintrin.h>
10#endif
11
12namespace eve::animation {
13
14namespace {
15
16struct Quat {
17 float x = 0.f, y = 0.f, z = 0.f, w = 1.f;
18};
19
20Quat quatMul(const Quat& a, const Quat& b) {
21 return {a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y, a.w * b.y - a.x * b.z + a.y * b.w + a.z * b.x,
22 a.w * b.z + a.x * b.y - a.y * b.x + a.z * b.w, a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z};
23}
24
25Quat quatInverse(const Quat& q) { return {-q.x, -q.y, -q.z, q.w}; }
26
27bool fromTo(float ax, float ay, float az, float bx, float by, float bz, Quat& out) {
28 const float al = std::sqrt(ax * ax + ay * ay + az * az);
29 const float bl = std::sqrt(bx * bx + by * by + bz * bz);
30 if (al < 1e-6f || bl < 1e-6f) return false;
31 ax /= al;
32 ay /= al;
33 az /= al;
34 bx /= bl;
35 by /= bl;
36 bz /= bl;
37 const float dot = clampf(ax * bx + ay * by + az * bz, -1.f, 1.f);
38 const float cx = ay * bz - az * by;
39 const float cy = az * bx - ax * bz;
40 const float cz = ax * by - ay * bx;
41 const float crossLength = std::hypot(cx, cy, cz);
42 if (dot < 0.f && crossLength < 1e-7f) {
43 float ox = std::fabs(ax) < 0.8f ? 1.f : 0.f;
44 float oy = std::fabs(ax) < 0.8f ? 0.f : 1.f;
45 float oz = 0.f;
46 const float cx = ay * oz - az * oy;
47 const float cy = az * ox - ax * oz;
48 const float cz = ax * oy - ay * ox;
49 const float cl = std::sqrt(cx * cx + cy * cy + cz * cz);
50 out = {cx / cl, cy / cl, cz / cl, 0.f};
51 return true;
52 }
53 if (crossLength < 1e-7f) {
54 out = {};
55 return true;
56 }
57 // atan2 preserves the small deviation from pi for nearly folded chains;
58 // 1 + dot loses that deviation when the float dot rounds to -1.
59 const float halfAngle = 0.5f * std::atan2(crossLength, dot);
60 const float scale = std::sin(halfAngle) / crossLength;
61 out = {cx * scale, cy * scale, cz * scale, std::cos(halfAngle)};
62 return true;
63}
64
65Quat worldToLocalRotation(const AnimSkeleton* skeleton, const AnimPose* pose, int bone, const Quat& world) {
66 const int parent = skeleton->getParent(bone);
67 if (parent < 0) return world;
68 const auto& p = pose->world(parent);
69 return quatMul(quatInverse({p.qx, p.qy, p.qz, p.qw}), world);
70}
71
72void blendLocalRotation(TransformTRS& local, const Quat& target, float weight) {
73 slerpQuat(local.qx, local.qy, local.qz, local.qw, target.x, target.y, target.z, target.w, clampf(weight, 0.f, 1.f),
74 local.qx, local.qy, local.qz, local.qw);
75}
76
77
78} // namespace
79
80AnimPose::AnimPose(int boneCount) { resize(boneCount); }
81
82void AnimPose::resize(int boneCount) {
83 if (boneCount < 0) throw Exception("AnimPose.resize: boneCount must be >= 0");
84 if (boneCount == getBoneCount()) return;
85 locals_.assign(static_cast<size_t>(boneCount), TransformTRS::identity());
86 worlds_.assign(static_cast<size_t>(boneCount), TransformTRS::identity());
87}
88
89void AnimPose::requireBone(int boneIndex) const {
90 if (boneIndex < 0 || boneIndex >= getBoneCount()) {
91 throw Exception("AnimPose: invalid bone index %d", boneIndex);
92 }
93}
94
95void AnimPose::copyFrom(const AnimPose* other) {
96 if (!other) throw Exception("AnimPose.copyFrom: other is null");
97 locals_ = other->locals_;
98 worlds_ = other->worlds_;
99}
100
101void AnimPose::blendFrom(const AnimPose* a, const AnimPose* b, float t) {
102 if (!a || !b) throw Exception("AnimPose.blendFrom: pose is null");
103 if (a->getBoneCount() != b->getBoneCount()) {
104 throw Exception("AnimPose.blendFrom: bone count mismatch");
105 }
106 resize(a->getBoneCount());
107 for (int i = 0; i < getBoneCount(); ++i) {
108 const TransformTRS& av = a->locals_[static_cast<size_t>(i)];
109 const TransformTRS& bv = b->locals_[static_cast<size_t>(i)];
110 TransformTRS& out = locals_[static_cast<size_t>(i)];
111#if defined(__SSE2__) || defined(_M_X64) || defined(_M_IX86_FP)
112 const __m128 weight = _mm_set1_ps(clampf(t, 0.f, 1.f));
113 const __m128 oneMinus = _mm_sub_ps(_mm_set1_ps(1.f), weight);
114 alignas(16) float values[4];
115 _mm_store_ps(values, _mm_add_ps(_mm_mul_ps(_mm_setr_ps(av.px, av.py, av.pz, 0.f), oneMinus),
116 _mm_mul_ps(_mm_setr_ps(bv.px, bv.py, bv.pz, 0.f), weight)));
117 out.px = values[0]; out.py = values[1]; out.pz = values[2];
118 _mm_store_ps(values, _mm_add_ps(_mm_mul_ps(_mm_setr_ps(av.sx, av.sy, av.sz, 0.f), oneMinus),
119 _mm_mul_ps(_mm_setr_ps(bv.sx, bv.sy, bv.sz, 0.f), weight)));
120 out.sx = values[0]; out.sy = values[1]; out.sz = values[2];
121#else
122 out.px = lerpf(av.px, bv.px, t); out.py = lerpf(av.py, bv.py, t); out.pz = lerpf(av.pz, bv.pz, t);
123 out.sx = lerpf(av.sx, bv.sx, t); out.sy = lerpf(av.sy, bv.sy, t); out.sz = lerpf(av.sz, bv.sz, t);
124#endif
125 slerpQuat(av.qx, av.qy, av.qz, av.qw, bv.qx, bv.qy, bv.qz, bv.qw, clampf(t, 0.f, 1.f),
126 out.qx, out.qy, out.qz, out.qw);
127 }
128}
129
131 requireBone(boneIndex);
132 return locals_[static_cast<size_t>(boneIndex)];
133}
134
135const TransformTRS& AnimPose::local(int boneIndex) const {
136 requireBone(boneIndex);
137 return locals_[static_cast<size_t>(boneIndex)];
138}
139
140void AnimPose::setLocalPosition(int boneIndex, float x, float y, float z) {
141 requireBone(boneIndex);
142 auto& t = locals_[static_cast<size_t>(boneIndex)];
143 t.px = x;
144 t.py = y;
145 t.pz = z;
146}
147
148void AnimPose::setLocalRotation(int boneIndex, float x, float y, float z, float w) {
149 requireBone(boneIndex);
150 auto& t = locals_[static_cast<size_t>(boneIndex)];
151 t.qx = x;
152 t.qy = y;
153 t.qz = z;
154 t.qw = w;
155 t.normalizeRotation();
156}
157
158void AnimPose::setLocalScale(int boneIndex, float x, float y, float z) {
159 requireBone(boneIndex);
160 auto& t = locals_[static_cast<size_t>(boneIndex)];
161 t.sx = x;
162 t.sy = y;
163 t.sz = z;
164}
165
166float AnimPose::getLocalPositionX(int boneIndex) const {
167 requireBone(boneIndex);
168 return locals_[static_cast<size_t>(boneIndex)].px;
169}
170float AnimPose::getLocalPositionY(int boneIndex) const {
171 requireBone(boneIndex);
172 return locals_[static_cast<size_t>(boneIndex)].py;
173}
174float AnimPose::getLocalPositionZ(int boneIndex) const {
175 requireBone(boneIndex);
176 return locals_[static_cast<size_t>(boneIndex)].pz;
177}
178float AnimPose::getLocalRotationX(int boneIndex) const {
179 requireBone(boneIndex);
180 return locals_[static_cast<size_t>(boneIndex)].qx;
181}
182float AnimPose::getLocalRotationY(int boneIndex) const {
183 requireBone(boneIndex);
184 return locals_[static_cast<size_t>(boneIndex)].qy;
185}
186float AnimPose::getLocalRotationZ(int boneIndex) const {
187 requireBone(boneIndex);
188 return locals_[static_cast<size_t>(boneIndex)].qz;
189}
190float AnimPose::getLocalRotationW(int boneIndex) const {
191 requireBone(boneIndex);
192 return locals_[static_cast<size_t>(boneIndex)].qw;
193}
194float AnimPose::getLocalScaleX(int boneIndex) const {
195 requireBone(boneIndex);
196 return locals_[static_cast<size_t>(boneIndex)].sx;
197}
198float AnimPose::getLocalScaleY(int boneIndex) const {
199 requireBone(boneIndex);
200 return locals_[static_cast<size_t>(boneIndex)].sy;
201}
202float AnimPose::getLocalScaleZ(int boneIndex) const {
203 requireBone(boneIndex);
204 return locals_[static_cast<size_t>(boneIndex)].sz;
205}
206
208 if (!skeleton) throw Exception("AnimPose.computeWorld: skeleton is null");
209 if (skeleton->getBoneCount() != getBoneCount()) {
210 throw Exception("AnimPose.computeWorld: bone count mismatch");
211 }
212 worlds_.resize(locals_.size());
213 for (int i = 0; i < getBoneCount(); ++i) {
214 const int parent = skeleton->getParent(i);
215 if (parent < 0) {
216 worlds_[static_cast<size_t>(i)] = locals_[static_cast<size_t>(i)];
217 } else {
218 worlds_[static_cast<size_t>(i)] =
219 detail::mulTRS(worlds_[static_cast<size_t>(parent)], locals_[static_cast<size_t>(i)]);
220 }
221 }
222}
223
224bool AnimPose::aimBone(const AnimSkeleton* skeleton, int boneIndex, float targetX, float targetY, float targetZ,
225 float weight) {
226 if (!skeleton) throw Exception("AnimPose.aimBone: skeleton is null");
227 requireBone(boneIndex);
228 computeWorld(skeleton);
229 const auto& bone = world(boneIndex);
230 const Mat4 mat = Mat4::fromTRS(bone);
231 Quat delta;
232 if (!fromTo(mat.m[8], mat.m[9], mat.m[10], targetX - bone.px, targetY - bone.py, targetZ - bone.pz, delta)) {
233 return false;
234 }
235 const Quat desiredWorld = quatMul(delta, {bone.qx, bone.qy, bone.qz, bone.qw});
236 blendLocalRotation(local(boneIndex), worldToLocalRotation(skeleton, this, boneIndex, desiredWorld), weight);
237 computeWorld(skeleton);
238 return true;
239}
240
241bool AnimPose::solveTwoBoneIK(const AnimSkeleton* skeleton, int rootBone, int midBone, int tipBone, float targetX,
242 float targetY, float targetZ, float weight) {
243 if (!skeleton) throw Exception("AnimPose.solveTwoBoneIK: skeleton is null");
244 requireBone(midBone);
245 computeWorld(skeleton);
246 const auto pole = world(midBone);
247 return solveTwoBoneIKPoleImpl(skeleton, rootBone, midBone, tipBone, targetX, targetY, targetZ, pole.px, pole.py,
248 pole.pz, weight);
249}
250
251bool AnimPose::solveTwoBoneIKPoleImpl(const AnimSkeleton* skeleton, int rootBone, int midBone, int tipBone,
252 float targetX, float targetY, float targetZ, float poleX, float poleY,
253 float poleZ, float weight) {
254 if (!skeleton) throw Exception("AnimPose.solveTwoBoneIK: skeleton is null");
255 requireBone(rootBone);
256 requireBone(midBone);
257 requireBone(tipBone);
258 if (skeleton->getParent(midBone) != rootBone || skeleton->getParent(tipBone) != midBone) return false;
259
260 if (!std::isfinite(targetX) || !std::isfinite(targetY) || !std::isfinite(targetZ) || !std::isfinite(poleX) ||
261 !std::isfinite(poleY) || !std::isfinite(poleZ) || !std::isfinite(weight))
262 throw Exception("AnimPose.solveTwoBoneIK: nonfinite target or weight");
263 computeWorld(skeleton);
264 using Vector = std::array<double, 3>;
265 auto position = [](const TransformTRS& t) -> Vector { return {t.px, t.py, t.pz}; };
266 auto sub = [](Vector a, Vector b) -> Vector { return {a[0] - b[0], a[1] - b[1], a[2] - b[2]}; };
267 auto dot = [](Vector a, Vector b) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; };
268 auto cross = [](Vector a, Vector b) -> Vector {
269 return {a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]};
270 };
271 const Vector a = position(world(rootBone)), b = position(world(midBone)), c = position(world(tipBone));
272 const Vector ab = sub(b, a), bc = sub(c, b);
273 const double upper = std::sqrt(dot(ab, ab)), lower = std::sqrt(dot(bc, bc));
274 if (upper < 1e-7 || lower < 1e-7) return false;
275 Vector direction = sub(Vector{targetX, targetY, targetZ}, a);
276 double distance = std::sqrt(dot(direction, direction));
277 if (distance < 1e-7) {
278 direction = sub(c, a);
279 distance = std::sqrt(dot(direction, direction));
280 }
281 if (distance < 1e-7) {
282 direction = ab;
283 distance = upper;
284 }
285 for (auto& value : direction) value /= distance;
286 const double requested =
287 std::sqrt(dot(sub(Vector{targetX, targetY, targetZ}, a), sub(Vector{targetX, targetY, targetZ}, a)));
288 const double reach = std::clamp(requested, std::max(std::abs(upper - lower), 1e-7), upper + lower);
289 const double along = (upper * upper - lower * lower + reach * reach) / (2 * reach);
290 const double height = std::sqrt(std::max(upper * upper - along * along, 0.0));
291 Vector pole = sub(Vector{poleX, poleY, poleZ}, a);
292 const double projected = dot(pole, direction);
293 for (int i = 0; i < 3; ++i) pole[i] -= projected * direction[i];
294 double poleLength = std::sqrt(dot(pole, pole));
295 if (poleLength < 1e-7) {
296 pole = cross(cross(ab, bc), direction);
297 poleLength = std::sqrt(dot(pole, pole));
298 }
299 if (poleLength < 1e-7) {
300 // A fully straight chain has no bend plane. Choose the least parallel
301 // axis deterministically; subsequent calls retain the resulting plane.
302 int axis = 0;
303 for (int i = 1; i < 3; ++i)
304 if (std::abs(direction[i]) < std::abs(direction[axis])) axis = i;
305 pole = {0, 0, 0};
306 pole[axis] = 1;
307 const double projection = dot(pole, direction);
308 for (int i = 0; i < 3; ++i) pole[i] -= projection * direction[i];
309 poleLength = std::sqrt(dot(pole, pole));
310 }
311 Vector knee{}, tip{};
312 for (int i = 0; i < 3; ++i) {
313 knee[i] = a[i] + direction[i] * along + pole[i] * height / poleLength;
314 tip[i] = a[i] + direction[i] * reach;
315 }
316 const auto originalRoot = local(rootBone), originalMid = local(midBone);
317 Quat delta;
318 if (!fromTo(float(ab[0]), float(ab[1]), float(ab[2]), float(knee[0] - a[0]), float(knee[1] - a[1]),
319 float(knee[2] - a[2]), delta))
320 return false;
321 const auto root = world(rootBone);
322 const Quat rootRotation =
323 worldToLocalRotation(skeleton, this, rootBone, quatMul(delta, {root.qx, root.qy, root.qz, root.qw}));
324 blendLocalRotation(local(rootBone), rootRotation, 1.f);
325 computeWorld(skeleton);
326 const auto mid = world(midBone), end = world(tipBone);
327 if (fromTo(end.px - mid.px, end.py - mid.py, end.pz - mid.pz, float(tip[0] - mid.px), float(tip[1] - mid.py),
328 float(tip[2] - mid.pz), delta)) {
329 const Quat midRotation =
330 worldToLocalRotation(skeleton, this, midBone, quatMul(delta, {mid.qx, mid.qy, mid.qz, mid.qw}));
331 blendLocalRotation(local(midBone), midRotation, 1.f);
332 }
333 const auto solvedRoot = local(rootBone), solvedMid = local(midBone);
334 local(rootBone) = originalRoot;
335 local(midBone) = originalMid;
336 blendLocalRotation(local(rootBone), {solvedRoot.qx, solvedRoot.qy, solvedRoot.qz, solvedRoot.qw}, weight);
337 blendLocalRotation(local(midBone), {solvedMid.qx, solvedMid.qy, solvedMid.qz, solvedMid.qw}, weight);
338 computeWorld(skeleton);
339 return true;
340}
341
342float AnimPose::getWorldPositionX(int boneIndex) const {
343 requireBone(boneIndex);
344 return worlds_[static_cast<size_t>(boneIndex)].px;
345}
346float AnimPose::getWorldPositionY(int boneIndex) const {
347 requireBone(boneIndex);
348 return worlds_[static_cast<size_t>(boneIndex)].py;
349}
350float AnimPose::getWorldPositionZ(int boneIndex) const {
351 requireBone(boneIndex);
352 return worlds_[static_cast<size_t>(boneIndex)].pz;
353}
354float AnimPose::getWorldRotationX(int boneIndex) const {
355 requireBone(boneIndex);
356 return worlds_[static_cast<size_t>(boneIndex)].qx;
357}
358float AnimPose::getWorldRotationY(int boneIndex) const {
359 requireBone(boneIndex);
360 return worlds_[static_cast<size_t>(boneIndex)].qy;
361}
362float AnimPose::getWorldRotationZ(int boneIndex) const {
363 requireBone(boneIndex);
364 return worlds_[static_cast<size_t>(boneIndex)].qz;
365}
366float AnimPose::getWorldRotationW(int boneIndex) const {
367 requireBone(boneIndex);
368 return worlds_[static_cast<size_t>(boneIndex)].qw;
369}
370
371const TransformTRS& AnimPose::world(int boneIndex) const {
372 requireBone(boneIndex);
373 return worlds_[static_cast<size_t>(boneIndex)];
374}
375
376float AnimPose::getWorldMatrixElement(int boneIndex, int elementIndex) const {
377 requireBone(boneIndex);
378 if (elementIndex < 0 || elementIndex > 15) {
379 throw Exception("AnimPose.getWorldMatrixElement: elementIndex must be 0..15");
380 }
381 const Mat4 mat = Mat4::fromTRS(worlds_[static_cast<size_t>(boneIndex)]);
382 return mat.m[elementIndex];
383}
384
385void AnimPose::getWorldMatrix(int boneIndex, float* out16) const {
386 requireBone(boneIndex);
387 if (!out16) throw Exception("AnimPose.getWorldMatrix: out16 is null");
388 const Mat4 mat = Mat4::fromTRS(worlds_[static_cast<size_t>(boneIndex)]);
389 for (int i = 0; i < 16; ++i) out16[i] = mat.m[i];
390}
391
392} // namespace eve::animation
double z
double y
double x
LogicalId target
float w
Definition AnimClip.cpp:738
int tip
Definition AnimSmr.cpp:121
int root
Definition AnimSmr.cpp:119
int mid
Definition AnimSmr.cpp:120
eve::EntitySpatialPose pose
float cx
Definition CardTypes.cpp:36
float cy
Definition CardTypes.cpp:37
glm::vec4 p[6]
std::array< double, 10 > q
std::uint32_t ab
std::int32_t c
std::vector< Colorf > px
std::uint32_t height
JointPoint2D axis
const ColourScope * parent
std::string local
std::array< float, 3 > position
std::array< float, 3 > scale
std::uint32_t bone
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
float distance
std::set< std::string > values
Object::Ptr value
float t
RoadLaneDirection direction
ScriptStructure out
size_t end
float targetX
double weight
double oy
double ox
EVENGINE_API_FOUNDATION public API.
Definition Exception.h:13
Evaluated local (and optional world) pose for an AnimSkeleton. Script type: AnimPose.
Definition AnimPose.h:17
float getLocalRotationX(int boneIndex) const
Returns the local rotation x.
Definition AnimPose.cpp:178
float getWorldRotationX(int boneIndex) const
Returns the world rotation x.
Definition AnimPose.cpp:354
int getBoneCount() const noexcept
Returns the bone count.
Definition AnimPose.h:36
float getWorldPositionZ(int boneIndex) const
Returns the world position z.
Definition AnimPose.cpp:350
AnimPose()=default
Anim pose.
float getLocalScaleZ(int boneIndex) const
Returns the local scale z.
Definition AnimPose.cpp:202
float getLocalPositionZ(int boneIndex) const
Returns the local position z.
Definition AnimPose.cpp:174
void blendFrom(const AnimPose *a, const AnimPose *b, float t)
Blend from.
Definition AnimPose.cpp:101
float getWorldMatrixElement(int boneIndex, int elementIndex) const
Column-major 4x4 world matrix for boneIndex after computeWorld(). elementIndex in [0,...
Definition AnimPose.cpp:376
float getLocalPositionX(int boneIndex) const
Returns the local position x.
Definition AnimPose.cpp:166
float getLocalRotationW(int boneIndex) const
Returns the local rotation w.
Definition AnimPose.cpp:190
float getWorldPositionX(int boneIndex) const
Returns the world position x.
Definition AnimPose.cpp:342
void setLocalScale(int boneIndex, float x, float y, float z)
Sets the local scale.
Definition AnimPose.cpp:158
const TransformTRS & world(int boneIndex) const
World.
Definition AnimPose.cpp:371
float getLocalScaleX(int boneIndex) const
Returns the local scale x.
Definition AnimPose.cpp:194
float getWorldPositionY(int boneIndex) const
Returns the world position y.
Definition AnimPose.cpp:346
void getWorldMatrix(int boneIndex, float *out16) const
Write 16 floats (column-major) into out16 (must not be null).
Definition AnimPose.cpp:385
void setLocalRotation(int boneIndex, float x, float y, float z, float w)
Sets the local rotation.
Definition AnimPose.cpp:148
float getWorldRotationW(int boneIndex) const
Returns the world rotation w.
Definition AnimPose.cpp:366
float getWorldRotationZ(int boneIndex) const
Returns the world rotation z.
Definition AnimPose.cpp:362
float getWorldRotationY(int boneIndex) const
Returns the world rotation y.
Definition AnimPose.cpp:358
float getLocalScaleY(int boneIndex) const
Returns the local scale y.
Definition AnimPose.cpp:198
TransformTRS & local(int boneIndex)
Local.
Definition AnimPose.cpp:130
float getLocalRotationZ(int boneIndex) const
Returns the local rotation z.
Definition AnimPose.cpp:186
void setLocalPosition(int boneIndex, float x, float y, float z)
Sets the local position.
Definition AnimPose.cpp:140
float getLocalPositionY(int boneIndex) const
Returns the local position y.
Definition AnimPose.cpp:170
void copyFrom(const AnimPose *other)
Copies from.
Definition AnimPose.cpp:95
float getLocalRotationY(int boneIndex) const
Returns the local rotation y.
Definition AnimPose.cpp:182
bool aimBone(const AnimSkeleton *skeleton, int boneIndex, float targetX, float targetY, float targetZ, float weight=1.f)
Rotate a bone so its local +Z axis aims at a world-space target.
Definition AnimPose.cpp:224
void computeWorld(const AnimSkeleton *skeleton)
Compute world transforms from local pose + skeleton hierarchy. World values readable via getWorld* af...
Definition AnimPose.cpp:207
void resize(int boneCount)
Resize.
Definition AnimPose.cpp:82
bool solveTwoBoneIK(const AnimSkeleton *skeleton, int rootBone, int midBone, int tipBone, float targetX, float targetY, float targetZ, float weight=1.f)
Analytically solve a root-mid-tip chain toward a world-space target.
Definition AnimPose.cpp:241
3D bone hierarchy + bind-pose local TRS for skeletal animation. Independent of ik::Skeleton3D (FABRIK...
int getBoneCount() const
Returns the bone count.
int getParent(int boneIndex) const
Returns the parent.
TransformTRS mulTRS(const TransformTRS &parent, const TransformTRS &local)
Mul trs.
void slerpQuat(float ax, float ay, float az, float aw, float bx, float by, float bz, float bw, float t, float &ox, float &oy, float &oz, float &ow)
Slerp quat.
Definition AnimMath.h:43
constexpr float lerpf(float a, float b, float t) noexcept
Lerpf.
Definition AnimMath.h:40
constexpr float clampf(float v, float lo, float hi) noexcept
Clampf.
Definition AnimMath.h:34
double dot(ForceVector a, ForceVector b)
Definition ForceMath.h:14
Vec3 sub(Vec3 a, Vec3 b)
V3 cross(V3 a, V3 b)
Module-private road bake implementation helper.
Definition RoadBake.cpp:29
Column-major 4x4 matrix (OpenGL / glTF / Assimp-compatible layout). Elements: m[col * 4 + row].
Definition AnimMath.h:156
static constexpr Mat4 fromTRS(const TransformTRS &t) noexcept
From trs.
Definition AnimMath.h:163
Local TRS used by skeletal animation (quaternion xyzw).
Definition AnimMath.h:9
static constexpr TransformTRS identity() noexcept
Identity.
Definition AnimMath.h:15