From 2ba61488349ea2d4ffc27569d2d4c38608e13b47 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 22 Oct 2018 08:19:56 +0300 Subject: [PATCH 1/8] - fixed default values for S_ChangeMusic https://forum.zdoom.org/viewtopic.php?t=62323#p1076849 --- src/s_sound.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 30e6f918e..be12d3693 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -2737,8 +2737,8 @@ DEFINE_ACTION_FUNCTION(DObject, S_ChangeMusic) PARAM_PROLOGUE; PARAM_STRING(music); PARAM_INT_DEF(order); - PARAM_BOOL(looping); - PARAM_BOOL(force); + PARAM_BOOL_DEF(looping); + PARAM_BOOL_DEF(force); ACTION_RETURN_BOOL(S_ChangeMusic(music, order, looping, force)); } From af9757abaf2e5e35825e6892506b33b686f6c3d3 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 23 Oct 2018 07:42:14 +0200 Subject: [PATCH 2/8] - Cull two-sided lines using the same rules as the software renderer is using (as suspicious as they may be) --- src/polyrenderer/scene/poly_cull.cpp | 48 +++++++++++++++++++++++++++- src/polyrenderer/scene/poly_cull.h | 2 ++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/polyrenderer/scene/poly_cull.cpp b/src/polyrenderer/scene/poly_cull.cpp index 4bda49b7c..7a42601f4 100644 --- a/src/polyrenderer/scene/poly_cull.cpp +++ b/src/polyrenderer/scene/poly_cull.cpp @@ -164,7 +164,7 @@ void PolyCull::CullSubsector(subsector_t *sub) angle_t angle2 = PointToPseudoAngle(line->v1->fX(), line->v1->fY()); angle_t angle1 = PointToPseudoAngle(line->v2->fX(), line->v2->fY()); bool lineVisible = !IsSegmentCulled(angle1, angle2); - if (lineVisible && line->backsector == nullptr) + if (lineVisible && IsBackSectorSolid(line)) { MarkSegmentCulled(angle1, angle2); } @@ -182,6 +182,52 @@ void PolyCull::CullSubsector(subsector_t *sub) SubsectorDepths[sub->Index()] = subsectorDepth; } +bool PolyCull::IsBackSectorSolid(seg_t *line) +{ + // One-sided + if (!line->backsector) return true; + + // Portal + if (line->linedef->isVisualPortal() && line->sidedef == line->linedef->sidedef[0]) return false; + + double frontCeilingZ1 = line->frontsector->ceilingplane.ZatPoint(line->v1); + double frontFloorZ1 = line->frontsector->floorplane.ZatPoint(line->v1); + double frontCeilingZ2 = line->frontsector->ceilingplane.ZatPoint(line->v2); + double frontFloorZ2 = line->frontsector->floorplane.ZatPoint(line->v2); + + double backCeilingZ1 = line->backsector->ceilingplane.ZatPoint(line->v1); + double backFloorZ1 = line->backsector->floorplane.ZatPoint(line->v1); + double backCeilingZ2 = line->backsector->ceilingplane.ZatPoint(line->v2); + double backFloorZ2 = line->backsector->floorplane.ZatPoint(line->v2); + + // Closed door. + if (backCeilingZ1 <= frontFloorZ1 && backCeilingZ2 <= frontFloorZ2) return true; + if (backFloorZ1 >= frontCeilingZ1 && backFloorZ2 >= frontCeilingZ2) return true; + + // properly render skies (consider door "open" if both ceilings are sky) + if (line->backsector->GetTexture(sector_t::ceiling) == skyflatnum && line->frontsector->GetTexture(sector_t::ceiling) == skyflatnum) return false; + + // if door is closed because back is shut: + if (!(backCeilingZ1 <= backFloorZ1 && backCeilingZ2 <= backFloorZ2)) return false; + + // preserve a kind of transparent door/lift special effect: + if (((backCeilingZ1 >= frontCeilingZ1 && backCeilingZ2 >= frontCeilingZ2) || line->sidedef->GetTexture(side_t::top).isValid()) + && ((backFloorZ1 <= frontFloorZ1 && backFloorZ2 <= frontFloorZ2) || line->sidedef->GetTexture(side_t::bottom).isValid())) + { + // killough 1/18/98 -- This function is used to fix the automap bug which + // showed lines behind closed doors simply because the door had a dropoff. + // + // It assumes that Doom has already ruled out a door being closed because + // of front-back closure (e.g. front floor is taller than back ceiling). + + // This fixes the automap floor height bug -- killough 1/18/98: + // killough 4/7/98: optimize: save result in doorclosed for use in r_segs.c + return true; + } + + return false; +} + bool PolyCull::IsSegmentCulled(angle_t startAngle, angle_t endAngle) const { if (startAngle > endAngle) diff --git a/src/polyrenderer/scene/poly_cull.h b/src/polyrenderer/scene/poly_cull.h index 53b14c9cc..7a893d89f 100644 --- a/src/polyrenderer/scene/poly_cull.h +++ b/src/polyrenderer/scene/poly_cull.h @@ -56,6 +56,8 @@ private: void MarkViewFrustum(); void InvertSegments(); + static bool IsBackSectorSolid(seg_t *line); + bool IsSegmentCulled(angle_t angle1, angle_t angle2) const; void CullNode(void *node); From 22422635a00bfd2578fc6e168b6655ae94b32e1f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 23 Oct 2018 09:08:41 +0200 Subject: [PATCH 3/8] - portal check is overridden by a different inverted check in the software renderer --- src/polyrenderer/scene/poly_cull.cpp | 6 +++--- src/polyrenderer/scene/poly_cull.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/polyrenderer/scene/poly_cull.cpp b/src/polyrenderer/scene/poly_cull.cpp index 7a42601f4..73ae9b3f2 100644 --- a/src/polyrenderer/scene/poly_cull.cpp +++ b/src/polyrenderer/scene/poly_cull.cpp @@ -164,7 +164,7 @@ void PolyCull::CullSubsector(subsector_t *sub) angle_t angle2 = PointToPseudoAngle(line->v1->fX(), line->v1->fY()); angle_t angle1 = PointToPseudoAngle(line->v2->fX(), line->v2->fY()); bool lineVisible = !IsSegmentCulled(angle1, angle2); - if (lineVisible && IsBackSectorSolid(line)) + if (lineVisible && IsSolidLine(line)) { MarkSegmentCulled(angle1, angle2); } @@ -182,13 +182,13 @@ void PolyCull::CullSubsector(subsector_t *sub) SubsectorDepths[sub->Index()] = subsectorDepth; } -bool PolyCull::IsBackSectorSolid(seg_t *line) +bool PolyCull::IsSolidLine(seg_t *line) { // One-sided if (!line->backsector) return true; // Portal - if (line->linedef->isVisualPortal() && line->sidedef == line->linedef->sidedef[0]) return false; + if (line->linedef->isVisualPortal() && line->sidedef == line->linedef->sidedef[0]) return true; double frontCeilingZ1 = line->frontsector->ceilingplane.ZatPoint(line->v1); double frontFloorZ1 = line->frontsector->floorplane.ZatPoint(line->v1); diff --git a/src/polyrenderer/scene/poly_cull.h b/src/polyrenderer/scene/poly_cull.h index 7a893d89f..81fa19387 100644 --- a/src/polyrenderer/scene/poly_cull.h +++ b/src/polyrenderer/scene/poly_cull.h @@ -56,7 +56,7 @@ private: void MarkViewFrustum(); void InvertSegments(); - static bool IsBackSectorSolid(seg_t *line); + static bool IsSolidLine(seg_t *line); bool IsSegmentCulled(angle_t angle1, angle_t angle2) const; From 43c30ff4850faabdd470fbea91868f67a63e2268 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 23 Oct 2018 09:17:55 +0200 Subject: [PATCH 4/8] - fix null pointer crash --- src/polyrenderer/scene/poly_cull.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/polyrenderer/scene/poly_cull.cpp b/src/polyrenderer/scene/poly_cull.cpp index 73ae9b3f2..6668e2f2b 100644 --- a/src/polyrenderer/scene/poly_cull.cpp +++ b/src/polyrenderer/scene/poly_cull.cpp @@ -188,7 +188,7 @@ bool PolyCull::IsSolidLine(seg_t *line) if (!line->backsector) return true; // Portal - if (line->linedef->isVisualPortal() && line->sidedef == line->linedef->sidedef[0]) return true; + if (line->linedef && line->linedef->isVisualPortal() && line->sidedef == line->linedef->sidedef[0]) return true; double frontCeilingZ1 = line->frontsector->ceilingplane.ZatPoint(line->v1); double frontFloorZ1 = line->frontsector->floorplane.ZatPoint(line->v1); From 75bd1b00b406f429357779e1d5e57ea5e59054ee Mon Sep 17 00:00:00 2001 From: Tommy Nguyen Date: Tue, 23 Oct 2018 13:19:10 -0400 Subject: [PATCH 5/8] - use value initialization for secspecial_t --- src/p_ceiling.cpp | 4 ++-- src/p_floor.cpp | 4 ++-- src/p_spec.h | 4 ++-- src/r_defs.h | 10 ---------- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index 5eb8157f5..0f37e3379 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -428,7 +428,7 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t switch (change & 3) { case 1: // type is zeroed - ceiling->m_NewSpecial.Clear(); + ceiling->m_NewSpecial = {}; ceiling->m_Type = DCeiling::genCeilingChg0; break; case 2: // type is copied @@ -447,7 +447,7 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t switch (change & 3) { case 1: // type is zeroed - ceiling->m_NewSpecial.Clear(); + ceiling->m_NewSpecial = {}; ceiling->m_Type = DCeiling::genCeilingChg0; break; case 2: // type is copied diff --git a/src/p_floor.cpp b/src/p_floor.cpp index d0b6cb077..7141a842e 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -229,7 +229,7 @@ void DFloor::SetFloorChangeType (sector_t *sec, int change) switch (change & 3) { case 1: - m_NewSpecial.Clear(); + m_NewSpecial = {}; m_Type = DFloor::genFloorChg0; break; case 2: @@ -828,7 +828,7 @@ bool EV_DoDonut (int tag, line_t *line, double pillarspeed, double slimespeed) floor->m_Speed = slimespeed; floor->m_Instant = false; floor->m_Texture = s3->GetTexture(sector_t::floor); - floor->m_NewSpecial.Clear(); + floor->m_NewSpecial = {}; height = s3->FindHighestFloorPoint (&spot); floor->m_FloorDestDist = s2->floorplane.PointToDist (spot, height); floor->StartFloorSound (); diff --git a/src/p_spec.h b/src/p_spec.h index 6dc118658..61cc7b2f0 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -439,7 +439,7 @@ protected: // [RH] Need these for BOOM-ish transferring ceilings FTextureID m_Texture; - secspecial_t m_NewSpecial; + secspecial_t m_NewSpecial{}; // ID int m_Tag; @@ -536,7 +536,7 @@ public: bool m_Hexencrush; bool m_Instant; int m_Direction; - secspecial_t m_NewSpecial; + secspecial_t m_NewSpecial{}; FTextureID m_Texture; double m_FloorDestDist; double m_Speed; diff --git a/src/r_defs.h b/src/r_defs.h index ffe526969..d319e6dd7 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -588,16 +588,6 @@ struct secspecial_t short damageinterval; // Interval for damage application short leakydamage; // chance of leaking through radiation suit int Flags; - - secspecial_t() - { - Clear(); - } - - void Clear() - { - memset(this, 0, sizeof(*this)); - } }; FSerializer &Serialize(FSerializer &arc, const char *key, secspecial_t &spec, secspecial_t *def); From 2404634d5d92a75c64d1822c7d22b52ff4c686a0 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 25 Oct 2018 12:40:56 +0200 Subject: [PATCH 6/8] - fix softpoly bug where sprites and translucent walls in front of models would disappear --- src/polyrenderer/scene/poly_model.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/polyrenderer/scene/poly_model.cpp b/src/polyrenderer/scene/poly_model.cpp index a49212989..fbf5642a6 100644 --- a/src/polyrenderer/scene/poly_model.cpp +++ b/src/polyrenderer/scene/poly_model.cpp @@ -39,6 +39,7 @@ void PolyRenderModel(PolyRenderThread *thread, const Mat4f &worldToClip, uint32_ renderer.AddLights(actor); renderer.RenderModel(x, y, z, smf, actor, r_viewpoint.TicFrac); PolyTriangleDrawer::SetModelVertexShader(thread->DrawQueue, -1, -1, 0.0f); + PolyTriangleDrawer::SetTransform(thread->DrawQueue, thread->FrameMemory->NewObject(worldToClip), nullptr); } void PolyRenderHUDModel(PolyRenderThread *thread, const Mat4f &worldToClip, uint32_t stencilValue, DPSprite *psp, float ofsx, float ofsy) From 649857c80dbb9e1a49540983ad626529f91d102e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 28 Oct 2018 15:58:18 +0200 Subject: [PATCH 7/8] - updated Travis configuration to use Clang 7 --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6962cbaff..39b3ee086 100644 --- a/.travis.yml +++ b/.travis.yml @@ -93,16 +93,15 @@ matrix: - os: linux compiler: clang env: - - CLANG_VERSION=6.0 + - CLANG_VERSION=7 - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=MinSizeRel -DDYN_OPENAL=NO -DDYN_SNDFILE=NO -DDYN_MPG123=NO -DDYN_FLUIDSYNTH=NO" addons: apt: sources: - ubuntu-toolchain-r-test - - llvm-toolchain-trusty-6.0 + - llvm-toolchain-trusty-7 packages: - - clang-6.0 - - libstdc++-5-dev + - clang-7 - libsdl2-dev - libgme-dev - libopenal-dev From 49c3ec6a87646121b1a48e5e6681ff075f547848 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 28 Oct 2018 15:59:28 +0200 Subject: [PATCH 8/8] - fixed compilation warnings reported by GCC and Clang src/gl/data/gl_viewpointbuffer.cpp:142:12: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare] src/gl/data/gl_viewpointbuffer.cpp:142:34: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare] --- src/gl/data/gl_viewpointbuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/data/gl_viewpointbuffer.h b/src/gl/data/gl_viewpointbuffer.h index 3ec1093df..08c1cab0c 100644 --- a/src/gl/data/gl_viewpointbuffer.h +++ b/src/gl/data/gl_viewpointbuffer.h @@ -14,7 +14,7 @@ class GLViewpointBuffer void * mBufferPointer; TArray mClipPlaneInfo; - unsigned int m2DWidth = ~0u, m2DHeight = ~0u; + int m2DWidth = -1, m2DHeight = -1; unsigned int mBlockSize;