-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
Crack stitching #372
Crack stitching #372
Conversation
(cherry picked from commit 263a02f7aac879c6bfabf6df57fbc64c568bc7c5)
foreach (var (x, y, z) in trianglesToAdd) | ||
{ | ||
var (subMeshIndex, mappingA) = posToSubMesh[vertices[x]]; | ||
var ( _, mappingB) = posToSubMesh[vertices[y]]; | ||
var ( _, mappingC) = posToSubMesh[vertices[z]]; | ||
|
||
// Effectively randomly picking subMesh, i.e.: material, those triangles will be assigned to, see comment above | ||
var indices = subMeshes[subMeshIndex]; | ||
|
||
// Not sure yet how to properly solve winding order, add both sides for now | ||
indices.Add(mappingA); | ||
indices.Add(mappingB); | ||
indices.Add(mappingC); | ||
indices.Add(mappingC); | ||
indices.Add(mappingB); | ||
indices.Add(mappingA); | ||
} |
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.
Small issue right now is the fact that I'm not yet sure how to solve triangle winding order, so I'm adding triangles facing both sides. If you have a suggestion I am open to implement it.
If I am not mistaken, these would technically be called "T-Junctions", if they are vertices along an edge like Also just a minor nitpick: an image comparison with wireframe on would help a bit with making it more apparent exactly what is being done. Thanks for this! I'm sure a few people would find this very useful (and it would probably fix some PostFX issues, like bloom, for some projects). |
(cherry picked from commit 5df561435376dcd80df2702a75ead19e2d16af20)
Currently in a very good spot, this feature is really amazing and RCSG will benefit greatly from it. |
I'm still looking into @Gawidev's issue, I have a fix - just have to iron out a couple of bugs and with the holidays and all I don't have a lot of time to go through it. |
There we go, this commit should fix those issues. |
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.
Usings should be outside of any namespace. Additionally, using static
will not compile on versions of Unity that don't have the C# 6 update.
Edit: It seems like GH decided I didn't need to quote specific code. This is in the CracksStitching.cs file.
if(bestMatch.dist <= maxDist) | ||
throw new InvalidOperationException($"Stray edge ({thisEdge}) could not be solved for"); | ||
|
||
debug?.LogWarning($"For edge {thisEdge}, closest match ({bestMatch.edge}) did not satisfy {nameof(maxDist)} constraint {bestMatch.dist}/{maxDist}"); |
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.
Should be using String.Combine
instead of string interpolation, as older versions of Unity do not support it.
Additionally, .?
is not supported, so if()
checks should be used instead.
foreach (var (x, y, z) in trianglesToAdd) | ||
{ | ||
var (subMeshIndex, mappingA) = posToSubMesh[vertices[x]]; | ||
var ( _, mappingB) = posToSubMesh[vertices[y]]; |
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.
Anonymous variables aren't supported on versions previous to C# 6.
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.
Everything looks OK. Just need to make sure that there aren't any unsupported API or C# features on older versions of Unity, until the oldest supported version by RCSG (5.6.4f1) is updated to 2019+. I didn't tag every single change, but its easy to find by checking changes on here.
Hey sorry resident "I-break-stuff" worker here, a bit of extra testing done and I've run into a similar issue where hidden faces are being treated strangely by the crack detection, this case particularly when there are hidden faces with different shadow-receiving and shadow-casting settings. Should be reproducible by creating a box brush, then setting one surface to non-visible, and another one to non-visible + non-shadow-casting. They seem to get merged into the same generated render mesh, which shouldn't be the case, iirc there should be up to 5 possible generated render meshes for the same material. |
Any updates? Would love to get around to merging this. |
I should have some time to take a look at this again this week end, I'll keep you posted |
Closing in favor of #399 |
Crack Stitching
Introduces a toggle to the model inspector UI which, once toggled on, fixes cracks appearing through generated geometry. It does so asynchronously to prevent interrupting the user while he's working.
See discussion on discord for further information.
Inspector
Result
Here's a more advanced implementation of the debugger interface if someone wants to debug this in the future:
StitchingDebugger.zip
Don't forget to comment out
#define YIELD_SUBSTEPS
aboveCracksStitching.cs