mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-25 04:00:56 +00:00
Merge branch 'linedef-alpha' into 'udmf-next'
Implement linedef alpha field See merge request STJr/SRB2!774
This commit is contained in:
commit
2f465e6740
6 changed files with 48 additions and 51 deletions
|
@ -895,6 +895,7 @@ FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf)
|
|||
{
|
||||
switch (transtablenum)
|
||||
{
|
||||
case 0 : pSurf->FlatColor.s.alpha = 0x00;return PF_Masked;
|
||||
case tr_trans10 : pSurf->FlatColor.s.alpha = 0xe6;return PF_Translucent;
|
||||
case tr_trans20 : pSurf->FlatColor.s.alpha = 0xcc;return PF_Translucent;
|
||||
case tr_trans30 : pSurf->FlatColor.s.alpha = 0xb3;return PF_Translucent;
|
||||
|
@ -1818,37 +1819,10 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
|||
}
|
||||
#endif
|
||||
|
||||
// set alpha for transparent walls (new boom and legacy linedef types)
|
||||
// set alpha for transparent walls
|
||||
// ooops ! this do not work at all because render order we should render it in backtofront order
|
||||
switch (gr_linedef->special)
|
||||
{
|
||||
case 900:
|
||||
blendmode = HWR_TranstableToAlpha(tr_trans10, &Surf);
|
||||
break;
|
||||
case 901:
|
||||
blendmode = HWR_TranstableToAlpha(tr_trans20, &Surf);
|
||||
break;
|
||||
case 902:
|
||||
blendmode = HWR_TranstableToAlpha(tr_trans30, &Surf);
|
||||
break;
|
||||
case 903:
|
||||
blendmode = HWR_TranstableToAlpha(tr_trans40, &Surf);
|
||||
break;
|
||||
case 904:
|
||||
blendmode = HWR_TranstableToAlpha(tr_trans50, &Surf);
|
||||
break;
|
||||
case 905:
|
||||
blendmode = HWR_TranstableToAlpha(tr_trans60, &Surf);
|
||||
break;
|
||||
case 906:
|
||||
blendmode = HWR_TranstableToAlpha(tr_trans70, &Surf);
|
||||
break;
|
||||
case 907:
|
||||
blendmode = HWR_TranstableToAlpha(tr_trans80, &Surf);
|
||||
break;
|
||||
case 908:
|
||||
blendmode = HWR_TranstableToAlpha(tr_trans90, &Surf);
|
||||
break;
|
||||
// Translucent
|
||||
case 102:
|
||||
case 121:
|
||||
|
@ -1869,7 +1843,10 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
|||
blendmode = PF_Translucent;
|
||||
break;
|
||||
default:
|
||||
blendmode = PF_Masked;
|
||||
if (gr_linedef->alpha >= 0 && gr_linedef->alpha < FRACUNIT)
|
||||
blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gr_linedef->alpha), &Surf);
|
||||
else
|
||||
blendmode = PF_Masked;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@ enum line_e {
|
|||
line_sidenum,
|
||||
line_frontside,
|
||||
line_backside,
|
||||
line_alpha,
|
||||
line_slopetype,
|
||||
line_frontsector,
|
||||
line_backsector,
|
||||
|
@ -122,6 +123,7 @@ static const char *const line_opt[] = {
|
|||
"sidenum",
|
||||
"frontside",
|
||||
"backside",
|
||||
"alpha",
|
||||
"slopetype",
|
||||
"frontsector",
|
||||
"backsector",
|
||||
|
@ -806,6 +808,9 @@ static int line_get(lua_State *L)
|
|||
return 0;
|
||||
LUA_PushUserdata(L, &sides[line->sidenum[1]], META_SIDE);
|
||||
return 1;
|
||||
case line_alpha:
|
||||
lua_pushfixed(L, line->alpha);
|
||||
return 1;
|
||||
case line_slopetype:
|
||||
switch(line->slopetype)
|
||||
{
|
||||
|
|
|
@ -1057,6 +1057,7 @@ static void P_LoadLinedefs(UINT8 *data)
|
|||
ld->tag = SHORT(mld->tag);
|
||||
memset(ld->args, 0, NUMLINEARGS*sizeof(*ld->args));
|
||||
memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs));
|
||||
ld->alpha = FRACUNIT;
|
||||
P_SetLinedefV1(i, SHORT(mld->v1));
|
||||
P_SetLinedefV2(i, SHORT(mld->v2));
|
||||
|
||||
|
@ -1461,6 +1462,8 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val)
|
|||
lines[i].sidenum[0] = atol(val);
|
||||
else if (fastcmp(param, "sideback"))
|
||||
lines[i].sidenum[1] = atol(val);
|
||||
else if (fastcmp(param, "alpha"))
|
||||
lines[i].alpha = FLOAT_TO_FIXED(atof(val));
|
||||
|
||||
// Flags
|
||||
else if (fastcmp(param, "blocking") && fastcmp("true", val))
|
||||
|
@ -1650,6 +1653,7 @@ static void P_LoadTextmap(void)
|
|||
ld->tag = 0;
|
||||
memset(ld->args, 0, NUMLINEARGS*sizeof(*ld->args));
|
||||
memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs));
|
||||
ld->alpha = FRACUNIT;
|
||||
ld->sidenum[0] = 0xffff;
|
||||
ld->sidenum[1] = 0xffff;
|
||||
|
||||
|
@ -2766,6 +2770,17 @@ static void P_ConvertBinaryMap(void)
|
|||
lines[i].args[1] = lines[i].tag;
|
||||
lines[i].special = 720;
|
||||
break;
|
||||
case 900: //Translucent wall (10%)
|
||||
case 901: //Translucent wall (20%)
|
||||
case 902: //Translucent wall (30%)
|
||||
case 903: //Translucent wall (40%)
|
||||
case 904: //Translucent wall (50%)
|
||||
case 905: //Translucent wall (60%)
|
||||
case 906: //Translucent wall (70%)
|
||||
case 907: //Translucent wall (80%)
|
||||
case 908: //Translucent wall (90%)
|
||||
lines[i].alpha = ((909 - lines[i].special) << FRACBITS)/10;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -423,6 +423,7 @@ typedef struct line_s
|
|||
|
||||
// Visual appearance: sidedefs.
|
||||
UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided
|
||||
fixed_t alpha; // translucency
|
||||
|
||||
fixed_t bbox[4]; // bounding box for the extent of the linedef
|
||||
|
||||
|
|
42
src/r_segs.c
42
src/r_segs.c
|
@ -286,6 +286,11 @@ static void R_DrawFlippedMaskedSegColumn(column_t *column)
|
|||
R_DrawFlippedMaskedColumn(column, column2s_length);
|
||||
}
|
||||
|
||||
transnum_t R_GetLinedefTransTable(fixed_t alpha)
|
||||
{
|
||||
return (20*(FRACUNIT - alpha - 1) + FRACUNIT) >> (FRACBITS+1);
|
||||
}
|
||||
|
||||
void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
||||
{
|
||||
size_t pindex;
|
||||
|
@ -314,31 +319,24 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
|||
texnum = R_GetTextureNum(curline->sidedef->midtexture);
|
||||
windowbottom = windowtop = sprbotscreen = INT32_MAX;
|
||||
|
||||
// hack translucent linedef types (900-909 for transtables 1-9)
|
||||
ldef = curline->linedef;
|
||||
switch (ldef->special)
|
||||
if (!ldef->alpha)
|
||||
return;
|
||||
|
||||
if (ldef->alpha > 0 && ldef->alpha < FRACUNIT)
|
||||
{
|
||||
case 900:
|
||||
case 901:
|
||||
case 902:
|
||||
case 903:
|
||||
case 904:
|
||||
case 905:
|
||||
case 906:
|
||||
case 907:
|
||||
case 908:
|
||||
dc_transmap = transtables + ((ldef->special-900)<<FF_TRANSSHIFT);
|
||||
colfunc = colfuncs[COLDRAWFUNC_FUZZY];
|
||||
break;
|
||||
case 909:
|
||||
colfunc = colfuncs[COLDRAWFUNC_FOG];
|
||||
windowtop = frontsector->ceilingheight;
|
||||
windowbottom = frontsector->floorheight;
|
||||
break;
|
||||
default:
|
||||
colfunc = colfuncs[BASEDRAWFUNC];
|
||||
break;
|
||||
dc_transmap = transtables + ((R_GetLinedefTransTable(ldef->alpha) - 1) << FF_TRANSSHIFT);
|
||||
colfunc = colfuncs[COLDRAWFUNC_FUZZY];
|
||||
|
||||
}
|
||||
else if (ldef->special == 909)
|
||||
{
|
||||
colfunc = colfuncs[COLDRAWFUNC_FOG];
|
||||
windowtop = frontsector->ceilingheight;
|
||||
windowbottom = frontsector->floorheight;
|
||||
}
|
||||
else
|
||||
colfunc = colfuncs[BASEDRAWFUNC];
|
||||
|
||||
if (curline->polyseg && curline->polyseg->translucency > 0)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#pragma interface
|
||||
#endif
|
||||
|
||||
transnum_t R_GetLinedefTransTable(fixed_t alpha);
|
||||
void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2);
|
||||
void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pffloor);
|
||||
void R_StoreWallRange(INT32 start, INT32 stop);
|
||||
|
|
Loading…
Reference in a new issue