+ }
+ else if (model->surfmesh.data_morphmdlvertex)
+ {
+ // vertex morph
+ int i, numblends, blendnum;
+ int numverts = model->surfmesh.num_vertices;
+ float translate[3];
+ VectorClear(translate);
+ numblends = 0;
+ // blend the frame translates to avoid redundantly doing so on each vertex
+ // (a bit of a brain twister but it works)
+ for (blendnum = 0;blendnum < 4;blendnum++)
+ {
+ if (model->surfmesh.data_morphmd2framesize6f)
+ VectorMA(translate, frameblend[blendnum].lerp, model->surfmesh.data_morphmd2framesize6f + frameblend[blendnum].frame * 6 + 3, translate);
+ else
+ VectorMA(translate, frameblend[blendnum].lerp, model->surfmesh.num_morphmdlframetranslate, translate);
+ if (frameblend[blendnum].lerp > 0)
+ numblends = blendnum + 1;
+ }
+ // special case for the first blend because it avoids some adds and the need to memset the arrays first
+ for (blendnum = 0;blendnum < numblends;blendnum++)
+ {
+ const trivertx_t *verts = model->surfmesh.data_morphmdlvertex + numverts * frameblend[blendnum].frame;
+ float scale[3];
+ if (model->surfmesh.data_morphmd2framesize6f)
+ VectorScale(model->surfmesh.data_morphmd2framesize6f + frameblend[blendnum].frame * 6, frameblend[blendnum].lerp, scale);
+ else
+ VectorScale(model->surfmesh.num_morphmdlframescale, frameblend[blendnum].lerp, scale);
+ if (blendnum == 0)
+ {
+ for (i = 0;i < numverts;i++)
+ {
+ vertex3f[i * 3 + 0] = translate[0] + verts[i].v[0] * scale[0];
+ vertex3f[i * 3 + 1] = translate[1] + verts[i].v[1] * scale[1];
+ vertex3f[i * 3 + 2] = translate[2] + verts[i].v[2] * scale[2];
+ }
+ }
+ else
+ {
+ for (i = 0;i < numverts;i++)
+ {
+ vertex3f[i * 3 + 0] += verts[i].v[0] * scale[0];
+ vertex3f[i * 3 + 1] += verts[i].v[1] * scale[1];
+ vertex3f[i * 3 + 2] += verts[i].v[2] * scale[2];
+ }
+ }
+ // the vertex normals in mdl models are an index into a table of
+ // 162 unique values, this very crude quantization reduces the
+ // vertex normal to only one byte, which saves a lot of space but
+ // also makes lighting pretty coarse
+ if (normal3f)
+ {
+ float lerp = frameblend[blendnum].lerp;
+ if (blendnum == 0)
+ {
+ for (i = 0;i < numverts;i++)
+ {
+ const float *vn = m_bytenormals[verts[i].lightnormalindex];
+ VectorScale(vn, lerp, normal3f + i*3);
+ }
+ }
+ else
+ {
+ for (i = 0;i < numverts;i++)
+ {
+ const float *vn = m_bytenormals[verts[i].lightnormalindex];
+ VectorMA(normal3f + i*3, lerp, vn, normal3f + i*3);
+ }
+ }
+ }