diff --git a/src/client/refresh/gl1/gl1_lightmap.c b/src/client/refresh/gl1/gl1_lightmap.c index 435e7484..9c7d06d8 100644 --- a/src/client/refresh/gl1/gl1_lightmap.c +++ b/src/client/refresh/gl1/gl1_lightmap.c @@ -143,7 +143,7 @@ LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa) medge_t *pedges, *r_pedge; float *vec; float s, t; - glpoly_t *poly; + mpoly_t *poly; vec3_t total; /* reconstruct the polygon */ @@ -153,7 +153,7 @@ LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa) VectorClear(total); /* draw texture */ - poly = Hunk_Alloc(sizeof(glpoly_t) + + poly = Hunk_Alloc(sizeof(mpoly_t) + (lnumverts - 4) * VERTEXSIZE * sizeof(float)); poly->next = fa->polys; poly->flags = fa->flags; @@ -225,8 +225,9 @@ LM_CreateSurfaceLightmap(msurface_t *surf) if (!LM_AllocBlock(smax, tmax, &surf->light_s, &surf->light_t)) { - ri.Sys_Error(ERR_FATAL, "Consecutive calls to LM_AllocBlock(%d,%d) failed\n", - smax, tmax); + ri.Sys_Error(ERR_FATAL, + "%s: Consecutive calls to LM_AllocBlock(%d,%d) failed\n", + __func__, smax, tmax); } } diff --git a/src/client/refresh/gl1/gl1_model.c b/src/client/refresh/gl1/gl1_model.c index 7f54d238..4c40b282 100644 --- a/src/client/refresh/gl1/gl1_model.c +++ b/src/client/refresh/gl1/gl1_model.c @@ -294,7 +294,7 @@ calcTexinfoAndFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl // GL3_SubdivideSurface(out, loadmodel); /* cut up polygon for warps */ // for each (pot. recursive) call to R_SubdividePolygon(): - // sizeof(glpoly_t) + ((numverts - 4) + 2) * sizeof(gl3_3D_vtx_t) + // sizeof(mpoly_t) + ((numverts - 4) + 2) * sizeof(gl3_3D_vtx_t) // this is tricky, how much is allocated depends on the size of the surface // which we don't know (we'd need the vertices etc to know, but we can't load @@ -306,8 +306,8 @@ calcTexinfoAndFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl else { // LM_BuildPolygonFromSurface(out); - // => poly = Hunk_Alloc(sizeof(glpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float)); - int polySize = sizeof(glpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float); + // => poly = Hunk_Alloc(sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float)); + int polySize = sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float); polySize = (polySize + 31) & ~31; ret += polySize; } @@ -370,7 +370,7 @@ calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *t // GL3_SubdivideSurface(out, loadmodel); /* cut up polygon for warps */ // for each (pot. recursive) call to R_SubdividePolygon(): - // sizeof(glpoly_t) + ((numverts - 4) + 2) * sizeof(gl3_3D_vtx_t) + // sizeof(mpoly_t) + ((numverts - 4) + 2) * sizeof(gl3_3D_vtx_t) // this is tricky, how much is allocated depends on the size of the surface // which we don't know (we'd need the vertices etc to know, but we can't load @@ -382,8 +382,8 @@ calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *t else { // LM_BuildPolygonFromSurface(out); - // => poly = Hunk_Alloc(sizeof(glpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float)); - int polySize = sizeof(glpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float); + // => poly = Hunk_Alloc(sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float)); + int polySize = sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float); polySize = (polySize + 31) & ~31; ret += polySize; } diff --git a/src/client/refresh/gl1/gl1_surf.c b/src/client/refresh/gl1/gl1_surf.c index 33b26b64..2c8fe3bb 100644 --- a/src/client/refresh/gl1/gl1_surf.c +++ b/src/client/refresh/gl1/gl1_surf.c @@ -43,7 +43,7 @@ void R_SetCacheState(msurface_t *surf); void R_BuildLightMap(msurface_t *surf, byte *dest, int stride); static void -R_DrawGLPoly(glpoly_t *p) +R_DrawGLPoly(mpoly_t *p) { float *v; @@ -65,7 +65,7 @@ R_DrawGLFlowingPoly(msurface_t *fa) { int i; float *v; - glpoly_t *p; + mpoly_t *p; float scroll; p = fa->polys; @@ -106,7 +106,7 @@ static void R_DrawTriangleOutlines(void) { int i, j; - glpoly_t *p; + mpoly_t *p; if (!r_showtris->value) { @@ -158,7 +158,7 @@ R_DrawTriangleOutlines(void) } static void -R_DrawGLPolyChain(glpoly_t *p, float soffset, float toffset) +R_DrawGLPolyChain(mpoly_t *p, float soffset, float toffset) { if ((soffset == 0) && (toffset == 0)) { @@ -184,7 +184,7 @@ R_DrawGLPolyChain(glpoly_t *p, float soffset, float toffset) // workaround for lack of VLAs (=> our workaround uses alloca() which is bad in loops) #ifdef _MSC_VER int maxNumVerts = 0; - for (glpoly_t* tmp = p; tmp; tmp = tmp->chain) + for (mpoly_t* tmp = p; tmp; tmp = tmp->chain) { if ( tmp->numverts > maxNumVerts ) maxNumVerts = tmp->numverts; @@ -372,8 +372,8 @@ R_BlendLightmaps(const model_t *currentmodel) if (!LM_AllocBlock(smax, tmax, &surf->dlight_s, &surf->dlight_t)) { ri.Sys_Error(ERR_FATAL, - "Consecutive calls to LM_AllocBlock(%d,%d) failed (dynamic)\n", - smax, tmax); + "%s: Consecutive calls to LM_AllocBlock(%d,%d) failed\n", + __func__, smax, tmax); } base = gl_lms.lightmap_buffer; diff --git a/src/client/refresh/gl1/gl1_warp.c b/src/client/refresh/gl1/gl1_warp.c index 7a520910..ed29640b 100644 --- a/src/client/refresh/gl1/gl1_warp.c +++ b/src/client/refresh/gl1/gl1_warp.c @@ -95,7 +95,7 @@ R_SubdividePolygon(int numverts, float *verts, msurface_t *warpface) int f, b; float dist[64]; float frac; - glpoly_t *poly; + mpoly_t *poly; float s, t; vec3_t total; float total_s, total_t; @@ -178,7 +178,7 @@ R_SubdividePolygon(int numverts, float *verts, msurface_t *warpface) } /* add a point in the center to help keep warp valid */ - poly = Hunk_Alloc(sizeof(glpoly_t) + ((numverts - 4) + 2) * VERTEXSIZE * sizeof(float)); + poly = Hunk_Alloc(sizeof(mpoly_t) + ((numverts - 4) + 2) * VERTEXSIZE * sizeof(float)); poly->next = warpface->polys; warpface->polys = poly; poly->numverts = numverts + 2; @@ -246,12 +246,12 @@ R_SubdivideSurface(model_t *loadmodel, msurface_t *fa) } /* - * Does a water warp on the pre-fragmented glpoly_t chain + * Does a water warp on the pre-fragmented mpoly_t chain */ void R_EmitWaterPolys(msurface_t *fa) { - glpoly_t *p, *bp; + mpoly_t *p, *bp; float *v; int i; float s, t, os, ot; @@ -270,7 +270,7 @@ R_EmitWaterPolys(msurface_t *fa) // workaround for lack of VLAs (=> our workaround uses alloca() which is bad in loops) #ifdef _MSC_VER int maxNumVerts = 0; - for ( glpoly_t* tmp = fa->polys; tmp; tmp = tmp->next ) + for ( mpoly_t* tmp = fa->polys; tmp; tmp = tmp->next ) { if (tmp->numverts > maxNumVerts) maxNumVerts = tmp->numverts; @@ -549,7 +549,7 @@ R_AddSkySurface(msurface_t *fa) { int i; vec3_t verts[MAX_CLIP_VERTS]; - glpoly_t *p; + mpoly_t *p; /* calculate vertex values for sky box */ for (p = fa->polys; p; p = p->next) diff --git a/src/client/refresh/gl1/header/local.h b/src/client/refresh/gl1/header/local.h index a99b3b79..ac4fe82b 100644 --- a/src/client/refresh/gl1/header/local.h +++ b/src/client/refresh/gl1/header/local.h @@ -273,7 +273,7 @@ void R_RotateForEntity(entity_t *e); void R_MarkLeaves(void); extern int r_dlightframecount; -glpoly_t *WaterWarpPolyVerts(glpoly_t *p); +mpoly_t *WaterWarpPolyVerts(mpoly_t *p); void R_EmitWaterPolys(msurface_t *fa); void R_AddSkySurface(msurface_t *fa); void R_ClearSkyBox(void); diff --git a/src/client/refresh/gl1/header/model.h b/src/client/refresh/gl1/header/model.h index 8f38e0c0..9e1281e8 100644 --- a/src/client/refresh/gl1/header/model.h +++ b/src/client/refresh/gl1/header/model.h @@ -27,55 +27,7 @@ #ifndef REF_MODEL_H #define REF_MODEL_H -#define VERTEXSIZE 7 - -/* in memory representation */ - -typedef struct glpoly_s -{ - struct glpoly_s *next; - struct glpoly_s *chain; - int numverts; - int flags; /* for SURF_UNDERWATER (not needed anymore?) */ - float verts[4][VERTEXSIZE]; /* variable sized (xyz s1t1 s2t2) */ -} glpoly_t; - -typedef struct msurface_s -{ - int visframe; /* should be drawn when node is crossed */ - - cplane_t *plane; - int flags; - - int firstedge; /* look up in model->surfedges[], negative numbers */ - int numedges; /* are backwards edges */ - - short texturemins[2]; - short extents[2]; - short lmshift; - - int light_s, light_t; /* gl lightmap coordinates */ - int dlight_s, dlight_t; /* gl lightmap coordinates for dynamic lightmaps */ - - glpoly_t *polys; /* multiple if warped */ - struct msurface_s *texturechain; - struct msurface_s *lightmapchain; - - mtexinfo_t *texinfo; - - /* decoupled lm */ - float lmvecs[2][4]; - float lmvlen[2]; - - /* lighting info */ - int dlightframe; - int dlightbits; - - int lightmaptexturenum; - byte styles[MAXLIGHTMAPS]; - float cached_light[MAXLIGHTMAPS]; /* values currently used in lightmap */ - byte *samples; /* [numstyles*surfsize] */ -} msurface_t; +#include "../../ref_model.h" /* Whole model */ diff --git a/src/client/refresh/gl3/gl3_lightmap.c b/src/client/refresh/gl3/gl3_lightmap.c index b508150a..3c4cb408 100644 --- a/src/client/refresh/gl3/gl3_lightmap.c +++ b/src/client/refresh/gl3/gl3_lightmap.c @@ -220,8 +220,9 @@ GL3_LM_CreateSurfaceLightmap(msurface_t *surf) if (!GL3_LM_AllocBlock(smax, tmax, &surf->light_s, &surf->light_t)) { - ri.Sys_Error(ERR_FATAL, "Consecutive calls to LM_AllocBlock(%d,%d) failed\n", - smax, tmax); + ri.Sys_Error(ERR_FATAL, + "%s: Consecutive calls to LM_AllocBlock(%d,%d) failed\n", + __func__, smax, tmax); } } diff --git a/src/client/refresh/gl4/gl4_lightmap.c b/src/client/refresh/gl4/gl4_lightmap.c index f0706442..5e26ccd5 100644 --- a/src/client/refresh/gl4/gl4_lightmap.c +++ b/src/client/refresh/gl4/gl4_lightmap.c @@ -220,8 +220,9 @@ GL4_LM_CreateSurfaceLightmap(msurface_t *surf) if (!GL4_LM_AllocBlock(smax, tmax, &surf->light_s, &surf->light_t)) { - ri.Sys_Error(ERR_FATAL, "Consecutive calls to LM_AllocBlock(%d,%d) failed\n", - smax, tmax); + ri.Sys_Error(ERR_FATAL, + "%s: Consecutive calls to LM_AllocBlock(%d,%d) failed\n", + __func__, smax, tmax); } } diff --git a/src/client/refresh/ref_model.h b/src/client/refresh/ref_model.h new file mode 100644 index 00000000..3540cc3b --- /dev/null +++ b/src/client/refresh/ref_model.h @@ -0,0 +1,49 @@ +#define VERTEXSIZE 7 + +/* in memory representation */ + +typedef struct glpoly_s +{ + struct glpoly_s *next; + struct glpoly_s *chain; + int numverts; + int flags; /* for SURF_UNDERWATER (not needed anymore?) */ + float verts[4][VERTEXSIZE]; /* variable sized (xyz s1t1 s2t2) */ +} mpoly_t; + +typedef struct msurface_s +{ + int visframe; /* should be drawn when node is crossed */ + + cplane_t *plane; + int flags; + + int firstedge; /* look up in model->surfedges[], negative numbers */ + int numedges; /* are backwards edges */ + + short texturemins[2]; + short extents[2]; + short lmshift; + + int light_s, light_t; /* gl lightmap coordinates */ + int dlight_s, dlight_t; /* gl lightmap coordinates for dynamic lightmaps */ + + mpoly_t *polys; /* multiple if warped */ + struct msurface_s *texturechain; + struct msurface_s *lightmapchain; + + mtexinfo_t *texinfo; + + /* decoupled lm */ + float lmvecs[2][4]; + float lmvlen[2]; + + /* lighting info */ + int dlightframe; + int dlightbits; + + int lightmaptexturenum; + byte styles[MAXLIGHTMAPS]; + float cached_light[MAXLIGHTMAPS]; /* values currently used in lightmap */ + byte *samples; /* [numstyles*surfsize] */ +} msurface_t; diff --git a/src/client/refresh/soft/header/local.h b/src/client/refresh/soft/header/local.h index fe8eaf14..543a15e2 100644 --- a/src/client/refresh/soft/header/local.h +++ b/src/client/refresh/soft/header/local.h @@ -250,7 +250,6 @@ typedef struct clipplane_s struct clipplane_s *next; byte leftedge; byte rightedge; - byte reserved[2]; } clipplane_t; typedef struct surfcache_s @@ -264,7 +263,7 @@ typedef struct surfcache_s unsigned height; // DEBUG only needed for debug float mipscale; image_t *image; - byte data[4]; // width*height elements + byte data[4]; // width * height elements } surfcache_t; typedef struct espan_s diff --git a/src/client/refresh/vk/header/model.h b/src/client/refresh/vk/header/model.h index 7dfd4ed2..d093e7be 100644 --- a/src/client/refresh/vk/header/model.h +++ b/src/client/refresh/vk/header/model.h @@ -48,53 +48,7 @@ BRUSH MODELS // in memory representation // -#define VERTEXSIZE 7 - -typedef struct vkpoly_s -{ - struct vkpoly_s *next; - struct vkpoly_s *chain; - int numverts; - int flags; // for SURF_UNDERWATER (not needed anymore?) - float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2) -} vkpoly_t; - -typedef struct msurface_s -{ - int visframe; // should be drawn when node is crossed - - cplane_t *plane; - int flags; - - int firstedge; // look up in model->surfedges[], negative numbers - int numedges; // are backwards edges - - short texturemins[2]; - short extents[2]; - short lmshift; - - int light_s, light_t; // gl lightmap coordinates - int dlight_s, dlight_t; // gl lightmap coordinates for dynamic lightmaps - - vkpoly_t *polys; // multiple if warped - struct msurface_s *texturechain; - struct msurface_s *lightmapchain; - - mtexinfo_t *texinfo; - - /* decoupled lm */ - float lmvecs[2][4]; - float lmvlen[2]; - - /* lighting info */ - int dlightframe; - int dlightbits; - - int lightmaptexturenum; - byte styles[MAXLIGHTMAPS]; - float cached_light[MAXLIGHTMAPS]; // values currently used in lightmap - byte *samples; // [numstyles*surfsize] -} msurface_t; +#include "../../ref_model.h" /* Whole model */ diff --git a/src/client/refresh/vk/vk_model.c b/src/client/refresh/vk/vk_model.c index 99736af4..075c2757 100644 --- a/src/client/refresh/vk/vk_model.c +++ b/src/client/refresh/vk/vk_model.c @@ -265,7 +265,7 @@ calcTexinfoAndFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl // Vk_SubdivideSurface(out, loadmodel); /* cut up polygon for warps */ // for each (pot. recursive) call to R_SubdividePolygon(): - // sizeof(vkpoly_t) + ((numverts - 4) + 2) * VERTEXSIZE*sizeof(float) + // sizeof(mpoly_t) + ((numverts - 4) + 2) * VERTEXSIZE*sizeof(float) // this is tricky, how much is allocated depends on the size of the surface // which we don't know (we'd need the vertices etc to know, but we can't load @@ -277,8 +277,8 @@ calcTexinfoAndFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl else { // Vk_BuildPolygonFromSurface(out); - // => poly = Hunk_Alloc(sizeof(vkpoly_t) + (numverts - 4) * VERTEXSIZE*sizeof(float)); - int polySize = sizeof(vkpoly_t) + (numverts - 4) * VERTEXSIZE*sizeof(float); + // => poly = Hunk_Alloc(sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE*sizeof(float)); + int polySize = sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE*sizeof(float); polySize = (polySize + 31) & ~31; ret += polySize; } @@ -341,7 +341,7 @@ calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *t // Vk_SubdivideSurface(out, loadmodel); /* cut up polygon for warps */ // for each (pot. recursive) call to R_SubdividePolygon(): - // sizeof(vkpoly_t) + ((numverts - 4) + 2) * VERTEXSIZE*sizeof(float) + // sizeof(mpoly_t) + ((numverts - 4) + 2) * VERTEXSIZE*sizeof(float) // this is tricky, how much is allocated depends on the size of the surface // which we don't know (we'd need the vertices etc to know, but we can't load @@ -353,8 +353,8 @@ calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *t else { // Vk_BuildPolygonFromSurface(out); - // => poly = Hunk_Alloc(sizeof(vkpoly_t) + (numverts - 4) * VERTEXSIZE*sizeof(float)); - int polySize = sizeof(vkpoly_t) + (numverts - 4) * VERTEXSIZE*sizeof(float); + // => poly = Hunk_Alloc(sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE*sizeof(float)); + int polySize = sizeof(mpoly_t) + (numverts - 4) * VERTEXSIZE*sizeof(float); polySize = (polySize + 31) & ~31; ret += polySize; } diff --git a/src/client/refresh/vk/vk_surf.c b/src/client/refresh/vk/vk_surf.c index 72287982..06487f2b 100644 --- a/src/client/refresh/vk/vk_surf.c +++ b/src/client/refresh/vk/vk_surf.c @@ -74,7 +74,7 @@ static qboolean LM_AllocBlock (int w, int h, int *x, int *y); DrawVkPoly ================ */ -static void DrawVkPoly (vkpoly_t *p, image_t *texture, float *color) +static void DrawVkPoly (mpoly_t *p, image_t *texture, float *color) { int i; float *v; @@ -129,7 +129,7 @@ static void DrawVkFlowingPoly (msurface_t *fa, image_t *texture, float *color) { int i; float *v; - vkpoly_t *p; + mpoly_t *p; float scroll; p = fa->polys; @@ -185,7 +185,7 @@ static void DrawVkFlowingPoly (msurface_t *fa, image_t *texture, float *color) static void R_DrawTriangleOutlines (void) { int i, j, k; - vkpoly_t *p; + mpoly_t *p; if (!r_showtris->value) return; @@ -429,7 +429,7 @@ static void Vk_RenderLightmappedPoly( msurface_t *surf, float *modelMatrix, floa image_t *image = R_TextureAnimation(currententity, surf->texinfo); qboolean is_dynamic = false; unsigned lmtex = surf->lightmaptexturenum; - vkpoly_t *p; + mpoly_t *p; struct { float model[16]; @@ -1111,7 +1111,9 @@ static qboolean LM_AllocBlock (int w, int h, int *x, int *y) } if (best + h > BLOCK_HEIGHT) + { return false; + } for (i=0 ; inext = fa->polys; - poly->flags = fa->flags; fa->polys = poly; poly->numverts = lnumverts; @@ -1221,7 +1222,9 @@ void Vk_CreateSurfaceLightmap (msurface_t *surf) LM_InitBlock(); if ( !LM_AllocBlock( smax, tmax, &surf->light_s, &surf->light_t ) ) { - ri.Sys_Error( ERR_FATAL, "%s: Consecutive calls to LM_AllocBlock(%d,%d) failed\n", __func__, smax, tmax ); + ri.Sys_Error(ERR_FATAL, + "%s: Consecutive calls to LM_AllocBlock(%d,%d) failed\n", + __func__, smax, tmax); } } diff --git a/src/client/refresh/vk/vk_warp.c b/src/client/refresh/vk/vk_warp.c index 7a6c6c43..b1e89c33 100644 --- a/src/client/refresh/vk/vk_warp.c +++ b/src/client/refresh/vk/vk_warp.c @@ -44,7 +44,7 @@ R_SubdividePolygon(int numverts, float *verts, msurface_t *warpface) int f, b; float dist[64]; float frac; - vkpoly_t *poly; + mpoly_t *poly; vec3_t total; float total_s, total_t; @@ -107,7 +107,7 @@ R_SubdividePolygon(int numverts, float *verts, msurface_t *warpface) } // add a point in the center to help keep warp valid - poly = Hunk_Alloc (sizeof(vkpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float)); + poly = Hunk_Alloc (sizeof(mpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float)); poly->next = warpface->polys; warpface->polys = poly; poly->numverts = numverts+2; @@ -181,14 +181,14 @@ void Vk_SubdivideSurface (msurface_t *fa, model_t *loadmodel) ============= EmitWaterPolys -Does a water warp on the pre-fragmented vkpoly_t chain +Does a water warp on the pre-fragmented mpoly_t chain ============= */ void EmitWaterPolys (msurface_t *fa, image_t *texture, float *modelMatrix, const float *color, qboolean solid_surface) { - vkpoly_t *p, *bp; + mpoly_t *p, *bp; float *v; int i; @@ -511,7 +511,7 @@ void R_AddSkySurface (msurface_t *fa) { int i; vec3_t verts[MAX_CLIP_VERTS]; - vkpoly_t *p; + mpoly_t *p; // calculate vertex values for sky box for (p=fa->polys ; p ; p=p->next)