ousnius / BodySlide-and-Outfit-Studio

BodySlide and Outfit Studio, a tool to convert, create, and customize outfits and bodies for Bethesda games.
GNU General Public License v3.0
286 stars 63 forks source link

Automatically triangulate imported meshes #443

Closed GrafPanzer closed 2 years ago

GrafPanzer commented 2 years ago

Outfit Studio does not currently handle mesh faces with more than three sides. Upon importing an .fbx or .obj with multi-sided faces, OS typically omits the 4+ sided faces (I think it sometimes triangulates them, not sure). A better way to handle this would be to automatically triangulate all faces upon import, so users don't inadvertently end up with holes in their meshes. [Inspired by a user issue in the outfitstudio-help channel on Discord today.]

sts1skj commented 2 years ago

I've taken a look through ObjFile::LoadForNif (which is Outfit Studio's function for parsing OBJ files), and it looks to me like it currently can handle faces with 3 or 4 vertices, but not more.

@GrafPanzer Is it possible that OBJ import only misbehaves for faces with 5 or more vertices, and works okay for 4?

ousnius commented 2 years ago

FBX import triangulates the mesh, however the UV map will be screwed up as it won't account for actually splitting up the mesh where the UV island seams are located.

OBJ import can handle quads (iirc it should turn them into two triangles, but need to check). I don't know if the OBJ format by itself even supports polygons with more than 4 points.

sts1skj commented 2 years ago

Could someone please verify that PR #444 fixes this issue? More specifically, can you now import OBJ files with more than 4 vertices per face, and can you now import FBX files with more than 3 vertices per face?

sts1skj commented 2 years ago

Verified importing a hand-written OBJ with a hexagon:

o hexagon
v 0 0 0
v -1 0 1
v -1 0 2
v 0 0 3
v 1 0 2
v 1 0 1
f 1 2 3 4 5 6
GrafPanzer commented 2 years ago

Thanks for taking a look at this, sts1skj. Sorry, but once again I'm not competent to verify fixes before they're merged and published.