From dffe702d782990b2b6fd36767254d35ab47f25eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 17 Oct 2019 11:18:46 +0200 Subject: Fix T69182: Auto-Smooth does not work on Alembic meshes without normals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The auto-smoothing flag can now be used by artists when the Alembic file does not contain custom loop normals. - Auto-smoothing disabled: mesh is flat-shaded. - Auto-smoothing enabled: works as usual; set angle to 180° to ensure a 100% smoothed mesh. --- source/blender/alembic/intern/abc_mesh.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/blender/alembic') diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc index 12c59964a8c..651f32e6ab0 100644 --- a/source/blender/alembic/intern/abc_mesh.cc +++ b/source/blender/alembic/intern/abc_mesh.cc @@ -885,7 +885,8 @@ static void process_normals(CDStreamConfig &config, const AbcMeshData &mesh_data if (!mesh_data.loop_normals) { BKE_mesh_calc_normals(config.mesh); - config.mesh->flag &= ~ME_AUTOSMOOTH; + /* Don't touch the ME_AUTOSMOOTH flag in this case. It can be used by artists to toggle between + * flat/smooth shaded when the Alembic mesh doesn't contain loop normals. */ return; } @@ -1018,7 +1019,10 @@ static void read_mesh_sample(const std::string &iobject_full_name, abc_mesh_data.face_counts = sample.getFaceCounts(); abc_mesh_data.face_indices = sample.getFaceIndices(); abc_mesh_data.positions = sample.getPositions(); - abc_mesh_data.poly_flag_smooth = false; + + /* The auto-smoothing flag can be used by artists when the Alembic file does not contain custom + * loop normals. Auto-smoothing only works when polys are marked as smooth. */ + abc_mesh_data.poly_flag_smooth = (config.mesh->flag & ME_AUTOSMOOTH); read_normals_params(abc_mesh_data, schema.getNormalsParam(), selector); -- cgit v1.2.3