question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.NotFiniteNumberException: Normal is invalid

See original GitHub issue

Hi 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.PrimitiveBuilder4.Validate()\r\n at SharpGLTF.Geometry.MeshBuilder4.Validate()\r\n at SharpGLTF.Schema2.Schema2Toolkit.CreateMeshes[TMaterial,TvP,TvM,TvS](ModelRoot root, Func2 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:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vpenadescommented, Jun 3, 2019

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.

0reactions
Imavercommented, Jun 3, 2019

Thank you for the extensive explanation

Read more comments on GitHub >

github_iconTop Results From Across the Web

NotFiniteNumberException Class (System)
Initializes a new instance of the NotFiniteNumberException class with a specified error message, the invalid number, and a reference to the inner exception ......
Read more >
C# Short Error: Negating the minimum value of a twos ...
Hi! Its just a regular value. Ive handled it using thresholding function so thanks! – user488792. Jun 7, 2011 at 15:17.
Read more >
All .Net Exceptions List
System.InvalidProgramException. The exception that is thrown when a program contains invalid Microsoft intermediate language (MSIL) or metadata.
Read more >
Common C# exceptions and how to fix them
The System.InvalidCastException occurs when an invalid type conversion is attempted. This exception occurs when a value of one type is cast to ...
Read more >
.NET Exceptions - System.OverflowException
OverflowException in .NET indicates that an invalid arithmetic, casting, or conversion error occurred within a checked context. Throughout this ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found