diff options
author | Stefan Werner <stefan.werner@tangent-animation.com> | 2021-08-21 23:03:31 +0300 |
---|---|---|
committer | Stefan Werner <stefan.werner@tangent-animation.com> | 2021-08-21 23:03:31 +0300 |
commit | c5b56a525cd6113caa2bd3ec7bfb91fe4a04513a (patch) | |
tree | 77dae5ae2fbeccf6703034c94ad3e1f3aa81140b /source/blender/editors/mesh/editmesh_knife_project.c | |
parent | 34e8d79c3edbc58fd242cec0c1f2bed4e43855af (diff) | |
parent | 67c29bc5a273b66e278bd20c18187b425acf1869 (diff) |
Merge branch 'master' into cycles_texture_cachecycles_texture_cache
Diffstat (limited to 'source/blender/editors/mesh/editmesh_knife_project.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife_project.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c index 09b17acf56d..669a09b3fd3 100644 --- a/source/blender/editors/mesh/editmesh_knife_project.c +++ b/source/blender/editors/mesh/editmesh_knife_project.c @@ -32,6 +32,8 @@ #include "BKE_curve.h" #include "BKE_customdata.h" #include "BKE_editmesh.h" +#include "BKE_layer.h" +#include "BKE_lib_id.h" #include "BKE_mesh.h" #include "BKE_mesh_runtime.h" #include "BKE_object.h" @@ -114,7 +116,7 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C, BKE_nurbList_free(&nurbslist); if (me_eval_needs_free) { - BKE_mesh_free((struct Mesh *)me_eval); + BKE_id_free(NULL, (ID *)me_eval); } } @@ -124,21 +126,39 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C, static int knifeproject_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Object *obedit = CTX_data_edit_object(C); - BMEditMesh *em = BKE_editmesh_from_object(obedit); const bool cut_through = RNA_boolean_get(op->ptr, "cut_through"); LinkNode *polys = NULL; CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { - if (ob != obedit) { - polys = knifeproject_poly_from_object(C, scene, ob, polys); + if (BKE_object_is_in_editmode(ob)) { + continue; } + polys = knifeproject_poly_from_object(C, scene, ob, polys); } CTX_DATA_END; - if (polys) { - EDBM_mesh_knife(C, polys, true, cut_through); + if (polys == NULL) { + BKE_report(op->reports, + RPT_ERROR, + "No other selected objects have wire or boundary edges to use for projection"); + return OPERATOR_CANCELLED; + } + + ViewContext vc; + em_setup_viewcontext(C, &vc); + + /* TODO: Ideally meshes would occlude each other, currently they don't + * since each knife-project runs as a separate operation. */ + uint objects_len; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( + vc.view_layer, vc.v3d, &objects_len); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + ED_view3d_viewcontext_init_object(&vc, obedit); + BMEditMesh *em = BKE_editmesh_from_object(obedit); + + EDBM_mesh_knife(&vc, polys, true, cut_through); /* select only tagged faces */ BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false); @@ -148,16 +168,12 @@ static int knifeproject_exec(bContext *C, wmOperator *op) BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, false, BM_ELEM_TAG); BM_mesh_select_mode_flush(em->bm); - - BLI_linklist_freeN(polys); - - return OPERATOR_FINISHED; } + MEM_freeN(objects); + + BLI_linklist_freeN(polys); - BKE_report(op->reports, - RPT_ERROR, - "No other selected objects have wire or boundary edges to use for projection"); - return OPERATOR_CANCELLED; + return OPERATOR_FINISHED; } void MESH_OT_knife_project(wmOperatorType *ot) |