Factor out scale support, add bmodels and sprites

This commit is contained in:
temx 2022-09-05 23:56:30 +03:00 committed by Ozkan Sezer
parent 239ec66233
commit dd8439b767
5 changed files with 18 additions and 26 deletions

View file

@ -332,12 +332,15 @@ qboolean R_CullModelForEntity (entity_t *e)
R_RotateForEntity -- johnfitz -- modified to take origin and angles instead of pointer to entity
===============
*/
void R_RotateForEntity (vec3_t origin, vec3_t angles)
void R_RotateForEntity (vec3_t origin, vec3_t angles, unsigned char scale)
{
float scalefactor = ENTSCALE_DECODE(scale);
glTranslatef (origin[0], origin[1], origin[2]);
glRotatef (angles[1], 0, 0, 1);
glRotatef (-angles[0], 0, 1, 0);
glRotatef (angles[2], 1, 0, 0);
if (scalefactor != 1.0f)
glScalef(scalefactor, scalefactor, scalefactor);
}
/*

View file

@ -345,7 +345,7 @@ void R_MarkSurfaces (void);
qboolean R_CullBox (vec3_t emins, vec3_t emaxs);
void R_StoreEfrags (efrag_t **ppefrag);
qboolean R_CullModelForEntity (entity_t *e);
void R_RotateForEntity (vec3_t origin, vec3_t angles);
void R_RotateForEntity (vec3_t origin, vec3_t angles, unsigned char scale);
void R_MarkLights (dlight_t *light, int num, mnode_t *node);
void R_InitParticles (void);

View file

@ -640,7 +640,6 @@ void R_DrawAliasModel (entity_t *e)
lerpdata_t lerpdata;
qboolean alphatest = !!(e->model->flags & MF_HOLEY);
float fovscale = 1.0f;
float scalefactor = 1.0f;
//
// setup pose/lerp data -- do it first so we don't miss updates due to culling
@ -662,12 +661,7 @@ void R_DrawAliasModel (entity_t *e)
fovscale = tan(scr_fov.value * (0.5f * M_PI / 180.f));
glPushMatrix ();
R_RotateForEntity (lerpdata.origin, lerpdata.angles);
scalefactor = ENTSCALE_DECODE(e->scale);
if (scalefactor != 1.0f)
{
glScalef (scalefactor, scalefactor, scalefactor);
}
R_RotateForEntity (lerpdata.origin, lerpdata.angles, e->scale);
glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1] * fovscale, paliashdr->scale_origin[2] * fovscale);
glScalef (paliashdr->scale[0], paliashdr->scale[1] * fovscale, paliashdr->scale[2] * fovscale);
@ -989,7 +983,6 @@ void R_DrawAliasModel_ShowTris (entity_t *e)
{
aliashdr_t *paliashdr;
lerpdata_t lerpdata;
float scalefactor;
if (R_CullModelForEntity(e))
return;
@ -999,12 +992,7 @@ void R_DrawAliasModel_ShowTris (entity_t *e)
R_SetupEntityTransform (e, &lerpdata);
glPushMatrix ();
R_RotateForEntity (lerpdata.origin,lerpdata.angles);
scalefactor = ENTSCALE_DECODE(e->scale);
if (scalefactor != 1.0f)
{
glScalef (scalefactor, scalefactor, scalefactor);
}
R_RotateForEntity (lerpdata.origin,lerpdata.angles, e->scale);
glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2]);
glScalef (paliashdr->scale[0], paliashdr->scale[1], paliashdr->scale[2]);

View file

@ -552,7 +552,7 @@ void R_DrawBrushModel (entity_t *e)
e->origin[1] -= DIST_EPSILON;
e->origin[2] -= DIST_EPSILON;
}
R_RotateForEntity (e->origin, e->angles);
R_RotateForEntity (e->origin, e->angles, e->scale);
if (gl_zfix.value)
{
e->origin[0] += DIST_EPSILON;
@ -618,7 +618,7 @@ void R_DrawBrushModel_ShowTris (entity_t *e)
glPushMatrix ();
e->angles[0] = -e->angles[0]; // stupid quake bug
R_RotateForEntity (e->origin, e->angles);
R_RotateForEntity (e->origin, e->angles, e->scale);
e->angles[0] = -e->angles[0]; // stupid quake bug
//

View file

@ -86,6 +86,7 @@ void R_DrawSpriteModel (entity_t *e)
mspriteframe_t *frame;
float *s_up, *s_right;
float angle, sr, cr;
float scale = ENTSCALE_DECODE(e->scale);
frame = R_GetSpriteFrame (e);
psprite = (msprite_t *) currententity->model->cache.data;
@ -152,23 +153,23 @@ void R_DrawSpriteModel (entity_t *e)
glBegin (GL_TRIANGLE_FAN); //was GL_QUADS, but changed to support r_showtris
glTexCoord2f (0, frame->tmax);
VectorMA (e->origin, frame->down, s_up, point);
VectorMA (point, frame->left, s_right, point);
VectorMA (e->origin, frame->down * scale, s_up, point);
VectorMA (point, frame->left * scale, s_right, point);
glVertex3fv (point);
glTexCoord2f (0, 0);
VectorMA (e->origin, frame->up, s_up, point);
VectorMA (point, frame->left, s_right, point);
VectorMA (e->origin, frame->up * scale, s_up, point);
VectorMA (point, frame->left * scale, s_right, point);
glVertex3fv (point);
glTexCoord2f (frame->smax, 0);
VectorMA (e->origin, frame->up, s_up, point);
VectorMA (point, frame->right, s_right, point);
VectorMA (e->origin, frame->up * scale, s_up, point);
VectorMA (point, frame->right * scale, s_right, point);
glVertex3fv (point);
glTexCoord2f (frame->smax, frame->tmax);
VectorMA (e->origin, frame->down, s_up, point);
VectorMA (point, frame->right, s_right, point);
VectorMA (e->origin, frame->down * scale, s_up, point);
VectorMA (point, frame->right * scale, s_right, point);
glVertex3fv (point);
glEnd ();