[Bf-blender-cvs] [34722fa8a0d] master: Cleanup: Reduce indentation in mesh operator
Hans Goudey
noreply at git.blender.org
Fri Dec 9 16:25:05 CET 2022
Commit: 34722fa8a0d5a6ab18a74711c9b30482a2ae72b4
Author: Hans Goudey
Date: Thu Dec 8 15:22:21 2022 -0600
Branches: master
https://developer.blender.org/rB34722fa8a0d5a6ab18a74711c9b30482a2ae72b4
Cleanup: Reduce indentation in mesh operator
Also use local variable for BMesh.
===================================================================
M source/blender/editors/mesh/mesh_data.cc
===================================================================
diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc
index 58b700b3a2e..1ecdc52ef0a 100644
--- a/source/blender/editors/mesh/mesh_data.cc
+++ b/source/blender/editors/mesh/mesh_data.cc
@@ -781,49 +781,48 @@ void MESH_OT_customdata_skin_clear(wmOperatorType *ot)
static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator * /*op*/)
{
Mesh *me = ED_mesh_context(C);
+ if (BKE_mesh_has_custom_loop_normals(me)) {
+ return OPERATOR_CANCELLED;
+ }
- if (!BKE_mesh_has_custom_loop_normals(me)) {
- CustomData *data = GET_CD_DATA(me, ldata);
-
- if (me->edit_mesh) {
- /* Tag edges as sharp according to smooth threshold if needed,
- * to preserve auto-smooth shading. */
- if (me->flag & ME_AUTOSMOOTH) {
- BM_edges_sharp_from_angle_set(me->edit_mesh->bm, me->smoothresh);
- }
-
- BM_data_layer_add(me->edit_mesh->bm, data, CD_CUSTOMLOOPNORMAL);
+ if (me->edit_mesh) {
+ BMesh &bm = *me->edit_mesh->bm;
+ /* Tag edges as sharp according to smooth threshold if needed,
+ * to preserve auto-smooth shading. */
+ if (me->flag & ME_AUTOSMOOTH) {
+ BM_edges_sharp_from_angle_set(&bm, me->smoothresh);
}
- else {
- /* Tag edges as sharp according to smooth threshold if needed,
- * to preserve auto-smooth shading. */
- if (me->flag & ME_AUTOSMOOTH) {
- const Span<MVert> verts = me->verts();
- MutableSpan<MEdge> edges = me->edges_for_write();
- const Span<MPoly> polys = me->polys();
- const Span<MLoop> loops = me->loops();
-
- BKE_edges_sharp_from_angle_set(verts.data(),
- verts.size(),
- edges.data(),
- edges.size(),
- loops.data(),
- loops.size(),
- polys.data(),
- BKE_mesh_poly_normals_ensure(me),
- polys.size(),
- me->smoothresh);
- }
- CustomData_add_layer(data, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, me->totloop);
+ BM_data_layer_add(&bm, &bm.ldata, CD_CUSTOMLOOPNORMAL);
+ }
+ else {
+ /* Tag edges as sharp according to smooth threshold if needed,
+ * to preserve auto-smooth shading. */
+ if (me->flag & ME_AUTOSMOOTH) {
+ const Span<MVert> verts = me->verts();
+ MutableSpan<MEdge> edges = me->edges_for_write();
+ const Span<MPoly> polys = me->polys();
+ const Span<MLoop> loops = me->loops();
+
+ BKE_edges_sharp_from_angle_set(verts.data(),
+ verts.size(),
+ edges.data(),
+ edges.size(),
+ loops.data(),
+ loops.size(),
+ polys.data(),
+ BKE_mesh_poly_normals_ensure(me),
+ polys.size(),
+ me->smoothresh);
}
- DEG_id_tag_update(&me->id, 0);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
-
- return OPERATOR_FINISHED;
+ CustomData_add_layer(&me->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, me->totloop);
}
- return OPERATOR_CANCELLED;
+
+ DEG_id_tag_update(&me->id, 0);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
+
+ return OPERATOR_FINISHED;
}
void MESH_OT_customdata_custom_splitnormals_add(wmOperatorType *ot)
More information about the Bf-blender-cvs
mailing list