Skip to content
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

tentative fix for gaps in fat line strokes #288

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mmalex
Copy link

@mmalex mmalex commented Jul 29, 2015

trying to fix the bug shown in this tweet:
https://twitter.com/mmalex/status/626162676318781440

works a bit grossly by forcing one short edge of each quad to copy the previous line's edge, provided there isnt too big an angle change. could be made more efficient by sharing vertices that are actually shared... I might do that in a bit.

@mmalex
Copy link
Author

mmalex commented Jul 29, 2015

I've added sharing of edges (fixes a FIXME) in the second commit, however to avoid looping twice over the edges it does a PrimReserve(0, -number) (second param is negative!) to 'unreserve' a number of verts based on how many shared edges there were. not sure how you feel about that. works here ;)

@ocornut
Copy link
Owner

ocornut commented Jul 31, 2015

Thanks Alex! I'll keep that on hold for a bit - just merged in thick line for the AA-path. It is merging normals in a way that looks pretty awesome: (that's code from mikko mononen)

capture

Compare to your version with a threshold (non-AA path):

capture2

So most likely I'll go and fix the non-AA path so that it behave like the AA one. Unless there is a reason for using that technique for some shapes.

PrimReserve with negative values is safe, added a comment. Hasn't occured I could use that (AddText does a similar thing manually). I am currently moving large chunk of the ImDrawList code around, when I'm done I'll look back to make sure the non-AA path behave the same.

Test code

ImDrawList* draw_list = ImGui::GetWindowDrawList();
ImVec2 pos = ImGui::GetCursorScreenPos();

draw_list->PathArcTo(ImVec2(pos.x+100.0f,pos.y+20), 90.0f, 0.0f, 3.1416f);
draw_list->PathArcTo(ImVec2(pos.x+100.0f,pos.y+20), 70.0f, 3.1416f, 0.0f);
draw_list->PathStroke(0xFF00FFFF, true, 12.0f);

pos.y += 150.0f;
draw_list->PathLineTo(ImVec2(pos.x+0,pos.y+0));
draw_list->PathLineTo(ImVec2(pos.x+30,pos.y+100));
draw_list->PathLineTo(ImVec2(pos.x+50,pos.y+10));
draw_list->PathLineTo(ImVec2(pos.x+100,pos.y+90));
draw_list->PathLineTo(ImVec2(pos.x+120,pos.y+0));
draw_list->PathStroke(0xFF00FFFF, false, 12.0f);

@ocornut ocornut force-pushed the master branch 2 times, most recently from 0c1e5bd to bb6a60b Compare August 27, 2021 19:10
@ocornut ocornut force-pushed the master branch 2 times, most recently from 8b83e0a to d735066 Compare December 13, 2021 11:31
@ocornut ocornut force-pushed the master branch 2 times, most recently from b3b85d8 to 0755767 Compare January 17, 2022 14:21
@ocornut ocornut force-pushed the master branch 3 times, most recently from c817acb to 8d39063 Compare February 15, 2022 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants