diff options
Diffstat (limited to 'source')
4 files changed, 29 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_editmesh.h b/source/blender/blenkernel/BKE_editmesh.h index 062968eddfc..37d84563402 100644 --- a/source/blender/blenkernel/BKE_editmesh.h +++ b/source/blender/blenkernel/BKE_editmesh.h @@ -28,8 +28,9 @@ #include "BKE_customdata.h" #include "bmesh.h" -struct BMLoop; struct BMesh; +struct BMLoop; +struct BoundBox; struct Depsgraph; struct EditMeshData; struct Mesh; @@ -59,6 +60,9 @@ typedef struct BMEditMesh { struct Mesh *mesh_eval_final, *mesh_eval_cage; + /** Cached cage bounding box for selection. */ + struct BoundBox *bb_cage; + /*derivedmesh stuff*/ CustomData_MeshMasks lastDataMask; unsigned char (*derivedVertColor)[4]; @@ -90,6 +94,7 @@ void BKE_editmesh_color_ensure(BMEditMesh *em, const char htype); float (*BKE_editmesh_vert_coords_alloc_orco(BMEditMesh *em, int *r_vert_len))[3]; void BKE_editmesh_lnorspace_update(BMEditMesh *em); void BKE_editmesh_ensure_autosmooth(BMEditMesh *em); +struct BoundBox *BKE_editmesh_cage_boundbox_get(BMEditMesh *em); /* editderivedmesh.c */ /* should really be defined in editmesh.c, but they use 'EditDerivedBMesh' */ diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c index 866c494d354..d929c953b89 100644 --- a/source/blender/blenkernel/intern/editmesh.c +++ b/source/blender/blenkernel/intern/editmesh.c @@ -32,6 +32,8 @@ #include "BKE_editmesh.h" #include "BKE_cdderivedmesh.h" #include "BKE_library.h" +#include "BKE_mesh.h" +#include "BKE_object.h" BMEditMesh *BKE_editmesh_create(BMesh *bm, const bool do_tessellate) { @@ -51,6 +53,7 @@ BMEditMesh *BKE_editmesh_copy(BMEditMesh *em) *em_copy = *em; em_copy->mesh_eval_cage = em_copy->mesh_eval_final = NULL; + em_copy->bb_cage = NULL; em_copy->derivedVertColor = NULL; em_copy->derivedVertColorLen = 0; @@ -151,6 +154,8 @@ void BKE_editmesh_free_derivedmesh(BMEditMesh *em) BKE_id_free(NULL, em->mesh_eval_final); } em->mesh_eval_cage = em->mesh_eval_final = NULL; + + MEM_SAFE_FREE(em->bb_cage); } /*does not free the BMEditMesh struct itself*/ @@ -257,3 +262,19 @@ void BKE_editmesh_ensure_autosmooth(BMEditMesh *em) BKE_editmesh_lnorspace_update(em); } } + +BoundBox *BKE_editmesh_cage_boundbox_get(BMEditMesh *em) +{ + if (em->bb_cage == NULL) { + float min[3], max[3]; + INIT_MINMAX(min, max); + if (em->mesh_eval_cage) { + BKE_mesh_minmax(em->mesh_eval_cage, min, max); + } + + em->bb_cage = MEM_callocN(sizeof(BoundBox), "BMEditMesh.bb_cage"); + BKE_boundbox_init_from_minmax(em->bb_cage, min, max); + } + + return em->bb_cage; +} diff --git a/source/blender/draw/engines/select/select_draw_utils.c b/source/blender/draw/engines/select/select_draw_utils.c index 0203b6cbebf..f1d008c29c7 100644 --- a/source/blender/draw/engines/select/select_draw_utils.c +++ b/source/blender/draw/engines/select/select_draw_utils.c @@ -49,8 +49,7 @@ void select_id_object_min_max(Object *obj, float r_min[3], float r_max[3]) BoundBox *bb; BMEditMesh *em = BKE_editmesh_from_object(obj); if (em) { - /* Use Object Texture Space. */ - bb = BKE_mesh_texspace_get(em->mesh_eval_cage, NULL, NULL, NULL); + bb = BKE_editmesh_cage_boundbox_get(em); } else { bb = BKE_object_boundbox_get(obj); diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 9c2642a46c1..1601acb1c8f 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -1717,7 +1717,7 @@ static short snapCurve(SnapData *snapdata, if (use_obedit == false) { /* Test BoundBox */ - BoundBox *bb = BKE_curve_texspace_get(cu, NULL, NULL, NULL); + BoundBox *bb = BKE_curve_boundbox_get(ob); if (bb && !snap_bound_box_check_dist( bb->vec[0], bb->vec[6], lpmat, snapdata->win_size, snapdata->mval, dist_px_sq)) { return 0; |