nicklockwood / Euclid

A Swift library for creating and manipulating 3D geometry
MIT License
644 stars 53 forks source link

Detessellate Not Working for Some Models #72

Open iwoj opened 3 years ago

iwoj commented 3 years ago

For example: https://www.icloud.com/iclouddrive/0K8FOcYTy7wEBf0WRt-70LrTw#Detessellate_Test

nicklockwood commented 3 years ago

Can you elaborate? Is the attached model the result of detessellation, or the input?

Can you provide a code sample of how you are loading the model, and what you expect the output to be?

Also, I notice that when I preview the model in the Finder, it seems to have inverted faces - could that be related to the issue?

iwoj commented 2 years ago

Long delayed reply: I want to use the above model as input into your detessellation method. All I'm doing is calling detessellate() on the mesh. When I invert the normals like you suggest (I use meshlab for that) and input the model again, I get the same result. Here, you can see both models have the same set of detessellated faces (with some that remain tessellated):

IMG_7331

Regardless, normals probably shouldn't affect detessellation. It's just a merging of coplanar polygons, no?

nicklockwood commented 2 years ago

@iwoj normals can affect detessellatioon because if two neighboring triangles face opposite directions then they are effectively not coplanar and cannot be merged into a single quad.

That said, you are right that it seems that was not the issue in this case. I believe I've now fixed the actual issue, and pushed a fix to the develop branch if you'd like to try it out.

iwoj commented 2 years ago

It works much better now! Thanks. I'm still noticing a few models that don't detessellate and I don't think it's because of normals. Does detessellation only reduce to quads or can it create planar polygons with any number of vertices?

nicklockwood commented 2 years ago

It can produce any number of vertices. If you have example models that don't detessellate properly please share them and I'll investigate further.

giln commented 1 year ago

Hello, I have a model that does not detessellate properly. I think it has to do with normals but have not been able to pinpoint the exact problem.

Wall.scn.zip