Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-05-05 13:36:15 +0300
committerCampbell Barton <campbell@blender.org>2022-05-05 13:36:15 +0300
commit78fc5ea1c398f70d22cda72be33c105146c0d542 (patch)
tree84482209d4a5bf317a6dae196ade6e0c67df9d57 /source/blender/editors/object/object_modifier.cc
parent598917f49b3564c1ca1b28907547332d69a85328 (diff)
Workaround T81065: Merge UV's when applying modifiers
Support merging UV's that share the same vertex and are very close when applying modifiers. This is needed to prevent UV's becoming "detached" which can happen when applying the subdivision surface modifier. This regression was caused by [0] which removed selection threshold for nearby coordinates. While restoring the UV selection threshold could be done - some selection operations that walk around connected UV fans wouldn't behave in a deterministic way (such as select shortest path). There are also other cases where UV's may be compared without a threshold such as tangent calculation and exporters which have their own logic to handling UV's. Also resolves T86896, T89903. [0]: b88dd3b8e7b9c02ae08d4679bb427963c5d21250 Reviewed By: sergey Ref D14841
Diffstat (limited to 'source/blender/editors/object/object_modifier.cc')
-rw-r--r--source/blender/editors/object/object_modifier.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc
index f90a31a7cbe..3328fe65f2e 100644
--- a/source/blender/editors/object/object_modifier.cc
+++ b/source/blender/editors/object/object_modifier.cc
@@ -1434,8 +1434,10 @@ static int modifier_apply_exec_ex(bContext *C, wmOperator *op, int apply_as, boo
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
+ const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)md->type);
const bool do_report = RNA_boolean_get(op->ptr, "report");
const bool do_single_user = RNA_boolean_get(op->ptr, "single_user");
+ const bool do_merge_customdata = RNA_boolean_get(op->ptr, "merge_customdata");
if (md == nullptr) {
return OPERATOR_CANCELLED;
@@ -1460,6 +1462,11 @@ static int modifier_apply_exec_ex(bContext *C, wmOperator *op, int apply_as, boo
return OPERATOR_CANCELLED;
}
+ if (do_merge_customdata &&
+ (mti->type & (eModifierTypeType_Constructive | eModifierTypeType_Nonconstructive))) {
+ BKE_mesh_merge_customdata_for_apply_modifier((Mesh *)ob->data);
+ }
+
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1518,6 +1525,12 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot)
edit_modifier_properties(ot);
edit_modifier_report_property(ot);
+ RNA_def_boolean(
+ ot->srna,
+ "merge_customdata",
+ true,
+ "Merge UV's",
+ "Merge UV coordinates that share a vertex to account for imprecision in some modifiers");
PropertyRNA *prop = RNA_def_boolean(ot->srna,
"single_user",
false,
@@ -1599,11 +1612,18 @@ static int modifier_convert_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
+ const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)md->type);
+ const bool do_merge_customdata = RNA_boolean_get(op->ptr, "merge_customdata");
if (!md || !ED_object_modifier_convert(op->reports, bmain, depsgraph, view_layer, ob, md)) {
return OPERATOR_CANCELLED;
}
+ if (do_merge_customdata &&
+ (mti->type & (eModifierTypeType_Constructive | eModifierTypeType_Nonconstructive))) {
+ BKE_mesh_merge_customdata_for_apply_modifier((Mesh *)ob->data);
+ }
+
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1631,6 +1651,13 @@ void OBJECT_OT_modifier_convert(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
+
+ RNA_def_boolean(
+ ot->srna,
+ "merge_customdata",
+ true,
+ "Merge UV's",
+ "Merge UV coordinates that share a vertex to account for imprecision in some modifiers");
}
/** \} */