first step to using a saner internal represnetation for the high precietion

models.
This commit is contained in:
Bill Currie 2002-01-07 06:32:46 +00:00
parent 14fb289f2f
commit 72d6f34dc8
3 changed files with 39 additions and 26 deletions

View file

@ -92,6 +92,11 @@ typedef struct {
byte lightnormalindex;
} trivertx_t;
typedef struct {
unsigned short v[3];
unsigned short lightnormalindex;
} trivertx16_t;
typedef struct {
trivertx_t bboxmin; // lightnormal isn't used
trivertx_t bboxmax; // lightnormal isn't used

View file

@ -346,7 +346,6 @@ Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s, i
{
int i, j;
int *cmds;
trivertx_t *verts;
char cache[MAX_QPATH], fullpath[MAX_OSPATH];
VFile *f;
unsigned char model_digest[MDFOUR_DIGEST_BYTES];
@ -489,21 +488,30 @@ Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s, i
paliashdr->commands = (byte *) cmds - (byte *) paliashdr;
memcpy (cmds, commands, numcommands * sizeof (int));
if (extra)
verts = Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts
* sizeof (trivertx_t) * 2);
else
verts = Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts
* sizeof (trivertx_t));
paliashdr->posedata = (byte *) verts - (byte *) paliashdr;
for (i = 0; i < paliashdr->numposes; i++)
{
for (j = 0; j < numorder; j++)
*verts++ = poseverts[i][vertexorder[j]];
if (extra)
if (extra) {
trivertx16_t *verts;
verts = Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts
* sizeof (trivertx16_t));
paliashdr->posedata = (byte *) verts - (byte *) paliashdr;
for (i = 0; i < paliashdr->numposes; i++) {
for (j = 0; j < numorder; j++) {
trivertx16_t v;
VectorMA (poseverts[i][vertexorder[j] + hdr->mdl.numverts].v,
256, poseverts[i][vertexorder[j]].v, v.v);
v.lightnormalindex =
poseverts[i][vertexorder[j]].lightnormalindex;
*verts++ = v;
}
}
} else {
trivertx_t *verts;
verts = Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts
* sizeof (trivertx_t));
paliashdr->posedata = (byte *) verts - (byte *) paliashdr;
for (i = 0; i < paliashdr->numposes; i++) {
for (j = 0; j < numorder; j++)
*verts++ = poseverts[i][vertexorder[j] + hdr->mdl.numverts];
*verts++ = poseverts[i][vertexorder[j]];
}
}
}

View file

@ -223,9 +223,9 @@ GL_DrawAliasShadow (aliashdr_t *paliashdr, vert_order_t *vo)
vert_order_t *
GL_GetAliasFrameVerts16 (int frame, aliashdr_t *paliashdr, entity_t *e)
{
float interval;
int count, numposes, pose, i;
trivertx_t *verts;
float interval;
int count, numposes, pose, i;
trivertx16_t *verts;
vert_order_t *vo;
blended_vert_t *vo_v;
@ -239,7 +239,7 @@ GL_GetAliasFrameVerts16 (int frame, aliashdr_t *paliashdr, entity_t *e)
pose = paliashdr->frames[frame].firstpose;
numposes = paliashdr->frames[frame].numposes;
verts = (trivertx_t *) ((byte *) paliashdr + paliashdr->posedata);
verts = (trivertx16_t *) ((byte *) paliashdr + paliashdr->posedata);
count = paliashdr->poseverts;
vo = Hunk_TempAlloc (sizeof (*vo) + count * sizeof (blended_vert_t));
@ -263,7 +263,7 @@ GL_GetAliasFrameVerts16 (int frame, aliashdr_t *paliashdr, entity_t *e)
}
if (gl_lerp_anim->int_val) {
trivertx_t *verts1, *verts2;
trivertx16_t *verts1, *verts2;
float blend;
vec3_t v1, v2;
@ -286,8 +286,8 @@ GL_GetAliasFrameVerts16 (int frame, aliashdr_t *paliashdr, entity_t *e)
if (r_paused || blend > 1)
blend = 1;
verts1 = verts + e->pose1 * count * 2;
verts2 = verts + e->pose2 * count * 2;
verts1 = verts + e->pose1 * count;
verts2 = verts + e->pose2 * count;
if (!blend) {
verts = verts1;
@ -296,8 +296,8 @@ GL_GetAliasFrameVerts16 (int frame, aliashdr_t *paliashdr, entity_t *e)
} else {
for (i = 0, vo_v = vo->verts; i < count;
i++, vo_v++, verts1++, verts2++) {
VectorMA (verts1->v, 1 / 256.0, (verts1 + count)->v, v1);
VectorMA (verts2->v, 1 / 256.0, (verts2 + count)->v, v2);
VectorScale (verts1->v, 1 / 256.0, v1);
VectorScale (verts2->v, 1 / 256.0, v2);
VectorBlend (v1, v2, blend, vo_v->vert);
vo_v->lightdot =
shadedots[verts1->lightnormalindex] * (1 - blend)
@ -306,10 +306,10 @@ GL_GetAliasFrameVerts16 (int frame, aliashdr_t *paliashdr, entity_t *e)
return vo;
}
} else {
verts += pose * count * 2;
verts += pose * count;
}
for (i = 0, vo_v = vo->verts; i < count; i++, vo_v++, verts++) {
VectorMA (verts->v, 1 / 256.0, (verts + count)->v, vo_v->vert);
VectorScale (verts->v, 1 / 256.0, vo_v->vert);
vo_v->lightdot = shadedots[verts->lightnormalindex];
}
return vo;