From 42456845f0c800d7b142ce24a176c53039ac727b Mon Sep 17 00:00:00 2001 From: Seth Galbraith Date: Sat, 5 Jan 2002 03:21:02 +0000 Subject: [PATCH] high precision software mdl rendering --- include/r_local.h | 1 - libs/models/alias/model_alias.c | 1 + libs/video/renderer/sw/sw_ralias.c | 45 +++++++++++++++++--------- libs/video/renderer/sw32/sw32_ralias.c | 34 +++++++++++++++---- 4 files changed, 58 insertions(+), 23 deletions(-) diff --git a/include/r_local.h b/include/r_local.h index 4418d2e67..1c2635627 100644 --- a/include/r_local.h +++ b/include/r_local.h @@ -238,7 +238,6 @@ void R_ZDrawSubmodelPolys (model_t *clmodel); // Alias models =========================================== -#define MAXALIASVERTS 1024 #define ALIAS_Z_CLIP_PLANE 5 extern int numverts; diff --git a/libs/models/alias/model_alias.c b/libs/models/alias/model_alias.c index 371e289dc..0f4b82f5d 100644 --- a/libs/models/alias/model_alias.c +++ b/libs/models/alias/model_alias.c @@ -184,6 +184,7 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator) mod->flags = LittleLong (pinmodel->flags); // endian-adjust and copy the data, starting with the alias model header + pmodel->ident = LittleLong (pinmodel->ident); pmodel->boundingradius = LittleFloat (pinmodel->boundingradius); pmodel->numskins = LittleLong (pinmodel->numskins); pmodel->skinwidth = LittleLong (pinmodel->skinwidth); diff --git a/libs/video/renderer/sw/sw_ralias.c b/libs/video/renderer/sw/sw_ralias.c index 9770cb6d9..9437602a2 100644 --- a/libs/video/renderer/sw/sw_ralias.c +++ b/libs/video/renderer/sw/sw_ralias.c @@ -94,8 +94,7 @@ void R_AliasTransformVector (vec3_t in, vec3_t out); void R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av, trivertx_t *pverts, stvert_t *pstverts); void R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av); - - + qboolean R_AliasCheckBBox (void) { @@ -374,7 +373,8 @@ R_AliasSetUpTransform (int trivial_accept) // Also scale down z, so 1/z is scaled 31 bits for free, and scale down x and y // correspondingly so the projected x and y come out right // FIXME: make this work for clipped case too? - if (trivial_accept) { + + if (trivial_accept && pmdl->ident != POLYHEADER16) { for (i = 0; i < 4; i++) { aliastransform[0][i] *= aliasxscale * (1.0 / ((float) 0x8000 * 0x10000)); @@ -385,7 +385,6 @@ R_AliasSetUpTransform (int trivial_accept) } } - void R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av, trivertx_t *pverts, stvert_t *pstverts) @@ -393,12 +392,31 @@ R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av, int temp; float lightcos, *plightnormal; - av->fv[0] = DotProduct (pverts->v, aliastransform[0]) + - aliastransform[0][3]; - av->fv[1] = DotProduct (pverts->v, aliastransform[1]) + - aliastransform[1][3]; - av->fv[2] = DotProduct (pverts->v, aliastransform[2]) + - aliastransform[2][3]; + if (pmdl->ident == POLYHEADER16) + { + trivertx_t * pextra; + float vextra[3]; + + pextra = pverts + pmdl->numverts; + vextra[0] = pverts->v[0] + pextra->v[0] / (float)256; + vextra[1] = pverts->v[1] + pextra->v[1] / (float)256; + vextra[2] = pverts->v[2] + pextra->v[2] / (float)256; + av->fv[0] = DotProduct (vextra, aliastransform[0]) + + aliastransform[0][3]; + av->fv[1] = DotProduct (vextra, aliastransform[1]) + + aliastransform[1][3]; + av->fv[2] = DotProduct (vextra, aliastransform[2]) + + aliastransform[2][3]; + } + else + { + av->fv[0] = DotProduct (pverts->v, aliastransform[0]) + + aliastransform[0][3]; + av->fv[1] = DotProduct (pverts->v, aliastransform[1]) + + aliastransform[1][3]; + av->fv[2] = DotProduct (pverts->v, aliastransform[2]) + + aliastransform[2][3]; + } fv->v[2] = pstverts->s; fv->v[3] = pstverts->t; @@ -422,7 +440,6 @@ R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av, fv->v[4] = temp; } - #ifdef PIC #undef USE_INTEL_ASM //XXX asm pic hack #endif @@ -475,7 +492,6 @@ R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts) } #endif - void R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av) { @@ -490,7 +506,6 @@ R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av) fv->v[1] = (av->fv[1] * aliasyscale * zi) + aliasycenter; } - void R_AliasPrepareUnclippedPoints (void) { @@ -652,7 +667,7 @@ R_AliasSetupFrame (void) ((byte *) paliashdr + paliasgroup->frames[i].frame); } - +#define MAXALIASVERTS 1024 void R_AliasDrawModel (alight_t *plighting) { @@ -696,7 +711,7 @@ R_AliasDrawModel (alight_t *plighting) else ziscale = (float) 0x8000 *(float) 0x10000 *3.0; - if (currententity->trivial_accept) + if (currententity->trivial_accept && pmdl->ident != POLYHEADER16) R_AliasPrepareUnclippedPoints (); else R_AliasPreparePoints (); diff --git a/libs/video/renderer/sw32/sw32_ralias.c b/libs/video/renderer/sw32/sw32_ralias.c index 0a20023df..296e44446 100644 --- a/libs/video/renderer/sw32/sw32_ralias.c +++ b/libs/video/renderer/sw32/sw32_ralias.c @@ -393,12 +393,31 @@ R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av, int temp; float lightcos, *plightnormal; - av->fv[0] = DotProduct (pverts->v, aliastransform[0]) + - aliastransform[0][3]; - av->fv[1] = DotProduct (pverts->v, aliastransform[1]) + - aliastransform[1][3]; - av->fv[2] = DotProduct (pverts->v, aliastransform[2]) + - aliastransform[2][3]; + if (pmdl->ident == POLYHEADER16) + { + trivertx_t * pextra; + float vextra[3]; + + pextra = pverts + pmdl->numverts; + vextra[0] = pverts->v[0] + pextra->v[0] / (float)256; + vextra[1] = pverts->v[1] + pextra->v[1] / (float)256; + vextra[2] = pverts->v[2] + pextra->v[2] / (float)256; + av->fv[0] = DotProduct (vextra, aliastransform[0]) + + aliastransform[0][3]; + av->fv[1] = DotProduct (vextra, aliastransform[1]) + + aliastransform[1][3]; + av->fv[2] = DotProduct (vextra, aliastransform[2]) + + aliastransform[2][3]; + } + else + { + av->fv[0] = DotProduct (pverts->v, aliastransform[0]) + + aliastransform[0][3]; + av->fv[1] = DotProduct (pverts->v, aliastransform[1]) + + aliastransform[1][3]; + av->fv[2] = DotProduct (pverts->v, aliastransform[2]) + + aliastransform[2][3]; + } fv->v[2] = pstverts->s; fv->v[3] = pstverts->t; @@ -640,6 +659,7 @@ R_AliasSetupFrame (void) } +#define MAXALIASVERTS 1024 void R_AliasDrawModel (alight_t *plighting) { @@ -682,7 +702,7 @@ R_AliasDrawModel (alight_t *plighting) else ziscale = (float) 0x8000 *(float) 0x10000 *3.0; - if (currententity->trivial_accept) + if (currententity->trivial_accept && pmdl->ident != POLYHEADER16) R_AliasPrepareUnclippedPoints (); else R_AliasPreparePoints ();