-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polyline with sharp angles causes segments to nearly disappear #3366
Comments
I'm currently pre-processing my graphs with the code below, which produces great results. It groups the points into clusters that don't have acute angles (by checking the sign of the dot product of successive line segments).
A typical small graph this produces is: |
Hello Trevor, Thanks for your report! We had this issue in mind a few months ago, there is (was-) actually a perfectly formed PR in #2964 back in January. Give us a little time and we'll resurrect #2964 to fix this :) Two things:
-Omar |
There's hardly any difference with texture or not. Here's without texture: and with: I only notice that the downward sloping part of the line looks slightly thicker with texture. Turning off antialiasing entirely (
At any rate, my workaround is to split into multiple calls to AddPolyline when there's a sharp angle: https://gitlab.com/umbrellaresearch/yoga2/-/blob/tlbdev/studio/ysgui.cc#L369 |
See this committed improvement: Toggling on/off: This is obviously not perfect but better. We actually can easily preserve thickness by raising the But the extrusion of geometry to preserve thickness means that geometry can stray very far out, which for this specific use of reading a plot is a really bad thing (before of this case I reverted my initial change of increasing that threshold, and I think once we have bevel option in you'll be able to choose depending on use). I'll close this even though it is only improved not fully fixed. When we make progress on #2964 an update will be posted here too. |
Version/Branch of Dear ImGui:
Version: 1.78 WIP
Branch: master
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp (or specify if using a custom engine/back-end)
Compiler: clang 9
Operating System: OSX
My Issue/Question:
Calling AddPolyline with a line with sharp corners causes the line segments adjacent to the corners to be nearly invisible. See the first screenshot below of graph drawn with
The culprit seems to be the algorithm for IM_FIXNORMAL2F as called in ImDrawList::AddPolyline. I'm in the case with
use_texture=true
,thick_line=true
,closed=false
,fractional_thickness=0.0
When there is a sharp corner, averaging 2 successive normals produces results with magnitude much less than 1. IM_FIXNORMAL2F doesn't scale the normal up by more than a factor of 2, so the end result is a vanishingly thin line.
Screenshots/Video
The top squiggle shows the current behavior. Right now, I'm working around it by adding some duplicate points when there's a sharp corner, as shown in the bottom squiggle.
This comes up for real a lot in my application which involves graphing time series which are often jagged.
Standalone, minimal, complete and verifiable example: (see #2261)
The text was updated successfully, but these errors were encountered: