| 77 | } |
| 78 | |
| 79 | void xMorphRender(xMorphSeqFile* seq, RwMatrix* mat, F32 time) |
| 80 | { |
| 81 | F32 lerp; |
| 82 | U32 tidx, tcount; |
| 83 | S16 weight[4]; |
| 84 | S16* wptr; |
| 85 | F32* times; |
| 86 | xMorphFrame* frame; |
| 87 | |
| 88 | times = (F32*)(seq + 1); |
| 89 | tcount = seq->TimeCount; |
| 90 | frame = (xMorphFrame*)(times + seq->TimeCount); |
| 91 | |
| 92 | if (time < 0.0f) time = 0.0f; |
| 93 | if (time > times[tcount-1]) time = times[tcount-1]; |
| 94 | |
| 95 | tidx = (tcount-1) & 0x3; |
| 96 | while (times[tidx] < time) tidx += 4; |
| 97 | while (tidx && time < times[tidx]) tidx--; |
| 98 | |
| 99 | frame += tidx; |
| 100 | |
| 101 | if (!frame->Targets[0]) { |
| 102 | iModelRender(frame->Model, mat); |
| 103 | } else { |
| 104 | lerp = frame->RecipTime * (time - times[tidx]); |
| 105 | if (lerp == 0.0f) { |
| 106 | wptr = frame->WeightStart; |
| 107 | } else { |
| 108 | weight[0] = (S32)(lerp * (frame->WeightEnd[0] - frame->WeightStart[0])) + frame->WeightStart[0], |
| 109 | weight[1] = (S32)(lerp * (frame->WeightEnd[1] - frame->WeightStart[1])) + frame->WeightStart[1], |
| 110 | weight[2] = (S32)(lerp * (frame->WeightEnd[2] - frame->WeightStart[2])) + frame->WeightStart[2], |
| 111 | weight[3] = (S32)(lerp * (frame->WeightEnd[3] - frame->WeightStart[3])) + frame->WeightStart[3]; |
| 112 | wptr = weight; |
| 113 | } |
| 114 | |
| 115 | iMorphRender(frame->Model, mat, frame->Targets, wptr, frame->Flags & 0x1, frame->Scale); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | F32 xMorphSeqDuration(xMorphSeqFile* seq) |
| 120 | { |
no test coverage detected