diff options
Diffstat (limited to 'source/blender/editors/mesh/editmesh_knife_project.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife_project.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c index 0d3cc07589b..5ccbcf063ad 100644 --- a/source/blender/editors/mesh/editmesh_knife_project.c +++ b/source/blender/editors/mesh/editmesh_knife_project.c @@ -40,8 +40,11 @@ #include "BKE_curve.h" #include "BKE_cdderivedmesh.h" #include "BKE_editmesh.h" +#include "BKE_mesh_runtime.h" #include "BKE_report.h" +#include "DEG_depsgraph.h" + #include "RNA_define.h" #include "RNA_access.h" @@ -56,29 +59,32 @@ #include "mesh_intern.h" /* own include */ -static LinkNode *knifeproject_poly_from_object(ARegion *ar, Scene *scene, Object *ob, LinkNode *polys) +static LinkNode *knifeproject_poly_from_object(const bContext *C, Scene *scene, Object *ob, LinkNode *polys) { - DerivedMesh *dm; - bool dm_needsFree; + Depsgraph *depsgraph = CTX_data_depsgraph(C); + ARegion *ar = CTX_wm_region(C); + struct Mesh *me_eval; + bool me_eval_needs_free; if (ob->type == OB_MESH || ob->derivedFinal) { - dm = ob->derivedFinal ? ob->derivedFinal : mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); - dm_needsFree = false; + me_eval = (ob->runtime.mesh_eval ? + ob->runtime.mesh_eval : mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH)); + me_eval_needs_free = false; } else if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { - dm = CDDM_from_curve(ob); - dm_needsFree = true; + me_eval = BKE_mesh_new_nomain_from_curve(ob); + me_eval_needs_free = true; } else { - dm = NULL; + me_eval = NULL; } - if (dm) { + if (me_eval) { ListBase nurbslist = {NULL, NULL}; float projmat[4][4]; - BKE_mesh_to_curve_nurblist(dm, &nurbslist, 0); /* wire */ - BKE_mesh_to_curve_nurblist(dm, &nurbslist, 1); /* boundary */ + BKE_mesh_to_curve_nurblist(me_eval, &nurbslist, 0); /* wire */ + BKE_mesh_to_curve_nurblist(me_eval, &nurbslist, 1); /* boundary */ ED_view3d_ob_project_mat_get(ar->regiondata, ob, projmat); @@ -105,18 +111,16 @@ static LinkNode *knifeproject_poly_from_object(ARegion *ar, Scene *scene, Object BKE_nurbList_free(&nurbslist); - if (dm_needsFree) { - dm->release(dm); + if (me_eval_needs_free) { + BKE_mesh_free(me_eval); } } - return polys; } static int knifeproject_exec(bContext *C, wmOperator *op) { - ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); @@ -127,7 +131,7 @@ static int knifeproject_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { if (ob != obedit) { - polys = knifeproject_poly_from_object(ar, scene, ob, polys); + polys = knifeproject_poly_from_object(C, scene, ob, polys); } } CTX_DATA_END; |