Page MenuHome

Add mesh utilities to flip all/some polygons.
ClosedPublic

Authored by Bastien Montagne (mont29) on Feb 19 2016, 11:57 PM.

Details

Summary

This allows to easily invert all or some normals of a mesh, outside of BMesh/editing context.
It is useful in several cases, this pacth use it to invert back normals after transforming
a mesh with a negative matrix, and to fix poly normals after setting custom loop normals
opposite to it in normal modifier.

Notes:

  • Obviously not for 2.77, this patch is not safe enough!
  • This invalidates tessellation, calling code has to take care of this as needed.
  • Not sure whether we can optimize CustomData_swap?
  • Remaed current CustomData_swap to CustomData_swap_corners, since that one does swapping 'internal' to one item, and not swapping between items of the cdata arrays...

Fix T47490: STL: faces not normalized correctly when exporting multiple meshes
Fix T42526: Generated normals can be opposed to face one, needs winding flipping in this case

Diff Detail

Repository
rB Blender

Event Timeline

Add flipping utils to mesh and polygon RNA struct.

Campbell Barton (campbellbarton) requested changes to this revision.Feb 21 2016, 3:34 PM
Campbell Barton (campbellbarton) edited edge metadata.

While good to have, flipping normals shouldn't be automatic.

Importers can exporters can check for this and handle it if they need.

source/blender/blenkernel/intern/mesh.c
1963–1967 ↗(On Diff #6149)

This is going to happen when you do: ob.data = mesh, and assigning this twice will flip the normals.

In fact think transforming the normals above is incorrect too.

This revision now requires changes to proceed.Feb 21 2016, 3:34 PM
Bastien Montagne (mont29) edited edge metadata.

Some minor adjustements, remove auto-flipping from BKE_mesh_transform.

Bastien Montagne (mont29) marked an inline comment as done.Feb 21 2016, 5:52 PM
Bastien Montagne (mont29) added inline comments.
source/blender/blenkernel/intern/mesh.c
1963–1967 ↗(On Diff #6149)

Removed that from patch, indeed not convinced we should do that implicitly.

Not sure I understand the comment about ob.data = mesh though, afaik it does not call BKE_mesh_transform at all?

Campbell Barton (campbellbarton) edited edge metadata.
Campbell Barton (campbellbarton) added inline comments.
source/blender/blenkernel/intern/mesh.c
1963–1967 ↗(On Diff #6149)

Though I think we discussed this? BKE_mesh_assign_object is called when assigning object's data.

This revision is now accepted and ready to land.Feb 23 2016, 8:06 PM
This revision was automatically updated to reflect the committed changes.
Bastien Montagne (mont29) marked an inline comment as done.