From 6b75f14c0fa18f276180a5585be40d270d76752c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 2 Feb 2016 01:04:59 +0100 Subject: [PATCH 1/4] - fixed some Linux/GCC warnings. --- src/p_3dfloors.h | 2 +- src/p_sight.cpp | 2 +- src/textures/pngtexture.cpp | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index 5ddded3d3..51761d31b 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -90,7 +90,7 @@ struct F3DFloor fixed_t delta; - int flags; + unsigned int flags; line_t* master; sector_t * model; diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 259b3baa8..b007410c8 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -56,7 +56,7 @@ class SightCheck fixed_t topslope, bottomslope; // slopes to top and bottom of target int Flags; divline_t trace; - int myseethrough; + unsigned int myseethrough; bool PTR_SightTraverse (intercept_t *in); bool P_SightCheckLine (line_t *ld); diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index 5a3ae960a..6a7370fac 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -276,9 +276,9 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename lump.Read (trans, len); HaveTrans = true; // Save for colortype 2 - NonPaletteTrans[0] = BigShort(((WORD *)trans)[0]); - NonPaletteTrans[1] = BigShort(((WORD *)trans)[1]); - NonPaletteTrans[2] = BigShort(((WORD *)trans)[2]); + NonPaletteTrans[0] = WORD(trans[0] * 256 + trans[1]); + NonPaletteTrans[1] = WORD(trans[2] * 256 + trans[3]); + NonPaletteTrans[2] = WORD(trans[4] * 256 + trans[5]); break; case MAKE_ID('a','l','P','h'): From 03f0e1dc5c6c3ce84f25ed8c3a1b82ff3cbe8070 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 1 Feb 2016 18:57:52 -0600 Subject: [PATCH 2/4] Remove something that looks like 3D floor development garbage --- src/r_segs.cpp | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 30738e657..7de317f0e 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -171,31 +171,27 @@ fixed_t MaskedScaleY; static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FTexture::Span *spans), FTexture *tex) { - if (maskedtexturecol[dc_x] != FIXED_MAX) + // calculate lighting + if (fixedcolormap == NULL && fixedlightlev < 0) { - // calculate lighting - if (fixedcolormap == NULL && fixedlightlev < 0) - { - dc_colormap = basecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); - } - - dc_iscale = MulScale18 (MaskedSWall[dc_x], MaskedScaleY); - sprtopscreen = centeryfrac - FixedMul (dc_texturemid, spryscale); - - // killough 1/25/98: here's where Medusa came in, because - // it implicitly assumed that the column was all one patch. - // Originally, Doom did not construct complete columns for - // multipatched textures, so there were no header or trailer - // bytes in the column referred to below, which explains - // the Medusa effect. The fix is to construct true columns - // when forming multipatched textures (see r_data.c). - - // draw the texture - const FTexture::Span *spans; - const BYTE *pixels = tex->GetColumn (maskedtexturecol[dc_x] >> FRACBITS, &spans); - blastfunc (pixels, spans); -// maskedtexturecol[dc_x] = FIXED_MAX; // kg3D - seems to be useless + dc_colormap = basecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); } + + dc_iscale = MulScale18 (MaskedSWall[dc_x], MaskedScaleY); + sprtopscreen = centeryfrac - FixedMul (dc_texturemid, spryscale); + + // killough 1/25/98: here's where Medusa came in, because + // it implicitly assumed that the column was all one patch. + // Originally, Doom did not construct complete columns for + // multipatched textures, so there were no header or trailer + // bytes in the column referred to below, which explains + // the Medusa effect. The fix is to construct true columns + // when forming multipatched textures (see r_data.c). + + // draw the texture + const FTexture::Span *spans; + const BYTE *pixels = tex->GetColumn (maskedtexturecol[dc_x] >> FRACBITS, &spans); + blastfunc (pixels, spans); rw_light += rw_lightstep; spryscale += rw_scalestep; } From 6b6c1af0dcce35bf6f532240d7f786e5deb1c3cc Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 1 Feb 2016 20:57:06 -0600 Subject: [PATCH 3/4] Add support for Y flipped non-vertically tiling masked midtextures --- src/r_segs.cpp | 63 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 7de317f0e..b738b1c10 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -178,7 +178,10 @@ static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FText } dc_iscale = MulScale18 (MaskedSWall[dc_x], MaskedScaleY); - sprtopscreen = centeryfrac - FixedMul (dc_texturemid, spryscale); + if (sprflipvert) + sprtopscreen = centeryfrac + FixedMul(dc_texturemid, spryscale); + else + sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); // killough 1/25/98: here's where Medusa came in, because // it implicitly assumed that the column was all one patch. @@ -222,7 +225,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) FTexture *tex; int i; sector_t tempsec; // killough 4/13/98 - fixed_t texheight, textop, texheightscale; + fixed_t texheight, texheightscale; bool notrelevant = false; const sector_t *sec; @@ -304,9 +307,14 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) spryscale = ds->iscale + ds->iscalestep * (x1 - ds->x1); rw_scalestep = ds->iscalestep; + if (fixedlightlev >= 0) + dc_colormap = basecolormap->Maps + fixedlightlev; + else if (fixedcolormap != NULL) + dc_colormap = fixedcolormap; + // find positioning texheight = tex->GetScaledHeight() << FRACBITS; - texheightscale = curline->sidedef->GetTextureYScale(side_t::mid); + texheightscale = abs(curline->sidedef->GetTextureYScale(side_t::mid)); if (texheightscale != FRACUNIT) { texheight = FixedDiv(texheight, texheightscale); @@ -320,8 +328,18 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) dc_texturemid = MIN (frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling)); } - { // encapsulate the lifetime of rowoffset - fixed_t rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid); + fixed_t rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid); + + if (!(curline->linedef->flags & ML_WRAP_MIDTEX) && + !(curline->sidedef->Flags & WALLF_WRAP_MIDTEX)) + { // Texture does not wrap vertically. + fixed_t textop; + + if (MaskedScaleY < 0) + { + MaskedScaleY = -MaskedScaleY; + sprflipvert = true; + } if (tex->bWorldPanning) { // rowoffset is added before the MulScale3 so that the masked texture will @@ -337,16 +355,11 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) textop = dc_texturemid - viewz + SafeDivScale16 (rowoffset, MaskedScaleY); dc_texturemid = MulScale16 (dc_texturemid - viewz, MaskedScaleY) + rowoffset; } - } - - if (fixedlightlev >= 0) - dc_colormap = basecolormap->Maps + fixedlightlev; - else if (fixedcolormap != NULL) - dc_colormap = fixedcolormap; - - if (!(curline->linedef->flags & ML_WRAP_MIDTEX) && - !(curline->sidedef->Flags & WALLF_WRAP_MIDTEX)) - { // Texture does not wrap vertically. + if (sprflipvert) + { + MaskedScaleY = -MaskedScaleY; + dc_texturemid -= tex->GetHeight() << FRACBITS; + } // [RH] Don't bother drawing segs that are completely offscreen if (MulScale12 (globaldclip, ds->sz1) < -textop && @@ -463,6 +476,20 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) } else { // Texture does wrap vertically. + if (tex->bWorldPanning) + { + // rowoffset is added before the MulScale3 so that the masked texture will + // still be positioned in world units rather than texels. + dc_texturemid += rowoffset - viewz; + dc_texturemid = MulScale16 (dc_texturemid, MaskedScaleY); + } + else + { + // rowoffset is added outside the multiply so that it positions the texture + // by texels instead of world units. + dc_texturemid = MulScale16 (dc_texturemid - viewz, MaskedScaleY) + rowoffset; + } + WallC.sz1 = ds->sz1; WallC.sz2 = ds->sz2; WallC.sx1 = ds->sx1; @@ -572,7 +599,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } xscale = FixedMul(rw_pic->xScale, scaledside->GetTextureXScale(scaledpart)); yscale = FixedMul(rw_pic->yScale, scaledside->GetTextureYScale(scaledpart)); - // encapsulate the lifetime of rowoffset + fixed_t rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid) + rover->master->sidedef[0]->GetTextureYOffset(side_t::mid); dc_texturemid = rover->model->GetPlaneTexZ(sector_t::ceiling); rw_offset = curline->sidedef->GetTextureXOffset(side_t::mid) + rover->master->sidedef[0]->GetTextureXOffset(side_t::mid); @@ -2504,9 +2531,9 @@ void R_StoreWallRange (int start, int stop) iend = DivScale32 (1, iend); ds_p->yrepeat = yrepeat; ds_p->iscale = istart; - if (stop - start > 1) + if (stop - start > 0) { - ds_p->iscalestep = (iend - istart) / (stop - start - 1); + ds_p->iscalestep = (iend - istart) / (stop - start); } else { From c9d81dff53d4983ad4376fa9b1a47b0b05bab6e8 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 1 Feb 2016 21:02:32 -0600 Subject: [PATCH 4/4] Use absolute value of Y scale for 3D midtex - Somebody might want to set a midtexture's Y scale negative to flip it vertically. I'm pretty sure this would mess up 3D mid textures if we don't make it positive again for those. --- src/p_3dmidtex.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index 3338956f3..5d5ba56d8 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -228,7 +228,7 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, f FTexture * tex= TexMan(texnum); if (!tex) return false; - fixed_t totalscale = FixedMul(side->GetTextureYScale(side_t::mid), tex->yScale); + fixed_t totalscale = abs(FixedMul(side->GetTextureYScale(side_t::mid), tex->yScale)); fixed_t y_offset = side->GetTextureYOffset(side_t::mid); fixed_t textureheight = tex->GetScaledHeight(totalscale) << FRACBITS; if (totalscale != FRACUNIT && !tex->bWorldPanning)