Selecting ultra sharp faces

Many tools exist to select faces that are in some sense unwieldy to work with. Blender has built-in tools to select faces that have an area that is too small or that have a perimeter that is too short. However, it lacks a tool to select faces with edges that form angles that are sharper than some limit. In some modeling tasks it would be very convenient if we could select such faces, as they are generally difficult to manipulate and may give rise to ugly artifacts when applying a subsurface modifier or deforming a mesh.

Note

Note that Blender's select sharp edges tool (Ctrl + Alt + Shift + S) does something different despite its name; it selects those edges that are shared by exactly two faces whose angle of contact is less than some minimum value or, to put it in another way, selects edges between faces that are relatively flat.

We already have seen that Blender's Mathutils module has a function to calculate the angle so our code is very brief as the real work is done by a single function shown below. (The full script is provided as sharpfaces.py.)

def sharpfaces(me,minimum_angle):
for face in me.faces:
n = len(face.verts)
edges = [face.verts[(i+1)%n].co - face.verts[i].co for i in range(n)]
for i in range(n):
a = AngleBetweenVecs(-edges[i],edges[(i+1)%n])
if a < minimum_angle :
face.sel = 1
break

Note that we do not distinguish between tris or quads as both may have edges that are joined by a sharp angle. The highlighted part in the preceding code shows one subtle detail; each time we calculate the angle between our two edge vectors, we invert one of them because to calculate the correct angle, each of the vectors should originate in the same vertex whereas we calculated them all as pointing from one vertex to the next.

The distinction is illustrated in the following figure:

Selecting ultra sharp faces
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.21.47