Fix cubic spline interpolation in glTF animations
This commit is contained in:
parent
8b5c35f89a
commit
b5d556d06f
1 changed files with 4 additions and 3 deletions
|
|
@ -129,7 +129,8 @@ namespace psemek::gfx
|
||||||
|
|
||||||
auto i = it - input_.begin();
|
auto i = it - input_.begin();
|
||||||
|
|
||||||
float t = (time - input_[i - 1]) / (input_[i] - input_[i - 1]);
|
float td = (input_[i] - input_[i - 1]);
|
||||||
|
float t = (time - input_[i - 1]) / td;
|
||||||
|
|
||||||
switch (interpolation_)
|
switch (interpolation_)
|
||||||
{
|
{
|
||||||
|
|
@ -144,9 +145,9 @@ namespace psemek::gfx
|
||||||
float t3 = t * t2;
|
float t3 = t * t2;
|
||||||
return traits::normalize(output_type::zero()
|
return traits::normalize(output_type::zero()
|
||||||
+ output_[3 * (i - 1) + 1] * ( 2.f * t3 - 3.f * t2 + 1.f)
|
+ output_[3 * (i - 1) + 1] * ( 2.f * t3 - 3.f * t2 + 1.f)
|
||||||
+ output_[3 * (i - 1) + 2] * ( t3 - 2.f * t2 + t )
|
+ output_[3 * (i - 1) + 2] * ( t3 - 2.f * t2 + t ) * td
|
||||||
+ output_[3 * (i + 0) + 1] * (- 2.f * t3 + 3.f * t2 )
|
+ output_[3 * (i + 0) + 1] * (- 2.f * t3 + 3.f * t2 )
|
||||||
+ output_[3 * (i + 0) + 0] * ( t3 - t2 )
|
+ output_[3 * (i + 0) + 0] * ( t3 - t2 ) * td
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue