Cleanup: minor changes to edit-mesh API calls
Rename: - EDBM_mesh_free -> EDBM_mesh_free_data BKE_editmesh_free -> BKE_editmesh_free_data Since this doesn't free the edit-mesh pointer. - BKE_editmesh_free_derivedmesh -> BKE_editmesh_free_derived_caches Since this no longer uses derived-mesh, match naming for the related object function BKE_object_free_derived_caches. Also remove `do_tessellate` argument from BKE_editmesh_create, since the caller can explicitly do this if it's needed, with the advantage that it can be combined with normal calculation which is faster on high-poly meshes.
This commit is contained in:
parent
b90b1af25c
commit
7a084c2eee
|
@ -94,11 +94,11 @@ void BKE_editmesh_looptri_and_normals_calc_with_partial(BMEditMesh *em,
|
|||
|
||||
void BKE_editmesh_looptri_and_normals_calc(BMEditMesh *em);
|
||||
|
||||
BMEditMesh *BKE_editmesh_create(BMesh *bm, const bool do_tessellate);
|
||||
BMEditMesh *BKE_editmesh_create(BMesh *bm);
|
||||
BMEditMesh *BKE_editmesh_copy(BMEditMesh *em);
|
||||
BMEditMesh *BKE_editmesh_from_object(struct Object *ob);
|
||||
void BKE_editmesh_free_derivedmesh(BMEditMesh *em);
|
||||
void BKE_editmesh_free(BMEditMesh *em);
|
||||
void BKE_editmesh_free_derived_caches(BMEditMesh *em);
|
||||
void BKE_editmesh_free_data(BMEditMesh *em);
|
||||
|
||||
float (*BKE_editmesh_vert_coords_alloc(struct Depsgraph *depsgraph,
|
||||
struct BMEditMesh *em,
|
||||
|
|
|
@ -1990,7 +1990,7 @@ static void editbmesh_build_data(struct Depsgraph *depsgraph,
|
|||
BKE_sculpt_update_object_before_eval(obedit);
|
||||
}
|
||||
|
||||
BKE_editmesh_free_derivedmesh(em);
|
||||
BKE_editmesh_free_derived_caches(em);
|
||||
|
||||
Mesh *me_cage;
|
||||
Mesh *me_final;
|
||||
|
|
|
@ -39,15 +39,14 @@
|
|||
#include "BKE_mesh_wrapper.h"
|
||||
#include "BKE_object.h"
|
||||
|
||||
BMEditMesh *BKE_editmesh_create(BMesh *bm, const bool do_tessellate)
|
||||
/**
|
||||
* \note The caller is responsible for ensuring triangulation data,
|
||||
* typically by calling #BKE_editmesh_looptri_calc.
|
||||
*/
|
||||
BMEditMesh *BKE_editmesh_create(BMesh *bm)
|
||||
{
|
||||
BMEditMesh *em = MEM_callocN(sizeof(BMEditMesh), __func__);
|
||||
|
||||
em->bm = bm;
|
||||
if (do_tessellate) {
|
||||
BKE_editmesh_looptri_calc(em);
|
||||
}
|
||||
|
||||
return em;
|
||||
}
|
||||
|
||||
|
@ -209,7 +208,7 @@ void BKE_editmesh_looptri_and_normals_calc_with_partial(BMEditMesh *em,
|
|||
});
|
||||
}
|
||||
|
||||
void BKE_editmesh_free_derivedmesh(BMEditMesh *em)
|
||||
void BKE_editmesh_free_derived_caches(BMEditMesh *em)
|
||||
{
|
||||
if (em->mesh_eval_cage) {
|
||||
BKE_id_free(NULL, em->mesh_eval_cage);
|
||||
|
@ -223,9 +222,9 @@ void BKE_editmesh_free_derivedmesh(BMEditMesh *em)
|
|||
}
|
||||
|
||||
/* Does not free the #BMEditMesh struct itself. */
|
||||
void BKE_editmesh_free(BMEditMesh *em)
|
||||
void BKE_editmesh_free_data(BMEditMesh *em)
|
||||
{
|
||||
BKE_editmesh_free_derivedmesh(em);
|
||||
BKE_editmesh_free_derived_caches(em);
|
||||
|
||||
if (em->looptris) {
|
||||
MEM_freeN(em->looptris);
|
||||
|
|
|
@ -86,7 +86,7 @@ void EDBM_mesh_clear(struct BMEditMesh *em);
|
|||
|
||||
void EDBM_selectmode_to_scene(struct bContext *C);
|
||||
void EDBM_mesh_make(struct Object *ob, const int select_mode, const bool add_key_index);
|
||||
void EDBM_mesh_free(struct BMEditMesh *em);
|
||||
void EDBM_mesh_free_data(struct BMEditMesh *em);
|
||||
void EDBM_mesh_load_ex(struct Main *bmain, struct Object *ob, bool free_data);
|
||||
void EDBM_mesh_load(struct Main *bmain, struct Object *ob);
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ static int geometry_extract_apply(bContext *C,
|
|||
.calc_face_normal = true,
|
||||
}));
|
||||
|
||||
BMEditMesh *em = BKE_editmesh_create(bm, false);
|
||||
BMEditMesh *em = BKE_editmesh_create(bm);
|
||||
|
||||
/* Generate the tags for deleting geometry in the extracted object. */
|
||||
tag_fn(bm, params);
|
||||
|
@ -206,7 +206,7 @@ static int geometry_extract_apply(bContext *C,
|
|||
}),
|
||||
mesh);
|
||||
|
||||
BKE_editmesh_free(em);
|
||||
BKE_editmesh_free_data(em);
|
||||
MEM_freeN(em);
|
||||
|
||||
if (new_mesh->totvert == 0) {
|
||||
|
|
|
@ -671,7 +671,7 @@ static void undomesh_to_editmesh(UndoMesh *um, Object *ob, BMEditMesh *em, Key *
|
|||
|
||||
em->bm->shapenr = um->shapenr;
|
||||
|
||||
EDBM_mesh_free(em);
|
||||
EDBM_mesh_free_data(em);
|
||||
|
||||
bm = BM_mesh_create(&allocsize,
|
||||
&((struct BMeshCreateParams){
|
||||
|
@ -685,9 +685,11 @@ static void undomesh_to_editmesh(UndoMesh *um, Object *ob, BMEditMesh *em, Key *
|
|||
.active_shapekey = um->shapenr,
|
||||
}));
|
||||
|
||||
em_tmp = BKE_editmesh_create(bm, true);
|
||||
em_tmp = BKE_editmesh_create(bm);
|
||||
*em = *em_tmp;
|
||||
|
||||
BKE_editmesh_looptri_calc(em);
|
||||
|
||||
em->selectmode = um->selectmode;
|
||||
bm->selectmode = um->selectmode;
|
||||
|
||||
|
|
|
@ -305,17 +305,13 @@ void EDBM_mesh_make(Object *ob, const int select_mode, const bool add_key_index)
|
|||
|
||||
if (me->edit_mesh) {
|
||||
/* this happens when switching shape keys */
|
||||
EDBM_mesh_free(me->edit_mesh);
|
||||
EDBM_mesh_free_data(me->edit_mesh);
|
||||
MEM_freeN(me->edit_mesh);
|
||||
}
|
||||
|
||||
/* currently executing operators re-tessellates, so we can avoid doing here
|
||||
* but at some point it may need to be added back. */
|
||||
#if 0
|
||||
me->edit_mesh = BKE_editmesh_create(bm, true);
|
||||
#else
|
||||
me->edit_mesh = BKE_editmesh_create(bm, false);
|
||||
#endif
|
||||
/* Executing operators re-tessellates,
|
||||
* so we can avoid doing here but at some point it may need to be added back. */
|
||||
me->edit_mesh = BKE_editmesh_create(bm);
|
||||
|
||||
me->edit_mesh->selectmode = me->edit_mesh->bm->selectmode = select_mode;
|
||||
me->edit_mesh->mat_nr = (ob->actcol > 0) ? ob->actcol - 1 : 0;
|
||||
|
@ -372,8 +368,8 @@ void EDBM_mesh_clear(BMEditMesh *em)
|
|||
/* clear bmesh */
|
||||
BM_mesh_clear(em->bm);
|
||||
|
||||
/* free derived meshes */
|
||||
BKE_editmesh_free_derivedmesh(em);
|
||||
/* Free evaluated meshes & cache. */
|
||||
BKE_editmesh_free_derived_caches(em);
|
||||
|
||||
/* free tessellation data */
|
||||
em->tottri = 0;
|
||||
|
@ -389,9 +385,9 @@ void EDBM_mesh_load(Main *bmain, Object *ob)
|
|||
}
|
||||
|
||||
/**
|
||||
* Should only be called on the active editmesh, otherwise call #BKE_editmesh_free
|
||||
* Should only be called on the active edit-mesh, otherwise call #BKE_editmesh_free_data.
|
||||
*/
|
||||
void EDBM_mesh_free(BMEditMesh *em)
|
||||
void EDBM_mesh_free_data(BMEditMesh *em)
|
||||
{
|
||||
/* These tables aren't used yet, so it's not strictly necessary
|
||||
* to 'end' them but if someone tries to start using them,
|
||||
|
@ -399,7 +395,7 @@ void EDBM_mesh_free(BMEditMesh *em)
|
|||
ED_mesh_mirror_spatial_table_end(NULL);
|
||||
ED_mesh_mirror_topo_table_end(NULL);
|
||||
|
||||
BKE_editmesh_free(em);
|
||||
BKE_editmesh_free_data(em);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -1471,8 +1467,8 @@ void EDBM_update(Mesh *mesh, const struct EDBMUpdate_Params *params)
|
|||
BM_lnorspace_invalidate(em->bm, false);
|
||||
em->bm->spacearr_dirty &= ~BM_SPACEARR_BMO_SET;
|
||||
}
|
||||
/* don't keep stale derivedMesh data around, see: T38872. */
|
||||
BKE_editmesh_free_derivedmesh(em);
|
||||
/* Don't keep stale evaluated mesh data around, see: T38872. */
|
||||
BKE_editmesh_free_derived_caches(em);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
|
|
|
@ -557,7 +557,7 @@ static bool ED_object_editmode_load_free_ex(Main *bmain,
|
|||
}
|
||||
|
||||
if (free_data) {
|
||||
EDBM_mesh_free(me->edit_mesh);
|
||||
EDBM_mesh_free_data(me->edit_mesh);
|
||||
MEM_freeN(me->edit_mesh);
|
||||
me->edit_mesh = NULL;
|
||||
}
|
||||
|
|
|
@ -1696,7 +1696,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
|
|||
}
|
||||
|
||||
if (rb->remove_doubles) {
|
||||
BMEditMesh *em = BKE_editmesh_create(bm, false);
|
||||
BMEditMesh *em = BKE_editmesh_create(bm);
|
||||
BMOperator findop, weldop;
|
||||
|
||||
/* See bmesh_opdefines.c and bmesh_operators.c for op names and argument formatting. */
|
||||
|
|
Loading…
Reference in New Issue