diff --git a/src/r_data.c b/src/r_data.c index d10919d81..4ae1a9b85 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -550,6 +550,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) if (holey) { texture->holes = true; + texture->holetype = TEXTUREHOLETYPE_SINGLEPATCH; texture->flip = patch->flip; blocksize = lumplength; block = Z_Calloc(blocksize, PU_STATIC, // will change tag at end of this function @@ -580,6 +581,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) // multi-patch textures (or 'composite') multipatch: texture->holes = false; + texture->holetype = TEXTUREHOLETYPE_NOHOLES; texture->flip = 0; blocksize = (texture->width * 4) + (texture->width * texture->height); texturememory += blocksize; @@ -666,6 +668,21 @@ static UINT8 *R_GenerateTexture(size_t texnum) Z_Free(realpatch); } + // Lactozilla: Check if the texture has holes + for (x = 0; x < texture->width; x++) + { + UINT8 *cache = block + LONG(*(UINT32 *)&colofs[x<<2]); + INT32 y = texture->height; + while (y--) + { + if (cache[y] == TRANSPARENTPIXEL) + { + texture->holetype = TEXTUREHOLETYPE_COMPOSITE; + goto done; + } + } + } + done: // Now that the texture has been built in column cache, it is purgable from zone memory. Z_ChangeTag(block, PU_CACHE); diff --git a/src/r_data.h b/src/r_data.h index 8b8d08c52..af6b99acb 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -48,7 +48,7 @@ typedef struct enum patchalphastyle style; } texpatch_t; -// texture type +// Texture type (single-patch, composite, flat) enum { TEXTURETYPE_UNKNOWN, @@ -59,6 +59,14 @@ enum #endif }; +// Texture hole type (none, single-patch, composite) +enum +{ + TEXTUREHOLETYPE_NOHOLES, + TEXTUREHOLETYPE_SINGLEPATCH, + TEXTUREHOLETYPE_COMPOSITE, +}; + // A maptexturedef_t describes a rectangular texture, // which is composed of one or more mappatch_t structures // that arrange graphic patches. @@ -69,6 +77,7 @@ typedef struct UINT8 type; // TEXTURETYPE_ INT16 width, height; boolean holes; + UINT8 holetype; // TEXTUREHOLETYPE_ UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both // All the patches[patchcount] are drawn back to front into the cached texture. diff --git a/src/r_segs.c b/src/r_segs.c index 265074498..bbf71bcd3 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1220,9 +1220,28 @@ static void R_ThickSideClip(INT32 x, drawseg_t *ds, ffloor_t *pfloor) INT32 cliptop, clipbottom; INT32 range = max(ds->x2-ds->x1, 1); + INT32 texnum; + if (ds->thicksidecol[x] == INT16_MAX) return; + // Check which texture will be used + if (pfloor->master->flags & ML_TFERLINE) + { + size_t linenum = ds->curline->linedef-pfloor->target->lines[0]; + line_t *newline = pfloor->master->frontsector->lines[0] + linenum; + texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); + } + else + texnum = R_GetTextureNum(sides[pfloor->master->sidenum[0]].midtexture); + + // Generate the texture if it already hasn't been + R_CheckTextureCache(texnum); + + // Don't clip if the texture has holes + if (textures[texnum]->holetype != TEXTUREHOLETYPE_NOHOLES) + return; + // calculate both left ends left_top = P_GetFFloorTopZAt (pfloor, ds->leftpos.x, ds->leftpos.y) - viewz; left_bottom = P_GetFFloorBottomZAt(pfloor, ds->leftpos.x, ds->leftpos.y) - viewz;