From dd8439b7671f69b1f183bb0d00099b371a06637c Mon Sep 17 00:00:00 2001 From: temx Date: Mon, 5 Sep 2022 23:56:30 +0300 Subject: [PATCH] Factor out scale support, add bmodels and sprites --- Quake/gl_rmain.c | 5 ++++- Quake/glquake.h | 2 +- Quake/r_alias.c | 16 ++-------------- Quake/r_brush.c | 4 ++-- Quake/r_sprite.c | 17 +++++++++-------- 5 files changed, 18 insertions(+), 26 deletions(-) diff --git a/Quake/gl_rmain.c b/Quake/gl_rmain.c index 0aa056ac..44c284ff 100644 --- a/Quake/gl_rmain.c +++ b/Quake/gl_rmain.c @@ -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); } /* diff --git a/Quake/glquake.h b/Quake/glquake.h index 86ba117a..43c4131d 100644 --- a/Quake/glquake.h +++ b/Quake/glquake.h @@ -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); diff --git a/Quake/r_alias.c b/Quake/r_alias.c index 581b3029..4b718519 100644 --- a/Quake/r_alias.c +++ b/Quake/r_alias.c @@ -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]); diff --git a/Quake/r_brush.c b/Quake/r_brush.c index 0ee701b9..0ffeadf8 100644 --- a/Quake/r_brush.c +++ b/Quake/r_brush.c @@ -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 // diff --git a/Quake/r_sprite.c b/Quake/r_sprite.c index b15393e1..42af2687 100644 --- a/Quake/r_sprite.c +++ b/Quake/r_sprite.c @@ -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 ();