[Bf-committers] New BMesh API to set normals

Howard Trickey howard.trickey at gmail.com
Tue Jun 7 22:31:23 CEST 2016


Wonderful! Thanks for the very quick work, Bastien.

On Tue, Jun 7, 2016, 4:17 PM Bastien Montagne <montagne29 at wanadoo.fr> wrote:

> 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
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> https://lists.blender.org/mailman/listinfo/bf-committers
>


More information about the Bf-committers mailing list