[Bf-committers] New BMesh API to set normals
Bastien Montagne
montagne29 at wanadoo.fr
Tue Jun 7 22:17:28 CEST 2016
Hi devs,
Today Howard requested the ability to set custom normals in BMesh (Edit
mode tools). While we are far from ready to have a real normal editing
feature/mode/whatever in Edit mode currently, I made a quick port of
BKE_mesh_evaluate code to set normals, in the new `custom-normals-bmesh`
branch for now.
As with non-bmesh code, currently you can only set all normals (either
per-loop or per-vertex) at once, since this is not a cheap operation.
Also added a python bmesh.utils.custom_normals_set() api func, at least
to allow easy testing of the feature, e.g. with default cube in Edit mode:
>>> import bmesh
>>> bm = bmesh.from_edit_mesh(C.edit_object.data)
>>> nors = sum(zip(((0, 0, 1),) * 4, (None,) * 4), ()) # Produces an
8-items tuples of Z-up vectors and None's
>>> # Set those vertex custom normals into bm, 'None' ones keeping
default auto-computed normals.
>>> bmesh.utils.custom_normals_set(bm, nors)
((0.0, 0.0, 1.0), (0.5773502588272095, -0.577350378036499,
-0.5773503184318542), (0.0, 0.0, 1.0), (-0.5773501396179199,
0.5773504972457886, -0.5773503184318542), (0.0, 0.0, 1.0),
(0.5773500204086304, -0.5773505568504333, 0.5773503184318542), (0.0,
0.0, 1.0), (-0.5773501992225647, 0.5773503184318542, 0.5773503184318542))
Testing and feedback is most welcome!
Cheers,
Bastien
More information about the Bf-committers
mailing list