From 52bea181f65b36acea0a5840b2f27a45918e92a8 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 24 Aug 2021 18:59:10 +0200 Subject: [PATCH] Shadows: Fix broken shadows due to zero-clear added in 9417acc2 --- imgui.h | 3 ++- imgui_draw.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/imgui.h b/imgui.h index 2aa376f31..957057c71 100644 --- a/imgui.h +++ b/imgui.h @@ -3292,7 +3292,8 @@ struct ImFontAtlasShadowTexConfig float TexDistanceFieldOffset; // How much to offset the distance field by (allows over/under-shadowing, potentially useful for accommodating rounded corners on the "casting" shape). bool TexBlur; // Do we want to Gaussian blur the shadow texture? - IMGUI_API ImFontAtlasShadowTexConfig(); + inline ImFontAtlasShadowTexConfig() { memset(this, 0, sizeof(*this)); } + IMGUI_API void SetupDefaults(); int GetRectTexPadding() const { return 2; } // Number of pixels of padding to add to the rectangular texture to avoid sampling artifacts at the edges. int CalcRectTexSize() const { return TexCornerSize + TexEdgeSize + GetRectTexPadding(); } // The size of the texture area required for the actual 2x2 rectangle shadow texture (after the redundant corners have been removed). Padding is required here to avoid sampling artifacts at the edge adjoining the removed corners. int CalcConvexTexWidth() const; // The width of the texture area required for the convex shape shadow texture. int GetConvexTexPadding() const { return 8; } // Number of pixels of padding to add to the convex shape texture to avoid sampling artifacts at the edges. This also acts as padding for the expanded corner triangles. diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 72230374e..539416155 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -376,7 +376,7 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst) // [SECTION] ImFontAtlasShadowTexConfig //----------------------------------------------------------------------------- -ImFontAtlasShadowTexConfig::ImFontAtlasShadowTexConfig() +void ImFontAtlasShadowTexConfig::SetupDefaults() { TexCornerSize = 16; TexEdgeSize = 1; @@ -3224,6 +3224,7 @@ ImFontAtlas::ImFontAtlas() TexGlyphPadding = 1; PackIdMouseCursors = PackIdLines = -1; ShadowRectIds[0] = ShadowRectIds[1] = -1; + ShadowTexConfig.SetupDefaults(); } ImFontAtlas::~ImFontAtlas()