Skip to content

fix(outline): resolve tip rendering artifacts on sharp tangents - #3658

Open
Abdelhadi-Wael wants to merge 2 commits into
synfig:masterfrom
Abdelhadi-Wael:outline-tip-artifact
Open

Abdelhadi-Wael wants to merge 2 commits into
synfig:masterfrom
Abdelhadi-Wael:outline-tip-artifact

Conversation

@Abdelhadi-Wael

Copy link
Copy Markdown
Contributor

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.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @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

  • Tangent Correction Logic: Implemented a mechanism to detect and correct backward-pointing tangents in BLine points, preventing mesh folding and rendering artifacts by ensuring tangents align with their respective line segments.
  • Improved Round Tip Generation: Replaced the previous conic-based round tip generation with a more accurate approach using Hermite curves, leading to smoother and better-defined tips for outlines.
  • Refactored Tip Constants: Introduced new constants (EPSILON, ROUND_END_FACTOR, TIP_SAMPLES) for controlling the precision and appearance of the newly generated tips, enhancing customization and quality.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@github-actions

Copy link
Copy Markdown

Thank you for contributing!
Below is how your contribution will appear in Synfig's release notes. Review it and improve your pull request's title and description so that your contribution is clear. You can add images, videos, and anything else you want. Have fun!

🐞 Bug Fixes

  • (Outline Related) Resolve tip rendering artifacts on sharp tangents

    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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the rest of the codebase, it's better to use the Real type alias instead of double directly. Real is defined as double in synfig/real.h.

	const Real EPSILON = 1.0e-12;

Comment on lines +233 to +236
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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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));
				}

@Svarov-RZM Svarov-RZM self-assigned this Jan 11, 2026
@Svarov-RZM

Copy link
Copy Markdown
Contributor

@Abdelhadi-Wael Can you please rebase?

@Abdelhadi-Wael

Copy link
Copy Markdown
Contributor Author

@Svarov-RZM rebased

Comment on lines 143 to +147
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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Svarov-RZM

Copy link
Copy Markdown
Contributor

Hmm, I did some tests and current implementation has a serious bug somewhere.
Look at this:
TipBug

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:
TipTest.zip

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.

@Svarov-RZM

Copy link
Copy Markdown
Contributor

Hey @Abdelhadi-Wael
Did you see a regression in rendering in my previous post?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Outline tip artifact

3 participants