Fix T66369: Excessive WARN messages in console when opening older files

CDData checking on file load was not taking into account deprecated
CD_MTEXPOLY datatype, which unfortunately shows same weird glitch as
CD_PAINT_MASK and CD_FACEMAP ones...

Note that it was annoying (due to amount of warnings in console), but
totally harmless, since that data type is just deleted anyway.

This commit also generally cleans up the CD_MTEXPOLY deprecation code, we
have a system to handle that, let's use it, instead of defining local
static values to replace it...
This commit is contained in:
Bastien Montagne 2019-07-03 15:43:05 +02:00
parent 3d187a2764
commit c441448359
Notes: blender-bot 2023-02-14 05:43:04 +01:00
Referenced by issue #66369, Excessive WARN messages in console when opening older files
5 changed files with 15 additions and 10 deletions

View File

@ -973,8 +973,7 @@ static void *add_customdata_cb(void *user_data, const char *name, int data_type)
return cd_ptr;
}
/* create a new layer, taking care to construct the hopefully-soon-to-be-removed
* CD_MTEXPOLY layer too, with the same name. */
/* Create a new layer. */
numloops = mesh->totloop;
cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_DEFAULT, NULL, numloops, name);
return cd_ptr;

View File

@ -26,6 +26,9 @@
#include "MEM_guardedalloc.h"
/* Since we have versioning code here (CustomData_verify_versions()). */
#define DNA_DEPRECATED_ALLOW
#include "DNA_customdata_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_ID.h"
@ -4191,9 +4194,10 @@ bool CustomData_verify_versions(struct CustomData *data, int index)
* Better to be safe here, and fix issue on the fly rather than crash... */
/* 0 structnum is used in writing code to tag layer types that should not be written. */
else if (typeInfo->structnum == 0 &&
/* XXX Not sure why those two are exception, maybe that should be fixed? */
!ELEM(layer->type, CD_PAINT_MASK, CD_FACEMAP)) {
/* XXX Not sure why those three are exception, maybe that should be fixed? */
!ELEM(layer->type, CD_PAINT_MASK, CD_FACEMAP, CD_MTEXPOLY)) {
keeplayer = false;
printf("%d\n", layer->type);
CLOG_WARN(&LOG, ".blend file read: removing a data layer that should not have been written");
}
}

View File

@ -1180,12 +1180,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* MTexPoly now removed. */
if (DNA_struct_find(fd->filesdna, "MTexPoly")) {
const int cd_mtexpoly = 15; /* CD_MTEXPOLY, deprecated */
for (Mesh *me = bmain->meshes.first; me; me = me->id.next) {
/* If we have UV's, so this file will have MTexPoly layers too! */
if (me->mloopuv != NULL) {
CustomData_update_typemap(&me->pdata);
CustomData_free_layers(&me->pdata, cd_mtexpoly, me->totpoly);
CustomData_free_layers(&me->pdata, CD_MTEXPOLY, me->totpoly);
BKE_mesh_update_customdata_pointers(me, false);
}
}

View File

@ -2282,7 +2282,6 @@ static void uvedit_unwrap_cube_project(BMesh *bm,
* component, but clusters all together around the center of map. */
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
/* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */
if (use_select && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
}

View File

@ -30,6 +30,8 @@
extern "C" {
#endif
#include "DNA_defs.h"
/** descriptor and storage for a custom data layer */
typedef struct CustomDataLayer {
/** Type of data in layer. */
@ -107,9 +109,11 @@ typedef enum CustomDataType {
CD_PROP_FLT = 10,
CD_PROP_INT = 11,
CD_PROP_STR = 12,
CD_ORIGSPACE = 13, /* for modifier stack face location mapping */
CD_ORCO = 14, /* undeformed vertex coordinates, normalized to 0..1 range */
/* CD_MTEXPOLY = 15, */ /* deprecated */
CD_ORIGSPACE = 13, /* for modifier stack face location mapping */
CD_ORCO = 14, /* undeformed vertex coordinates, normalized to 0..1 range */
#ifdef DNA_DEPRECATED
CD_MTEXPOLY = 15, /* deprecated */
#endif
CD_MLOOPUV = 16,
CD_MLOOPCOL = 17,
CD_TANGENT = 18,