Vertex normal calculations with bad model vertices / indices

I am using the normal calculation formula from one of the books I have (might be Reimers). For the most part, this has been working great.

I have recently run into errors with some models. The issue seems to be these.models have bad vertices (e.g. 2 of them have the exact same value) or bad indices e.g 2 of the 3 indices point to the same vertex.

How should I deal with this in my normal calculations (outside of fixing the model, which I can’t do)?


It won’t matter. Detect this error and put anything you want in the normal.

Why is this valid?

A triangle with two identical points is very unlikely to display. You MAY get a line a single pixel wide, but I doubt it.

Note if you are smoothing your normals, you should not include it in the calculation.

@StainlessTobii Thanks! Putting in any value seems to fix the problem.