Let's suppose I create a bmesh with the following commands:

import bmesh
bm = bmesh.new()
bmesh.ops.triangulate(bm, faces=bm.faces)

Have a look at the following picture to get to know what counterclockwise (CCW) and clockwise (CW) indexing means:


Now when I iterate over the meshes faces after triangulating it is there any indication/standard in what order (CCW or CW) relative to the faces front/normal I will iterate over the loops of each face? Is it safe to assume that I will the following script will either always output [1,2,3] or [3,2,1] for a triangle like seen above?

l = []
for face in bm.faces:
    for loop in face.loops:
assert l==[1,2,3] // Or [3,2,1], or one of those lists rotated

PS: Can anyone propose a nice solution that will always guarantee CCW indexing for the faces loops?


From http://wiki.blender.org/index.php/Dev:2.6/Source/Modeling/BMesh/Design:

Loops store several handy pointers:

  • v - pointer to the vertex at the start of the edge (where "start" is defined by CCW order)

this means that CCW indexing can be assumed if I don't get it wrong. Also note that the loop-list on the face is circular according to this:

Faces link to a loop in the loop cycle, the circular linked list of loops defining the boundary of the face.


Your Answer

