code cleanup:
authorCampbell Barton <ideasman42@gmail.com>
Fri, 28 Dec 2012 09:06:48 +0000 (09:06 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 28 Dec 2012 09:06:48 +0000 (09:06 +0000)
- free_dverts -> BKE_defvert_array_free
- copy_dverts -> BKE_defvert_array_copy

also move the functions from BKE_mesh into BKE_deform

source/blender/blenkernel/BKE_deform.h
source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/mesh.c
source/blender/editors/object/object_lattice.c
source/blender/editors/sculpt_paint/paint_vertex.c

index 8306da714324195d6c9ae88f081fee6cac8869c1..ab27421b383b041bfbdb253580da6debae1c0cfc 100644 (file)
@@ -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);
 
index 320ced67a2f975cacd833d6d08d7368b070a7c45..db9f1228f768dd29ad30aa1b22eef1e7fe5dfdd6 100644 (file)
@@ -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);
index 3f400155f7bc5145797b9aba79a22f78f9106429..b5280fdc039c66d812ee877cea9980d9d46581e1 100644 (file)
@@ -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);
+}
+
index d98188d8a6f0acbbecf6cac6bcb9eb25a9a0f51b..fa01e9fd93361e96961cf0b94f0e39cbd1c55a86 100644 (file)
@@ -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);
index f788bbabf4df0524f076ab8f7386987dc3462ae6..30e7cb3bb36717d78952df9537bfc3c95ccb321c 100644 (file)
@@ -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) {
index 4aa2e8259543acc11fc2db943bc868968bcc6ee3..c9eae776ac718e9c5b6ba268d5f1b5b58fff7137 100644 (file)
@@ -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);
        }
 }
 
index c31d40e54747a651dd41fa4bc35e3bd86ad8c9d6..17bf5c841c343bc8f9d19fc7a3bca233b1eee869 100644 (file)
@@ -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);