title: Winding order of vertices
body: <p>I understand what winding order is, and how it is used for backface culling.</p>
  
  <p>However, I am not exactly sure how 3d modelling programs like Blender can take an arbitrary group of triangles and wind them all correctly.</p>
  
  <p>I tried googling the answer and this was the best I found:</p>
  
  <p><a href="http://www.gamedev.net/topic/550481-vertex-winding-order-counter-clockwise-oder-vertex---algorithm/" rel="nofollow">http://www.gamedev.net/topic/550481-vertex-winding-order-counter-clockwise-oder-vertex---algorithm/</a></p>
  
  <p>Basically, for each triangle, you find its center (barycenter to be precise), calculate a normal vector from that triangle, which gives you a ray. You take this ray and test it against intersection against every other triangle. If it's an even number, then your winding is correct, if it's an odd number, your winding is incorrect (I guess this depends on how exactly you generated the normal vector, but you use the odd/even strategy somehow).
  Anyways, that means this whole process is generally O(n^2). If you have 1000 triangles, then for each triangle, you have to test it against intersection for 999 other triangles. Is there a less obvious way to correctly wind vertices, that is more efficient?</p>