Open Tugcga opened 1 year ago
Debugging the app, I run into an exception here import_mesh.cpp
line 549
Exception thrown at 0x00000000151713A7 (mogeometry.dll) in XSI.exe: 0xC0000005: Access violation writing location 0x00000001E7075A50.
cluster.SetValues(attr_data.data(), samples_start_index);
samples_start_index seems too large for the Normal Cluster.
cluster.SetValues(attr_data.data(), cluster.GetElements().GetCount());
avoids the crash but some normals are bad for about half of the objects. I'll try investigating a bit further.
I think the buggy model just might be broken, it reports sometimes more normals than the object has samples in its cluster. I would suggest to do a check (samples_start_index == xsi_mesh.GetSamples().GetCount()) and if that fails, not import that cluster data.
Ok, I thought something like that. May be I will implement this solution.
Finally I found the problem. It turns out that meshes in Buggy
sample contains trivial triangles. These triangles span three vertices, where two of them are the same. When I build the mesh in Softimage by using
XSI::CMeshBuilder mesh_builder;
mesh_builder.AddVertices(vertex_count, positions.data());
mesh_builder.AddPolygons(triangles_count, polygon_sizes.data(), triangles.data());
mesh_builder.Build(false);
then the Softimage ignores these trivial triangles. As a result the actual number of samples in the generated mesh is less than the number of normals in the input gltf-file. So, the Softimage is fails to assign a big array with normals to the cluster with smaller size.
Nice job . I updated it here: si-community.com/community/resources.php (Let me know in case you want some changes to your listings)
When I try to import Buggy sample model, the Softimage is crashed.
It imports some materials and geometry, but crashed with errors in the middle of the process. Why it happens?