-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Add closed
property to Line2D
#79182
Conversation
f2e18ab
to
77048f7
Compare
Looks like you referenced wrong issue👀 |
Ah, sorry, I put in an issue instead of a proposal. Bugsquad fixed it for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test project I made. |
Addressed the concerns, but this feature is a tougher nut to track than I thought. Sorry, I think I misjudged and put it out way too undercooked. Putting as draft for now until I fix some bugs with the new feature. p.s. Can I please combine the |
Potentially a good idea but I'd suggest not complicating this PR and making it only add the new |
19be64f
to
c018faf
Compare
Well, aside from transparent closed curves being slightly messed up in Bevel and Round joint mode, it works. I changed the gradient to not flip around automatically. If the user wants a smooth transition of shape and color, they should set up the width curve and gradient in a way that achieves this. Trying to fix those joint modes with transparent lines currently. |
031c5c9
to
ca8254f
Compare
Huh, I don't think the check fails are on me. I guess I'll rebase then? |
ca8254f
to
cee76c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this behavior is the most reasonable possible way to do this :v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the geometry of the line now indeed seems to be fine.
However, there are still issues with the bevel/round joint modes (for closed line).
- For bevel/round joint modes the start/end seam goes through the joint's beginning instead of through the line's first point (like it does for the sharp joint mode).
sharp | bevel | round |
---|---|---|
- The UVs at the start/end are also incorrect (as already mentioned in Add
closed
property to Line2D #79182 (comment)). Specifically, I thinkV = 0.0
line should also go through the first point (just as the seam mentioned in the previous point). Currently for bevel/round modes the whole joint at the first point hasV = 0.0
.
sharp | bevel | round |
---|---|---|
If these are too hard to fix then I guess:
Sharp joint mode is the absense of a joint; I think the first issue you've brought up surrounds something I basically threw a coin on how to implement: Whether the joint that connects the last line to the first should be the first thing drawn or the last. I made it the first, although I'm now thinking maybe it should be the last. What you point out to be a broken UV, if I understand you correctly, are actually the leftmost pixels of Godot.svg, since it's the first joint and the line has not yet started (?) |
The half-joints idea looks quite interesting and should be possible. I'll need some extra logic, but at least no fake pass to only draw a single joint, instead it will be half a joint before the segments drawing logic, half a joint after. I'll also need to modify arc-drawing to be splittable in two. |
Well, I added the following to the docs of the new property:
I'll do some benchmarking now. I implemented a few safe little optimizations so I don't expect the performance with |
4177fe3
to
7754be2
Compare
Performance is good, maybe even better, and there are no regressions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've skimmed through the code. Most things looks fine AFAICT. I'm gonna do some more in-action testing later.
Well, I added the following to the docs of the new property:
Note: The joint between the closing segment and the first segment is drawn first and it samples the [member gradient] and the [member width_curve] at the beginning. This is an implementation detail that might change in a future version.
@MewPurPur Looks like a solution to me! 😄 I'm absolutely fine with just documenting that quirk. 👍
2d9ddba
to
6bfbdd2
Compare
Nice catch, I haven't actually tested if my changes fixed the above but I can't see why they wouldn't |
a39cc3a
to
9cb006f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style and docs looks good!
9cb006f
to
e39875a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So today I've finally done some procedural testing against potential regressions, by brute force comparing every rendered pixel for some specific configurations of line parameters (8748 images per tested build = 3 * 3 * 3 begin/end/joint types * 2 widths * 9 different width curves (including no curve) * 6 different line types (UV stretched/tiled, solid color + translucent, gradient + translucent) * 3 different point densities (default points + subdivided twice)). Stuff like:
The results are that there are slight differences between this PR and other versions (which all produce the exact same results between themselves) like: v4.1.1.stable.official [bd6af8e], v4.2.dev1.official [0c2144d], v4.2.dev4.official [549fcce], or some random artifact downloaded from a recent GH action for master
(v4.2.dev.custom_build [a79955c]).
However, the mentioned differences are AFAICT negligible. These are either:
- a single pixel "missing" (non-background vs background),
- or some pixels mismatched by approximately no more than
1.0 / 255.0
.
Here's an example of a test case with the highest difference count, specifically 34 pixels mismatched where:
- 1 pixel "missing" (pointed by the arrows),
- 33 pixels off by approx no more than
1.0 / 255.0
(can you spot them?:smile::mag:).
I've rechecked the code and the only change I suspect could have resulted in such small discrepancies is that segment intersection check is now done with Geometry2D::segment_intersects_segment
instead of a custom method. But haven't verified it anyhow.
Anyway, I doubt anyone will notice anything has changed. 🙃
Overall LGTM and seems to be working fine. 👍
(@MewPurPur Thanks for all your patience! 🙂)
Thanks, this PR was lots of fun! |
Thanks! |
closed
property to Line2D
Closes godotengine/godot-proposals#4330
Also helps some of the use cases in godotengine/godot-proposals#1126
Simplified Line2D's codebase a bit, as it reinvents a bunch of wheels for no reason (or maybe Line2D is very old and the wheels were invented later). This could help in a potential future rework of these files, which have lots of TODOs comments.
(the fact it's not representing the gradient properly is unrelated to my PR)
Test project I'm using
PuttingLine2DThroughIntenseTrials.zip