Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/t3d/t3danim.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static void rewind_anim(T3DAnim *anim)
rewind(anim->file);
}

static inline bool load_keyframe(T3DAnim *anim);
void t3d_anim_attach(T3DAnim *anim, const T3DSkeleton *skeleton) {
if(anim->targetsQuat)free(anim->targetsQuat);

Expand Down Expand Up @@ -79,6 +80,25 @@ void t3d_anim_attach(T3DAnim *anim, const T3DSkeleton *skeleton) {
default: {assertf(false, "Unknown animation target %d", channelMap->targetType);}
}
}

uint32_t initCount = 0;
while(initCount < channelCount) {
if(!load_keyframe(anim)) break;
initCount = 0;
for(int c = 0; c < anim->animRef->channelsQuat; c++) {
if(anim->targetsQuat[c].base.timeEnd > 0) initCount++;
}
for(int c = 0; c < anim->animRef->channelsScalar; c++) {
if(anim->targetsScalar[c].base.timeEnd > 0) initCount++;
}
}
for(int c = 0; c < anim->animRef->channelsQuat; c++) {
anim->targetsQuat[c].kfCurr = anim->targetsQuat[c].kfNext;
}
for(int c = 0; c < anim->animRef->channelsScalar; c++) {
anim->targetsScalar[c].kfCurr = anim->targetsScalar[c].kfNext;
}
rewind_anim(anim);
}

inline static void attach_scalar(T3DAnim* anim, uint32_t targetIdx, T3DVec3* target, int32_t *updateFlag, uint8_t targetType) {
Expand Down