From 1d0a3d19c870d0fdcf83b5e7ffa8f2e58d49edd0 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 31 Jan 2016 20:45:37 -0600 Subject: [PATCH 1/4] Fix a part in maskwallscan that was missed for right-edge exclusivity --- src/r_segs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index d55b31bbe..30738e657 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1082,7 +1082,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t basecolormapdata = basecolormap->Maps; x = x1; - //while ((umost[x] > dmost[x]) && (x <= x2)) x++; + //while ((umost[x] > dmost[x]) && (x < x2)) x++; bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0); if (fixed) @@ -1439,7 +1439,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixe palookupoffse[3] = dc_colormap; } - for(; (x <= x2) && ((size_t)p & 3); ++x, ++p) + for(; (x < x2) && ((size_t)p & 3); ++x, ++p) { light += rw_lightstep; y1ve[0] = uwal[x];//max(uwal[x],umost[x]); From 0b9aeb33e13418c9049527ec7768cbf101749a1b Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 31 Jan 2016 20:52:56 -0600 Subject: [PATCH 2/4] Fixed potential divide by 0 when drawing voxels - Since voxels can have their origin behind the viewer and still have a portion visible in front of the viewer, they aren't clipped to MINZ like face sprites are. The 3D floor handling in R_DrawSprite() neglected to clamp it when recalculating the diminished light colormap. - Aside, but R_DrawSprite() probably shouldn't be messing with these properties at all. Why isn't this done in R_ProjectSprite() before it ever gets to the drawing part? --- src/r_things.cpp | 5 +++-- zdoom.vcproj | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 57a82ebb0..e1e7adcf4 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -673,7 +673,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor fixedvec3 pos = thing->InterpolatedPosition(r_TicFrac); fx = pos.x; fy = pos.y; - fz = pos.z +thing->GetBobOffset(r_TicFrac); + fz = pos.z + thing->GetBobOffset(r_TicFrac); tex = NULL; voxel = NULL; @@ -960,6 +960,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor vis->fakeceiling = fakeceiling; vis->ColormapNum = 0; vis->bInMirror = MirrorFlags & RF_XFLIP; + vis->bSplitSprite = false; if (voxel != NULL) { @@ -1895,7 +1896,7 @@ void R_DrawSprite (vissprite_t *spr) { // diminished light spriteshade = LIGHT2SHADE(sec->lightlevel + r_actualextralight); spr->Style.colormap = mybasecolormap->Maps + (GETPALOOKUP ( - (fixed_t)DivScale12 (r_SpriteVisibility, spr->depth), spriteshade) << COLORMAPSHIFT); + (fixed_t)DivScale12 (r_SpriteVisibility, MAX(MINZ, spr->depth)), spriteshade) << COLORMAPSHIFT); } } } diff --git a/zdoom.vcproj b/zdoom.vcproj index 597b56f2f..58d8cd4a0 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -292,7 +292,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="src\win32;src\sound;src;zlib;src\g_shared;src\g_doom;src\g_raven;src\g_heretic;src\g_hexen;src\g_strife;"jpeg-6b";"game-music-emu";gdtoa;bzip2;lzma\C" - PreprocessorDefinitions="WIN32,_DEBUG,_WIN32,_WINDOWS,_CRTDBG_MAP_ALLOC,HAVE_STRUPR,HAVE_FILELENGTH;NO_VA_COPY,BACKPATCH,HAVE_FLUIDSYNTH,DYN_FLUIDSYNTH,NO_OPENAL" + PreprocessorDefinitions="NOASM,WIN32,_DEBUG,_WIN32,_WINDOWS,_CRTDBG_MAP_ALLOC,HAVE_STRUPR,HAVE_FILELENGTH;NO_VA_COPY,BACKPATCH,HAVE_FLUIDSYNTH,DYN_FLUIDSYNTH,NO_OPENAL" MinimalRebuild="true" RuntimeLibrary="1" EnableFunctionLevelLinking="true" From 809a9d801cb69aedc0f449604954aaddd08e89f7 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 31 Jan 2016 21:23:45 -0600 Subject: [PATCH 3/4] Got a flag backwards --- src/p_lnspec.cpp | 2 +- zdoom.vcproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index da0c87aa3..192a217d8 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -903,7 +903,7 @@ FUNC(LS_Teleport_NoFog) // Teleport_NoFog (tid, useang, sectortag, keepheight) { int flags = 0; - if (arg1) + if (!arg1) { flags |= TELF_KEEPORIENTATION; } diff --git a/zdoom.vcproj b/zdoom.vcproj index 58d8cd4a0..597b56f2f 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -292,7 +292,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="src\win32;src\sound;src;zlib;src\g_shared;src\g_doom;src\g_raven;src\g_heretic;src\g_hexen;src\g_strife;"jpeg-6b";"game-music-emu";gdtoa;bzip2;lzma\C" - PreprocessorDefinitions="NOASM,WIN32,_DEBUG,_WIN32,_WINDOWS,_CRTDBG_MAP_ALLOC,HAVE_STRUPR,HAVE_FILELENGTH;NO_VA_COPY,BACKPATCH,HAVE_FLUIDSYNTH,DYN_FLUIDSYNTH,NO_OPENAL" + PreprocessorDefinitions="WIN32,_DEBUG,_WIN32,_WINDOWS,_CRTDBG_MAP_ALLOC,HAVE_STRUPR,HAVE_FILELENGTH;NO_VA_COPY,BACKPATCH,HAVE_FLUIDSYNTH,DYN_FLUIDSYNTH,NO_OPENAL" MinimalRebuild="true" RuntimeLibrary="1" EnableFunctionLevelLinking="true" From 2f4dc1795496ba25217bc0a28325a993039675b0 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 31 Jan 2016 22:05:32 -0600 Subject: [PATCH 4/4] Add support for face sprite Y flipping --- src/r_things.cpp | 61 +++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index e1e7adcf4..b209fb284 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -359,11 +359,24 @@ void R_DrawVisSprite (vissprite_t *vis) spryscale = vis->yscale; sprflipvert = false; dc_iscale = 0xffffffffu / (unsigned)vis->yscale; - dc_texturemid = vis->texturemid; frac = vis->startfrac; xiscale = vis->xiscale; + dc_texturemid = vis->texturemid; - sprtopscreen = centeryfrac - FixedMul (dc_texturemid, spryscale); + + if (vis->renderflags & RF_YFLIP) + { + sprflipvert = true; + spryscale = -spryscale; + dc_iscale = -dc_iscale; + dc_texturemid -= (vis->pic->GetHeight() << FRACBITS); + sprtopscreen = centeryfrac + FixedMul(dc_texturemid, spryscale); + } + else + { + sprflipvert = false; + sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); + } dc_x = vis->x1; x2 = vis->x2; @@ -652,8 +665,6 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor FTexture *tex; FVoxelDef *voxel; - WORD flip; - vissprite_t* vis; fixed_t iscale; @@ -681,6 +692,12 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor int spritenum = thing->sprite; fixed_t spritescaleX = thing->scaleX; fixed_t spritescaleY = thing->scaleY; + int renderflags = thing->renderflags; + if (spritescaleY < 0) + { + spritescaleY = -spritescaleY; + renderflags ^= RF_YFLIP; + } if (thing->player != NULL) { P_CheckPlayerSprite(thing, spritenum, spritescaleX, spritescaleY); @@ -695,7 +712,6 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor { return; } - flip = 0; if (tex->Rotations != 0xFFFF) { @@ -712,7 +728,10 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor rot = (ang - thing->angle + (angle_t)(ANGLE_45/2)*9-(angle_t)(ANGLE_180/16)) >> 28; } picnum = sprframe->Texture[rot]; - flip = sprframe->Flip & (1 << rot); + if (sprframe->Flip & (1 << rot)) + { + renderflags ^= RF_XFLIP; + } tex = TexMan[picnum]; // Do not animate the rotation } } @@ -748,7 +767,10 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor rot = (ang - thing->angle + (angle_t)(ANGLE_45/2)*9-(angle_t)(ANGLE_180/16)) >> 28; } picnum = sprframe->Texture[rot]; - flip = sprframe->Flip & (1 << rot); + if (sprframe->Flip & (1 << rot)) + { + renderflags ^= RF_XFLIP; + } tex = TexMan[picnum]; // Do not animate the rotation if (r_drawvoxels) { @@ -759,16 +781,16 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor if (spritescaleX < 0) { spritescaleX = -spritescaleX; - flip = !flip; + renderflags ^= RF_XFLIP; } if (voxel == NULL && (tex == NULL || tex->UseType == FTexture::TEX_Null)) { return; } - if ((thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) + if ((renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) { - R_ProjectWallSprite(thing, fx, fy, fz, picnum, spritescaleX, spritescaleY, flip); + R_ProjectWallSprite(thing, fx, fy, fz, picnum, spritescaleX, spritescaleY, renderflags); return; } @@ -855,16 +877,13 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor return; } - // [RH] Flip for mirrors and renderflags - if ((MirrorFlags ^ thing->renderflags) & RF_XFLIP) - { - flip = !flip; - } + // [RH] Flip for mirrors + renderflags ^= MirrorFlags & RF_XFLIP; // calculate edges of the shape const fixed_t thingxscalemul = DivScale16(spritescaleX, tex->xScale); - tx -= (flip ? (tex->GetWidth() - tex->LeftOffset - 1) : tex->LeftOffset) * thingxscalemul; + tx -= ((renderflags & RF_XFLIP) ? (tex->GetWidth() - tex->LeftOffset - 1) : tex->LeftOffset) * thingxscalemul; x1 = centerx + MulScale32 (tx, xscale); // off the right side? @@ -895,7 +914,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor vis->x2 = x2 > WindowRight ? WindowRight : x2; vis->angle = thing->angle; - if (flip) + if (renderflags & RF_XFLIP) { vis->startfrac = (tex->GetWidth() << FRACBITS) - 1; vis->xiscale = -iscale; @@ -949,7 +968,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor vis->gzt = gzt; // killough 3/27/98 vis->deltax = fx - viewx; vis->deltay = fy - viewy; - vis->renderflags = thing->renderflags; + vis->renderflags = renderflags; if(thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D vis->Style.RenderStyle = thing->RenderStyle; vis->FillColor = thing->fillcolor; @@ -1022,7 +1041,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor { vis->Style.colormap = mybasecolormap->Maps + fixedlightlev; } - else if (!foggy && ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) + else if (!foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) { // full bright vis->Style.colormap = mybasecolormap->Maps; } @@ -1035,7 +1054,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor } } -static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t fz, FTextureID picnum, fixed_t xscale, fixed_t yscale, INTBOOL flip) +static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t fz, FTextureID picnum, fixed_t xscale, fixed_t yscale, int renderflags) { FWallCoords wallc; int x1, x2; @@ -1089,7 +1108,7 @@ static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t f vis->gzt = gzt; vis->deltax = fx - viewx; vis->deltay = fy - viewy; - vis->renderflags = thing->renderflags; + vis->renderflags = renderflags; if(thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D vis->Style.RenderStyle = thing->RenderStyle; vis->FillColor = thing->fillcolor;