From 80b47cafb4dbdc18387aeab737602c2d08807c1a Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 18 Nov 2017 14:35:45 +0200 Subject: [PATCH 1/9] Fixed detection of the first entry from internal IWADINFO https://forum.zdoom.org/viewtopic.php?t=58333 --- src/d_iwad.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index f10d48fb7..fadb9e65b 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -583,7 +583,7 @@ int FIWadManager::IdentifyVersion (TArray &wadfiles, const char *iwad, // We have a -iwad parameter. Pick the first usable IWAD we found through that. for (unsigned i = numFoundWads; i < mFoundWads.Size(); i++) { - if (mFoundWads[i].mInfoIndex > 0) + if (mFoundWads[i].mInfoIndex >= 0) { picks.Push(mFoundWads[i]); break; From c2b4efbea03cc70887e6493d66b816d89d998919 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 18 Nov 2017 17:07:42 +0200 Subject: [PATCH 2/9] Fixed applying of brightmaps to overridden textures https://forum.zdoom.org/viewtopic.php?t=58444 --- src/gl/textures/gl_texture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index e5a91fe14..51425d40d 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -564,7 +564,7 @@ void gl_ParseBrightmap(FScanner &sc, int deflump) else sc.UnGet(); sc.MustGetString(); - FTextureID no = TexMan.CheckForTexture(sc.String, type); + FTextureID no = TexMan.CheckForTexture(sc.String, type, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_Overridable); FTexture *tex = TexMan[no]; sc.MustGetToken('{'); From 2c24d2e047772e8becd344b9152abaaac8c39da3 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 19 Nov 2017 04:40:16 -0500 Subject: [PATCH 3/9] - fixed: Made shader targets not case sensitive --- src/gl/renderer/gl_renderstate.cpp | 9 ++++++++- src/gl/shaders/gl_shader.cpp | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 67c9c21fa..887de5276 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -143,6 +143,12 @@ bool FRenderState::ApplyShader() } } + if (!activeShader) + { + assert(0); // We should not be getting to this point! + return false; + } + glVertexAttrib4fv(VATTR_COLOR, mColor.vec); glVertexAttrib4fv(VATTR_NORMAL, mNormal.vec); //activeShader->muObjectColor2.Set(mObjectColor2); @@ -367,7 +373,8 @@ void FRenderState::ApplyLightIndex(int index) { index = GLRenderer->mLights->BindUBO(index); } - activeShader->muLightIndex.Set(index); + if (activeShader) + activeShader->muLightIndex.Set(index); } } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 41b6c18a1..6c9ee416d 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -682,6 +682,7 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump) PostProcessShader shaderdesc; shaderdesc.Target = sc.String; + shaderdesc.Target.ToLower(); bool validTarget = false; if (sc.Compare("beforebloom")) validTarget = true; From 351de94311fef64d9c45e1341f36c4d5bec957ad Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 19 Nov 2017 04:45:42 -0500 Subject: [PATCH 4/9] - fixed: Accidentally committed in-progress work... again Partial Revert "- fixed: Made shader targets not case sensitive" This reverts commit 2c24d2e047772e8becd344b9152abaaac8c39da3. --- src/gl/renderer/gl_renderstate.cpp | 9 +-------- src/gl/shaders/gl_shader.cpp | 1 - 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 887de5276..67c9c21fa 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -143,12 +143,6 @@ bool FRenderState::ApplyShader() } } - if (!activeShader) - { - assert(0); // We should not be getting to this point! - return false; - } - glVertexAttrib4fv(VATTR_COLOR, mColor.vec); glVertexAttrib4fv(VATTR_NORMAL, mNormal.vec); //activeShader->muObjectColor2.Set(mObjectColor2); @@ -373,8 +367,7 @@ void FRenderState::ApplyLightIndex(int index) { index = GLRenderer->mLights->BindUBO(index); } - if (activeShader) - activeShader->muLightIndex.Set(index); + activeShader->muLightIndex.Set(index); } } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 6c9ee416d..41b6c18a1 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -682,7 +682,6 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump) PostProcessShader shaderdesc; shaderdesc.Target = sc.String; - shaderdesc.Target.ToLower(); bool validTarget = false; if (sc.Compare("beforebloom")) validTarget = true; From de19efa79d64cf2a9f3cd06b829cce276e5b59e2 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 19 Nov 2017 04:48:26 -0500 Subject: [PATCH 5/9] - trying again: fix shader targets being case sensitive --- src/gl/shaders/gl_shader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 41b6c18a1..6c9ee416d 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -682,6 +682,7 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump) PostProcessShader shaderdesc; shaderdesc.Target = sc.String; + shaderdesc.Target.ToLower(); bool validTarget = false; if (sc.Compare("beforebloom")) validTarget = true; From f0dc619b5b3e45739858e83592a85dc0f0022160 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Nov 2017 15:30:45 +0100 Subject: [PATCH 6/9] - fixed bad use of FScanner::GetNumber and GetFloat in code inherited from ZDoomGL. This could lead to bad error messages if some malformed definitions were used. --- src/g_shared/a_dynlightdata.cpp | 4 +- src/gl/shaders/gl_texshader.cpp | 88 ++++++++++++++++----------------- src/textures/texturemanager.cpp | 4 +- 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/g_shared/a_dynlightdata.cpp b/src/g_shared/a_dynlightdata.cpp index c45d6fe9f..fcdbcd3d1 100644 --- a/src/g_shared/a_dynlightdata.cpp +++ b/src/g_shared/a_dynlightdata.cpp @@ -269,7 +269,7 @@ extern int ScriptDepth; inline float ParseFloat(FScanner &sc) { - sc.GetFloat(); + sc.MustGetFloat(); return float(sc.Float); } @@ -277,7 +277,7 @@ inline float ParseFloat(FScanner &sc) inline int ParseInt(FScanner &sc) { - sc.GetNumber(); + sc.MustGetNumber(); return sc.Number; } diff --git a/src/gl/shaders/gl_texshader.cpp b/src/gl/shaders/gl_texshader.cpp index f91529909..6276d7a4f 100644 --- a/src/gl/shaders/gl_texshader.cpp +++ b/src/gl/shaders/gl_texshader.cpp @@ -265,11 +265,11 @@ bool FShaderLayer::ParseLayer(FScanner &sc) alpha.ShouldCycle(true); alpha.SetCycleType(ParseCycleType(sc)); - sc.GetFloat(); + sc.MustGetFloat(); start = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); end = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); cycle = sc.Float; alpha.SetParams(start, end, cycle); @@ -287,11 +287,11 @@ bool FShaderLayer::ParseLayer(FScanner &sc) srcFactor.ShouldCycle(true); srcFactor.SetCycleType(ParseCycleType(sc)); - sc.GetFloat(); + sc.MustGetFloat(); start = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); end = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); cycle = sc.Float; srcFactor.SetParams(start, end, cycle); @@ -309,11 +309,11 @@ bool FShaderLayer::ParseLayer(FScanner &sc) dstFactor.ShouldCycle(true); dstFactor.SetCycleType(ParseCycleType(sc)); - sc.GetFloat(); + sc.MustGetFloat(); start = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); end = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); cycle = sc.Float; dstFactor.SetParams(start, end, cycle); @@ -351,23 +351,23 @@ bool FShaderLayer::ParseLayer(FScanner &sc) g.SetCycleType(type); b.SetCycleType(type); - sc.GetFloat(); + sc.MustGetFloat(); r1 = float(sc.Float); - sc.GetFloat(); + sc.MustGetFloat(); g1 = float(sc.Float); - sc.GetFloat(); + sc.MustGetFloat(); b1 = float(sc.Float); // get color2 - sc.GetFloat(); + sc.MustGetFloat(); r2 = float(sc.Float); - sc.GetFloat(); + sc.MustGetFloat(); g2 = float(sc.Float); - sc.GetFloat(); + sc.MustGetFloat(); b2 = float(sc.Float); // get cycle time - sc.GetFloat(); + sc.MustGetFloat(); cycle = sc.Float; r.SetParams(r1, r2, cycle); @@ -376,11 +376,11 @@ bool FShaderLayer::ParseLayer(FScanner &sc) } else { - sc.GetFloat(); + sc.MustGetFloat(); r1 = float(sc.Float); - sc.GetFloat(); + sc.MustGetFloat(); g1 = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); b1 = sc.Float; r.SetParams(r1, r1, 0.f); @@ -390,9 +390,9 @@ bool FShaderLayer::ParseLayer(FScanner &sc) } else if (sc.Compare("center")) { - sc.GetFloat(); + sc.MustGetFloat(); centerX = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); centerY = sc.Float; } else if (sc.Compare("emissive")) @@ -407,17 +407,17 @@ bool FShaderLayer::ParseLayer(FScanner &sc) adjustX.ShouldCycle(true); adjustY.ShouldCycle(true); - sc.GetFloat(); + sc.MustGetFloat(); r1 = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); r2 = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); g1 = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); g2 = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); cycle = sc.Float; offsetX = r1; @@ -428,9 +428,9 @@ bool FShaderLayer::ParseLayer(FScanner &sc) } else { - sc.GetFloat(); + sc.MustGetFloat(); offsetX = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); offsetY = sc.Float; } } @@ -447,12 +447,12 @@ bool FShaderLayer::ParseLayer(FScanner &sc) } else if (sc.Compare("rotate")) { - sc.GetFloat(); + sc.MustGetFloat(); rotate = sc.Float; } else if (sc.Compare("rotation")) { - sc.GetFloat(); + sc.MustGetFloat(); rotation = sc.Float; } else if (sc.Compare("scale")) @@ -462,17 +462,17 @@ bool FShaderLayer::ParseLayer(FScanner &sc) scaleX.ShouldCycle(true); scaleY.ShouldCycle(true); - sc.GetFloat(); + sc.MustGetFloat(); r1 = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); r2 = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); g1 = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); g2 = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); cycle = sc.Float; scaleX.SetParams(r1, g1, cycle); @@ -480,9 +480,9 @@ bool FShaderLayer::ParseLayer(FScanner &sc) } else { - sc.GetFloat(); + sc.MustGetFloat(); scaleX.SetParams(sc.Float, sc.Float, 0.f); - sc.GetFloat(); + sc.MustGetFloat(); scaleY.SetParams(sc.Float, sc.Float, 0.f); } } @@ -510,15 +510,15 @@ bool FShaderLayer::ParseLayer(FScanner &sc) vectorX.ShouldCycle(true); vectorY.ShouldCycle(true); - sc.GetFloat(); + sc.MustGetFloat(); r1 = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); g1 = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); r2 = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); g2 = sc.Float; - sc.GetFloat(); + sc.MustGetFloat(); cycle = sc.Float; vectorX.SetParams(r1, r2, cycle); @@ -526,9 +526,9 @@ bool FShaderLayer::ParseLayer(FScanner &sc) } else { - sc.GetFloat(); + sc.MustGetFloat(); vectorX.SetParams(sc.Float, sc.Float, 0.f); - sc.GetFloat(); + sc.MustGetFloat(); vectorY.SetParams(sc.Float, sc.Float, 0.f); } } diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index f7aa4926d..5039f48b6 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -699,9 +699,9 @@ void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname) is32bit = !!sc.Compare("force32bit"); if (!is32bit) sc.UnGet(); - sc.GetNumber(); + sc.MustGetNumber(); width = sc.Number; - sc.GetNumber(); + sc.MustGetNumber(); height = sc.Number; if (lumpnum>=0) From 5532266b147858d2184f42dd42d59722c20f6d3d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 20 Nov 2017 22:43:44 +0100 Subject: [PATCH 7/9] - Fix softpoly sprite positioning bug --- src/polyrenderer/scene/poly_sprite.cpp | 41 ++++++++++---------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index 02cb9e657..8bc1c5054 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -57,18 +57,17 @@ bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right) double thingxscalemul = spriteScale.X / tex->Scale.X; double thingyscalemul = spriteScale.Y / tex->Scale.Y; - if (flipTextureX) - pos.X -= (tex->GetWidth() - tex->LeftOffset) * thingxscalemul; - else - pos.X -= tex->LeftOffset * thingxscalemul; - - double spriteHalfWidth = thingxscalemul * tex->GetWidth() * 0.5; + double spriteWidth = thingxscalemul * tex->GetWidth(); double spriteHeight = thingyscalemul * tex->GetHeight(); - pos.X += spriteHalfWidth; + double offsetX; + if (flipTextureX) + offsetX = (tex->GetWidth() - tex->LeftOffset) * thingxscalemul; + else + offsetX = tex->LeftOffset * thingxscalemul; - left = DVector2(pos.X - viewpoint.Sin * spriteHalfWidth, pos.Y + viewpoint.Cos * spriteHalfWidth); - right = DVector2(pos.X + viewpoint.Sin * spriteHalfWidth, pos.Y - viewpoint.Cos * spriteHalfWidth); + left = DVector2(pos.X - viewpoint.Sin * offsetX, pos.Y + viewpoint.Cos * offsetX); + right = DVector2(left.X + viewpoint.Sin * spriteWidth, left.Y - viewpoint.Cos * spriteWidth); return true; } @@ -81,36 +80,26 @@ void RenderPolySprite::Render(PolyRenderThread *thread, const TriMatrix &worldTo const auto &viewpoint = PolyRenderer::Instance()->Viewpoint; DVector3 thingpos = thing->InterpolatedPosition(viewpoint.TicFrac); - DVector3 pos = thingpos; + double posZ = thingpos.Z; uint32_t spritetype = (thing->renderflags & RF_SPRITETYPEMASK); if (spritetype == RF_FACESPRITE) - pos.Z -= thing->Floorclip; + posZ -= thing->Floorclip; if (thing->flags2 & MF2_FLOATBOB) - pos.Z += thing->GetBobOffset(viewpoint.TicFrac); + posZ += thing->GetBobOffset(viewpoint.TicFrac); bool flipTextureX = false; FTexture *tex = GetSpriteTexture(thing, flipTextureX); if (tex == nullptr || tex->UseType == FTexture::TEX_Null) return; - DVector2 spriteScale = thing->Scale; - double thingxscalemul = spriteScale.X / tex->Scale.X; - double thingyscalemul = spriteScale.Y / tex->Scale.Y; - double spriteHalfWidth = thingxscalemul * tex->GetWidth() * 0.5; + double thingyscalemul = thing->Scale.Y / tex->Scale.Y; double spriteHeight = thingyscalemul * tex->GetHeight(); - if (flipTextureX) - pos.X -= (tex->GetWidth() - tex->LeftOffset) * thingxscalemul; - else - pos.X -= tex->LeftOffset * thingxscalemul; - - pos.X += spriteHalfWidth; - - pos.Z -= (tex->GetHeight() - tex->TopOffset) * thingyscalemul; - pos.Z = PerformSpriteClipAdjustment(thing, thingpos, spriteHeight, pos.Z); + posZ -= (tex->GetHeight() - tex->TopOffset) * thingyscalemul; + posZ = PerformSpriteClipAdjustment(thing, thingpos, spriteHeight, posZ); //double depth = 1.0; //visstyle_t visstyle = GetSpriteVisStyle(thing, depth); @@ -142,7 +131,7 @@ void RenderPolySprite::Render(PolyRenderThread *thread, const TriMatrix &worldTo vertices[i].x = (float)p.X; vertices[i].y = (float)p.Y; - vertices[i].z = (float)(pos.Z + spriteHeight * offsets[i].second); + vertices[i].z = (float)(posZ + spriteHeight * offsets[i].second); vertices[i].w = 1.0f; vertices[i].u = (float)(offsets[i].first * tex->Scale.X); vertices[i].v = (float)((1.0f - offsets[i].second) * tex->Scale.Y); From 2bc86b52c8e8cf2005e8ab3d894f7a62625d1caf Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 21 Nov 2017 04:05:47 -0500 Subject: [PATCH 8/9] - fixed a few of the more obvious logic errors --- src/gl/renderer/gl_postprocess.cpp | 2 +- src/vectors.h | 1 + src/win32/fb_d3d9.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index cea7cbb3f..7202ee2a9 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -938,7 +938,7 @@ int FGLRenderer::PTM_BestColor (const uint32_t *pal_in, int r, int g, int b, int static bool firstTime = true; static float trackpowtable = 0.; - double fbestdist, fdist; + double fbestdist = (double)(1<<53), fdist; int bestcolor = 0; if (firstTime || trackpowtable != gl_paltonemap_powtable) diff --git a/src/vectors.h b/src/vectors.h index 5fa0970f1..95d7c5fdf 100644 --- a/src/vectors.h +++ b/src/vectors.h @@ -651,6 +651,7 @@ struct TVector3 TVector3 &operator ^= (const TVector3 &other) { *this = *this ^ other; + return *this; } }; diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index d568ce60f..63722a371 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -1223,7 +1223,7 @@ void D3DFB::Flip() { RECT box; GetClientRect(Window, &box); - if (box.right > 0 && box.right > 0 && (Width != box.right || Height != box.bottom)) + if (box.right > 0 && (Width != box.right || Height != box.bottom)) { Resize(box.right, box.bottom); From 47e9975e9068e4c2f6020937122c9d2f83601994 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 21 Nov 2017 05:20:02 -0500 Subject: [PATCH 9/9] - fixed a couple of fixes from the previous commit --- src/gl/renderer/gl_postprocess.cpp | 2 +- src/win32/fb_d3d9.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 7202ee2a9..142358af6 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -938,7 +938,7 @@ int FGLRenderer::PTM_BestColor (const uint32_t *pal_in, int r, int g, int b, int static bool firstTime = true; static float trackpowtable = 0.; - double fbestdist = (double)(1<<53), fdist; + double fbestdist = DBL_MAX, fdist; int bestcolor = 0; if (firstTime || trackpowtable != gl_paltonemap_powtable) diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 63722a371..ff05faca9 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -1223,7 +1223,7 @@ void D3DFB::Flip() { RECT box; GetClientRect(Window, &box); - if (box.right > 0 && (Width != box.right || Height != box.bottom)) + if (box.right > 0 && box.bottom > 0 && (Width != box.right || Height != box.bottom)) { Resize(box.right, box.bottom);