mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 19:23:58 +02:00
Merge pull request #16214 from hyperlogic/bug-fix/additive-blend-scale-fix
Fix additive blending on avatars with non identity scale.
This commit is contained in:
commit
a5fdf5bb40
1 changed files with 5 additions and 3 deletions
|
@ -54,12 +54,14 @@ void blend4(size_t numPoses, const AnimPose* a, const AnimPose* b, const AnimPos
|
|||
// additive blend
|
||||
void blendAdd(size_t numPoses, const AnimPose* a, const AnimPose* b, float alpha, AnimPose* result) {
|
||||
|
||||
const glm::quat identity = glm::quat();
|
||||
const glm::vec3 IDENTITY_SCALE = glm::vec3(1.0f);
|
||||
const glm::quat IDENTITY_ROT = glm::quat();
|
||||
|
||||
for (size_t i = 0; i < numPoses; i++) {
|
||||
const AnimPose& aPose = a[i];
|
||||
const AnimPose& bPose = b[i];
|
||||
|
||||
result[i].scale() = lerp(aPose.scale(), bPose.scale(), alpha);
|
||||
result[i].scale() = aPose.scale() * lerp(IDENTITY_SCALE, bPose.scale(), alpha);
|
||||
|
||||
// ensure that delta has the same "polarity" as the identity quat.
|
||||
// we don't need to do a full dot product, just sign of w is sufficient.
|
||||
|
@ -67,7 +69,7 @@ void blendAdd(size_t numPoses, const AnimPose* a, const AnimPose* b, float alpha
|
|||
if (delta.w < 0.0f) {
|
||||
delta = -delta;
|
||||
}
|
||||
delta = glm::lerp(identity, delta, alpha);
|
||||
delta = glm::lerp(IDENTITY_ROT, delta, alpha);
|
||||
result[i].rot() = glm::normalize(aPose.rot() * delta);
|
||||
result[i].trans() = aPose.trans() + (alpha * bPose.trans());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue