| Code: |
| if face.use_smooth:
# use vertex normal (full smooth effect) else: # use face normal (no smooth effect) |
| Code: |
| def get_autosmooth_normal(mesh, fop, mesh_vi):
'''check if smoothing has to be applied and return the depending normal''' ## is at least one neighbourface smooth, the we return the vertex ## normal(smooth applied), else the face normal will be returned result = fop.normal # init with the normal for the un-smooth case ## faulty (none-planar) faces may have a zero-length normal, and without ## direction you can't calculate direction difference if fop.normal.length > 0.0: for p in mesh.polygons: if ( p != fop ) and ( mesh_vi in p.vertices ) and ( p.normal.length > 0.0): angle = int(round(math.degrees(fop.normal.angle(p.normal)))) if angle <= mesh.auto_smooth_angle: result = mesh.vertices[mesh_vi].normal return result ------------------- if face.use_smooth: if mesh.use_auto_smooth: no = mathutils.Vector(obj_prop[OBJ.ROT] * get_autosmooth_normal(mesh, face, face.vertices[face_vi])) else: no = mathutils.Vector(obj_prop[OBJ.ROT] * mesh.vertices[face.vertices[face_vi]].normal) else: no = mathutils.Vector(obj_prop[OBJ.ROT] * face.normal) |