Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/customdata.c
| Show First 20 Lines • Show All 5,098 Lines • ▼ Show 20 Lines | for (int i = 0; i < data->totlayer; i++) { | ||||
| } | } | ||||
| else if (layer->type == CD_GRID_PAINT_MASK) { | else if (layer->type == CD_GRID_PAINT_MASK) { | ||||
| write_grid_paint_mask(writer, count, layer->data); | write_grid_paint_mask(writer, count, layer->data); | ||||
| } | } | ||||
| else if (layer->type == CD_FACEMAP) { | else if (layer->type == CD_FACEMAP) { | ||||
| const int *layer_data = layer->data; | const int *layer_data = layer->data; | ||||
| BLO_write_raw(writer, sizeof(*layer_data) * count, layer_data); | BLO_write_raw(writer, sizeof(*layer_data) * count, layer_data); | ||||
| } | } | ||||
| else if (layer->type == CD_PROP_BOOL) { | |||||
| const bool *layer_data = layer->data; | |||||
| BLO_write_raw(writer, sizeof(*layer_data) * count, layer_data); | |||||
| } | |||||
| else { | else { | ||||
| const char *structname; | const char *structname; | ||||
| int structnum; | int structnum; | ||||
| CustomData_file_write_info(layer->type, &structname, &structnum); | CustomData_file_write_info(layer->type, &structname, &structnum); | ||||
| if (structnum) { | if (structnum) { | ||||
| int datasize = structnum * count; | int datasize = structnum * count; | ||||
| BLO_write_struct_array_by_name(writer, structname, datasize, layer->data); | BLO_write_struct_array_by_name(writer, structname, datasize, layer->data); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | while (i < data->totlayer) { | ||||
| if (layer->flag & CD_FLAG_EXTERNAL) { | if (layer->flag & CD_FLAG_EXTERNAL) { | ||||
| layer->flag &= ~CD_FLAG_IN_MEMORY; | layer->flag &= ~CD_FLAG_IN_MEMORY; | ||||
| } | } | ||||
| layer->flag &= ~CD_FLAG_NOFREE; | layer->flag &= ~CD_FLAG_NOFREE; | ||||
| if (CustomData_verify_versions(data, i)) { | if (CustomData_verify_versions(data, i)) { | ||||
| BLO_read_data_address(reader, &layer->data); | BLO_read_data_address(reader, &layer->data); | ||||
| if (layer->data == NULL) { | |||||
| /* Usually this should never happen, except when a custom data layer has not been written | |||||
| * to a file correctly. */ | |||||
| CLOG_WARN(&LOG, "Reallocating custom data layer that was not saved correctly."); | |||||
| const LayerTypeInfo *info = layerType_getInfo(layer->type); | |||||
| layer->data = MEM_calloc_arrayN((size_t)count, info->size, layerType_getName(layer->type)); | |||||
| if (info->set_default) { | |||||
| info->set_default(layer->data, count); | |||||
| } | |||||
| } | |||||
| if (layer->type == CD_MDISPS) { | if (layer->type == CD_MDISPS) { | ||||
| blend_read_mdisps(reader, count, layer->data, layer->flag & CD_FLAG_EXTERNAL); | blend_read_mdisps(reader, count, layer->data, layer->flag & CD_FLAG_EXTERNAL); | ||||
| } | } | ||||
| else if (layer->type == CD_GRID_PAINT_MASK) { | else if (layer->type == CD_GRID_PAINT_MASK) { | ||||
| blend_read_paint_mask(reader, count, layer->data); | blend_read_paint_mask(reader, count, layer->data); | ||||
| } | } | ||||
| i++; | i++; | ||||
| } | } | ||||
| } | } | ||||
| CustomData_update_typemap(data); | CustomData_update_typemap(data); | ||||
| } | } | ||||