System.NotFiniteNumberException: Normal is invalid
See original GitHub issueHi vpenades,
Could you please have a look at the issue that I currently struggling with?
I found one object that produces SYstem.NotFiniteNumberException
It occurs on model.CreateMeshes(meshBuilder) method.
" at SharpGLTF._Extensions.ValidateNormal(Vector3 normal, String msg)\r\n at SharpGLTF.Geometry.VertexTypes.VertexPositionNormal.Validate()\r\n at SharpGLTF.Geometry.Vertex3.Validate()\r\n at SharpGLTF.Geometry.PrimitiveBuilder
4.Validate()\r\n at SharpGLTF.Geometry.MeshBuilder4.Validate()\r\n at SharpGLTF.Schema2.Schema2Toolkit.CreateMeshes[TMaterial,TvP,TvM,TvS](ModelRoot root, Func
2 materialEvaluator, MeshBuilder`4[] meshBuilders)\r\n at GltfExporter.GLTFExporter.<>c__DisplayClass8_0.<ExportObjectGroupToGLTF>b__0(MaterialObejct3D materialObject3D, Object context) in C:\Work\Dev\Source\GltfExporter\GLTFExporter.cs:line 662"
I debugged the normals that are going in while method primitive.AddTriangle(vertexPositionNormal1, vertexPositionNormal2, vertexPositionNormal3); is executing, and found no infinite float values or Nan value. All normals are normalized to 1 before passed to this method.
Attaching the file with normal output. NormalAddLog.txt
Could you please add validate to primitive.AddTriangle method? So that it will be easier to debug. With current workflow, I am adding all triangles first and then validate method throws an exception on model.CreateMeshes(meshBuilder)
If validation was checked on AddTriangle method, it would be easier to see the exact incorrect normal
Also, it is quite strange that this exception is happening because Normals look good
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Maybe the ScrictMode should be renamed to DebugMode or something like that.
It’s still in development, and certainly, when normal (or tangent) is zero, it should throw an exception in script mode, or do nothing in non scrict mode.
The idea behihd non strict mode is to prevent crashes in environments where the library is being used unatended, or in production, where you want a user to import a model that has invalid data, but you don’t want to crash the application.
something I’m considering is to add a warnings section in the meshbuilder object… so if strict mode is NOT set, errors will be logged as warnings.
Thank you for the extensive explanation