Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/render/render_shading.c
| Show First 20 Lines • Show All 745 Lines • ▼ Show 20 Lines | static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| /* hook into UI */ | /* hook into UI */ | ||||
| UI_context_active_but_prop_get_templateID(C, &ptr, &prop); | UI_context_active_but_prop_get_templateID(C, &ptr, &prop); | ||||
| Object *ob = (prop && RNA_struct_is_a(ptr.type, &RNA_Object)) ? ptr.data : NULL; | Object *ob = (prop && RNA_struct_is_a(ptr.type, &RNA_Object)) ? ptr.data : NULL; | ||||
| /* add or copy material */ | /* add or copy material */ | ||||
| if (ma) { | if (ma) { | ||||
| Material *new_ma = (Material *)BKE_id_copy_ex( | /* Take into account user preferences for duplicating actions. */ | ||||
| bmain, &ma->id, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS); | int copy_flag = LIB_ID_COPY_DEFAULT; | ||||
| if ((U.dupflag & USER_DUP_ACT) != 0) { | |||||
| copy_flag |= LIB_ID_COPY_ACTIONS; | |||||
| } | |||||
| Material *new_ma = (Material *)BKE_id_copy_ex(bmain, &ma->id, NULL, copy_flag); | |||||
| ma = new_ma; | ma = new_ma; | ||||
| } | } | ||||
| else { | else { | ||||
| const char *name = DATA_("Material"); | const char *name = DATA_("Material"); | ||||
| if (!(ob != NULL && ob->type == OB_GPENCIL)) { | if (!(ob != NULL && ob->type == OB_GPENCIL)) { | ||||
| ma = BKE_material_add(bmain, name); | ma = BKE_material_add(bmain, name); | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data; | World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data; | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| PointerRNA ptr, idptr; | PointerRNA ptr, idptr; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| /* add or copy world */ | /* add or copy world */ | ||||
| if (wo) { | if (wo) { | ||||
| World *new_wo = (World *)BKE_id_copy_ex( | /* Take into account user preferences for duplicating actions. */ | ||||
| bmain, &wo->id, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS); | int copy_flag = LIB_ID_COPY_DEFAULT; | ||||
| if ((U.dupflag & USER_DUP_ACT) != 0) { | |||||
| copy_flag |= LIB_ID_COPY_ACTIONS; | |||||
| } | |||||
| World *new_wo = (World *)BKE_id_copy_ex(bmain, &wo->id, NULL, copy_flag); | |||||
| wo = new_wo; | wo = new_wo; | ||||
| } | } | ||||
| else { | else { | ||||
| wo = BKE_world_add(bmain, DATA_("World")); | wo = BKE_world_add(bmain, DATA_("World")); | ||||
| ED_node_shader_default(C, &wo->id); | ED_node_shader_default(C, &wo->id); | ||||
| wo->use_nodes = true; | wo->use_nodes = true; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,558 Lines • Show Last 20 Lines | |||||