Calculating Normals Speed Tips

BlitzMax Forums/BlitzMax Programming/Calculating Normals Speed Tips

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

It looks like you are over complicating it. The following pseudo code, shows a simpler way:
For Every Vertex
 NormalX = 0.0
 NormalY = 0.0
 NormalZ = 0.0
Next

For Every Triangle
 CalculateNormal
 For Every Vertex Used By Triangle
  NormalX :+ TriangleNormalX
  NormalY :+ TriangleNormalY
  NormalZ :+ TriangleNormalZ
 Next
Next

For Every Vertex
 NormalLength = SquareRoot (NormalX^2 + NormalY^2 + NormalZ^2)
 NormalX :/ NormalLength
 NormalY :/ NormalLength
 NormalZ :/ NormalLength
Next