diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_deform.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_mesh.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 40 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 36 | ||||
-rw-r--r-- | source/blender/editors/object/object_lattice.c | 10 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 6 |
7 files changed, 55 insertions, 50 deletions
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index 8306da71432..ab27421b383 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -56,6 +56,9 @@ void defvert_remove_group(struct MDeformVert *dvert, struct void defvert_clear(struct MDeformVert *dvert); int defvert_find_shared(const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b); +void BKE_defvert_array_free(struct MDeformVert *dvert, int totvert); +void BKE_defvert_array_copy(struct MDeformVert *dst, const struct MDeformVert *src, int totvert); + float defvert_find_weight(const struct MDeformVert *dvert, const int defgroup); float defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int index, const int defgroup); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 320ced67a2f..db9f1228f76 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -162,8 +162,6 @@ void BKE_mesh_from_nurbs(struct Object *ob); void BKE_mesh_from_nurbs_displist(struct Object *ob, struct ListBase *dispbase, int **orco_index_ptr); void BKE_mesh_from_curve(struct Scene *scene, struct Object *ob); -void free_dverts(struct MDeformVert *dvert, int totvert); -void copy_dverts(struct MDeformVert *dst, const struct MDeformVert *src, int totvert); void BKE_mesh_delete_material_index(struct Mesh *me, short index); void BKE_mesh_smooth_flag_set(struct Object *meshOb, int enableSmooth); void BKE_mesh_convert_mfaces_to_mpolys(struct Mesh *mesh); diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 3f400155f7b..b5280fdc039 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -786,3 +786,43 @@ int defvert_find_shared(const MDeformVert *dvert_a, const MDeformVert *dvert_b) return -1; } + +/* -------------------------------------------------------------------- */ +/* Defvert Array functions */ + +void BKE_defvert_array_copy(MDeformVert *dst, const MDeformVert *src, int copycount) +{ + /* Assumes dst is already set up */ + int i; + + if (!src || !dst) + return; + + memcpy(dst, src, copycount * sizeof(MDeformVert)); + + for (i = 0; i < copycount; i++) { + if (src[i].dw) { + dst[i].dw = MEM_mallocN(sizeof(MDeformWeight) * src[i].totweight, "copy_deformWeight"); + memcpy(dst[i].dw, src[i].dw, sizeof(MDeformWeight) * src[i].totweight); + } + } + +} + +void BKE_defvert_array_free(MDeformVert *dvert, int totvert) +{ + /* Instead of freeing the verts directly, + * call this function to delete any special + * vert data */ + int i; + + if (!dvert) + return; + + /* Free any special data from the verts */ + for (i = 0; i < totvert; i++) { + if (dvert[i].dw) MEM_freeN(dvert[i].dw); + } + MEM_freeN(dvert); +} + diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index d98188d8a6f..fa01e9fd933 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -88,7 +88,7 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) /* vertex weight groups are just freed all for now */ if (lt->dvert) { - free_dverts(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); + BKE_defvert_array_free(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); lt->dvert = NULL; } @@ -209,7 +209,7 @@ Lattice *BKE_lattice_copy(Lattice *lt) if (lt->dvert) { int tot = lt->pntsu * lt->pntsv * lt->pntsw; ltn->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); - copy_dverts(ltn->dvert, lt->dvert, tot); + BKE_defvert_array_copy(ltn->dvert, lt->dvert, tot); } ltn->editlatt = NULL; @@ -220,12 +220,12 @@ Lattice *BKE_lattice_copy(Lattice *lt) void BKE_lattice_free(Lattice *lt) { if (lt->def) MEM_freeN(lt->def); - if (lt->dvert) free_dverts(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); + if (lt->dvert) BKE_defvert_array_free(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); if (lt->editlatt) { Lattice *editlt = lt->editlatt->latt; if (editlt->def) MEM_freeN(editlt->def); - if (editlt->dvert) free_dverts(editlt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); + if (editlt->dvert) BKE_defvert_array_free(editlt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); MEM_freeN(editlt); MEM_freeN(lt->editlatt); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index f788bbabf4d..30e7cb3bb36 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -430,42 +430,6 @@ void BKE_mesh_free(Mesh *me, int unlink) if (me->edit_btmesh) MEM_freeN(me->edit_btmesh); } -void copy_dverts(MDeformVert *dst, const MDeformVert *src, int copycount) -{ - /* Assumes dst is already set up */ - int i; - - if (!src || !dst) - return; - - memcpy(dst, src, copycount * sizeof(MDeformVert)); - - for (i = 0; i < copycount; i++) { - if (src[i].dw) { - dst[i].dw = MEM_mallocN(sizeof(MDeformWeight) * src[i].totweight, "copy_deformWeight"); - memcpy(dst[i].dw, src[i].dw, sizeof(MDeformWeight) * src[i].totweight); - } - } - -} - -void free_dverts(MDeformVert *dvert, int totvert) -{ - /* Instead of freeing the verts directly, - * call this function to delete any special - * vert data */ - int i; - - if (!dvert) - return; - - /* Free any special data from the verts */ - for (i = 0; i < totvert; i++) { - if (dvert[i].dw) MEM_freeN(dvert[i].dw); - } - MEM_freeN(dvert); -} - static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata) { if (free_customdata) { diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 4aa2e825954..c9eae776ac7 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -52,7 +52,7 @@ #include "BKE_depsgraph.h" #include "BKE_key.h" #include "BKE_lattice.h" -#include "BKE_mesh.h" +#include "BKE_deform.h" #include "ED_lattice.h" #include "ED_object.h" @@ -77,7 +77,7 @@ void free_editLatt(Object *ob) if (editlt->def) MEM_freeN(editlt->def); if (editlt->dvert) - free_dverts(editlt->dvert, editlt->pntsu * editlt->pntsv * editlt->pntsw); + BKE_defvert_array_free(editlt->dvert, editlt->pntsu * editlt->pntsv * editlt->pntsw); MEM_freeN(editlt); MEM_freeN(lt->editlatt); @@ -104,7 +104,7 @@ void make_editLatt(Object *obedit) if (lt->dvert) { int tot = lt->pntsu * lt->pntsv * lt->pntsw; lt->editlatt->latt->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); - copy_dverts(lt->editlatt->latt->dvert, lt->dvert, tot); + BKE_defvert_array_copy(lt->editlatt->latt->dvert, lt->dvert, tot); } if (lt->key) lt->editlatt->shapenr = obedit->shapenr; @@ -156,7 +156,7 @@ void load_editLatt(Object *obedit) } if (lt->dvert) { - free_dverts(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); + BKE_defvert_array_free(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); lt->dvert = NULL; } @@ -164,7 +164,7 @@ void load_editLatt(Object *obedit) tot = lt->pntsu * lt->pntsv * lt->pntsw; lt->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); - copy_dverts(lt->dvert, editlt->dvert, tot); + BKE_defvert_array_copy(lt->dvert, editlt->dvert, tot); } } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index c31d40e5474..17bf5c841c3 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -405,7 +405,7 @@ static void free_vpaint_prev(VPaint *vp) static void free_wpaint_prev(VPaint *vp) { if (vp->wpaint_prev) { - free_dverts(vp->wpaint_prev, vp->tot); + BKE_defvert_array_free(vp->wpaint_prev, vp->tot); vp->wpaint_prev = NULL; vp->tot = 0; } @@ -432,7 +432,7 @@ static void copy_wpaint_prev(VPaint *wp, MDeformVert *dverts, int dcount) wp->wpaint_prev = MEM_mallocN(sizeof(MDeformVert) * dcount, "wpaint prev"); wp->tot = dcount; - copy_dverts(wp->wpaint_prev, dverts, dcount); + BKE_defvert_array_copy(wp->wpaint_prev, dverts, dcount); } } @@ -3142,7 +3142,7 @@ static int paint_weight_gradient_modal(bContext *C, wmOperator *op, wmEvent *eve VPaint *wp = ts->wpaint; Object *ob = CTX_data_active_object(C); Mesh *me = ob->data; - copy_dverts(me->dvert, wp->wpaint_prev, me->totvert); + BKE_defvert_array_copy(me->dvert, wp->wpaint_prev, me->totvert); free_wpaint_prev(wp); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); |