Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/render/render_shading.c
| Show First 20 Lines • Show All 460 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /********************** new material operator *********************/ | /********************** new material operator *********************/ | ||||
| static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) | static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data; | Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data; | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Object *ob = CTX_data_active_object(C); | |||||
| PointerRNA ptr, idptr; | PointerRNA ptr, idptr; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| /* add or copy material */ | /* add or copy material */ | ||||
| if (ma) { | if (ma) { | ||||
| ma = BKE_material_copy(bmain, ma); | ma = BKE_material_copy(bmain, ma); | ||||
| } | } | ||||
| else { | else { | ||||
| if ((!ob) || (ob->type != OB_GPENCIL)) { | |||||
| ma = BKE_material_add(bmain, DATA_("Material")); | ma = BKE_material_add(bmain, DATA_("Material")); | ||||
| } | |||||
| else { | |||||
| ma = BKE_material_add_gpencil(bmain, DATA_("Material")); | |||||
| } | |||||
| ED_node_shader_default(C, &ma->id); | ED_node_shader_default(C, &ma->id); | ||||
| ma->use_nodes = true; | ma->use_nodes = true; | ||||
| } | } | ||||
| /* 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); | ||||
| if (prop) { | if (prop) { | ||||
| ▲ Show 20 Lines • Show All 1,212 Lines • Show Last 20 Lines | |||||