Code cleanup: modifier_skin_customdata_ensure was a bad level call
authorCampbell Barton <ideasman42@gmail.com>
Sun, 16 Mar 2014 10:55:30 +0000 (21:55 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 16 Mar 2014 10:55:30 +0000 (21:55 +1100)
source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/BKE_modifier.h
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/object.c
source/blender/editors/object/object_modifier.c
source/blenderplayer/bad_level_call_stubs/stubs.c

index 25fd95176b2a52a3647d3eec519ff86fc56c1725..9c57b7c9a712a4c111fcdee2d50585a8226f99cd 100644 (file)
@@ -90,6 +90,7 @@ struct Mesh *BKE_mesh_add(struct Main *bmain, const char *name);
 struct Mesh *BKE_mesh_copy_ex(struct Main *bmain, struct Mesh *me);
 struct Mesh *BKE_mesh_copy(struct Mesh *me);
 void BKE_mesh_update_customdata_pointers(struct Mesh *me, const bool do_ensure_tess_cd);
+void BKE_mesh_ensure_skin_customdata(struct Mesh *me);
 
 void BKE_mesh_make_local(struct Mesh *me);
 void BKE_mesh_boundbox_calc(struct Mesh *me, float r_loc[3], float r_size[3]);
index 2d47cf307f7b1240e6c1d028732ca7f26fddd3e2..3b2bafa799f417fd1a730aa894e934da02c9452b 100644 (file)
@@ -359,7 +359,6 @@ bool          modifiers_usesArmature(struct Object *ob, struct bArmature *arm);
 bool          modifiers_isCorrectableDeformed(struct Scene *scene, struct Object *ob);
 void          modifier_freeTemporaryData(struct ModifierData *md);
 bool          modifiers_isPreview(struct Object *ob);
-void          modifier_skin_customdata_ensure(struct Object *ob);
 
 typedef struct CDMaskLink {
        struct CDMaskLink *next;
index 838f93e52222663858c18c180c57ae237613d3cd..b7ebd5c013d54a9f6041d0b302f6cc4f408b3010 100644 (file)
@@ -337,6 +337,43 @@ static void mesh_ensure_tessellation_customdata(Mesh *me)
        }
 }
 
+void BKE_mesh_ensure_skin_customdata(Mesh *me)
+{
+       BMesh *bm = me->edit_btmesh ? me->edit_btmesh->bm : NULL;
+       MVertSkin *vs;
+
+       if (bm) {
+               if (!CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN)) {
+                       BMVert *v;
+                       BMIter iter;
+
+                       BM_data_layer_add(bm, &bm->vdata, CD_MVERT_SKIN);
+
+                       /* Mark an arbitrary vertex as root */
+                       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+                               vs = CustomData_bmesh_get(&bm->vdata, v->head.data,
+                                                         CD_MVERT_SKIN);
+                               vs->flag |= MVERT_SKIN_ROOT;
+                               break;
+                       }
+               }
+       }
+       else {
+               if (!CustomData_has_layer(&me->vdata, CD_MVERT_SKIN)) {
+                       vs = CustomData_add_layer(&me->vdata,
+                                                 CD_MVERT_SKIN,
+                                                 CD_DEFAULT,
+                                                 NULL,
+                                                 me->totvert);
+
+                       /* Mark an arbitrary vertex as root */
+                       if (vs) {
+                               vs->flag |= MVERT_SKIN_ROOT;
+                       }
+               }
+       }
+}
+
 /* this ensures grouped customdata (e.g. mtexpoly and mloopuv and mtface, or
  * mloopcol and mcol) have the same relative active/render/clone/mask indices.
  *
index 0970af46a6b83c7d9f6062fd00f2516ee2e5c917..de9dd011e0495b2d8684fde2a7ca9627ad6af8f7 100644 (file)
@@ -273,7 +273,7 @@ void BKE_object_link_modifiers(struct Object *ob_dst, struct Object *ob_src)
                
                if (md->type == eModifierType_Skin) {
                        /* ensure skin-node customdata exists */
-                       modifier_skin_customdata_ensure(ob_dst);
+                       BKE_mesh_ensure_skin_customdata(ob_dst->data);
                }
 
                nmd = modifier_new(md->type);
index 013a6c78a15fc7af349b226bb8f370ad714387cb..327e840a873d058c0f84d9166592996bc2c98344 100644 (file)
@@ -166,7 +166,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
                }
                else if (type == eModifierType_Skin) {
                        /* ensure skin-node customdata exists */
-                       modifier_skin_customdata_ensure(ob);
+                       BKE_mesh_ensure_skin_customdata(ob->data);
                }
        }
 
@@ -1431,39 +1431,6 @@ void OBJECT_OT_multires_base_apply(wmOperatorType *ot)
 
 /************************** skin modifier ***********************/
 
-void modifier_skin_customdata_ensure(Object *ob)
-{
-       Mesh *me = ob->data;
-       BMesh *bm = me->edit_btmesh ? me->edit_btmesh->bm : NULL;
-       MVertSkin *vs;
-
-       if (bm && !CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN)) {
-               BMVert *v;
-               BMIter iter;
-
-               BM_data_layer_add(bm, &bm->vdata, CD_MVERT_SKIN);
-               
-               /* Mark an arbitrary vertex as root */
-               BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
-                       vs = CustomData_bmesh_get(&bm->vdata, v->head.data,
-                                                 CD_MVERT_SKIN);
-                       vs->flag |= MVERT_SKIN_ROOT;
-                       break;
-               }
-       }
-       else if (!CustomData_has_layer(&me->vdata, CD_MVERT_SKIN)) {
-               vs = CustomData_add_layer(&me->vdata,
-                                         CD_MVERT_SKIN,
-                                         CD_DEFAULT,
-                                         NULL,
-                                         me->totvert);
-
-               /* Mark an arbitrary vertex as root */
-               if (vs)
-                       vs->flag |= MVERT_SKIN_ROOT;
-       }
-}
-
 static void modifier_skin_customdata_delete(Object *ob)
 {
        Mesh *me = ob->data;
@@ -1520,7 +1487,7 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op))
 
        visited = BLI_ghash_ptr_new("skin_root_mark_exec visited");
 
-       modifier_skin_customdata_ensure(ob);
+       BKE_mesh_ensure_skin_customdata(ob->data);
 
        BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) {
                if (!BLI_ghash_lookup(visited, bm_vert) &&
index 055036158d6461861f3e9599589eb37f2b824f5d..806fa596f598a724e82aaabc84b5e546990de7eb 100644 (file)
@@ -236,9 +236,6 @@ void RE_free_sample_material(struct Material *mat) RET_NONE
 void RE_sample_material_color(struct Material *mat, float color[3], float *alpha, const float volume_co[3], const float surface_co[3],
                               int face_index, short hit_quad, struct DerivedMesh *orcoDm, struct Object *ob) RET_NONE
 
-/* skin modifier*/
-void modifier_skin_customdata_ensure(struct Object *ob) RET_NONE
-
 /* nodes */
 struct Render *RE_GetRender(const char *name) RET_NULL
 float RE_lamp_get_data(struct ShadeInput *shi, struct Object *lamp_obj, float col[4], float lv[3], float *dist, float shadow[4]) RET_ZERO