mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-04-20 09:11:01 +00:00
Don't clip thick sides that have textures with holes
This commit is contained in:
parent
c0847a55f7
commit
9febd263e9
3 changed files with 46 additions and 1 deletions
17
src/r_data.c
17
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);
|
||||
|
|
11
src/r_data.h
11
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.
|
||||
|
|
19
src/r_segs.c
19
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;
|
||||
|
|
Loading…
Reference in a new issue