code cleanup:
- free_dverts -> BKE_defvert_array_free - copy_dverts -> BKE_defvert_array_copy also move the functions from BKE_mesh into BKE_deform
This commit is contained in:
parent
3f68790108
commit
7730ddb3d6
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue