Repository navigation
fix(outline): resolve tip rendering artifacts on sharp tangents - #3658
Abdelhadi-Wael wants to merge 2 commits into
Conversation
Summary of ChangesHello @Abdelhadi-Wael, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses rendering artifacts that occur when outlines have sharp tangents, particularly affecting the appearance of round tips. It introduces a robust tangent correction mechanism to ensure tangents always point in the correct direction relative to their line segments. Furthermore, it significantly enhances the quality of round tip rendering by transitioning from a less precise conic-based method to a more accurate Hermite curve generation, resulting in visually smoother and more consistent outline shapes. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Thank you for contributing! 🐞 Bug Fixes
|
There was a problem hiding this comment.
Code Review
This pull request fixes rendering artifacts for outlines with sharp tangents. It introduces two main changes: first, it corrects backward-pointing tangents to prevent mesh folding. Second, it replaces the old conic-based round tip rendering with a more accurate method using Hermite curves. The changes are logical and well-commented. My review includes a couple of suggestions to improve code consistency and robustness.
|
|
||
|
|
||
| // Used for tip generation | ||
| const double EPSILON = 1.0e-12; |
| for (float n=0; n<1.0f; n+=1.0f/TIP_SAMPLES) | ||
| shape_contour().line_to(curve(n)); | ||
|
|
||
| shape_contour().line_to(curve(1.0f)); |
There was a problem hiding this comment.
This loop for sampling the Hermite curve can be made more robust and concise. The current implementation has a redundant first iteration (n=0) and uses a floating-point variable as a loop counter, which can be prone to precision issues.
I suggest using an integer-based loop that starts from the second sample and goes up to the last one. This avoids the redundant call and is more robust against floating-point inaccuracies.
for (int i = 1; i <= TIP_SAMPLES; ++i) {
shape_contour().line_to(curve(static_cast<float>(i) / TIP_SAMPLES));
}|
@Abdelhadi-Wael Can you please rebase? |
e201ac9 to
d629dda
Compare
|
@Svarov-RZM rebased |
| const ValueBase::List &bline = bline_segment.is_valid() ? bline_segment.get_list() : param_bline.get_list(); | ||
|
|
||
| std::vector<BLinePoint> points; | ||
| for (const auto & i : bline) | ||
| points.push_back(i.get(blank)); |
There was a problem hiding this comment.
If you don't need the bline variable of (original) line 140, you can fill the points variable via get_list_of():
const std::vector<BLinePoint> points = param_bline.get_list_of(BLinePoint());for example. The bline_segment has the same method.
|
Hmm, I did some tests and current implementation has a serious bug somewhere. When I move the tangent on last vertex just ever so slightly, the outline renders incorrectly. Other versions of Synfig, including 1.0.2, handle this properly. Here's the source: To reproduce select the tangent of the last vertex and hit arrow up key one time or maybe a couple, depending on current canvas zoom. |
|
Hey @Abdelhadi-Wael |

fixes #951
We could have simply increased the number of segments as @blackwarthog suggested, but that would have required a large value (at least 128), and the quality still would not have been as good as this approach.
Inspired by the old implementation.