rapidobj icon indicating copy to clipboard operation
rapidobj copied to clipboard

Triangulate causing missing triangles?

Open blitz-research opened this issue 1 year ago • 1 comments

Hi,

Trianglulate used on this file appears to be causing triangles to go missing:

https://murena.io/s/Z6MSrKkCf2Mr72Y

Screenshot showing some of the missing triangles outlined in red here:

triangulate_bug

If I skip the triangulate step and do my own simple triangulate while loading (which effectively just treats all faces like a triangle fan), everything loads correctly.

[edit] Ok, it looks like triangulate is flipping some triangles. If I force the material to be double sided, the missing triangles re-appear.

Changing lines 6983-ish to this (which basically just duplicates my loader code) fixes the problem with this model:

		dst->indices[idst + 0] = index0;
		dst->indices[idst + 1] = index1;
		dst->indices[idst + 2] = index2; // d02_is_less ? index2 : index3;
		dst->indices[idst + 3] = index0; // d02_is_less ? index0 : index1;
		dst->indices[idst + 4] = index2;
		dst->indices[idst + 5] = index3;

Not sure what d02_is_less is supposed to do though so probably not that simple. [/edit]

Bye, Mark

blitz-research avatar Mar 30 '23 06:03 blitz-research

Thanks for the report and investigation. I will take a closer look, probably this weekend.

guybrush77 avatar Mar 31 '23 00:03 guybrush77