commit 31fcbf2df0ccda97fbd18ae5f16c4e640410f2b8
parent e0cc772b66c5eb206f0f827d7e8c3936e69ba862
Author: Michael Savage <mikejsavage@gmail.com>
Date: Fri, 31 May 2019 15:52:09 +0300
Actually interpolate between samples
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/gltf.cc b/gltf.cc
@@ -125,7 +125,8 @@ void SampleAnimationClip( const AnimationReel & reel, u32 clip_idx, float t, flo
}
for( u32 i = 0; i < reel.num_joints; i++ ) {
- AnimationReel::Joint & joint = reel.joints[ i ];
+ const AnimationReel::Joint & joint = reel.joints[ i ];
+
u32 rotation_sample, translation_sample, scale_sample;
float rotation_lerp_frac, translation_lerp_frac, scale_lerp_frac;
@@ -133,9 +134,9 @@ void SampleAnimationClip( const AnimationReel & reel, u32 clip_idx, float t, flo
SampleAnimationChannel( joint.translations.times, joint.translations.num_samples, local_time, &translation_sample, &translation_lerp_frac );
SampleAnimationChannel( joint.scales.times, joint.scales.num_samples, local_time, &scale_sample, &scale_lerp_frac );
- joint_poses[ i ].rotation = NLerp( joint.rotations.samples[ rotation_sample ], rotation_lerp_frac, joint.rotations.samples[ rotation_sample ] );
- joint_poses[ i ].translation = Lerp( joint.translations.samples[ translation_sample ], translation_lerp_frac, joint.translations.samples[ translation_sample ] );
- joint_poses[ i ].scale = Lerp( joint.scales.samples[ scale_sample ], scale_lerp_frac, joint.scales.samples[ scale_sample ] );
+ joint_poses[ i ].rotation = NLerp( joint.rotations.samples[ rotation_sample ], rotation_lerp_frac, joint.rotations.samples[ ( rotation_sample + 1 ) % joint.rotations.num_samples ] );
+ joint_poses[ i ].translation = Lerp( joint.translations.samples[ translation_sample ], translation_lerp_frac, joint.translations.samples[ ( translation_sample + 1 ) % joint.translations.num_samples ] );
+ joint_poses[ i ].scale = Lerp( joint.scales.samples[ scale_sample ], scale_lerp_frac, joint.scales.samples[ ( scale_sample + 1 ) % joint.scales.num_samples ] );
}
}