WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob);
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, ob);
if (changed) {
changed_multi = true;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
}
}
if (changed) {
changed_multi = true;
- DEG_id_tag_update(ob->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
}
}
if (ob_iter->totcol == ob->totcol) {
ob_iter->actcol = ob->actcol;
- DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_iter->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_iter);
}
}
MEM_freeN(slot_remap);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob);
{
Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
Main *bmain = CTX_data_main(C);
- Object *ob = CTX_data_active_object(C);
PointerRNA ptr, idptr;
PropertyRNA *prop;
+ /* hook into UI */
+ UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
+
+ Object *ob = (prop && RNA_struct_is_a(ptr.type, &RNA_Object)) ? ptr.data : NULL;
+
/* add or copy material */
if (ma) {
ma = BKE_material_copy(bmain, ma);
}
else {
- if ((!ob) || (ob->type != OB_GPENCIL)) {
- ma = BKE_material_add(bmain, DATA_("Material"));
+ const char *name = DATA_("Material");
+ if (!(ob != NULL && ob->type == OB_GPENCIL)) {
+ ma = BKE_material_add(bmain, name);
}
else {
- ma = BKE_material_add_gpencil(bmain, DATA_("Material"));
+ ma = BKE_material_add_gpencil(bmain, name);
}
ED_node_shader_default(C, &ma->id);
ma->use_nodes = true;
}
- /* hook into UI */
- UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
if (prop) {
+ if (ob != NULL) {
+ /* Add slot follows user-preferences for creating new slots,
+ * RNA pointer assignment doesn't, see: T60014. */
+ if (give_current_material_p(ob, ob->actcol) == NULL) {
+ BKE_object_material_slot_add(bmain, ob);
+ }
+ }
+
/* when creating new ID blocks, use is already 1, but RNA
* pointer use also increases user, so this compensates it */
id_us_min(&ma->id);
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
}
+static bool view_layer_remove_poll(bContext *C)
+{
+ Scene *scene = CTX_data_scene(C);
+ return (scene->view_layers.first != scene->view_layers.last);
+}
+
static int view_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
/* api callbacks */
ot->exec = view_layer_remove_exec;
+ ot->poll = view_layer_remove_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
EEVEE_lightcache_info_update(&scene->eevee);
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
ot->exec = copy_material_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL; /* no undo needed since no changes are made to the material */
+ /* no undo needed since no changes are made to the material */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL;
}
static int paste_material_exec(bContext *C, wmOperator *UNUSED(op))
paste_matcopybuf(CTX_data_main(C), ma);
+ DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma);
return OPERATOR_FINISHED;
ot->poll = copy_mtex_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL; /* no undo needed since no changes are made to the mtex */
+ /* no undo needed since no changes are made to the mtex */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL;
}
static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))