mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Nav: Ensure g.NavScoringRectScreen is always finite and not inverted. (#787)
This commit is contained in:
parent
e2654a097b
commit
66ff820eaa
10
imgui.cpp
10
imgui.cpp
@ -2130,8 +2130,10 @@ static ImGuiDir NavScoreItemGetQuadrant(float dx, float dy)
|
|||||||
|
|
||||||
static float NavScoreItemDistInterval(float a0, float a1, float b0, float b1)
|
static float NavScoreItemDistInterval(float a0, float a1, float b0, float b1)
|
||||||
{
|
{
|
||||||
if (a1 < b0) return a1 - b0;
|
if (a1 < b0)
|
||||||
if (b1 < a0) return a0 - b1;
|
return a1 - b0;
|
||||||
|
if (b1 < a0)
|
||||||
|
return a0 - b1;
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3133,9 +3135,11 @@ static void ImGui::NavUpdate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
|
// For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
|
||||||
g.NavScoringRectScreen = g.NavWindow ? ImRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[g.NavLayer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[g.NavLayer].Max) : ImRect();
|
ImRect nav_rect_rel = (g.NavWindow && g.NavWindow->NavRectRel[g.NavLayer].IsFinite()) ? g.NavWindow->NavRectRel[g.NavLayer] : ImRect(0,0,0,0);
|
||||||
|
g.NavScoringRectScreen = g.NavWindow ? ImRect(g.NavWindow->Pos + nav_rect_rel.Min, g.NavWindow->Pos + nav_rect_rel.Max) : GetViewportRect();
|
||||||
g.NavScoringRectScreen.Min.x = ImMin(g.NavScoringRectScreen.Min.x + 1.0f, g.NavScoringRectScreen.Max.x);
|
g.NavScoringRectScreen.Min.x = ImMin(g.NavScoringRectScreen.Min.x + 1.0f, g.NavScoringRectScreen.Max.x);
|
||||||
g.NavScoringRectScreen.Max.x = g.NavScoringRectScreen.Min.x;
|
g.NavScoringRectScreen.Max.x = g.NavScoringRectScreen.Min.x;
|
||||||
|
IM_ASSERT(!g.NavScoringRectScreen.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows us to remove extraneous fabsf() calls in NavScoreItem().
|
||||||
//g.OverlayDrawList.AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
|
//g.OverlayDrawList.AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
|
||||||
#if IMGUI_DEBUG_NAV_RECTS
|
#if IMGUI_DEBUG_NAV_RECTS
|
||||||
if (g.NavWindow) { for (int layer = 0; layer < 2; layer++) g.OverlayDrawList.AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255,200,0,255)); } // [DEBUG]
|
if (g.NavWindow) { for (int layer = 0; layer < 2; layer++) g.OverlayDrawList.AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255,200,0,255)); } // [DEBUG]
|
||||||
|
Loading…
Reference in New Issue
Block a user