-
-
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
ImDrawList::PathArcToAdaptive - path arc that automatically adjust precision according to arc radius #3491
Conversation
Few tweaks and Everything is sampled 10000 times, repeated 10 times and then averaged.
Most common radii are around 10. What is interesting To try it by yourself replace yours You can checkout spreadsheet with data, there are also more charts inside (file is in ods format): Feedback will be appreciated. |
827cf74
to
b6a56db
Compare
Rebased and squashed to make it easier to view. |
b6a56db
to
338fb46
Compare
Rebased on master. It is green now. |
Thank you very much. I'm hoping to adopt that shortly after 1.80. |
338fb46
to
cab8ab6
Compare
cab8ab6
to
fc5da7a
Compare
Quick question:
What's the reasoning for it? |
That matches the equivalent test in |
Values can be swapped. It was a guard to prevent invalid input values. |
fc5da7a
to
7ff027d
Compare
PR was rebased on #3808, cleaned up and grew a need for feedback. At the moment I introduced One thing I do want to address and need the feedback the most is the Also updated benchmark results. There will be more after technical issued get addressed. |
3190c38
to
8be757e
Compare
I made a test using The BenchmarkEach ResultsWe have four graphs in this order:
Worst case
More realistic case
ConclusionsOverall, adaptive arcs are on pair with current implementation. They are faster for small radii, on pair with most commonly used ones and became slower as number of vertices grow. Please take a note that we're in microseconds (1e-6) realm while reading graphs. Arc generation to SummaryI'm open for any feedback you can have. Branch currently have a benchmark code embedded in image_demo.cpp. You can build it and test it yourself. There are more test cases for arc in the code, but disabled. Demo can generate CSV file for enabled benchmarks. After few days waiting for feedback I will move forward to wrap up this PR by replacing current implementation. Thanks! Edit: |
86c58a0
to
cfa7862
Compare
…dius < 0.0f. (#3491) + changed poor-man ceiling in _CalcCircleAutoSegmentCount() to use 0.999999f to reduce gaps Previously it sorts of accidentally worked but would lead to counter-clockwise paths which and have an effect on anti-aliasing.
Merged (had lots of privates discussions leading to this), thanks for your amazing work. I'll close this. As you know part of the demo/test bed may be worth including in either Demo or our Test Facilities in the future. |
This PR adds
ImDrawList::PathArcToAdaptive()
. An implementation ofPathArcTo
that automatically adjust number of used samples according to used arc radius.Implementation use 32 element lookup table to fill arc content. On worst case scenario calculate two sampling points when start or end angles are not in lookup table. 32 samples cover radii up to 80 pixels.
To complete this PR decision to call
PathArcToAdptive
instead ofPathArcTo
by default inAddXXX
functions should be made.I'm looking for your feedback.
Node: Demo in DO NOT MERGE commit may not work out of the box.
Drawing results
Benchmark results
Notice a jump around 80 pixel radius. This is where fallback to
PathArcTo
kick in.With PathArcToFast
With PathArcTo