AddCircle, AddCircleFilled: Add auto-calculation of circle segment counts

This commit is contained in:
Ben Carter
2019-12-09 15:57:24 +09:00
committed by omar
parent 2eda3585e7
commit 051ce0765e
5 changed files with 62 additions and 8 deletions

View File

@ -855,6 +855,7 @@ struct IMGUI_API ImDrawListSharedData
ImFont* Font; // Current/default font (optional, for simplified AddText overload)
float FontSize; // Current/default font size (optional, for simplified AddText overload)
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo()
float CircleSegmentMaxError; // Number of circle segments to use per pixel of radius for AddCircle() etc
ImVec4 ClipRectFullscreen; // Value for PushClipRectFullscreen()
ImDrawListFlags InitialFlags; // Initial flags at the beginning of the frame (it is possible to alter flags on a per-drawlist basis afterwards)
@ -862,6 +863,13 @@ struct IMGUI_API ImDrawListSharedData
// FIXME: Bake rounded corners fill/borders in atlas
ImVec2 CircleVtx12[12];
// Cached circle segment counts for the first <n> radii (to avoid calculation overhead)
static const int NumCircleSegmentCounts = 64;// Number of circle segment counts to cache (i.e. the maximum radius before we calculate dynamically)
int CircleSegmentCounts[NumCircleSegmentCounts]; // The segment count for radius (array index + 1)
float CircleSegmentCountsMaxCircleSegmentError; // The MaxCircleSegmentError used to calculate these counts
void RecalculateCircleSegmentCounts(); // Recalculate circle segment counts based on the current MaxCircleSegmentError
ImDrawListSharedData();
};