15#define DNA_DEPRECATED_ALLOW
79#define CUSTOMDATA_GROW 5
104 return (((mask_required->
vmask & mask_ref->
vmask) == mask_required->
vmask) &&
165 void (*swap)(
void *
data,
const int *corner_indices);
182 bool (*
equal)(
const void *data1,
const void *data2);
185 void (*add)(
void *data1,
const void *data2);
187 void (*
copyvalue)(
const void *source,
void *dest,
int mixmode,
const float mixfactor);
213 memcpy(dest, source,
count * size);
215 for (i = 0; i <
count; i++) {
222 memcpy(dw, dvert->
dw, dvert->
totweight *
sizeof(*dw));
243 const float *weights,
250 struct MDeformWeight_Link {
251 MDeformWeight_Link *
next;
256 MDeformWeight_Link *dest_dwlink =
nullptr;
257 MDeformWeight_Link *
node;
261 for (
int i = 0; i <
count; i++) {
263 float interp_weight = weights[i];
265 for (
int j = 0; j < source->
totweight; j++) {
267 float weight = dw->
weight * interp_weight;
269 if (weight == 0.0f) {
273 for (node = dest_dwlink;
node; node = node->next) {
284 MDeformWeight_Link *tmp_dwlink =
static_cast<MDeformWeight_Link *
>(
285 alloca(
sizeof(*tmp_dwlink)));
286 tmp_dwlink->dw.def_nr = dw->
def_nr;
287 tmp_dwlink->dw.weight = weight;
290 tmp_dwlink->next = dest_dwlink;
291 dest_dwlink = tmp_dwlink;
301 if (dvert->
dw && (dvert->
totweight == totweight)) {
318 for (node = dest_dwlink;
node; node = node->next, i++) {
319 if (node->dw.weight > 1.0f) {
320 node->dw.weight = 1.0f;
322 dvert->
dw[i] = node->dw;
326 memset(dvert, 0,
sizeof(*dvert));
342 const float *weights,
350 float no[3] = {0.0f};
353 madd_v3_v3fl(no, (
const float *)sources[i], weights[i]);
363 const float mixfactor)
365 const float *no_src = (
const float *)source;
366 float *no_dst = (
float *)dest;
408 for (
int i = 0; i <
count; i++) {
409 dest_tf[i] = source_tf[i];
414 const float *weights,
415 const float *sub_weights,
420 float uv[4][2] = {{0.0f}};
422 const float *sub_weight = sub_weights;
423 for (
int i = 0; i <
count; i++) {
424 const float interp_weight = weights[i];
425 const MTFace *src =
static_cast<const MTFace *
>(sources[i]);
427 for (
int j = 0; j < 4; j++) {
429 for (
int k = 0; k < 4; k++, sub_weight++) {
440 *tf = *(
MTFace *)(*sources);
441 memcpy(tf->
uv, uv,
sizeof(tf->
uv));
449 for (
int j = 0; j < 4; j++) {
450 const int source_index = corner_indices[j];
454 memcpy(tf->
uv, uv,
sizeof(tf->
uv));
459 static MTFace default_tf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}};
462 for (
int i = 0; i <
count; i++) {
484 const float *weights,
490 for (
int i = 0; i <
count; i++) {
491 const float interp_weight = weights[i];
492 const float src = *(
const float *)sources[i];
493 result += src * interp_weight;
495 *(
float *)dest = result;
501 bool has_errors =
false;
503 for (
int i = 0; i < totitems; i++, fp++) {
504 if (!isfinite(fp->
f)) {
522 const float *weights,
529 const float weight = weights[i];
530 const float src = *
static_cast<const int *
>(sources[i]);
531 result += src * weight;
533 const int rounded_result =
int(round(result));
534 *
static_cast<int *
>(dest) = rounded_result;
559 for (
int i = 0; i <
count; i++) {
560 dest_tf[i] = source_tf[i];
565 const float *weights,
566 const float *sub_weights,
571 float uv[4][2] = {{0.0f}};
573 const float *sub_weight = sub_weights;
574 for (
int i = 0; i <
count; i++) {
575 const float interp_weight = weights[i];
578 for (
int j = 0; j < 4; j++) {
580 for (
int k = 0; k < 4; k++, sub_weight++) {
591 memcpy(osf->
uv, uv,
sizeof(osf->
uv));
599 for (
int j = 0; j < 4; j++) {
602 memcpy(osf->
uv, uv,
sizeof(osf->
uv));
607 static OrigSpaceFace default_osf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}};
610 for (
int i = 0; i <
count; i++) {
611 osf[i] = default_osf;
626 int nverts = (ci[1] == 3) ? 4 : 3;
628 int cornersize = s->totdisp / corners;
630 if (corners != nverts) {
635 s->totdisp = (s->totdisp / corners) * nverts;
642 for (
int S = 0; S < corners; S++) {
643 memcpy(d + cornersize * S, s->disps + cornersize * ci[S],
sizeof(
float[3]) * cornersize);
656 for (
int i = 0; i <
count; i++) {
662 d[i].
disps =
nullptr;
668 d[i].
level = s[i].level;
691 for (
int i = 0; i <
count; i++) {
696 if (!
cdf_read_data(cdf,
sizeof(
float[3]) * d[i].totdisp, d[i].disps)) {
697 CLOG_ERROR(&
LOG,
"failed to read multires displacement %d/%d %d", i,
count, d[i].totdisp);
709 for (
int i = 0; i <
count; i++) {
710 if (!
cdf_write_data(cdf,
sizeof(
float[3]) * d[i].totdisp, d[i].disps)) {
711 CLOG_ERROR(&
LOG,
"failed to write multires displacement %d/%d %d", i,
count, d[i].totdisp);
724 for (
int i = 0; i <
count; i++) {
725 size +=
sizeof(
float[3]) * d[i].totdisp;
740 const int size =
sizeof(
void *);
742 for (
int i = 0; i <
count; i++) {
757 for (
int i = 0; i <
count; i++) {
776 for (
int i = 0; i <
count; i++) {
779 d[i].
level = s[i].level;
810 const float mixfactor)
838 uchar src[4] = {m1->
r, m1->
g, m1->
b, m1->
a};
839 uchar dst[4] = {m2->
r, m2->
g, m2->
b, m2->
a};
854 memcpy(tmp_col, src,
sizeof(tmp_col));
859 m2->
r = char(dst[0]);
860 m2->
g = char(dst[1]);
861 m2->
b = char(dst[2]);
862 m2->
a = char(dst[3]);
877 return r * r + g * g +
b *
b + a * a < 0.001f;
951 MLoopCol default_mloopcol = {255, 255, 255, 255};
953 for (
int i = 0; i <
count; i++) {
954 mlcol[i] = default_mloopcol;
959 const float *weights,
972 for (
int i = 0; i <
count; i++) {
973 const float interp_weight = weights[i];
975 col.
r += src->
r * interp_weight;
976 col.g += src->
g * interp_weight;
977 col.b += src->
b * interp_weight;
978 col.a += src->
a * interp_weight;
1050 const float *weights,
1058 for (
int i = 0; i <
count; i++) {
1059 const float interp_weight = weights[i];
1070 const float *weights,
1071 const float *sub_weights,
1075 MCol *mc =
static_cast<MCol *
>(dest);
1081 }
col[4] = {{0.0f}};
1083 const float *sub_weight = sub_weights;
1084 for (
int i = 0; i <
count; i++) {
1085 const float interp_weight = weights[i];
1087 for (
int j = 0; j < 4; j++) {
1089 const MCol *src =
static_cast<const MCol *
>(sources[i]);
1090 for (
int k = 0; k < 4; k++, sub_weight++, src++) {
1091 const float w = (*sub_weight) * interp_weight;
1093 col[j].r += src->
r *
w;
1094 col[j].g += src->
g *
w;
1095 col[j].b += src->
b *
w;
1099 const MCol *src =
static_cast<const MCol *
>(sources[i]);
1100 col[j].
a += src[j].
a * interp_weight;
1101 col[j].r += src[j].
r * interp_weight;
1102 col[j].g += src[j].
g * interp_weight;
1103 col[j].b += src[j].
b * interp_weight;
1109 for (
int j = 0; j < 4; j++) {
1125 for (
int j = 0; j < 4; j++) {
1126 col[j] = mcol[corner_indices[j]];
1129 memcpy(mcol,
col,
sizeof(
col));
1134 static MCol default_mcol = {255, 255, 255, 255};
1137 for (
int i = 0; i < 4 *
count; i++) {
1138 mcol[i] = default_mcol;
1148 const float *weights,
1153 float **in = (
float **)sources;
1162 for (
int i = 0; i <
count; i++) {
1163 const float interp_weight = weights[i];
1181 for (
int i = 0; i <
count; i++) {
1193 const float *weights,
1201 for (
int i = 0; i <
count; i++) {
1202 const float interp_weight = weights[i];
1211 vs_dst->
flag &= ~MVERT_SKIN_ROOT;
1222 short(*flnors)[4][3] =
static_cast<short(*)[4][3]
>(
data);
1230 memcpy(flnors, nors,
sizeof(nors));
1242 const float mixfactor)
1280 memcpy(tmp_col, m1->
color,
sizeof(tmp_col));
1292 for (
int i = 0; i < 4; i++) {
1297 return tot < 0.001f;
1333 MPropCol default_propcol = {{1.0f, 1.0f, 1.0f, 1.0f}};
1335 for (
int i = 0; i <
count; i++) {
1341 const float *weights,
1347 float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
1348 for (
int i = 0; i <
count; i++) {
1349 const float interp_weight = weights[i];
1363 const float *weights,
1368 vec3f result = {0.0f, 0.0f, 0.0f};
1369 for (
int i = 0; i <
count; i++) {
1370 const float interp_weight = weights[i];
1371 const vec3f *src =
static_cast<const vec3f *
>(sources[i]);
1388 const vec3f *vec2 =
static_cast<const vec3f *
>(data2);
1396 float *values =
static_cast<float *
>(
data);
1397 bool has_errors =
false;
1398 for (
int i = 0; i < totitems * 3; i++) {
1399 if (!isfinite(values[i])) {
1416 const float *weights,
1421 vec2f result = {0.0f, 0.0f};
1422 for (
int i = 0; i <
count; i++) {
1423 const float interp_weight = weights[i];
1424 const vec2f *src =
static_cast<const vec2f *
>(sources[i]);
1440 const vec2f *vec2 =
static_cast<const vec2f *
>(data2);
1447 float *values =
static_cast<float *
>(
data);
1448 bool has_errors =
false;
1449 for (
int i = 0; i < totitems * 2; i++) {
1450 if (!isfinite(values[i])) {
1485 const float mixfactor)
1487 const float2 &a = *
static_cast<const float2 *
>(source);
1507 const float *weights,
1512 bool result =
false;
1513 for (
int i = 0; i <
count; i++) {
1514 const float interp_weight = weights[i];
1515 const bool src = *(
const bool *)sources[i];
1516 result |= src && (interp_weight > 0.0f);
1518 *(
bool *)dest = result;
1534 const float *weights,
1542 Quaternion::identity());
1544 for (
int i = 0; i <
count; i++) {
1545 const float interp_weight = weights[i];
1546 const Quaternion *src =
static_cast<const Quaternion *
>(sources[i]);
1547 mixer.mix_in(0, *src, interp_weight);
1550 *
static_cast<Quaternion *
>(dest) = result;
1693 {
sizeof(
int),
alignof(
int),
""},
1752 {
sizeof(
int),
alignof(
int),
"", 0,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr},
1754 {
sizeof(MLoopUV),
alignof(MLoopUV),
"MLoopUV", 1,
N_(
"UVMap")},
1816 N_(
"4 by 4 Float Matrix"),
1881 N_(
"NGon Face-Vertex"),
1888 {
sizeof(
int),
alignof(
int),
"", 0,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr},
1901 {
sizeof(
float),
alignof(
float),
""},
1935 {
sizeof(
float),
alignof(
float),
"", 0,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr},
1993 {
sizeof(
short[4][3]),
1994 alignof(
short[4][3]),
2015 {
sizeof(
int),
alignof(
int),
""},
2174 "CDMStringProperty",
2205 "CDCustomLoopNormal",
2206 "CDSculptFaceGroups",
2348 std::optional<eCDAllocType> alloctype,
2349 void *layer_data_to_assign,
2359 data->typemap[i] = -1;
2362 for (
int i = 0; i < data->totlayer; i++) {
2364 if (type != lasttype) {
2365 data->typemap[type] = i;
2377 return (memcmp(data->typemap, data_copy.
typemap,
sizeof(data->typemap)) == 0);
2386 if (type_info.
copy) {
2387 type_info.
copy(data, new_data, totelem);
2390 memcpy(new_data, data, size_in_bytes);
2398 if (type_info.
free) {
2399 type_info.
free(
const_cast<void *
>(data), totelem);
2406 const eCustomDataMask mask,
2407 const std::optional<eCDAllocType> alloctype,
2410 bool changed =
false;
2413 int last_active = 0;
2414 int last_render = 0;
2417 int current_type_layer_count = 0;
2418 int max_current_type_layer_count = -1;
2420 for (
int i = 0; i < source->
totlayer; i++) {
2423 const int src_layer_flag = src_layer.
flag;
2425 if (type != last_type) {
2428 current_type_layer_count = layernum_dst;
2430 last_active = src_layer.
active;
2437 current_type_layer_count++;
2448 if ((max_current_type_layer_count != -1) &&
2449 (current_type_layer_count >= max_current_type_layer_count))
2459 void *layer_data_to_assign =
nullptr;
2461 if (!alloctype.has_value()) {
2462 if (src_layer.
data !=
nullptr) {
2469 layer_data_to_assign = src_layer.
data;
2478 layer_data_to_assign,
2479 sharing_info_to_assign,
2483 new_layer->
uid = src_layer.
uid;
2485 new_layer->
active = last_active;
2498 eCustomDataMask mask,
2506 const eCustomDataMask mask,
2514 const eCustomDataMask mask)
2524 dst_layers.
append(layer);
2555 void delete_self_with_data()
override
2557 if (data_ !=
nullptr) {
2563 void delete_data_only()
override
2576 return MEM_new<CustomDataLayerImplicitSharing>(__func__, data, totelem, type);
2584 if (layer.data ==
nullptr) {
2587 if (layer.sharing_info ==
nullptr) {
2591 if (layer.sharing_info->is_mutable()) {
2592 layer.sharing_info->tag_ensured_mutable();
2596 const void *old_data = layer.data;
2600 layer.sharing_info->remove_user_and_delete_if_last();
2607 if (layer.sharing_info ==
nullptr) {
2610 return layer.sharing_info->is_mutable();
2620 for (
const int i :
IndexRange(data->totlayer)) {
2631 for (
int i = 0; i < data->totlayer; i++) {
2639 if (old_size_in_bytes) {
2640 if (typeInfo->
copy) {
2641 typeInfo->
copy(layer->data, new_layer_data, std::min(old_size, new_size));
2645 memcpy(new_layer_data, layer->data, std::min(old_size_in_bytes, new_size_in_bytes));
2649 if (layer->sharing_info) {
2650 layer->sharing_info->remove_user_and_delete_if_last();
2651 layer->sharing_info =
nullptr;
2654 layer->data = new_layer_data;
2660 if (new_size > old_size) {
2661 const int new_elements_num = new_size - old_size;
2662 void *new_elements_begin =
POINTER_OFFSET(layer->data, old_size_in_bytes);
2663 switch (alloctype) {
2667 typeInfo->
construct(new_elements_begin, new_elements_num);
2676 memset(new_elements_begin, 0, typeInfo->
size * new_elements_num);
2687 eCustomDataMask mask,
2701 eCustomDataMask mask,
2717 if (layer->sharing_info ==
nullptr) {
2723 layer->sharing_info->remove_user_and_delete_if_last();
2724 layer->sharing_info =
nullptr;
2730 if (data->external) {
2732 data->external =
nullptr;
2738 memset(data, 0,
sizeof(*data));
2744 for (
int i = 0; i < data->totlayer; i++) {
2758 for (
int i = 0; i < data->totlayer; i++) {
2779 for (
int i = 0; i < data->totlayer; i++) {
2782 data->layers[i].offset = offset;
2783 offset += typeInfo->
size;
2786 data->totsize = offset;
2794 for (
int i = 0; i < data->totlayer; i++) {
2795 if (data->layers[i].type == type) {
2809 return data->typemap[type];
2819 i = (i + n < data->totlayer && data->layers[i + n].type == type) ? (i + n) : (-1);
2829 for (
int i = 0; i < data->totlayer; i++) {
2830 if (data->layers[i].type == type) {
2831 if (data->layers[i].name == name) {
2842 for (
int i = 0; i < data->totlayer; i++) {
2843 if (data->layers[i].name == name) {
2853 const int layer_index = data->typemap[type];
2855 return (layer_index != -1) ? layer_index + data->layers[layer_index].active : -1;
2860 const int layer_index = data->typemap[type];
2862 return (layer_index != -1) ? layer_index + data->layers[layer_index].active_rnd : -1;
2867 const int layer_index = data->typemap[type];
2869 return (layer_index != -1) ? layer_index + data->layers[layer_index].active_clone : -1;
2874 const int layer_index = data->typemap[type];
2876 return (layer_index != -1) ? layer_index + data->layers[layer_index].active_mask : -1;
2887 const int layer_index = data->typemap[type];
2889 return (named_index != -1) ? named_index - layer_index : -1;
2894 const int layer_index = data->typemap[type];
2896 return (layer_index != -1) ? data->layers[layer_index].active : -1;
2901 const int layer_index = data->typemap[type];
2903 return (layer_index != -1) ? data->layers[layer_index].active_rnd : -1;
2908 const int layer_index = data->typemap[type];
2910 return (layer_index != -1) ? data->layers[layer_index].active_clone : -1;
2915 const int layer_index = data->typemap[type];
2917 return (layer_index != -1) ? data->layers[layer_index].active_mask : -1;
2924 return layer_index < 0 ? nullptr : data->layers[layer_index].name;
2930 return layer_index < 0 ? nullptr : data->layers[layer_index].name;
2938 for (
int i = 0; i < data->totlayer; i++) {
2939 if (data->layers[i].type == type) {
2941 data->layers[i].active = n;
2951 for (
int i = 0; i < data->totlayer; i++) {
2952 if (data->layers[i].type == type) {
2954 data->layers[i].active_rnd = n;
2964 for (
int i = 0; i < data->totlayer; i++) {
2965 if (data->layers[i].type == type) {
2967 data->layers[i].active_clone = n;
2977 for (
int i = 0; i < data->totlayer; i++) {
2978 if (data->layers[i].type == type) {
2980 data->layers[i].active_mask = n;
2990 const int layer_index = n - data->typemap[type];
2993 for (
int i = 0; i < data->totlayer; i++) {
2994 if (data->layers[i].type == type) {
2996 data->layers[i].active = layer_index;
3006 const int layer_index = n - data->typemap[type];
3009 for (
int i = 0; i < data->totlayer; i++) {
3010 if (data->layers[i].type == type) {
3012 data->layers[i].active_rnd = layer_index;
3022 const int layer_index = n - data->typemap[type];
3025 for (
int i = 0; i < data->totlayer; i++) {
3026 if (data->layers[i].type == type) {
3028 data->layers[i].active_clone = layer_index;
3038 const int layer_index = n - data->typemap[type];
3041 for (
int i = 0; i < data->totlayer; i++) {
3042 if (data->layers[i].type == type) {
3044 data->layers[i].active_mask = layer_index;
3051 for (
int i = 0; i < data->totlayer; i++) {
3052 if (data->layers[i].type == type) {
3053 data->layers[i].flag |=
flag;
3060 const int nflag = ~flag;
3062 for (
int i = 0; i < data->totlayer; i++) {
3063 if (data->layers[i].type == type) {
3064 data->layers[i].flag &= nflag;
3082 data->maxlayer += grow_amount;
3088 const std::optional<eCDAllocType> alloctype,
3089 void *layer_data_to_assign,
3105 int index = data->totlayer;
3106 if (index >= data->maxlayer) {
3113 for (; index > 0 && data->layers[index - 1].type > type; index--) {
3114 data->layers[index] = data->layers[index - 1];
3127 if (alloctype.has_value()) {
3128 switch (*alloctype) {
3137 memset(new_layer.
data, 0, size_in_bytes);
3154 if (totelem == 0 && sharing_info_to_assign ==
nullptr) {
3158 new_layer.
data = layer_data_to_assign;
3171 new_layer.
type = type;
3181 if (!name.is_empty()) {
3182 name.copy(new_layer.
name);
3186 new_layer.
name[0] =
'\0';
3189 if (index > 0 && data->layers[index - 1].type == type) {
3190 new_layer.
active = data->layers[index - 1].active;
3191 new_layer.
active_rnd = data->layers[index - 1].active_rnd;
3192 new_layer.
active_clone = data->layers[index - 1].active_clone;
3193 new_layer.
active_mask = data->layers[index - 1].active_mask;
3204 return &data->layers[index];
3215 data, type, alloctype,
nullptr,
nullptr, totelem, typeInfo->
defaultname);
3234 data, type, std::nullopt, layer_data, sharing_info, totelem, typeInfo->
defaultname);
3251 data, type, alloctype,
nullptr,
nullptr, totelem, name);
3268 data, type, std::nullopt, layer_data, sharing_info, totelem, name);
3283 const int n = index - index_first;
3286 if ((index_first == -1) || (n < 0)) {
3289 BLI_assert(data->layers[index].type == type);
3293 for (
int i = index + 1; i < data->totlayer; i++) {
3294 data->layers[i - 1] = data->layers[i];
3304 const int index_nonzero = n ? n : 1;
3307 for (layer = &data->layers[i]; i < data->totlayer && layer->type == type; i++, layer++) {
3308 if (layer->active >= index_nonzero) {
3311 if (layer->active_rnd >= index_nonzero) {
3312 layer->active_rnd--;
3314 if (layer->active_clone >= index_nonzero) {
3315 layer->active_clone--;
3317 if (layer->active_mask >= index_nonzero) {
3318 layer->active_mask--;
3334 for (
const int i :
IndexRange(data->totlayer)) {
3377 for (
int i = 0; i < data->totlayer; i++) {
3378 if (data->layers[i].type == type) {
3390 for (
int i = 0; i < data->totlayer; i++) {
3391 if (data->layers[i].type == type &&
3405 for (
int i = 0; i < data->totlayer; i++) {
3416 for (
int i = 0; i < data->totlayer; i++) {
3430 if (typeInfo->
copy) {
3431 typeInfo->
copy(src_data_ofs, dst_data_ofs,
count);
3434 memcpy(dst_data_ofs, src_data_ofs,
size_t(
count) * typeInfo->
size);
3440 const int src_layer_index,
3441 const int dst_layer_index,
3442 const int src_index,
3443 const int dst_index,
3450 const void *src_data = source->
layers[src_layer_index].
data;
3451 void *dst_data = dest->
layers[dst_layer_index].
data;
3455 const size_t src_offset = size_t(src_index) * typeInfo->
size;
3456 const size_t dst_offset = size_t(dst_index) * typeInfo->
size;
3458 if (!
count || !src_data || !dst_data) {
3459 if (
count && !(src_data ==
nullptr && dst_data ==
nullptr)) {
3461 "null data for %s type (%p --> %p), skipping",
3469 if (typeInfo->
copy) {
3482 const int source_index,
3483 const int dest_index,
3487 for (
int src_i = 0; src_i < source->
totlayer; src_i++) {
3501 const int source_index,
3502 const int dest_index,
3507 for (
int src_i = 0; src_i < source->
totlayer; src_i++) {
3538 int destination_index,
3542 if (source_layer_index == -1) {
3546 if (destinaiton_layer_index == -1) {
3552 destinaiton_layer_index,
3560 for (
int i = 0; i < data->totlayer; i++) {
3563 if (typeInfo->
free) {
3564 size_t offset = size_t(index) * typeInfo->
size;
3572#define SOURCE_BUF_SIZE 100
3576 const int *src_indices,
3577 const float *weights,
3578 const float *sub_weights,
3587 const void **sources = source_buf;
3596 float *default_weights =
nullptr;
3597 if (weights ==
nullptr) {
3599 static_cast<float *
>(
3601 default_weights_buf;
3603 weights = default_weights;
3608 for (
int src_i = 0; src_i < source->
totlayer; src_i++) {
3630 for (
int j = 0; j <
count; j++) {
3652 if (!
ELEM(default_weights,
nullptr, default_weights_buf)) {
3659 for (
int i = 0; i < data->totlayer; i++) {
3662 if (typeInfo->
swap) {
3663 const size_t offset = size_t(index) * typeInfo->
size;
3698 if (layer_index == -1) {
3702 return data->layers[layer_index].data;
3710 if (layer_index == -1) {
3721 if (layer_index == -1) {
3724 return data->layers[layer_index].data;
3733 if (layer_index == -1) {
3746 if (layer_index == -1) {
3749 return data->layers[layer_index].data;
3758 if (layer_index == -1) {
3769 if (layer_index == -1) {
3772 return data->layers[layer_index].offset;
3778 if (layer_index == -1) {
3782 return data->layers[layer_index].offset;
3790 if (layer_index == -1) {
3794 return data->layers[layer_index].offset;
3803 if (layer_index == -1) {
3807 name.copy(data->layers[layer_index].name);
3818 return (layer_index == -1) ? nullptr : data->layers[layer_index].name;
3850 if (data->totlayer) {
3857 eCustomDataMask mask,
3909 dest->
pool =
nullptr;
3917 void *tmp =
nullptr;
3932 void *tmp =
nullptr;
3951 if (*block ==
nullptr) {
3955 for (
int i = 0; i < data->totlayer; i++) {
3958 if (typeInfo->
free) {
3959 int offset = data->layers[i].offset;
3964 if (data->totsize) {
3973 if (block ==
nullptr) {
3976 for (
int i = 0; i < data->totlayer; i++) {
3978 if (typeInfo->
free) {
3979 const size_t offset = data->layers[i].offset;
3983 if (data->totsize) {
3984 memset(block, 0, data->totsize);
3994 if (data->totsize > 0) {
4004 const eCustomDataMask mask_exclude)
4006 if (block ==
nullptr) {
4009 for (
int i = 0; i < data->totlayer; i++) {
4012 const size_t offset = data->layers[i].offset;
4013 if (typeInfo->
free) {
4028 memset(elem, 0, typeInfo->
size);
4034 const int offset = data->layers[n].offset;
4041 if (*block ==
nullptr) {
4045 for (
int i = 0; i < data->totlayer; i++) {
4052 const eCustomDataMask mask_exclude)
4056 const int dst_offset = layer_dst.offset;
4066 map.trivial_defaults.append({type_info.
size, dst_offset});
4070 if (type_info.
copy) {
4071 map.copies.append({type_info.
copy, src_offset, dst_offset});
4076 map.trivial_copies.append({type_info.
size, src_offset, dst_offset});
4080 if (type_info.
free) {
4081 map.free.append({type_info.
free, dst_offset});
4089 const void *src_block,
4115 memset(
POINTER_OFFSET(*dst_block, info.dst_offset), 0, info.size);
4133 if (data.totsize == 0) {
4140 const int offset = layer.offset;
4154 if (layer_index == -1) {
4167 if (layer_index == -1) {
4171 return POINTER_OFFSET(block, data->layers[layer_index + n].offset);
4176 if (n < 0 || n >= data->totlayer) {
4210 for (
int i = 0; i < data->totlayer; i++) {
4221 for (
int i = 0; i < data->totlayer; i++) {
4223 if (typeInfo->
free) {
4233 for (
int i = 0; i < data->totlayer; i++) {
4250 if (typeInfo->
copy) {
4251 typeInfo->
copy(source, dest, 1);
4254 memcpy(dest, source, typeInfo->
size);
4262 const float mixfactor)
4271 typeInfo->
copyvalue(source, dest, mixmode, mixfactor);
4275 memcpy(dest, source, typeInfo->
size);
4283 if (typeInfo->
equal) {
4284 return typeInfo->
equal(data1, data2);
4287 return !memcmp(data1, data2, typeInfo->
size);
4321 if (typeInfo->
add) {
4322 typeInfo->
add(data1, data2);
4336 if (typeInfo->
copy) {
4337 typeInfo->
copy(source, dest, 1);
4340 memcpy(dest, source, typeInfo->
size);
4345 const void **src_blocks_ofs,
4346 const float *weights,
4347 const float *sub_weights,
4349 void *dst_block_ofs,
4358 typeInfo->
interp(src_blocks_ofs, weights, sub_weights,
count, dst_block_ofs);
4362 const void **src_blocks,
4363 const float *weights,
4364 const float *sub_weights,
4373 const void **sources = (
const void **)source_buf;
4382 float *default_weights =
nullptr;
4383 if (weights ==
nullptr) {
4386 default_weights_buf;
4388 weights = default_weights;
4392 for (
int i = 0; i < data->totlayer; i++) {
4396 for (
int j = 0; j <
count; j++) {
4407 if (!
ELEM(default_weights,
nullptr, default_weights_buf)) {
4413 const char **r_struct_name,
4433 if (skip_names.
contains(layer.name)) {
4436 layers_to_write.
append(layer);
4438 data.totlayer = layers_to_write.
size();
4439 data.maxlayer = data.totlayer;
4445 if (!data.layers && layers_to_write.
size() > 0) {
4455 return typeInfo->
size;
4473 return (typeInfo->
free !=
nullptr);
4497 for (
int i = 0; i < data->totlayer; i++) {
4507 if (i != index && layer->type == type && layer->name == name) {
4531 if (name.startswith(
".")) {
4537 if (name.startswith(prefix)) {
4559 if (nlayer->
name[0] ==
'\0') {
4563 const char *defname =
"";
4575 if (!name.is_empty()) {
4588 name.copy(name_c_str);
4597 bool keeplayer =
true;
4605 if (!typeInfo->
defaultname && (index > 0) && data->layers[index - 1].type == layer->type) {
4622 CD_SCULPT_FACE_SETS,
4626 CLOG_WARN(&
LOG,
".blend file read: removing a data layer that should not have been written");
4631 for (
int i = index + 1; i < data->totlayer; i++) {
4632 data->layers[i - 1] = data->layers[i];
4646 if (layer->data ||
count == 0) {
4650 switch (layer->type) {
4670 CLOG_WARN(&
LOG,
"CustomDataLayer->data is null for type %d.", layer->
type);
4689 if (typeInfo->
validate !=
nullptr) {
4690 return typeInfo->
validate(layer->data, totitems, do_fixes);
4712 for (
int i = 0; i < data->totlayer; i++) {
4720 if (typeInfo->
free) {
4721 typeInfo->
free(layer->data, totelem);
4723 layer->flag &= ~CD_FLAG_IN_MEMORY;
4739 for (
int i = 0; i < data->totlayer; i++) {
4740 layer = &data->layers[i];
4764 "Failed to read %s layer from %s.",
4770 for (
int i = 0; i < data->totlayer; i++) {
4771 layer = &data->layers[i];
4785 if (typeInfo->
read(cdf, layer->data, totelem)) {
4805 CustomData *data,
ID *
id, eCustomDataMask mask,
const int totelem,
const int free)
4816 for (
int i = 0; i < data->totlayer; i++) {
4838 for (
int i = 0; i < data->totlayer; i++) {
4845 cdf, layer->
type, layer->name, typeInfo->
filesize(cdf, layer->data, totelem));
4855 CLOG_ERROR(&
LOG,
"Failed to open %s for writing.", filepath);
4861 for (i = 0; i < data->totlayer; i++) {
4869 if (typeInfo->
write(cdf, layer->data, totelem)) {
4882 if (i != data->totlayer) {
4889 for (i = 0; i < data->totlayer; i++) {
4895 if (typeInfo->
free) {
4896 typeInfo->
free(layer->data, totelem);
4898 layer->flag &= ~CD_FLAG_IN_MEMORY;
4911 const char *filepath)
4916 if (layer_index == -1) {
4927 external = MEM_cnew<CustomDataExternal>(__func__);
4928 data->external = external;
4943 if (layer_index == -1) {
4958 layer->flag &= ~CD_FLAG_EXTERNAL;
4965 if (layer_index == -1) {
4981#define COPY_BIT_FLAG(_type, _dst, _src, _f) \
4983 const _type _val = *((_type *)(_src)) & (_type)(_f); \
4984 *((_type *)(_dst)) &= ~(_type)(_f); \
4985 *((_type *)(_dst)) |= _val; \
4989 switch (data_size) {
5012 switch (data_size) {
5029 const void **sources,
5030 const float *weights,
5032 const float mix_factor)
5041 int best_src_idx = 0;
5043 const int data_type = laymap->
data_type;
5044 const int mix_mode = laymap->
mix_mode;
5057 if (
int(data_type) &
CD_FAKE) {
5063 data_size = size_t(type_info->
size);
5064 interp_cd = type_info->
interp;
5065 copy_cd = type_info->
copy;
5070 if (
count > 1 && !interp_cd) {
5074 float tot_weight_true = 0.0f;
5075 int item_true_idx = -1, item_false_idx = -1;
5077 for (
int i = 0; i <
count; i++) {
5079 tot_weight_true += weights[i];
5086 best_src_idx = (tot_weight_true >= 0.5f) ? item_true_idx : item_false_idx;
5090 float max_weight = 0.0f;
5092 for (
int i = 0; i <
count; i++) {
5093 if (weights[i] > max_weight) {
5094 max_weight = weights[i];
5104 interp_cd(sources, weights,
nullptr,
count, tmp_dst);
5106 else if (data_flag) {
5107 copy_bit_flag(tmp_dst, sources[best_src_idx], data_size, data_flag);
5111 copy_cd(sources[best_src_idx], tmp_dst, 1);
5114 memcpy(tmp_dst, sources[best_src_idx], data_size);
5129 else if (!(
int(data_type) &
CD_FAKE)) {
5135 if (mix_factor >= 0.5f) {
5136 memcpy(data_dst, tmp_dst, data_size);
5145 const void **sources,
5146 const float *weights,
5148 const float mix_factor)
5155 const int mix_mode = laymap->
mix_mode;
5169 interp_cd(sources, weights,
nullptr,
count, tmp_dst);
5170 if (space_transform) {
5182 const int totelem = me_remap->
items_num;
5184 const int data_type = laymap->
data_type;
5185 const void *data_src = laymap->
data_src;
5194 size_t tmp_buff_size = 32;
5195 const void **tmp_data_src =
nullptr;
5204 tmp_buff_size,
sizeof(*tmp_data_src), __func__);
5207 if (
int(data_type) &
CD_FAKE) {
5216 data_size = size_t(type_info->
size);
5223 for (
int i = 0; i < totelem; i++, data_dst =
POINTER_OFFSET(data_dst, data_step), mapit++) {
5225 const float mix_factor = laymap->
mix_factor *
5234 if (
UNLIKELY(sources_num > tmp_buff_size)) {
5235 tmp_buff_size = size_t(sources_num);
5236 tmp_data_src = (
const void **)
MEM_reallocN((
void *)tmp_data_src,
5237 sizeof(*tmp_data_src) * tmp_buff_size);
5240 for (
int j = 0; j < sources_num; j++) {
5241 const size_t src_idx = size_t(mapit->
indices_src[j]);
5242 tmp_data_src[j] =
POINTER_OFFSET(data_src, (data_step * src_idx) + data_offset);
5270 for (
int i = 0; i <
count; i++) {
5271 const MDisps *md = &mdlist[i];
5291 if (grid_paint_mask) {
5293 for (
int i = 0; i <
count; i++) {
5307 switch (layer.type) {
5323 "bool type is expected to have the same size as uint8_t")
5327 const char *structname;
5330 if (structnum > 0) {
5331 int datasize = structnum *
count;
5335 printf(
"%s error: layer '%s':%d - can't be written to file\n",
5348 eCustomDataMask cddata_mask,
5361 BLO_write_shared(writer, layer.data, size_in_bytes, layer.sharing_info, [&]() {
5362 blend_write_layer_data(writer, layer, count);
5366 if (data->external) {
5377 for (
int i = 0; i <
count; i++) {
5394 if (!external && !md.
disps) {
5405 if (grid_paint_mask) {
5406 for (
int i = 0; i <
count; i++) {
5418 switch (layer.type) {
5437 "bool type is expected to have the same size as uint8_t")
5441 const char *structname;
5444 if (structnum > 0) {
5445 const int data_num = structnum *
count;
5461 "Allocated custom data layer that was not saved correctly for layer.type = %d.",
5472 if (
UNLIKELY(
count == 0 && data->layers ==
nullptr && data->totlayer != 0)) {
5480 while (i < data->totlayer) {
5484 layer->
flag &= ~CD_FLAG_IN_MEMORY;
5486 layer->sharing_info =
nullptr;
5491 blend_read_layer_data(reader, *layer, count);
5492 if (layer->data == nullptr) {
5505 data->maxlayer = data->totlayer;
5529 const char *structname;
5534 "%sdict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n",
5568 return std::nullopt;
5584 return std::nullopt;
5605 shared_memory.
add(totelem * elem_size);
CustomData interface, see also DNA_customdata_types.h.
void(*)( const void **sources, const float *weights, const float *sub_weights, int count, void *dest) cd_interp
@ CDT_MIX_REPLACE_BELOW_THRESHOLD
@ CDT_MIX_REPLACE_ABOVE_THRESHOLD
void(*)(const CustomDataTransferLayerMap *laymap, void *dest, const void **sources, const float *weights, int count, float mix_factor) cd_datatransfer_interp
void(*)(void *data, int count) cd_set_default_value
void(*)(void *data, int count) cd_free
void(*)(const void *source, void *dest, int count) cd_copy
bool(*)(void *item, uint totitems, bool do_fixes) cd_validate
#define CD_TYPE_AS_MASK(_type)
CDataFile * cdf_create(int type)
bool cdf_read_layer(CDataFile *cdf, const CDataFileLayer *blay)
bool cdf_write_open(CDataFile *cdf, const char *filepath)
bool cdf_read_data(CDataFile *cdf, unsigned int size, void *data)
bool cdf_write_data(CDataFile *cdf, unsigned int size, const void *data)
CDataFileLayer * cdf_layer_find(CDataFile *cdf, int type, const char *name)
void cdf_read_close(CDataFile *cdf)
CDataFileLayer * cdf_layer_add(CDataFile *cdf, int type, const char *name, size_t datasize)
void cdf_write_close(CDataFile *cdf)
void cdf_free(CDataFile *cdf)
bool cdf_write_layer(CDataFile *cdf, CDataFileLayer *blay)
bool cdf_read_open(CDataFile *cdf, const char *filepath)
int multires_mdisp_corners(const MDisps *s)
int BKE_ccg_gridsize(int level)
@ VOLUME_GRID_VECTOR_FLOAT
#define BLI_assert_unreachable()
#define BLI_STATIC_ASSERT(a, msg)
#define BLI_assert_msg(a, msg)
#define BLI_BITMAP_SIZE(_num)
A dynamically sized string ADT.
void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format,...) ATTR_PRINTF_FORMAT(2
void BLI_kdtree_nd_ free(KDTree *tree)
MINLINE unsigned char round_fl_to_uchar_clamp(float a)
MINLINE void blend_color_add_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_sub_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_mul_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_mul_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_sub_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_add_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_mix_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_interpolate_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], float ft)
MINLINE void blend_color_interpolate_float(float dst[4], const float src1[4], const float src2[4], float t)
void BLI_space_transform_invert_normal(const struct SpaceTransform *data, float no[3])
MINLINE void mul_v4_fl(float r[4], float f)
MINLINE void add_v4_v4(float r[4], const float a[4])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void copy_vn_fl(float *array_tar, int size, float val)
void interp_v3_v3v3_slerp_safe(float target[3], const float a[3], const float b[3], float t)
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
MINLINE void add_v2_v2(float r[2], const float a[2])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_v3_short(short r[3], const short a[3])
void minmax_v4v4_v4(float min[4], float max[4], const float vec[4])
MINLINE void mul_v3_v3v3(float r[3], const float v1[3], const float v2[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
void copy_vn_i(int *array_tar, int size, int val)
MINLINE void zero_v2(float r[2])
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f)
MINLINE void zero_v3(float r[3])
MINLINE void copy_v4_fl(float r[4], float f)
MINLINE float normalize_v3(float n[3])
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void BLI_mempool_free(BLI_mempool *pool, void *addr) ATTR_NONNULL(1
BLI_mempool * BLI_mempool_create(unsigned int esize, unsigned int elem_num, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
#define STRNCPY(dst, src)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define STRNCPY_UTF8(dst, src)
size_t void BLI_uniquename_cb(UniquenameCheckCallback unique_check, void *arg, const char *defname, char delim, char *name, size_t name_maxncpy) ATTR_NONNULL(1
#define INIT_MINMAX2(min, max)
#define POINTER_OFFSET(v, ofs)
void BLO_read_float3_array(BlendDataReader *reader, int array_size, float **ptr_p)
void * BLO_read_struct_by_name_array(BlendDataReader *reader, const char *struct_name, uint32_t items_num, const void *old_address)
void BLO_write_float3_array(BlendWriter *writer, uint num, const float *data_ptr)
void BLO_read_uint8_array(BlendDataReader *reader, int array_size, uint8_t **ptr_p)
#define BLO_write_struct_array_at_address(writer, struct_name, array_size, address, data_ptr)
void BLO_write_uint8_array(BlendWriter *writer, uint num, const uint8_t *data_ptr)
void BLO_read_float_array(BlendDataReader *reader, int array_size, float **ptr_p)
#define BLO_write_struct(writer, struct_name, data_ptr)
void BLO_write_float_array(BlendWriter *writer, uint num, const float *data_ptr)
#define BLO_write_struct_array(writer, struct_name, array_size, data_ptr)
void BLO_write_int8_array(BlendWriter *writer, uint num, const int8_t *data_ptr)
void BLO_write_struct_array_by_name(BlendWriter *writer, const char *struct_name, int array_size, const void *data_ptr)
#define BLO_read_struct_array(reader, struct_name, array_size, ptr_p)
#define BLO_read_struct(reader, struct_name, ptr_p)
bool BLO_write_is_undo(BlendWriter *writer)
void BLO_write_shared(BlendWriter *writer, const void *data, size_t approximate_size_in_bytes, const blender::ImplicitSharingInfo *sharing_info, blender::FunctionRef< void()> write_fn)
void BLO_read_int8_array(BlendDataReader *reader, int array_size, int8_t **ptr_p)
const blender::ImplicitSharingInfo * BLO_read_shared(BlendDataReader *reader, T **data_ptr, blender::FunctionRef< const blender::ImplicitSharingInfo *()> read_fn)
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
ID and Library types, which are fundamental for SDNA.
#define ID_BLEND_PATH_FROM_GLOBAL(_id)
#define CD_MASK_BM_ELEM_PYPTR
#define MAX_CUSTOMDATA_LAYER_NAME
#define CD_MASK_PROP_FLOAT3
#define CD_MASK_ORIGINDEX
#define CD_MASK_MDEFORMVERT
#define CD_MASK_TESSLOOPNORMAL
#define CD_MASK_MVERT_SKIN
#define CD_MASK_PROP_INT32_2D
#define CD_MASK_FREESTYLE_FACE
#define CD_MASK_SHAPE_KEYINDEX
#define CD_MASK_ORIGSPACE_MLOOP
#define CD_MASK_CLOTH_ORCO
#define CD_MASK_PROP_INT32
#define CD_MASK_GRID_PAINT_MASK
#define CD_MASK_CUSTOMLOOPNORMAL
#define CD_MASK_FREESTYLE_EDGE
#define CD_MASK_ORIGSPACE
#define CD_MASK_MLOOPTANGENT
#define MAX_CUSTOMDATA_LAYER_NAME_NO_PREFIX
struct FreestyleEdge FreestyleEdge
struct MVertSkin MVertSkin
struct MStringProperty MStringProperty
struct GridPaintMask GridPaintMask
struct MDeformVert MDeformVert
struct OrigSpaceFace OrigSpaceFace
struct OrigSpaceLoop OrigSpaceLoop
struct MIntProperty MIntProperty
struct MFloatProperty MFloatProperty
struct FreestyleFace FreestyleFace
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
ATTR_WARN_UNUSED_RESULT BMesh * bm
const BMAllocTemplate bm_mesh_chunksize_default
bool BM_attribute_stored_in_bmesh_builtin(const StringRef name)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
CustomDataLayerImplicitSharing(const void *data, const int totelem, const eCustomDataType type)
constexpr void fill(const T &value) const
bool contains(const Key &key) const
constexpr const T * data() const
void append(const T &value)
Span< T > as_span() const
void add(const int64_t bytes)
void add_shared(const ImplicitSharingInfo *sharing_info, const FunctionRef< void(MemoryCounter &shared_memory)> count_fn)
local_group_size(16, 16) .push_constant(Type b
void CustomData_debug_info_from_layers(const CustomData *data, const char *indent, DynStr *dynstr)
static int layerMaxNum_tface()
void * CustomData_get_layer_named_for_write(CustomData *data, const eCustomDataType type, const StringRef name, const int totelem)
bool CustomData_verify_versions(CustomData *data, const int index)
static void layerFree_mdisps(void *data, const int count)
void * CustomData_get_for_write(CustomData *data, const int index, const eCustomDataType type, int totelem)
static void layerCopy_propString(const void *source, void *dest, const int count)
static void layerDoMinMax_propcol(const void *data, void *vmin, void *vmax)
static void layerMultiply_propfloat2(void *data, const float fac)
void CustomData_data_mix_value(const eCustomDataType type, const void *source, void *dest, const int mixmode, const float mixfactor)
const CustomData_MeshMasks CD_MASK_EVERYTHING
static void layerInitMinMax_mloop_origspace(void *vmin, void *vmax)
int CustomData_get_active_layer(const CustomData *data, const eCustomDataType type)
int CustomData_get_layer_index_n(const CustomData *data, const eCustomDataType type, const int n)
void * CustomData_get_n_for_write(CustomData *data, const eCustomDataType type, const int index, const int n, int totelem)
static const LayerTypeInfo * layerType_getInfo(const eCustomDataType type)
static size_t layerFilesize_mdisps(CDataFile *, const void *data, const int count)
static void layerSwap_flnor(void *data, const int *corner_indices)
static void layerInitMinMax_propfloat2(void *vmin, void *vmax)
static void blend_write_layer_data(BlendWriter *writer, const CustomDataLayer &layer, const int count)
void CustomData_free(CustomData *data, const int totelem)
static void layerCopyValue_mloop_origspace(const void *source, void *dest, const int, const float)
void CustomData_blend_write_prepare(CustomData &data, Vector< CustomDataLayer, 16 > &layers_to_write, const Set< std::string > &skip_names)
void CustomData_set_layer_flag(CustomData *data, const eCustomDataType type, const int flag)
int CustomData_layertype_layers_max(const eCustomDataType type)
static void layerInitMinMax_mloopcol(void *vmin, void *vmax)
const CustomData_MeshMasks CD_MASK_BAREMESH_ORIGINDEX
static bool layerRead_mdisps(CDataFile *cdf, void *data, const int count)
void CustomData_set_layer_active_index(CustomData *data, const eCustomDataType type, const int n)
static void layerInterp_propcol(const void **sources, const float *weights, const float *, int count, void *dest)
static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES]
int CustomData_get_offset_named(const CustomData *data, const eCustomDataType type, const StringRef name)
void CustomData_validate_layer_name(const CustomData *data, const eCustomDataType type, const StringRef name, char *outname)
void customdata_data_transfer_interp_normal_normals(const CustomDataTransferLayerMap *laymap, void *data_dst, const void **sources, const float *weights, const int count, const float mix_factor)
static void blend_read_mdisps(BlendDataReader *reader, const int count, MDisps *mdisps, const int external)
static bool check_bit_flag(const void *data, const size_t data_size, const uint64_t flag)
bool CustomData_layer_is_anonymous(const CustomData *data, eCustomDataType type, int n)
static void layerConstruct_mdeformvert(void *data, const int count)
void CustomData_blend_write(BlendWriter *writer, CustomData *data, Span< CustomDataLayer > layers_to_write, int count, eCustomDataMask cddata_mask, ID *id)
void CustomData_interp(const CustomData *source, CustomData *dest, const int *src_indices, const float *weights, const float *sub_weights, int count, int dest_index)
static bool layerEqual_mloop_origspace(const void *data1, const void *data2)
static void layerCopy_propFloat(const void *source, void *dest, const int count)
static void layerMultiply_mloopcol(void *data, const float fac)
static void layerDefault_mloopcol(void *data, const int count)
int CustomData_get_stencil_layer(const CustomData *data, const eCustomDataType type)
int CustomData_get_render_layer_index(const CustomData *data, const eCustomDataType type)
const char * CustomData_layertype_name(const eCustomDataType type)
void CustomData_set_layer_stencil(CustomData *data, const eCustomDataType type, const int n)
void CustomData_bmesh_free_block(CustomData *data, void **block)
static bool CustomData_layer_ensure_data_exists(CustomDataLayer *layer, size_t count)
void CustomData_data_add(const eCustomDataType type, void *data1, const void *data2)
static void layerCopy_grid_paint_mask(const void *source, void *dest, const int count)
static void customdata_data_transfer_interp_generic(const CustomDataTransferLayerMap *laymap, void *data_dst, const void **sources, const float *weights, const int count, const float mix_factor)
void * CustomData_get_layer_for_write(CustomData *data, const eCustomDataType type, const int totelem)
bool CustomData_layertype_is_dynamic(const eCustomDataType type)
static void layerDefault_propquaternion(void *data, const int count)
void CustomData_clear_layer_flag(CustomData *data, const eCustomDataType type, const int flag)
const void * CustomData_get_layer_n(const CustomData *data, const eCustomDataType type, const int n)
bool CustomData_free_layer_active(CustomData *data, const eCustomDataType type, const int totelem)
void CustomData_MeshMasks_update(CustomData_MeshMasks *mask_dst, const CustomData_MeshMasks *mask_src)
void CustomData_set_layer_render_index(CustomData *data, const eCustomDataType type, const int n)
int CustomData_get_named_layer_index_notype(const CustomData *data, const StringRef name)
static void layerCopy_origspace_face(const void *source, void *dest, const int count)
static bool layerEqual_propfloat2(const void *data1, const void *data2)
void CustomData_copy_layer_type_data(const CustomData *source, CustomData *destination, const eCustomDataType type, int source_index, int destination_index, int count)
static void layerMultiply_mloop_origspace(void *data, const float fac)
static void layerInterp_mvert_skin(const void **sources, const float *weights, const float *, int count, void *dest)
static void write_mdisps(BlendWriter *writer, const int count, const MDisps *mdlist, const int external)
static void CustomData_bmesh_set_default_n(CustomData *data, void **block, const int n)
void CustomData_bmesh_free_block_data_exclude_by_type(CustomData *data, void *block, const eCustomDataMask mask_exclude)
void customData_mask_layers__print(const CustomData_MeshMasks *mask)
void CustomData_blend_read(BlendDataReader *reader, CustomData *data, const int count)
void CustomData_reset(CustomData *data)
bool CustomData_free_layer_named(CustomData *data, const StringRef name, const int totelem)
static void layerMultiply_propcol(void *data, const float fac)
static void layerFree_grid_paint_mask(void *data, const int count)
static void layerInterp_mcol(const void **sources, const float *weights, const float *sub_weights, const int count, void *dest)
static void layerCopy_bmesh_elem_py_ptr(const void *, void *dest, const int count)
static void * copy_layer_data(const eCustomDataType type, const void *data, const int totelem)
static void write_grid_paint_mask(BlendWriter *writer, int count, const GridPaintMask *grid_paint_mask)
static void layerDefault_origspace_face(void *data, const int count)
static void layerMultiply_propfloat3(void *data, const float fac)
static bool customdata_unique_check(void *arg, const char *name)
int CustomData_get_layer_index(const CustomData *data, const eCustomDataType type)
static void layerDoMinMax_mloop_origspace(const void *data, void *vmin, void *vmax)
static void layerSwap_tface(void *data, const int *corner_indices)
bool CustomData_MeshMasks_are_matching(const CustomData_MeshMasks *mask_ref, const CustomData_MeshMasks *mask_required)
int CustomData_get_render_layer(const CustomData *data, const eCustomDataType type)
int CustomData_get_clone_layer_index(const CustomData *data, const eCustomDataType type)
static const ImplicitSharingInfo * make_implicit_sharing_info_for_layer(const eCustomDataType type, const void *data, const int totelem)
void CustomData_copy_data(const CustomData *source, CustomData *dest, const int source_index, const int dest_index, const int count)
bool CustomData_has_interp(const CustomData *data)
bool CustomData_layer_validate(CustomDataLayer *layer, const uint totitems, const bool do_fixes)
void CustomData_copy_elements(const eCustomDataType type, void *src_data_ofs, void *dst_data_ofs, const int count)
const void * CustomData_add_layer_with_data(CustomData *data, const eCustomDataType type, void *layer_data, const int totelem, const ImplicitSharingInfo *sharing_info)
void CustomData_bmesh_interp(CustomData *data, const void **src_blocks, const float *weights, const float *sub_weights, int count, void *dst_block)
const CustomData_MeshMasks CD_MASK_BAREMESH
int CustomData_get_active_layer_index(const CustomData *data, const eCustomDataType type)
void CustomData_free_typemask(CustomData *data, const int totelem, eCustomDataMask mask)
static void customData_update_offsets(CustomData *data)
const char * CustomData_get_render_layer_name(const CustomData *data, const eCustomDataType type)
static void layerAdd_mloopcol(void *data1, const void *data2)
static void copy_bit_flag(void *dst, const void *src, const size_t data_size, const uint64_t flag)
void CustomData_free_layers(CustomData *data, const eCustomDataType type, const int totelem)
static void layerCopy_mdeformvert(const void *source, void *dest, const int count)
static void layerInterp_tface(const void **sources, const float *weights, const float *sub_weights, const int count, void *dest)
static CustomDataLayer * customData_add_layer__internal(CustomData *data, eCustomDataType type, std::optional< eCDAllocType > alloctype, void *layer_data_to_assign, const ImplicitSharingInfo *sharing_info_to_assign, int totelem, const StringRef name)
void CustomData_data_initminmax(const eCustomDataType type, void *min, void *max)
void CustomData_copy_data_named(const CustomData *source, CustomData *dest, const int source_index, const int dest_index, const int count)
static void layerAdd_mloop_origspace(void *data1, const void *data2)
void CustomData_set_layer_render(CustomData *data, const eCustomDataType type, const int n)
static void layerSwap_origspace_face(void *data, const int *corner_indices)
static void layerCopy_mvert_skin(const void *source, void *dest, const int count)
int CustomData_name_maxncpy_calc(const blender::StringRef name)
void * CustomData_bmesh_get(const CustomData *data, void *block, const eCustomDataType type)
void CustomData_data_copy_value(const eCustomDataType type, const void *source, void *dest)
void CustomData_init_from(const CustomData *source, CustomData *dest, eCustomDataMask mask, int totelem)
const void * CustomData_add_layer_named_with_data(CustomData *data, eCustomDataType type, void *layer_data, int totelem, const StringRef name, const ImplicitSharingInfo *sharing_info)
static bool layerEqual_propcol(const void *data1, const void *data2)
static void layerInterp_shapekey(const void **sources, const float *weights, const float *, int count, void *dest)
static void layerInitMinMax_propcol(void *vmin, void *vmax)
void CustomData_bmesh_interp_n(CustomData *data, const void **src_blocks_ofs, const float *weights, const float *sub_weights, int count, void *dst_block_ofs, int n)
const void * CustomData_get_layer_named(const CustomData *data, const eCustomDataType type, const StringRef name)
bool CustomData_has_layer(const CustomData *data, const eCustomDataType type)
bool CustomData_merge_layout(const CustomData *source, CustomData *dest, const eCustomDataMask mask, const eCDAllocType alloctype, const int totelem)
static void customData_free_layer__internal(CustomDataLayer *layer, const int totelem)
bool CustomData_merge(const CustomData *source, CustomData *dest, eCustomDataMask mask, int totelem)
int CustomData_number_of_layers_typemask(const CustomData *data, const eCustomDataMask mask)
void CustomData_file_write_info(const eCustomDataType type, const char **r_struct_name, int *r_struct_num)
static void layerAdd_propfloat3(void *data1, const void *data2)
bool CustomData_data_equals(const eCustomDataType type, const void *data1, const void *data2)
static bool layerValidate_propfloat3(void *data, const uint totitems, const bool do_fixes)
static void layerInterp_propFloat(const void **sources, const float *weights, const float *, const int count, void *dest)
void CustomData_external_reload(CustomData *data, ID *, eCustomDataMask mask, int totelem)
CustomData CustomData_shallow_copy_remove_non_bmesh_attributes(const CustomData *src, const eCustomDataMask mask)
static void layerDefault_tface(void *data, const int count)
void CustomData_set_layer_clone(CustomData *data, const eCustomDataType type, const int n)
void CustomData_free_elem(CustomData *data, const int index, const int count)
static void layerDefault_propcol(void *data, const int count)
static void blend_read_paint_mask(BlendDataReader *reader, int count, GridPaintMask *grid_paint_mask)
void CustomData_data_set_default_value(const eCustomDataType type, void *elem)
static bool layer_is_mutable(CustomDataLayer &layer)
static void layerCopy_tface(const void *source, void *dest, const int count)
const CustomData_MeshMasks CD_MASK_BMESH
static bool layerWrite_mdisps(CDataFile *cdf, const void *data, const int count)
void CustomData_update_typemap(CustomData *data)
void CustomData_bmesh_copy_block(CustomData &dst_data, const BMCustomDataCopyMap ©_map, const void *src_block, void **dst_block)
void CustomData_bmesh_set_default(CustomData *data, void **block)
static void layerAdd_propcol(void *data1, const void *data2)
void CustomData_data_dominmax(const eCustomDataType type, const void *data, void *min, void *max)
static void layerInterp_propfloat2(const void **sources, const float *weights, const float *, int count, void *dest)
void CustomData_bmesh_init_pool(CustomData *data, const int totelem, const char htype)
static void layerInterp_origspace_face(const void **sources, const float *weights, const float *sub_weights, const int count, void *dest)
void CustomData_realloc(CustomData *data, const int old_size, const int new_size, const eCDAllocType alloctype)
void bpy_bm_generic_invalidate(struct BPy_BMGeneric *)
void CustomData_set_layer_clone_index(CustomData *data, const eCustomDataType type, const int n)
static void CustomData_external_free(CustomData *data)
void CustomData_set_layer_stencil_index(CustomData *data, const eCustomDataType type, const int n)
static void layerAdd_propfloat2(void *data1, const void *data2)
const char * CustomData_get_active_layer_name(const CustomData *data, const eCustomDataType type)
static bool customdata_typemap_is_valid(const CustomData *data)
static void layerInterp_normal(const void **sources, const float *weights, const float *, const int count, void *dest)
static void layerDefault_mcol(void *data, const int count)
bool CustomData_layertype_is_singleton(const eCustomDataType type)
bool CustomData_layer_has_interp(const CustomData *data, const int layer_n)
static void layerFree_mdeformvert(void *data, const int count)
static void layerInterp_mloopcol(const void **sources, const float *weights, const float *, int count, void *dest)
static bool layerEqual_mloopcol(const void *data1, const void *data2)
void CustomData_init_layout_from(const CustomData *source, CustomData *dest, eCustomDataMask mask, eCDAllocType alloctype, int totelem)
bool CustomData_free_layer(CustomData *data, const eCustomDataType type, const int totelem, const int index)
void CustomData_data_transfer(const MeshPairRemap *me_remap, const CustomDataTransferLayerMap *laymap)
static void free_layer_data(const eCustomDataType type, const void *data, const int totelem)
static void layerDefault_origindex(void *data, const int count)
static void layerDefault_mvert_skin(void *data, const int count)
void * CustomData_add_layer(CustomData *data, const eCustomDataType type, eCDAllocType alloctype, const int totelem)
int CustomData_get_stencil_layer_index(const CustomData *data, const eCustomDataType type)
int CustomData_get_named_layer(const CustomData *data, const eCustomDataType type, const StringRef name)
static void ensure_layer_data_is_mutable(CustomDataLayer &layer, const int totelem)
void CustomData_external_add(CustomData *data, ID *, const eCustomDataType type, const int, const char *filepath)
void CustomData_external_remove(CustomData *data, ID *id, const eCustomDataType type, const int totelem)
static void customdata_external_filename(char filepath[FILE_MAX], ID *id, CustomDataExternal *external)
bool CustomData_bmesh_has_free(const CustomData *data)
static void layerInterp_propInt(const void **sources, const float *weights, const float *, const int count, void *dest)
static void layerDefault_propfloat4x4(void *data, const int count)
static void layerInterp_mdeformvert(const void **sources, const float *weights, const float *, const int count, void *dest)
static bool customdata_merge_internal(const CustomData *source, CustomData *dest, const eCustomDataMask mask, const std::optional< eCDAllocType > alloctype, const int totelem)
void CustomData_external_read(CustomData *data, ID *id, eCustomDataMask mask, const int totelem)
static void layerFree_bmesh_elem_py_ptr(void *data, const int count)
int CustomData_number_of_anonymous_layers(const CustomData *data, const eCustomDataType type)
void CustomData_swap_corners(CustomData *data, const int index, const int *corner_indices)
static void layerCopyValue_propfloat2(const void *source, void *dest, const int mixmode, const float mixfactor)
size_t CustomData_get_elem_size(const CustomDataLayer *layer)
void CustomData_count_memory(const CustomData &data, const int totelem, blender::MemoryCounter &memory)
int CustomData_number_of_layers(const CustomData *data, const eCustomDataType type)
bool CustomData_has_layer_named(const CustomData *data, const eCustomDataType type, const StringRef name)
static void layerCopyValue_propcol(const void *source, void *dest, const int mixmode, const float mixfactor)
BMCustomDataCopyMap CustomData_bmesh_copy_map_calc(const CustomData &src, const CustomData &dst, const eCustomDataMask mask_exclude)
const void * CustomData_get_layer(const CustomData *data, const eCustomDataType type)
static void blend_read_layer_data(BlendDataReader *reader, CustomDataLayer &layer, const int count)
static int CustomData_get_layer_index__notypemap(const CustomData *data, const eCustomDataType type)
void CustomData_set_layer_unique_name(CustomData *data, const int index)
void CustomData_ensure_layers_are_mutable(CustomData *data, int totelem)
static void layerSwap_mcol(void *data, const int *corner_indices)
static void customData_resize(CustomData *data, const int grow_amount)
static bool layerValidate_propFloat(void *data, const uint totitems, const bool do_fixes)
const CustomData_MeshMasks CD_MASK_DERIVEDMESH
int CustomData_sizeof(const eCustomDataType type)
static void layerInterp_mloop_origspace(const void **sources, const float *weights, const float *, int count, void *dest)
static void layerCopyValue_normal(const void *source, void *dest, const int mixmode, const float mixfactor)
bool CustomData_external_test(CustomData *data, const eCustomDataType type)
void CustomData_bmesh_set_n(CustomData *data, void *block, const eCustomDataType type, const int n, const void *source)
bool CustomData_bmesh_merge_layout(const CustomData *source, CustomData *dest, eCustomDataMask mask, eCDAllocType alloctype, BMesh *bm, const char htype)
bool CustomData_set_layer_name(CustomData *data, const eCustomDataType type, const int n, const StringRef name)
int CustomData_get_clone_layer(const CustomData *data, const eCustomDataType type)
void CustomData_ensure_data_is_mutable(CustomDataLayer *layer, const int totelem)
static void layerDoMinMax_mloopcol(const void *data, void *vmin, void *vmax)
const char * CustomData_get_layer_name(const CustomData *data, const eCustomDataType type, const int n)
int CustomData_get_named_layer_index(const CustomData *data, const eCustomDataType type, const StringRef name)
static void layerConstruct_mdisps(void *data, const int count)
static const char * LAYERTYPENAMES[CD_NUMTYPES]
static void layerCopy_mdisps(const void *source, void *dest, const int count)
int CustomData_get_offset(const CustomData *data, const eCustomDataType type)
void * CustomData_bmesh_get_n(const CustomData *data, void *block, const eCustomDataType type, const int n)
bool CustomData_layer_has_math(const CustomData *data, const int layer_n)
static void layerDoMinMax_propfloat2(const void *data, void *vmin, void *vmax)
static void layerInterp_propbool(const void **sources, const float *weights, const float *, int count, void *dest)
bool CustomData_has_math(const CustomData *data)
void CustomData_bmesh_alloc_block(CustomData *data, void **block)
static bool cd_layer_find_dupe(CustomData *data, const StringRef name, const eCustomDataType type, const int index)
void CustomData_data_multiply(const eCustomDataType type, void *data, const float fac)
void CustomData_set_only_copy(const CustomData *data, const eCustomDataMask mask)
static const char * layerType_getName(const eCustomDataType type)
void * CustomData_bmesh_get_layer_n(const CustomData *data, void *block, const int n)
static bool layerValidate_propfloat2(void *data, const uint totitems, const bool do_fixes)
static void layerInterp_propquaternion(const void **sources, const float *weights, const float *, int count, void *dest)
const CustomData_MeshMasks CD_MASK_MESH
void CustomData_bmesh_free_block_data(CustomData *data, void *block)
#define COPY_BIT_FLAG(_type, _dst, _src, _f)
void CustomData_external_write(CustomData *data, ID *id, eCustomDataMask mask, const int totelem, const int free)
void * CustomData_get_layer_n_for_write(CustomData *data, const eCustomDataType type, const int n, const int totelem)
static void layerCopyValue_mloopcol(const void *source, void *dest, const int mixmode, const float mixfactor)
static void layerSwap_mdisps(void *data, const int *ci)
void CustomData_set_layer_active(CustomData *data, const eCustomDataType type, const int n)
static void layerConstruct_grid_paint_mask(void *data, const int count)
void * CustomData_add_layer_named(CustomData *data, const eCustomDataType type, const eCDAllocType alloctype, const int totelem, const StringRef name)
void CustomData_copy_data_layer(const CustomData *source, CustomData *dest, const int src_layer_index, const int dst_layer_index, const int src_index, const int dst_index, const int count)
int CustomData_get_n_offset(const CustomData *data, const eCustomDataType type, const int n)
static void layerInterp_propfloat3(const void **sources, const float *weights, const float *, int count, void *dest)
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void * MEM_mallocN_aligned(size_t len, size_t alignment, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
size_t(* MEM_allocN_len)(const void *vmemh)
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
ccl_device_inline float2 interp(const float2 a, const float2 b, float t)
typename DefaultMixerStruct< T >::type DefaultMixer
bool attribute_name_is_anonymous(const StringRef name)
std::optional< VolumeGridType > custom_data_type_to_volume_grid_type(eCustomDataType type)
std::optional< eCustomDataType > volume_grid_type_to_custom_data_type(VolumeGridType type)
T interpolate(const T &a, const T &b, const FactorT &t)
void min_max(const T &value, T &min, T &max)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 2 > int2
static void update(bNodeTree *ntree)
unsigned __int64 uint64_t
blender::Vector< Free > free
blender::Vector< TrivialCopy > trivial_copies
blender::Vector< TrivialDefault > trivial_defaults
blender::Vector< Default > defaults
blender::Vector< Copy > copies
const ImplicitSharingInfoHandle * sharing_info
const float * mix_weights
cd_datatransfer_interp interp
struct BLI_mempool * pool
CustomDataExternal * external
bool(* write)(CDataFile *cdf, const void *data, int count)
void(* dominmax)(const void *data1, void *min, void *max)
void(* copyvalue)(const void *source, void *dest, int mixmode, const float mixfactor)
void(* add)(void *data1, const void *data2)
cd_set_default_value set_default_value
size_t(* filesize)(CDataFile *cdf, const void *data, int count)
bool(* read)(CDataFile *cdf, void *data, int count)
void(* initminmax)(void *min, void *max)
void(* swap)(void *data, const int *corner_indices)
bool(* equal)(const void *data1, const void *data2)
void(* construct)(void *data, int count)
void(* multiply)(void *data, float fac)
MeshPairRemapItem * items