From 0b9aeb33e13418c9049527ec7768cbf101749a1b Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 31 Jan 2016 20:52:56 -0600 Subject: [PATCH] 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"