Sculpt: Fix T103341: Move sculpt overlay flags to View3DOverlay.flag
"Show mask" and "Show face sets" were being stored in `Sculpt`, yet their opacities are in `View3dOverlay`. Now `View3DOverlay` has the flags too.
This commit is contained in:
parent
15c433d7d5
commit
f803a0a95b
Notes:
blender-bot
2023-02-14 07:25:51 +01:00
Referenced by issue #103341, Mask & Face Set overlays are not per viewport
|
@ -6741,15 +6741,15 @@ class VIEW3D_PT_overlay_sculpt(Panel):
|
|||
overlay = view.overlay
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(sculpt, "show_mask", text="")
|
||||
row.prop(overlay, "sculpt_show_mask", text="")
|
||||
sub = row.row()
|
||||
sub.active = sculpt.show_mask
|
||||
sub.active = overlay.sculpt_show_mask
|
||||
sub.prop(overlay, "sculpt_mode_mask_opacity", text="Mask")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(sculpt, "show_face_sets", text="")
|
||||
row.prop(overlay, "sculpt_show_face_sets", text="")
|
||||
sub = row.row()
|
||||
sub.active = sculpt.show_face_sets
|
||||
sub.active = overlay.sculpt_show_face_sets
|
||||
row.prop(overlay, "sculpt_mode_face_sets_opacity", text="Face Sets")
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ extern "C" {
|
|||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 5
|
||||
#define BLENDER_FILE_SUBVERSION 6
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and show a warning if the file
|
||||
|
|
|
@ -632,8 +632,6 @@ typedef struct SculptSession {
|
|||
|
||||
/* PBVH acceleration structure */
|
||||
struct PBVH *pbvh;
|
||||
bool show_mask;
|
||||
bool show_face_sets;
|
||||
|
||||
/* Painting on deformed mesh */
|
||||
bool deform_modifiers_active; /* Object is deformed with some modifiers. */
|
||||
|
|
|
@ -1675,8 +1675,6 @@ static void sculpt_update_object(
|
|||
ss->depsgraph = depsgraph;
|
||||
|
||||
ss->deform_modifiers_active = sculpt_modifiers_active(scene, sd, ob);
|
||||
ss->show_mask = (sd->flags & SCULPT_HIDE_MASK) == 0;
|
||||
ss->show_face_sets = (sd->flags & SCULPT_HIDE_FACE_SETS) == 0;
|
||||
|
||||
ss->building_vp_handle = false;
|
||||
|
||||
|
@ -1775,9 +1773,6 @@ static void sculpt_update_object(
|
|||
}
|
||||
}
|
||||
|
||||
pbvh_show_mask_set(ss->pbvh, ss->show_mask);
|
||||
pbvh_show_face_sets_set(ss->pbvh, ss->show_face_sets);
|
||||
|
||||
if (ss->deform_modifiers_active) {
|
||||
/* Painting doesn't need crazyspace, use already evaluated mesh coordinates if possible. */
|
||||
bool used_me_eval = false;
|
||||
|
@ -2173,8 +2168,6 @@ static PBVH *build_pbvh_for_dynamic_topology(Object *ob)
|
|||
ob->sculpt->bm_log,
|
||||
ob->sculpt->attrs.dyntopo_node_id_vertex->bmesh_cd_offset,
|
||||
ob->sculpt->attrs.dyntopo_node_id_face->bmesh_cd_offset);
|
||||
pbvh_show_mask_set(pbvh, ob->sculpt->show_mask);
|
||||
pbvh_show_face_sets_set(pbvh, false);
|
||||
return pbvh;
|
||||
}
|
||||
|
||||
|
@ -2207,9 +2200,6 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool
|
|||
looptri,
|
||||
looptris_num);
|
||||
|
||||
pbvh_show_mask_set(pbvh, ob->sculpt->show_mask);
|
||||
pbvh_show_face_sets_set(pbvh, ob->sculpt->show_face_sets);
|
||||
|
||||
const bool is_deformed = check_sculpt_object_deformed(ob, true);
|
||||
if (is_deformed && me_eval_deform != nullptr) {
|
||||
int totvert;
|
||||
|
@ -2240,8 +2230,6 @@ static PBVH *build_pbvh_from_ccg(Object *ob, SubdivCCG *subdiv_ccg, bool respect
|
|||
subdiv_ccg->grid_hidden,
|
||||
base_mesh,
|
||||
subdiv_ccg);
|
||||
pbvh_show_mask_set(pbvh, ob->sculpt->show_mask);
|
||||
pbvh_show_face_sets_set(pbvh, ob->sculpt->show_face_sets);
|
||||
return pbvh;
|
||||
}
|
||||
|
||||
|
|
|
@ -3419,16 +3419,6 @@ bool pbvh_has_face_sets(PBVH *pbvh)
|
|||
return false;
|
||||
}
|
||||
|
||||
void pbvh_show_mask_set(PBVH *pbvh, bool show_mask)
|
||||
{
|
||||
pbvh->show_mask = show_mask;
|
||||
}
|
||||
|
||||
void pbvh_show_face_sets_set(PBVH *pbvh, bool show_face_sets)
|
||||
{
|
||||
pbvh->show_face_sets = show_face_sets;
|
||||
}
|
||||
|
||||
void BKE_pbvh_set_frustum_planes(PBVH *pbvh, PBVHFrustumPlanes *planes)
|
||||
{
|
||||
pbvh->num_planes = planes->num_planes;
|
||||
|
|
|
@ -191,8 +191,6 @@ struct PBVH {
|
|||
|
||||
/* flag are verts/faces deformed */
|
||||
bool deformed;
|
||||
bool show_mask;
|
||||
bool show_face_sets;
|
||||
bool respect_hide;
|
||||
|
||||
/* Dynamic topology */
|
||||
|
|
|
@ -3822,6 +3822,19 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 305, 6)) {
|
||||
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
if (sl->spacetype == SPACE_VIEW3D) {
|
||||
View3D *v3d = (View3D *)sl;
|
||||
v3d->overlay.flag |= (int)(V3D_OVERLAY_SCULPT_SHOW_MASK |
|
||||
V3D_OVERLAY_SCULPT_SHOW_FACE_SETS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
|
|
|
@ -92,10 +92,10 @@ static void OVERLAY_engine_init(void *vedata)
|
|||
}
|
||||
|
||||
if (ts->sculpt) {
|
||||
if (ts->sculpt->flags & SCULPT_HIDE_FACE_SETS) {
|
||||
if (!(v3d->overlay.flag & (int)V3D_OVERLAY_SCULPT_SHOW_FACE_SETS)) {
|
||||
pd->overlay.sculpt_mode_face_sets_opacity = 0.0f;
|
||||
}
|
||||
if (ts->sculpt->flags & SCULPT_HIDE_MASK) {
|
||||
if (!(v3d->overlay.flag & (int)V3D_OVERLAY_SCULPT_SHOW_MASK)) {
|
||||
pd->overlay.sculpt_mode_mask_opacity = 0.0f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2470,13 +2470,8 @@ typedef enum eSculptFlags {
|
|||
/** If set, dynamic-topology detail size will be constant in object space. */
|
||||
SCULPT_DYNTOPO_DETAIL_CONSTANT = (1 << 13),
|
||||
SCULPT_DYNTOPO_DETAIL_BRUSH = (1 << 14),
|
||||
/* unused = (1 << 15), */
|
||||
SCULPT_DYNTOPO_DETAIL_MANUAL = (1 << 16),
|
||||
|
||||
/** Don't display mask in viewport, but still use it for strokes. */
|
||||
SCULPT_HIDE_MASK = (1 << 15),
|
||||
|
||||
/** Don't display face sets in viewport. */
|
||||
SCULPT_HIDE_FACE_SETS = (1 << 17),
|
||||
} eSculptFlags;
|
||||
|
||||
/** #Sculpt.transform_mode */
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#define _DNA_DEFAULT_View3DOverlay \
|
||||
{ \
|
||||
.flag = V3D_OVERLAY_VIEWER_ATTRIBUTE, \
|
||||
.flag = V3D_OVERLAY_VIEWER_ATTRIBUTE | V3D_OVERLAY_SCULPT_SHOW_MASK | V3D_OVERLAY_SCULPT_SHOW_FACE_SETS, \
|
||||
.wireframe_threshold = 1.0f, \
|
||||
.wireframe_opacity = 1.0f, \
|
||||
.viewer_attribute_opacity = 1.0f, \
|
||||
|
|
|
@ -546,6 +546,8 @@ enum {
|
|||
V3D_OVERLAY_STATS = (1 << 11),
|
||||
V3D_OVERLAY_FADE_INACTIVE = (1 << 12),
|
||||
V3D_OVERLAY_VIEWER_ATTRIBUTE = (1 << 13),
|
||||
V3D_OVERLAY_SCULPT_SHOW_MASK = (1 << 14),
|
||||
V3D_OVERLAY_SCULPT_SHOW_FACE_SETS = (1 << 15),
|
||||
};
|
||||
|
||||
/** #View3DOverlay.edit_flag */
|
||||
|
|
|
@ -393,24 +393,6 @@ static void rna_Sculpt_update(bContext *C, PointerRNA *UNUSED(ptr))
|
|||
}
|
||||
}
|
||||
|
||||
static void rna_Sculpt_ShowMask_update(bContext *C, PointerRNA *UNUSED(ptr))
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
BKE_view_layer_synced_ensure(scene, view_layer);
|
||||
Object *object = BKE_view_layer_active_object_get(view_layer);
|
||||
if (object == NULL || object->sculpt == NULL) {
|
||||
return;
|
||||
}
|
||||
Sculpt *sd = scene->toolsettings->sculpt;
|
||||
object->sculpt->show_mask = ((sd->flags & SCULPT_HIDE_MASK) == 0);
|
||||
if (object->sculpt->pbvh != NULL) {
|
||||
pbvh_show_mask_set(object->sculpt->pbvh, object->sculpt->show_mask);
|
||||
}
|
||||
DEG_id_tag_update(&object->id, ID_RECALC_GEOMETRY);
|
||||
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, object);
|
||||
}
|
||||
|
||||
static char *rna_Sculpt_path(const PointerRNA *UNUSED(ptr))
|
||||
{
|
||||
return BLI_strdup("tool_settings.sculpt");
|
||||
|
@ -848,18 +830,6 @@ static void rna_def_sculpt(BlenderRNA *brna)
|
|||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update");
|
||||
|
||||
prop = RNA_def_property(srna, "show_mask", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "flags", SCULPT_HIDE_MASK);
|
||||
RNA_def_property_ui_text(prop, "Show Mask", "Show mask as overlay on object");
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowMask_update");
|
||||
|
||||
prop = RNA_def_property(srna, "show_face_sets", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "flags", SCULPT_HIDE_FACE_SETS);
|
||||
RNA_def_property_ui_text(prop, "Show Face Sets", "Show Face Sets as overlay on object");
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowMask_update");
|
||||
|
||||
prop = RNA_def_property(srna, "detail_size", PROP_FLOAT, PROP_PIXEL);
|
||||
RNA_def_property_ui_range(prop, 0.5, 40.0, 0.1, 2);
|
||||
RNA_def_property_ui_scale_type(prop, PROP_SCALE_CUBIC);
|
||||
|
|
|
@ -4720,6 +4720,16 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
|
|||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "sculpt_show_mask", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_SCULPT_SHOW_MASK);
|
||||
RNA_def_property_ui_text(prop, "Sculpt Show Mask", "");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "sculpt_show_face_sets", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_SCULPT_SHOW_FACE_SETS);
|
||||
RNA_def_property_ui_text(prop, "Sculpt Show Face Sets", "");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
/* grease pencil paper settings */
|
||||
prop = RNA_def_property(srna, "show_annotation", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_ANNOTATION);
|
||||
|
|
Loading…
Reference in New Issue