Cleanup: remove UV name syncing function
authorCampbell Barton <ideasman42@gmail.com>
Sun, 25 Aug 2019 04:54:48 +0000 (14:54 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 25 Aug 2019 06:45:47 +0000 (16:45 +1000)
MTFace's on the mesh are now only used for conversion.
There is no need to keep both UV layers in sync at once.

source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/intern/mesh.c
source/blender/makesrna/intern/rna_mesh.c

index cfbece9457ee41654f5de0a0c13aa6a4372b0786..53b7b16057a1a2478686e440edb7132766aae586 100644 (file)
@@ -198,16 +198,6 @@ void BKE_mesh_texspace_get_reference(
     struct Mesh *me, short **r_texflag, float **r_loc, float **r_rot, float **r_size);
 void BKE_mesh_texspace_copy_from_object(struct Mesh *me, struct Object *ob);
 
-bool BKE_mesh_uv_cdlayer_rename_index(struct Mesh *me,
-                                      const int loop_index,
-                                      const int face_index,
-                                      const char *new_name,
-                                      const bool do_tessface);
-bool BKE_mesh_uv_cdlayer_rename(struct Mesh *me,
-                                const char *old_name,
-                                const char *new_name,
-                                bool do_tessface);
-
 void BKE_mesh_split_faces(struct Mesh *mesh, bool free_loop_normals);
 
 /* Create new mesh from the given object at its current state.
index 68dfc263d3e1ea71285c1c4d89b0d14bcfd161e9..71fd65d1f23b801a49c7608eb2fbef849035e875 100644 (file)
@@ -813,92 +813,6 @@ void BKE_mesh_make_local(Main *bmain, Mesh *me, const bool lib_local)
   BKE_id_make_local_generic(bmain, &me->id, true, lib_local);
 }
 
-bool BKE_mesh_uv_cdlayer_rename_index(Mesh *me,
-                                      const int loop_index,
-                                      const int face_index,
-                                      const char *new_name,
-                                      const bool do_tessface)
-{
-  CustomData *ldata, *fdata;
-  CustomDataLayer *cdlu, *cdlf;
-
-  if (me->edit_mesh) {
-    ldata = &me->edit_mesh->bm->ldata;
-    fdata = NULL; /* No tessellated data in BMesh! */
-  }
-  else {
-    ldata = &me->ldata;
-    fdata = &me->fdata;
-  }
-
-  cdlu = &ldata->layers[loop_index];
-  cdlf = (face_index != -1) && fdata && do_tessface ? &fdata->layers[face_index] : NULL;
-
-  if (cdlu->name != new_name) {
-    /* Mesh validate passes a name from the CD layer as the new name,
-     * Avoid memcpy from self to self in this case.
-     */
-    BLI_strncpy(cdlu->name, new_name, sizeof(cdlu->name));
-    CustomData_set_layer_unique_name(ldata, loop_index);
-  }
-
-  if (cdlf == NULL) {
-    return false;
-  }
-
-  BLI_strncpy(cdlf->name, cdlu->name, sizeof(cdlf->name));
-  CustomData_set_layer_unique_name(fdata, face_index);
-
-  return true;
-}
-
-bool BKE_mesh_uv_cdlayer_rename(Mesh *me,
-                                const char *old_name,
-                                const char *new_name,
-                                bool do_tessface)
-{
-  CustomData *ldata, *fdata;
-  if (me->edit_mesh) {
-    ldata = &me->edit_mesh->bm->ldata;
-    /* No tessellated data in BMesh! */
-    fdata = NULL;
-    do_tessface = false;
-  }
-  else {
-    ldata = &me->ldata;
-    fdata = &me->fdata;
-    do_tessface = (do_tessface && fdata->totlayer);
-  }
-
-  {
-    const int lidx_start = CustomData_get_layer_index(ldata, CD_MLOOPUV);
-    const int fidx_start = do_tessface ? CustomData_get_layer_index(fdata, CD_MTFACE) : -1;
-    int lidx = CustomData_get_named_layer(ldata, CD_MLOOPUV, old_name);
-    int fidx = do_tessface ? CustomData_get_named_layer(fdata, CD_MTFACE, old_name) : -1;
-
-    /* None of those cases should happen, in theory!
-     * Note this assume we have the same number of mtexpoly, mloopuv and mtface layers!
-     */
-    if (lidx == -1) {
-      if (fidx == -1) {
-        /* No layer found with this name! */
-        return false;
-      }
-      else {
-        lidx = fidx;
-      }
-    }
-
-    /* Go back to absolute indices! */
-    lidx += lidx_start;
-    if (fidx != -1) {
-      fidx += fidx_start;
-    }
-
-    return BKE_mesh_uv_cdlayer_rename_index(me, lidx, fidx, new_name, do_tessface);
-  }
-}
-
 void BKE_mesh_boundbox_calc(Mesh *me, float r_loc[3], float r_size[3])
 {
   BoundBox *bb;
index cfffa3bf4e3c5ae8bff828d4795c96492a9197b0..81480eda4d6d1a61d43e50e0b251e30542fb480f 100644 (file)
@@ -651,14 +651,6 @@ static void rna_MPoly_freestyle_face_mark_set(PointerRNA *ptr, int value)
   }
 }
 
-/* Generic UV rename! */
-static void rna_MeshUVLayer_name_set(PointerRNA *ptr, const char *name)
-{
-  char buf[MAX_CUSTOMDATA_LAYER_NAME];
-  BLI_strncpy_utf8(buf, name, MAX_CUSTOMDATA_LAYER_NAME);
-  BKE_mesh_uv_cdlayer_rename(rna_mesh(ptr), ((CustomDataLayer *)ptr->data)->name, buf, true);
-}
-
 /* uv_layers */
 
 DEFINE_CUSTOMDATA_LAYER_COLLECTION(uv_layer, ldata, CD_MLOOPUV)
@@ -1941,7 +1933,7 @@ static void rna_def_mloopuv(BlenderRNA *brna)
 
   prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
   RNA_def_struct_name_property(srna, prop);
-  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshUVLayer_name_set");
+  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshLoopLayer_name_set");
   RNA_def_property_ui_text(prop, "Name", "Name of UV map");
   RNA_def_property_update(prop, 0, "rna_Mesh_update_data");