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 | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index a284b17a0b4..8e1d47db61a 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -1053,7 +1053,7 @@ static bool check_seam( /* set up the other face */ *other_face = tri_index; - + /* we check if difference is 1 here, else we might have a case of edge 2-0 for a tri */ *orig_fidx = (i1_fidx < i2_fidx && (i2_fidx - i1_fidx == 1)) ? i1_fidx : i2_fidx; @@ -2115,7 +2115,7 @@ static void project_bucket_clip_face( int inside_face_flag = 0; int flip; bool collinear = false; - + float bucket_bounds_ss[4][2]; /* detect pathological case where face the three vertices are almost collinear in screen space. @@ -2126,12 +2126,12 @@ static void project_bucket_clip_face( { collinear = true; } - + /* get the UV space bounding box */ inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v1coSS); inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v2coSS) << 1; inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v3coSS) << 2; - + if (inside_bucket_flag == ISECT_ALL3) { /* is_flip_object is used here because we use the face winding */ flip = (((line_point_side_v2(v1coSS, v2coSS, v3coSS) > 0.0f) != is_flip_object) != @@ -2148,20 +2148,20 @@ static void project_bucket_clip_face( copy_v2_v2(bucket_bounds_uv[0], uv1co); copy_v2_v2(bucket_bounds_uv[1], uv2co); copy_v2_v2(bucket_bounds_uv[2], uv3co); - } - + } + *tot = 3; return; } /* handle pathological case here, no need for further intersections below since tringle area is almost zero */ if (collinear) { int flag; - + (*tot) = 0; if (cull) return; - + if (inside_bucket_flag & ISECT_1) { copy_v2_v2(bucket_bounds_uv[*tot], uv1co); (*tot)++; } flag = inside_bucket_flag & (ISECT_1 | ISECT_2); @@ -2169,9 +2169,9 @@ static void project_bucket_clip_face( if (line_rect_clip(bucket_bounds, v1coSS, v2coSS, uv1co, uv2co, bucket_bounds_uv[*tot], is_ortho)) (*tot)++; } - + if (inside_bucket_flag & ISECT_2) { copy_v2_v2(bucket_bounds_uv[*tot], uv2co); (*tot)++; } - + flag = inside_bucket_flag & (ISECT_2 | ISECT_3); if (flag && flag != (ISECT_2 | ISECT_3)) { if (line_rect_clip(bucket_bounds, v2coSS, v3coSS, uv2co, uv3co, bucket_bounds_uv[*tot], is_ortho)) @@ -2185,7 +2185,7 @@ static void project_bucket_clip_face( if (line_rect_clip(bucket_bounds, v3coSS, v1coSS, uv3co, uv1co, bucket_bounds_uv[*tot], is_ortho)) (*tot)++; } - + if ((*tot) < 3) { /* no intersections to speak of, but more probable is that all face is just outside the * rectangle and culled due to float precision issues. Since above tests have failed, @@ -2350,7 +2350,7 @@ static void project_bucket_clip_face( (*tot)--; } } - + /* its possible there is only a few left after remove doubles */ if ((*tot) < 3) { // printf("removed too many doubles B\n"); @@ -2991,7 +2991,7 @@ static bool project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int buck int fidx; project_bucket_bounds(ps, bucket_x, bucket_y, &bucket_bounds); - + /* Is one of the faces verts in the bucket bounds? */ fidx = 2; @@ -3500,7 +3500,7 @@ static void proj_paint_layer_clone_init( /* get active instead */ mloopuv_clone_base = CustomData_get_layer(&ps->dm->loopData, CD_MLOOPUV); } - + } memset(layer_clone, 0, sizeof(*layer_clone)); @@ -3526,7 +3526,7 @@ static bool project_paint_clone_face_skip( if (ps->do_material_slots) { if (lc->slot_clone != lc->slot_last_clone) { - if (!slot->uvname || + if (!slot->uvname || !(lc->mloopuv_clone_base = CustomData_get_layer_named( &ps->dm->loopData, CD_MLOOPUV, lc->slot_clone->uvname))) @@ -3720,7 +3720,7 @@ static void project_paint_prepare_all_faces( ps->dm_mloopuv[lt->poly] = mloopuv_base; continue; } - + tpage = slot->ima; } } @@ -4412,7 +4412,7 @@ static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, con if (ps->is_texbrush) mul_v3_v3(rgba, texrgb); - + mul_v3_fl(rgba, mask); rgba[3] = mask; @@ -4621,7 +4621,7 @@ static void *do_projectpaint_thread(void *ph_v) projPixel->newColor.ch, ps->blend); } } - + if (lock_alpha) { if (is_floatbuf) { /* slightly more involved case since floats are in premultiplied space we need @@ -4699,7 +4699,7 @@ static void *do_projectpaint_thread(void *ph_v) /* masking to keep brush contribution to a pixel limited. note we do not do * a simple max(mask, mask_accum), as this is very sensitive to spacing and * gives poor results for strokes crossing themselves. - * + * * Instead we use a formula that adds up but approaches brush_alpha slowly * and never exceeds it, which gives nice smooth results. */ float mask_accum = *projPixel->mask_accum; @@ -4932,14 +4932,14 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po touch_any = 1; } } - + /* calculate pivot for rotation around seletion if needed */ if (U.uiflag & USER_ORBIT_SELECTION) { float w[3]; int tri_index; - + tri_index = project_paint_PickFace(ps, pos, w); - + if (tri_index != -1) { const MLoopTri *lt = &ps->dm_mlooptri[tri_index]; const int lt_vtri[3] = { PS_LOOPTRI_AS_VERT_INDEX_3(ps, lt) }; @@ -4952,14 +4952,14 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po ps->dm_mvert[lt_vtri[1]].co, ps->dm_mvert[lt_vtri[2]].co, w); - + ups->average_stroke_counter++; mul_m4_v3(ps->obmat, world); add_v3_v3(ups->average_stroke_accum, world); ups->last_stroke_valid = true; } } - + return touch_any; } @@ -5095,9 +5095,9 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int ps->do_material_slots = (settings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL); ps->stencil_ima = settings->imapaint.stencil; - ps->canvas_ima = (!ps->do_material_slots) ? + ps->canvas_ima = (!ps->do_material_slots) ? settings->imapaint.canvas : NULL; - ps->clone_ima = (!ps->do_material_slots) ? + ps->clone_ima = (!ps->do_material_slots) ? settings->imapaint.clone : NULL; ps->do_mask_cavity = (settings->imapaint.paint.flags & PAINT_USE_CAVITY_MASK) ? true : false; @@ -5329,7 +5329,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) if (!BKE_paint_proj_mesh_data_check(scene, ob, &uvs, &mat, &tex, NULL)) { BKE_paint_data_warning(op->reports, uvs, mat, tex, true); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); - return OPERATOR_CANCELLED; + return OPERATOR_CANCELLED; } project_state_init(C, ob, &ps, BRUSH_STROKE_NORMAL); @@ -5528,7 +5528,7 @@ void PAINT_OT_image_from_view(wmOperatorType *ot) void BKE_paint_data_warning(struct ReportList *reports, bool uvs, bool mat, bool tex, bool stencil) { - BKE_reportf(reports, RPT_WARNING, "Missing%s%s%s%s detected!", + BKE_reportf(reports, RPT_WARNING, "Missing%s%s%s%s detected!", !uvs ? " UVs," : "", !mat ? " Materials," : "", !tex ? " Textures," : "", @@ -5549,7 +5549,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m bool hasuvs = true; imapaint->missing_data = 0; - + BLI_assert(ob->type == OB_MESH); if (imapaint->mode == IMAGEPAINT_MODE_MATERIAL) { @@ -5563,16 +5563,16 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m int i; hasmat = false; hastex = false; - + for (i = 1; i < ob->totcol + 1; i++) { Material *ma = give_current_material(ob, i); - + if (ma) { hasmat = true; if (!ma->texpaintslot) { /* refresh here just in case */ BKE_texpaint_slot_refresh_cache(scene, ma); - + /* if still no slots, we have to add */ if (ma->texpaintslot) { hastex = true; @@ -5592,7 +5592,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m hastex = false; } } - + me = BKE_mesh_from_object(ob); layernum = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY); @@ -5613,7 +5613,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m if (!hasmat) imapaint->missing_data |= IMAGEPAINT_MISSING_MATERIAL; if (!hastex) imapaint->missing_data |= IMAGEPAINT_MISSING_TEX; if (!hasstencil) imapaint->missing_data |= IMAGEPAINT_MISSING_STENCIL; - + if (uvs) { *uvs = hasuvs; } @@ -5626,7 +5626,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m if (stencil) { *stencil = hasstencil; } - + return hasuvs && hasmat && hastex && hasstencil; } @@ -5672,7 +5672,7 @@ static Image *proj_paint_image_create(wmOperator *op, Main *bmain) } ima = BKE_image_add_generated(bmain, width, height, imagename, alpha ? 32 : 24, use_float, gen_type, color, false); - + return ima; } @@ -5700,17 +5700,17 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) 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 { @@ -5738,20 +5738,20 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_TEXTURE | NA_ADDED, mtex->tex); } } - + if (ima) { BKE_texpaint_slot_refresh_cache(scene, ma); BKE_image_signal(ima, NULL, IMA_SIGNAL_USER_NEW_IMAGE); WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima); DAG_id_tag_update(&ma->id, 0); ED_area_tag_redraw(CTX_wm_area(C)); - + BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); - + return true; } } - + return false; } @@ -5779,7 +5779,7 @@ static int texture_paint_add_texture_paint_slot_invoke(bContext *C, wmOperator * /* no material found, just assign to first slot */ assign_material(bmain, ob, ma, ob->actcol, BKE_MAT_ASSIGN_USERPREF); } - + type = RNA_enum_from_value(layer_type_items, type); /* get the name of the texture layer type */ @@ -5837,28 +5837,28 @@ static int texture_paint_delete_texture_paint_slot_exec(bContext *C, wmOperator Material *ma; bool is_bi = BKE_scene_uses_blender_internal(scene) || BKE_scene_uses_blender_game(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); DAG_id_tag_update(&ma->id, 0); WM_event_add_notifier(C, NC_MATERIAL, ma); @@ -5917,7 +5917,7 @@ static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op)) scene->toolsettings->uv_flag |= UV_SYNC_SELECTION; BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); - + DAG_id_tag_update(ob->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, scene); |