Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. # We need the absolute normals as generated by Blender
  2. for shape_vert in shape.vertices:
  3. shape_vert.co -= ob.data.vertices[shape_vert.index].co - corrective_target.vertices[shape_vert.index].co
  4.  
  5. shape.calc_normals_split()
  6.  
  7. for ob_loop in ob.data.loops:
  8. shape_loop = shape.loops[ob_loop.index]
  9. norm = shape_loop.normal
  10.  
  11. if corrective:
  12. base = Vector(ob_loop.normal)
  13. for corrective_target in corrective_target_shapes:
  14. # Normals for corrective shape keys are deltas from those of the deformed mesh, not the basis shape.
  15. base += corrective_target.loops[shape_loop.index].normal - ob_loop.normal
  16. else:
  17. base = ob_loop.normal
  18.  
  19. if norm.dot(base.normalized()) < 1 - 1e-3:
  20. shape_norms.append(datamodel.Vector3(norm - base))
  21. shape_normIndices.append(shape_loop.index)
  22.  
  23. if wrinkle_scale:
  24. delta_len = delta_lengths[ob_loop.vertex_index]
  25. if delta_len:
  26. max_delta = max(max_delta,delta_len)
  27. wrinkle.append(delta_len)
  28. wrinkleIndices.append(texcoIndices[ob_loop.index])
  29.  
  30. del shape_vert
  31.  
  32. if wrinkle_scale and max_delta:
  33. wrinkle_mod = wrinkle_scale / max_delta
  34. if wrinkle_mod != 1:
  35. for i in range(len(wrinkle)):
  36. wrinkle[i] *= wrinkle_mod
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement