imgui icon indicating copy to clipboard operation
imgui copied to clipboard

bug fix: float precision overflow in IM_NORMALIZE2F_OVER_ZERO

Open InJoins opened this issue 2 years ago • 2 comments

when added vertices are particularly dense or close together, sometimes the resulting lines will crack, flicker, or even cover the entire screen, causing the screen to flicker Since a root-splitting calculation will be performed later, 0.001 is appropriate

affected functions: AddPolyline, AddConvexPolyFilled

InJoins avatar Apr 14 '23 14:04 InJoins

Since the added points are in the unit of screen pixels, two consecutive points in a polyline with a distance of sqrt(0.001)=0.0316 pixels have no effect on the final accuracy and display effect as a single point.

InJoins avatar Apr 14 '23 14:04 InJoins

Hello,

Could you post repro of shapes that are noticeably affected?

If I try:


ImDrawList* draw_list = ImGui::GetForegroundDrawList();
draw_list->PathLineTo(ImVec2(100, 100));
draw_list->PathLineTo(ImVec2(200, 100));
draw_list->PathLineTo(ImVec2(200, 100.00001f));
draw_list->PathLineTo(ImVec2(100, 300.0f));
draw_list->PathStroke(IM_COL32_WHITE, 0, 3.0f);

Original code: image

Yours: image

I'd be interested to see how your case behave with #2964 because my case behave well with it (branch: https://github.com/ocornut/imgui/tree/features/potocpav-newer-lines-2)

Ref #4053, #3366 for similar change in the other macro.

ocornut avatar May 18 '23 14:05 ocornut