File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -63,8 +63,7 @@ void t3d_skeleton_update(T3DSkeleton *skeleton)
6363 int updateLevel = -1 ;
6464 bool forceUpdate = false;
6565
66- skeleton -> currentBufferIdx = (skeleton -> currentBufferIdx + 1 ) % skeleton -> bufferCount ;
67- T3DMat4FP * matStackFP = & skeleton -> boneMatricesFP [skeleton -> skeletonRef -> boneCount * skeleton -> currentBufferIdx ];
66+ T3DMat4FP * matStackFP = nullptr ;
6867
6968 for (int i = 0 ; i < skeleton -> skeletonRef -> boneCount ; i ++ )
7069 {
@@ -78,6 +77,14 @@ void t3d_skeleton_update(T3DSkeleton *skeleton)
7877
7978 if (bone -> hasChanged || forceUpdate )
8079 {
80+ // only cycle through matrices if at least one bone changes.
81+ // this avoids flickering at the end of an animation, since it would cycle through the last X frames otherwise.
82+ if (matStackFP == nullptr )
83+ {
84+ skeleton -> currentBufferIdx = (skeleton -> currentBufferIdx + 1 ) % skeleton -> bufferCount ;
85+ matStackFP = & skeleton -> boneMatricesFP [skeleton -> skeletonRef -> boneCount * skeleton -> currentBufferIdx ];
86+ }
87+
8188 // if a bone changed we need to also update any children.
8289 // To do so, update all following bones until we hit one that has the same depth as the changed bone.
8390 if (!forceUpdate )updateLevel = boneDef -> depth ;
You can’t perform that action at this time.
0 commit comments