diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_image_proj.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 140 |
1 files changed, 24 insertions, 116 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 469498f927a..cacb75b2668 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -283,7 +283,6 @@ typedef struct ProjPaintState { bool do_backfacecull; /* ignore faces with normals pointing away, skips a lot of raycasts if your normals are correctly flipped */ bool do_mask_normal; /* mask out pixels based on their normals */ bool do_mask_cavity; /* mask out pixels based on cavity */ - bool do_new_shading_nodes; /* cache BKE_scene_use_new_shading_nodes value */ float normal_angle; /* what angle to mask at */ float normal_angle__cos; /* cos(normal_angle), faster to compare */ float normal_angle_inner; @@ -5102,7 +5101,6 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int else { ps->do_backfacecull = ps->do_occlude = ps->do_mask_normal = 0; } - ps->do_new_shading_nodes = BKE_scene_use_new_shading_nodes(scene); /* only cache the value */ if (ps->tool == PAINT_TOOL_CLONE) ps->do_layer_clone = (settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) ? 1 : 0; @@ -5438,7 +5436,6 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); ToolSettings *settings = scene->toolsettings; View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); @@ -5455,7 +5452,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) if (h > maxsize) h = maxsize; ibuf = ED_view3d_draw_offscreen_imbuf( - depsgraph, scene, view_layer, v3d->drawtype, + depsgraph, scene, v3d->drawtype, v3d, CTX_wm_region(C), w, h, IB_rect, V3D_OFSDRAW_NONE, R_ALPHAPREMUL, 0, NULL, NULL, err_out); @@ -5626,20 +5623,11 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m /* Add layer operator */ static const EnumPropertyItem layer_type_items[] = { - {MAP_COL, "DIFFUSE_COLOR", 0, "Diffuse Color", ""}, - {MAP_REF, "DIFFUSE_INTENSITY", 0, "Diffuse Intensity", ""}, - {MAP_ALPHA, "ALPHA", 0, "Alpha", ""}, - {MAP_TRANSLU, "TRANSLUCENCY", 0, "Translucency", ""}, - {MAP_COLSPEC, "SPECULAR_COLOR", 0, "Specular Color", ""}, - {MAP_SPEC, "SPECULAR_INTENSITY", 0, "Specular Intensity", ""}, - {MAP_HAR, "SPECULAR_HARDNESS", 0, "Specular Hardness", ""}, - {MAP_AMB, "AMBIENT", 0, "Ambient", ""}, - {MAP_EMIT, "EMIT", 0, "Emit", ""}, - {MAP_COLMIR, "MIRROR_COLOR", 0, "Mirror Color", ""}, - {MAP_RAYMIRR, "RAYMIRROR", 0, "Ray Mirror", ""}, - {MAP_NORM, "NORMAL", 0, "Normal", ""}, - {MAP_WARP, "WARP", 0, "Warp", ""}, - {MAP_DISPLACE, "DISPLACE", 0, "Displace", ""}, + {0, "BASE_COLOR", 0, "Base Color", ""}, + {1, "EMISSION", 0, "Emission", ""}, + {2, "NORMAL", 0, "Normal", ""}, + {3, "BUMP", 0, "Bump", ""}, + {4, "DISPLACEMENT", 0, "Displacement", ""}, {0, NULL, 0, NULL, NULL} }; @@ -5674,7 +5662,6 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); Material *ma; - bool is_bi = BKE_scene_uses_blender_internal(scene); Image *ima = NULL; if (!ob) @@ -5683,55 +5670,29 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) ma = give_current_material(ob, ob->actcol); if (ma) { + /* TODO: use type to link to proper socket. */ Main *bmain = CTX_data_main(C); - if (!is_bi && BKE_scene_use_new_shading_nodes(scene)) { - bNode *imanode; - bNodeTree *ntree = ma->nodetree; - - if (!ntree) { - ED_node_shader_default(C, &ma->id); - ntree = ma->nodetree; - } - - ma->use_nodes = true; - - /* try to add an image node */ - imanode = nodeAddStaticNode(C, ntree, SH_NODE_TEX_IMAGE); - - ima = proj_paint_image_create(op, bmain); - imanode->id = &ima->id; - - nodeSetActive(ntree, imanode); - - ntreeUpdateTree(CTX_data_main(C), ntree); - } - else { - MTex *mtex = BKE_texture_mtex_add_id(&ma->id, -1); - - /* successful creation of mtex layer, now create set */ - if (mtex) { - int type = MAP_COL; - char imagename_buff[MAX_ID_NAME - 2]; - const char *imagename = DATA_("Diffuse Color"); - - if (op) { - type = RNA_enum_get(op->ptr, "type"); - RNA_string_get(op->ptr, "name", imagename_buff); - imagename = imagename_buff; - } - - mtex->tex = BKE_texture_add(bmain, imagename); - mtex->mapto = type; - - if (mtex->tex) { - ima = mtex->tex->ima = proj_paint_image_create(op, bmain); - } + bNode *imanode; + bNodeTree *ntree = ma->nodetree; - WM_event_add_notifier(C, NC_TEXTURE | NA_ADDED, mtex->tex); - } + if (!ntree) { + ED_node_shader_default(C, &ma->id); + ntree = ma->nodetree; } + ma->use_nodes = true; + + /* try to add an image node */ + imanode = nodeAddStaticNode(C, ntree, SH_NODE_TEX_IMAGE); + + ima = proj_paint_image_create(op, bmain); + imanode->id = &ima->id; + + nodeSetActive(ntree, imanode); + + ntreeUpdateTree(CTX_data_main(C), ntree); + if (ima) { BKE_texpaint_slot_refresh_cache(scene, ma); BKE_image_signal(ima, NULL, IMA_SIGNAL_USER_NEW_IMAGE); @@ -5822,59 +5783,6 @@ void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot) RNA_def_boolean(ot->srna, "float", 0, "32 bit Float", "Create image with 32 bit floating point bit depth"); } -static int texture_paint_delete_texture_paint_slot_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Object *ob = CTX_data_active_object(C); - Scene *scene = CTX_data_scene(C); - Material *ma; - bool is_bi = BKE_scene_uses_blender_internal(scene); - TexPaintSlot *slot; - - /* not supported for node-based engines */ - if (!ob || !is_bi) - return OPERATOR_CANCELLED; - - ma = give_current_material(ob, ob->actcol); - - if (!ma->texpaintslot || ma->use_nodes) - return OPERATOR_CANCELLED; - - slot = ma->texpaintslot + ma->paint_active_slot; - - if (ma->mtex[slot->index]->tex) { - id_us_min(&ma->mtex[slot->index]->tex->id); - - if (ma->mtex[slot->index]->tex->ima) { - id_us_min(&ma->mtex[slot->index]->tex->ima->id); - } - } - MEM_freeN(ma->mtex[slot->index]); - ma->mtex[slot->index] = NULL; - - BKE_texpaint_slot_refresh_cache(scene, ma); - DEG_id_tag_update(&ma->id, 0); - WM_event_add_notifier(C, NC_MATERIAL, ma); - /* we need a notifier for data change since we change the displayed modifier uvs */ - WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); - return OPERATOR_FINISHED; -} - - -void PAINT_OT_delete_texture_paint_slot(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Delete Texture Paint Slot"; - ot->description = "Delete selected texture paint slot"; - ot->idname = "PAINT_OT_delete_texture_paint_slot"; - - /* api callbacks */ - ot->exec = texture_paint_delete_texture_paint_slot_exec; - ot->poll = ED_operator_region_view3d_active; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op)) { /* no checks here, poll function does them for us */ |