Skip to content
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

PSK morph data is exported incorrectly for meshes with overlapping vertices #106

Open
cmbasnett opened this issue Oct 3, 2023 · 3 comments

Comments

@cmbasnett
Copy link
Contributor

cmbasnett commented Oct 3, 2023

I had a report for this on my addon: DarklightGames/io_scene_psk_psa#49

To sum it up, the person reporting the bug has a model exported out of FModel that has overlapping vertices which also has morph data.

The code that exports the morph data (https://github.com/FabianFG/CUE4Parse/blob/b35b843a1193d225df8583b664ef66854557a613/CUE4Parse-Conversion/Meshes/MeshExporter.cs#L456C9-L470) will only ever export morph data for 1 of the overlapping vertices because of the the FindVertex call:

var index = FindVertex(vertex.Position, share.Points);

I'm not too familiar with how this code is supposed to work, but it seems like, at least for LOD0, it should be possible to forego the FindVertex call and just use the SourceIdx as the vertex index for the morph datum.

@h4lfheart
Copy link
Collaborator

the issue with this is that psk merges overlapping verts so the source index does not line up at all, there's no proper way to do this other than completely removing that part of the code, I'll look into it later but as far as I'm aware this is the only "hacky" way to remap the vertex indices properly

@cmbasnett
Copy link
Contributor Author

Are you sure that the PSK export merges overlapping vertices? 🤔 This doesn't appear to be the case, since the model that the person sent had many overlapping vertices.

@h4lfheart
Copy link
Collaborator

it's possible the vertices for their mesh aren't perfectly overlapping (a tolerance could be added if that's the issue when comparing vertex positions) but it's done here

https://github.com/FabianFG/CUE4Parse/blob/master/CUE4Parse-Conversion/Meshes/PSK/CVertexShare.cs#L58

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

No branches or pull requests

2 participants