LDrawLoader: Check if a face edge is a sub segment of a long edge when smoothing normals #23077
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue: #22957 (comment)
Description
This PR implements the approach mentioned in #22957 (comment) to create hard edges in the corner cases when a part is made up of multiple materials and edges stretch over multiple face edges that are broken up by color. It works by indexing every edge line as a normalized ray and then checking to see if face edges lie on that ray. This is more expensive but it is only run when if a part is made of 2 or more materials.
In the Scorpion Pyramid model there are 55 parts total that are made of 2 or more materials and are therefore smoothed with this more advanced logic. Here's an image of those parts:
From doing some performance checks it doesn't look like this significantly impacts the performance of smoothing normals on the pieces where it's relevant.
A small side note that that red seat piece in the bottom left that looks like it is all one color is incorrectly formed and actually has one triangle that is a different material causing it to fall into the above condition. The most segments that have to be checked against once a face edge has been found to lie on an edge ray is 9 in the Scorpion Pyramid model.
cc @yomboprime