From 46c654b3797d3ed1e757ad027a583761afdd3057 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Mon, 20 Sep 2021 12:56:18 +0300 Subject: [PATCH] gl1: use local currentmodel --- src/client/refresh/gl3/gl3_lightmap.c | 2 +- src/client/refresh/gl3/gl3_main.c | 15 +++++++-------- src/client/refresh/gl3/gl3_model.c | 4 +--- src/client/refresh/gl3/gl3_surf.c | 8 +++----- src/client/refresh/gl3/header/local.h | 5 ++--- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/client/refresh/gl3/gl3_lightmap.c b/src/client/refresh/gl3/gl3_lightmap.c index 9a95c4dd..80d93b62 100644 --- a/src/client/refresh/gl3/gl3_lightmap.c +++ b/src/client/refresh/gl3/gl3_lightmap.c @@ -118,7 +118,7 @@ GL3_LM_AllocBlock(int w, int h, int *x, int *y) } void -GL3_LM_BuildPolygonFromSurface(msurface_t *fa) +GL3_LM_BuildPolygonFromSurface(gl3model_t *currentmodel, msurface_t *fa) { int i, lindex, lnumverts; medge_t *pedges, *r_pedge; diff --git a/src/client/refresh/gl3/gl3_main.c b/src/client/refresh/gl3/gl3_main.c index 4696c97d..d10b284e 100644 --- a/src/client/refresh/gl3/gl3_main.c +++ b/src/client/refresh/gl3/gl3_main.c @@ -50,7 +50,6 @@ refdef_t gl3_newrefdef; viddef_t vid; gl3model_t *gl3_worldmodel; -gl3model_t *currentmodel; entity_t *currententity; float gl3depthmin=0.0f, gl3depthmax=1.0f; @@ -773,7 +772,7 @@ GL3_DrawBeam(entity_t *e) } static void -GL3_DrawSpriteModel(entity_t *e) +GL3_DrawSpriteModel(entity_t *e, gl3model_t *currentmodel) { float alpha = 1.0F; gl3_3D_vtx_t verts[4]; @@ -990,7 +989,7 @@ GL3_DrawEntitiesOnList(void) } else { - currentmodel = currententity->model; + gl3model_t *currentmodel = currententity->model; if (!currentmodel) { @@ -1004,10 +1003,10 @@ GL3_DrawEntitiesOnList(void) GL3_DrawAliasModel(currententity); break; case mod_brush: - GL3_DrawBrushModel(currententity); + GL3_DrawBrushModel(currententity, currentmodel); break; case mod_sprite: - GL3_DrawSpriteModel(currententity); + GL3_DrawSpriteModel(currententity, currentmodel); break; default: ri.Sys_Error(ERR_DROP, "Bad modeltype"); @@ -1036,7 +1035,7 @@ GL3_DrawEntitiesOnList(void) } else { - currentmodel = currententity->model; + gl3model_t *currentmodel = currententity->model; if (!currentmodel) { @@ -1050,10 +1049,10 @@ GL3_DrawEntitiesOnList(void) GL3_DrawAliasModel(currententity); break; case mod_brush: - GL3_DrawBrushModel(currententity); + GL3_DrawBrushModel(currententity, currentmodel); break; case mod_sprite: - GL3_DrawSpriteModel(currententity); + GL3_DrawSpriteModel(currententity, currentmodel); break; default: ri.Sys_Error(ERR_DROP, "Bad modeltype"); diff --git a/src/client/refresh/gl3/gl3_model.c b/src/client/refresh/gl3/gl3_model.c index 7e332ec7..4694e90e 100644 --- a/src/client/refresh/gl3/gl3_model.c +++ b/src/client/refresh/gl3/gl3_model.c @@ -543,8 +543,6 @@ Mod_LoadFaces(gl3model_t *loadmodel, byte *mod_base, lump_t *l) loadmodel->surfaces = out; loadmodel->numsurfaces = count; - currentmodel = loadmodel; - GL3_LM_BeginBuildingLightmaps(loadmodel); for (surfnum = 0; surfnum < count; surfnum++, in++, out++) @@ -623,7 +621,7 @@ Mod_LoadFaces(gl3model_t *loadmodel, byte *mod_base, lump_t *l) if (!(out->texinfo->flags & SURF_WARP)) { - GL3_LM_BuildPolygonFromSurface(out); + GL3_LM_BuildPolygonFromSurface(loadmodel, out); } } diff --git a/src/client/refresh/gl3/gl3_surf.c b/src/client/refresh/gl3/gl3_surf.c index e3ae6d38..8f22d646 100644 --- a/src/client/refresh/gl3/gl3_surf.c +++ b/src/client/refresh/gl3/gl3_surf.c @@ -526,7 +526,7 @@ RenderLightmappedPoly(msurface_t *surf) } static void -DrawInlineBModel(void) +DrawInlineBModel(gl3model_t *currentmodel) { int i, k; cplane_t *pplane; @@ -590,7 +590,7 @@ DrawInlineBModel(void) } void -GL3_DrawBrushModel(entity_t *e) +GL3_DrawBrushModel(entity_t *e, gl3model_t *currentmodel) { vec3_t mins, maxs; int i; @@ -656,7 +656,7 @@ GL3_DrawBrushModel(entity_t *e) e->angles[0] = -e->angles[0]; e->angles[2] = -e->angles[2]; - DrawInlineBModel(); + DrawInlineBModel(currentmodel); // glPopMatrix(); gl3state.uni3DData.transModelMat4 = oldMat; @@ -824,8 +824,6 @@ GL3_DrawWorld(void) return; } - currentmodel = gl3_worldmodel; - VectorCopy(gl3_newrefdef.vieworg, modelorg); /* auto cycle the world frame for texture animation */ diff --git a/src/client/refresh/gl3/header/local.h b/src/client/refresh/gl3/header/local.h index 1b9a77b8..b5bee801 100644 --- a/src/client/refresh/gl3/header/local.h +++ b/src/client/refresh/gl3/header/local.h @@ -300,7 +300,6 @@ typedef struct } gl3lightmapstate_t; extern gl3model_t *gl3_worldmodel; -extern gl3model_t *currentmodel; extern entity_t *currententity; extern float gl3depthmin, gl3depthmax; @@ -436,7 +435,7 @@ extern void GL3_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride); extern void GL3_LM_InitBlock(void); extern void GL3_LM_UploadBlock(void); extern qboolean GL3_LM_AllocBlock(int w, int h, int *x, int *y); -extern void GL3_LM_BuildPolygonFromSurface(msurface_t *fa); +extern void GL3_LM_BuildPolygonFromSurface(gl3model_t *currentmodel, msurface_t *fa); extern void GL3_LM_CreateSurfaceLightmap(msurface_t *surf); extern void GL3_LM_BeginBuildingLightmaps(gl3model_t *m); extern void GL3_LM_EndBuildingLightmaps(void); @@ -458,7 +457,7 @@ extern void GL3_DrawGLPoly(msurface_t *fa); extern void GL3_DrawGLFlowingPoly(msurface_t *fa); extern void GL3_DrawTriangleOutlines(void); extern void GL3_DrawAlphaSurfaces(void); -extern void GL3_DrawBrushModel(entity_t *e); +extern void GL3_DrawBrushModel(entity_t *e, gl3model_t *currentmodel); extern void GL3_DrawWorld(void); extern void GL3_MarkLeaves(void);