[Bf-blender-cvs] [6f523ffacbc] temp_bmesh_multires: Sculpt dyntopo: Don't allow dyntopo when multires modfier exists
Joseph Eagar
noreply at git.blender.org
Sun Aug 22 00:20:12 CEST 2021
Commit: 6f523ffacbc33254164f05d11bdea754d6a41544
Author: Joseph Eagar
Date: Sat Aug 21 15:19:15 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB6f523ffacbc33254164f05d11bdea754d6a41544
Sculpt dyntopo: Don't allow dyntopo when multires modfier exists
Note that thoeretically we could support multires in dyntopo,
but numerical instability would probably make the grid data
explode.
===================================================================
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
===================================================================
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index e0c189a1bac..95a7b61e87d 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -9662,6 +9662,8 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
paint_cursor_start(paint, SCULPT_mode_poll_view3d);
+ bool has_multires = false;
+
/* Check dynamic-topology flag; re-enter dynamic-topology mode when changing modes,
* As long as no data was added that is not supported. */
if (me->flag & ME_SCULPT_DYNAMIC_TOPOLOGY) {
@@ -9670,21 +9672,16 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
const char *message_unsupported = NULL;
if (mmd != NULL) {
message_unsupported = TIP_("multi-res modifier");
+ has_multires = true;
}
else {
enum eDynTopoWarnFlag flag = SCULPT_dynamic_topology_check(scene, ob);
if (flag == 0) {
/* pass */
}
- else if (flag & DYNTOPO_WARN_VDATA) {
- message_unsupported = TIP_("vertex data");
- }
else if (flag & DYNTOPO_WARN_EDATA) {
message_unsupported = TIP_("edge data");
}
- else if (flag & DYNTOPO_WARN_LDATA) {
- message_unsupported = TIP_("face data");
- }
else if (flag & DYNTOPO_WARN_MODIFIER) {
message_unsupported = TIP_("constructive modifier");
}
@@ -9693,7 +9690,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
}
}
- if ((message_unsupported == NULL) || force_dyntopo) {
+ if (!has_multires && ((message_unsupported == NULL) || force_dyntopo)) {
/* Needed because we may be entering this mode before the undo system loads. */
wmWindowManager *wm = bmain->wm.first;
bool has_undo = wm->undo_stack != NULL;
diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
index 6147469062d..b913121ae09 100644
--- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
@@ -1009,14 +1009,36 @@ static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(o
return OPERATOR_FINISHED;
}
+
+static int dyntopo_error_popup(bContext *C, wmOperatorType *ot, enum eDynTopoWarnFlag flag)
+{
+ uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Error!"), ICON_ERROR);
+ uiLayout *layout = UI_popup_menu_layout(pup);
+
+
+ if (flag & DYNTOPO_ERROR_MULTIRES) {
+ const char *msg_error = TIP_("Multires modifier detected; cannot enable dyntopo.");
+ const char *msg = TIP_(
+ "Dyntopo and multires cannot be mixed.");
+
+ uiItemL(layout, msg_error, ICON_INFO);
+ uiItemL(layout, msg, ICON_NONE);
+ uiItemS(layout);
+ }
+
+ UI_popup_menu_end(C, pup);
+
+ return OPERATOR_INTERFACE;
+}
+
static int dyntopo_warning_popup(bContext *C, wmOperatorType *ot, enum eDynTopoWarnFlag flag)
{
uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Warning!"), ICON_ERROR);
uiLayout *layout = UI_popup_menu_layout(pup);
- if (flag & (DYNTOPO_WARN_VDATA | DYNTOPO_WARN_EDATA | DYNTOPO_WARN_LDATA)) {
- const char *msg_error = TIP_("Vertex Data Detected!");
- const char *msg = TIP_("Dyntopo will not preserve vertex colors, UVs, or other customdata");
+ if (flag & (DYNTOPO_WARN_EDATA)) {
+ const char *msg_error = TIP_("Edge Data Detected!");
+ const char *msg = TIP_("Dyntopo will not preserve custom edge attributes");
uiItemL(layout, msg_error, ICON_INFO);
uiItemL(layout, msg, ICON_NONE);
uiItemS(layout);
@@ -1076,6 +1098,10 @@ enum eDynTopoWarnFlag SCULPT_dynamic_topology_check(Scene *scene, Object *ob)
continue;
}
+ if (md->type == eModifierType_Multires) {
+ flag |= DYNTOPO_ERROR_MULTIRES;
+ }
+
if (mti->type == eModifierTypeType_Constructive) {
flag |= DYNTOPO_WARN_MODIFIER;
break;
@@ -1097,7 +1123,9 @@ static int sculpt_dynamic_topology_toggle_invoke(bContext *C,
Scene *scene = CTX_data_scene(C);
enum eDynTopoWarnFlag flag = SCULPT_dynamic_topology_check(scene, ob);
- if (flag) {
+ if (flag & DYNTOPO_ERROR_MULTIRES) {
+ return dyntopo_error_popup(C, op->type, flag);
+ } else if (flag) {
/* The mesh has customdata that will be lost, let the user confirm this is OK. */
return dyntopo_warning_popup(C, op->type, flag);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index de05509d57e..af87af8d009 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -360,10 +360,9 @@ void SCULPT_floodfill_free(SculptFloodFill *flood);
/* Dynamic topology */
enum eDynTopoWarnFlag {
- DYNTOPO_WARN_VDATA = (1 << 0),
DYNTOPO_WARN_EDATA = (1 << 1),
- DYNTOPO_WARN_LDATA = (1 << 2),
DYNTOPO_WARN_MODIFIER = (1 << 3),
+ DYNTOPO_ERROR_MULTIRES = (1 << 4)
};
struct Mesh;
More information about the Bf-blender-cvs
mailing list