MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / xMorphRender

Function xMorphRender

src/SB/Core/x/xMorph.cpp:79–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void 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
119F32 xMorphSeqDuration(xMorphSeqFile* seq)
120{

Callers 1

xModelRenderSingleFunction · 0.70

Calls 2

iMorphRenderFunction · 0.85
iModelRenderFunction · 0.50

Tested by

no test coverage detected