18#define DNA_DEPRECATED_ALLOW
77#define CUSTOMDATA_GROW 5
102 return (((mask_required->
vmask & mask_ref->
vmask) == mask_required->
vmask) &&
160 void (*
swap)(
void *
data,
const int *corner_indices) =
nullptr;
177 bool (*
equal)(
const void *data1,
const void *data2) =
nullptr;
180 void (*
add)(
void *data1,
const void *data2) =
nullptr;
182 void (*
copyvalue)(
const void *source,
void *dest,
int mixmode,
const float mixfactor) =
nullptr;
210 memcpy(dest, source, count * size);
212 for (i = 0; i < count; i++) {
219 memcpy(dw, dvert->
dw, dvert->
totweight *
sizeof(*dw));
232 MEM_delete(dvert.dw);
240 const float *weights,
246 struct MDeformWeight_Link {
247 MDeformWeight_Link *next;
252 MDeformWeight_Link *dest_dwlink =
nullptr;
253 MDeformWeight_Link *
node;
257 for (
int i = 0; i < count; i++) {
259 float interp_weight = weights[i];
261 for (
int j = 0; j < source->
totweight; j++) {
263 float weight = dw->
weight * interp_weight;
265 if (weight == 0.0f) {
280 MDeformWeight_Link *tmp_dwlink =
static_cast<MDeformWeight_Link *
>(
281 alloca(
sizeof(*tmp_dwlink)));
282 tmp_dwlink->dw.def_nr = dw->
def_nr;
283 tmp_dwlink->dw.weight = weight;
286 tmp_dwlink->next = dest_dwlink;
287 dest_dwlink = tmp_dwlink;
297 if (dvert->
dw && (dvert->
totweight == totweight)) {
302 MEM_delete(dvert->
dw);
314 node->dw.weight = std::min(
node->dw.weight, 1.0f);
335 const float *weights,
342 float no[3] = {0.0f};
345 madd_v3_v3fl(no,
static_cast<const float *
>(sources[i]), weights[i]);
355 const float mixfactor)
357 const float *no_src =
static_cast<const float *
>(source);
358 float *no_dst =
static_cast<float *
>(dest);
398 const MTFace *source_tf =
static_cast<const MTFace *
>(source);
400 for (
int i = 0; i < count; i++) {
401 dest_tf[i] = source_tf[i];
406 const float *weights,
411 float uv[4][2] = {{0.0f}};
413 for (
int i = 0; i < count; i++) {
414 const float interp_weight = weights[i];
415 const MTFace *src =
static_cast<const MTFace *
>(sources[i]);
417 for (
int j = 0; j < 4; j++) {
423 *tf = *
static_cast<MTFace *
>(
const_cast<void *
>((*sources)));
424 memcpy(tf->
uv, uv,
sizeof(tf->
uv));
432 for (
int j = 0; j < 4; j++) {
433 const int source_index = corner_indices[j];
437 memcpy(tf->
uv, uv,
sizeof(tf->
uv));
442 static MTFace default_tf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}};
445 for (
int i = 0; i < count; i++) {
467 const float *weights,
472 for (
int i = 0; i < count; i++) {
473 const float interp_weight = weights[i];
474 const float src = *
static_cast<const float *
>(sources[i]);
475 result += src * interp_weight;
477 *
static_cast<float *
>(dest) =
result;
483 bool has_errors =
false;
485 for (
int i = 0; i < totitems; i++, fp++) {
486 if (!isfinite(fp->
f)) {
504 const float *weights,
510 const float weight = weights[i];
511 const float src = *
static_cast<const int *
>(sources[i]);
515 *
static_cast<int *
>(dest) = rounded_result;
540 for (
int i = 0; i < count; i++) {
541 dest_tf[i] = source_tf[i];
546 const float *weights,
551 float uv[4][2] = {{0.0f}};
553 for (
int i = 0; i < count; i++) {
554 const float interp_weight = weights[i];
557 for (
int j = 0; j < 4; j++) {
563 memcpy(osf->
uv, uv,
sizeof(osf->
uv));
571 for (
int j = 0; j < 4; j++) {
574 memcpy(osf->
uv, uv,
sizeof(osf->
uv));
579 static OrigSpaceFace default_osf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}};
582 for (
int i = 0; i < count; i++) {
583 osf[i] = default_osf;
598 int nverts = (ci[1] == 3) ? 4 : 3;
600 int cornersize = s->
totdisp / corners;
602 if (corners != nverts) {
606 MEM_delete(s->
disps);
614 for (
int S = 0; S < corners; S++) {
615 memcpy(d + cornersize * S, s->
disps + cornersize * ci[S],
sizeof(
float[3]) * cornersize);
618 MEM_delete(s->
disps);
628 for (
int i = 0; i < count; i++) {
630 d[i].
disps = MEM_dupalloc(s[i].disps);
631 d[i].
hidden = MEM_dupalloc(s[i].hidden);
634 d[i].
disps =
nullptr;
646 MEM_SAFE_DELETE(d.disps);
647 MEM_SAFE_DELETE(d.hidden);
661 for (
int i = 0; i < count; i++) {
666 if (!
cdf_read_data(cdf,
sizeof(
float[3]) * d[i].totdisp, d[i].disps)) {
667 CLOG_ERROR(&
LOG,
"failed to read multires displacement %d/%d %d", i, count, d[i].totdisp);
679 for (
int i = 0; i < count; i++) {
680 if (!
cdf_write_data(cdf,
sizeof(
float[3]) * d[i].totdisp, d[i].disps)) {
681 CLOG_ERROR(&
LOG,
"failed to write multires displacement %d/%d %d", i, count, d[i].totdisp);
694 for (
int i = 0; i < count; i++) {
695 size +=
sizeof(
float[3]) * d[i].totdisp;
710 const int size =
sizeof(
void *);
712 for (
int i = 0; i < count; i++) {
727 for (
int i = 0; i < count; i++) {
746 for (
int i = 0; i < count; i++) {
748 d[i].
data = MEM_dupalloc(s[i].
data);
761 MEM_SAFE_DELETE(gpm.data);
780 const float mixfactor)
808 uchar src[4] = {m1->
r, m1->
g, m1->
b, m1->
a};
809 uchar dst[4] = {m2->
r, m2->
g, m2->
b, m2->
a};
824 memcpy(tmp_col, src,
sizeof(tmp_col));
829 m2->
r = char(dst[0]);
830 m2->
g = char(dst[1]);
831 m2->
b = char(dst[2]);
832 m2->
a = char(dst[3]);
847 return r * r + g * g +
b *
b + a * a < 0.001f;
877 min->r = std::min(m->
r,
min->r);
878 min->g = std::min(m->
g,
min->g);
879 min->b = std::min(m->
b,
min->b);
880 min->a = std::min(m->
a,
min->a);
881 max->r = std::max(m->
r,
max->r);
882 max->g = std::max(m->
g,
max->g);
883 max->b = std::max(m->
b,
max->b);
884 max->a = std::max(m->
a,
max->a);
905 MLoopCol default_mloopcol = {255, 255, 255, 255};
907 for (
int i = 0; i < count; i++) {
908 mlcol[i] = default_mloopcol;
922 for (
int i = 0; i < count; i++) {
923 const float interp_weight = weights[i];
925 col.
r += src->
r * interp_weight;
926 col.g += src->
g * interp_weight;
927 col.b += src->
b * interp_weight;
928 col.a += src->
a * interp_weight;
1000 const float *weights,
1007 for (
int i = 0; i < count; i++) {
1008 const float interp_weight = weights[i];
1019 const float *weights,
1023 MCol *mc =
static_cast<MCol *
>(dest);
1029 } col[4] = {{0.0f}};
1031 for (
int i = 0; i < count; i++) {
1032 const float interp_weight = weights[i];
1034 for (
int j = 0; j < 4; j++) {
1035 const MCol *src =
static_cast<const MCol *
>(sources[i]);
1036 col[j].
a += src[j].
a * interp_weight;
1037 col[j].r += src[j].
r * interp_weight;
1038 col[j].g += src[j].
g * interp_weight;
1039 col[j].b += src[j].
b * interp_weight;
1044 for (
int j = 0; j < 4; j++) {
1060 for (
int j = 0; j < 4; j++) {
1061 col[j] = mcol[corner_indices[j]];
1064 memcpy(mcol, col,
sizeof(col));
1069 static MCol default_mcol = {255, 255, 255, 255};
1072 for (
int i = 0; i < 4 * count; i++) {
1073 mcol[i] = default_mcol;
1084 float **
in =
reinterpret_cast<float **
>(
const_cast<void **
>(sources));
1093 for (
int i = 0; i < count; i++) {
1094 const float interp_weight = weights[i];
1110 short (*flnors)[4][3] =
static_cast<short (*)[4][3]
>(
data);
1118 memcpy(flnors, nors,
sizeof(nors));
1130 const float mixfactor)
1168 memcpy(tmp_col, m1->
color,
sizeof(tmp_col));
1180 for (
int i = 0; i < 4; i++) {
1185 return tot < 0.001f;
1221 MPropCol default_propcol = {{1.0f, 1.0f, 1.0f, 1.0f}};
1223 for (
int i = 0; i < count; i++) {
1231 float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
1232 for (
int i = 0; i < count; i++) {
1233 const float interp_weight = weights[i];
1247 const float *weights,
1252 for (
int i = 0; i < count; i++) {
1253 const float interp_weight = weights[i];
1254 const vec4f *src =
static_cast<const vec4f *
>(sources[i]);
1272 const vec4f *vec2 =
static_cast<const vec4f *
>(data2);
1286 const float *weights,
1291 for (
int i = 0; i < count; i++) {
1292 const float interp_weight = weights[i];
1293 const vec3f *src =
static_cast<const vec3f *
>(sources[i]);
1310 const vec3f *vec2 =
static_cast<const vec3f *
>(data2);
1318 float *values =
static_cast<float *
>(
data);
1319 bool has_errors =
false;
1320 for (
int i = 0; i < totitems * 3; i++) {
1321 if (!isfinite(values[i])) {
1338 const float *weights,
1343 for (
int i = 0; i < count; i++) {
1344 const float interp_weight = weights[i];
1345 const vec2f *src =
static_cast<const vec2f *
>(sources[i]);
1361 const vec2f *vec2 =
static_cast<const vec2f *
>(data2);
1368 float *values =
static_cast<float *
>(
data);
1369 bool has_errors =
false;
1370 for (
int i = 0; i < totitems * 2; i++) {
1371 if (!isfinite(values[i])) {
1406 const float mixfactor)
1408 const float2 &a = *
static_cast<const float2 *
>(source);
1430 for (
int i = 0; i < count; i++) {
1431 const float interp_weight = weights[i];
1432 const bool src = *
static_cast<const bool *
>(sources[i]);
1433 result |= src && (interp_weight > 0.0f);
1435 *
static_cast<bool *
>(dest) =
result;
1450 const float *weights,
1458 for (
int i = 0; i < count; i++) {
1459 const float interp_weight = weights[i];
1461 mixer.mix_in(0, *src, interp_weight);
1487 .size =
sizeof(MVert),
1488 .alignment =
alignof(MVert),
1489 .structname =
"MVert",
1494 .size =
sizeof(
float[2]),
1495 .alignment =
alignof(
float2),
1503 .structname =
"MDeformVert",
1512 .size =
sizeof(MEdge),
1513 .alignment =
alignof(MEdge),
1514 .structname =
"MEdge",
1519 .size =
sizeof(
MFace),
1520 .alignment =
alignof(
MFace),
1521 .structname =
"MFace",
1527 .alignment =
alignof(
MTFace),
1528 .structname =
"MTFace",
1530 .defaultname =
N_(
"UVMap"),
1540 .size =
sizeof(
MCol[4]),
1541 .alignment =
alignof(
MCol[4]),
1542 .structname =
"MCol",
1544 .defaultname =
N_(
"Col"),
1551 .size =
sizeof(int),
1552 .alignment =
alignof(
int),
1560 .size =
sizeof(
float[3]),
1561 .alignment =
alignof(
float3),
1562 .structname =
"vec3f",
1569 .size =
sizeof(int),
1570 .alignment =
alignof(
int),
1576 .alignment =
alignof(
float),
1577 .structname =
"MFloatProperty",
1579 .defaultname =
N_(
"Float"),
1587 .alignment =
alignof(
int),
1588 .structname =
"MIntProperty",
1590 .defaultname =
N_(
"Int"),
1597 .structname =
"MStringProperty",
1599 .defaultname =
N_(
"String"),
1606 .structname =
"OrigSpaceFace",
1608 .defaultname =
N_(
"UVMap"),
1616 .size =
sizeof(
float[3]),
1617 .alignment =
alignof(
float3),
1625 .size =
sizeof(int),
1626 .alignment =
alignof(
int),
1632 .size =
sizeof(MLoopUV),
1633 .alignment =
alignof(MLoopUV),
1634 .structname =
"MLoopUV",
1636 .defaultname =
N_(
"UVMap"),
1642 .structname =
"MLoopCol",
1644 .defaultname =
N_(
"Col"),
1656 .size =
sizeof(
float[4]),
1657 .alignment =
alignof(
float[4]),
1660 .defaultname =
N_(
"Tangent"),
1665 .alignment =
alignof(
MDisps),
1666 .structname =
"MDisps",
1680 .structname =
"mat4x4f",
1682 .defaultname =
N_(
"4 by 4 Float Matrix"),
1687 .size =
sizeof(
MCol[4]),
1688 .alignment =
alignof(
MCol[4]),
1695 .alignment =
alignof(
short2),
1696 .structname =
"vec2s",
1698 .defaultname =
N_(
"2D 16-Bit Integer"),
1702 .size =
sizeof(
float[3]),
1703 .alignment =
alignof(
float[3]),
1710 .alignment =
alignof(
float4),
1711 .structname =
"vec4f",
1713 .defaultname =
N_(
"Float4"),
1720 .size =
sizeof(MPoly),
1721 .alignment =
alignof(MPoly),
1722 .structname =
"MPoly",
1724 .defaultname =
N_(
"NGon Face"),
1728 .size =
sizeof(MLoop),
1729 .alignment =
alignof(MLoop),
1730 .structname =
"MLoop",
1732 .defaultname =
N_(
"NGon Face-Vertex"),
1736 .size =
sizeof(int),
1737 .alignment =
alignof(
int),
1743 .size =
sizeof(
float[3]),
1744 .alignment =
alignof(
float[3]),
1747 .defaultname =
N_(
"ShapeKey"),
1754 .structname =
"MFloatProperty",
1759 .size =
sizeof(
float),
1760 .alignment =
alignof(
float),
1767 .structname =
"OrigSpaceLoop",
1769 .defaultname =
N_(
"OS Loop"),
1782 .size =
sizeof(
void *),
1783 .alignment =
alignof(
void *),
1791 .size =
sizeof(
float),
1792 .alignment =
alignof(
float),
1800 .structname =
"GridPaintMask",
1808 .size =
sizeof(MVertSkin),
1809 .alignment =
alignof(MVertSkin),
1810 .structname =
"MVertSkin",
1815 .size =
sizeof(FreestyleEdge),
1816 .alignment =
alignof(FreestyleEdge),
1817 .structname =
"FreestyleEdge",
1822 .size =
sizeof(FreestyleFace),
1823 .alignment =
alignof(FreestyleFace),
1824 .structname =
"FreestyleFace",
1829 .size =
sizeof(
float[4]),
1830 .alignment =
alignof(
float[4]),
1836 .size =
sizeof(
short[4][3]),
1837 .alignment =
alignof(
short[4][3]),
1844 .size =
sizeof(
short[2]),
1845 .alignment =
alignof(
short[2]),
1846 .structname =
"vec2s",
1851 .size =
sizeof(int),
1852 .alignment =
alignof(
int),
1857 .size =
sizeof(
float[3]),
1858 .alignment =
alignof(
float[3]),
1859 .structname =
"vec3f",
1864 .size =
sizeof(
float),
1865 .alignment =
alignof(
float),
1866 .structname =
"MFloatProperty",
1872 .alignment =
alignof(
int8_t),
1873 .structname =
"MInt8Property",
1875 .defaultname =
N_(
"Int8"),
1879 .size =
sizeof(
int2),
1880 .alignment =
alignof(
int2),
1881 .structname =
"vec2i",
1883 .defaultname =
N_(
"Int 2D"),
1889 .structname =
"MPropCol",
1891 .defaultname =
N_(
"Color"),
1903 .size =
sizeof(
float[3]),
1904 .alignment =
alignof(
float3),
1905 .structname =
"vec3f",
1907 .defaultname =
N_(
"Float3"),
1915 .size =
sizeof(
float[2]),
1916 .alignment =
alignof(
float2),
1917 .structname =
"vec2f",
1919 .defaultname =
N_(
"Float2"),
1931 .size =
sizeof(bool),
1932 .alignment =
alignof(
bool),
1933 .structname =
"bool",
1935 .defaultname =
N_(
"Boolean"),
1940 .size =
sizeof(
float),
1941 .alignment =
alignof(
float),
1942 .structname =
"float",
1947 .size =
sizeof(
float[4]),
1948 .alignment =
alignof(
float4),
1949 .structname =
"vec4f",
1951 .defaultname =
N_(
"Quaternion"),
1957static_assert(
sizeof(mat4x4f) ==
sizeof(
float4x4));
1972 "CDMStringProperty",
2003 "CDCustomLoopNormal",
2004 "CDSculptFaceGroups",
2143 std::optional<eCDAllocType> alloctype,
2144 void *layer_data_to_assign,
2147 const StringRef name);
2154 data->typemap[i] = -1;
2157 for (
int i = 0; i <
data->totlayer; i++) {
2159 if (type != lasttype) {
2160 data->typemap[type] = i;
2172 return (memcmp(
data->typemap, data_copy.
typemap,
sizeof(
data->typemap)) == 0);
2181 if (type_info.
copy) {
2182 type_info.
copy(
data, new_data, totelem);
2185 memcpy(new_data,
data, size_in_bytes);
2193 if (type_info.
free) {
2194 type_info.
free(
const_cast<void *
>(
data), totelem);
2202 const std::optional<eCDAllocType> alloctype,
2205 bool changed =
false;
2208 int last_active = 0;
2209 int last_render = 0;
2210 int current_type_layer_count = 0;
2211 int max_current_type_layer_count = -1;
2213 for (
int i = 0; i < source->
totlayer; i++) {
2218 if (type != last_type) {
2221 current_type_layer_count = layernum_dst;
2223 last_active = src_layer.
active;
2228 current_type_layer_count++;
2239 if ((max_current_type_layer_count != -1) &&
2240 (current_type_layer_count >= max_current_type_layer_count))
2250 void *layer_data_to_assign =
nullptr;
2252 if (!alloctype.has_value()) {
2253 if (src_layer.
data !=
nullptr) {
2260 layer_data_to_assign = src_layer.
data;
2269 layer_data_to_assign,
2270 sharing_info_to_assign,
2274 new_layer->
uid = src_layer.
uid;
2276 new_layer->
active = last_active;
2319 void delete_self_with_data()
override
2321 if (data_ !=
nullptr) {
2327 void delete_data_only()
override
2339 return MEM_new<CustomDataLayerImplicitSharing>(__func__,
data, totelem, type);
2347 if (
layer.data ==
nullptr) {
2351 if (
layer.sharing_info->is_mutable()) {
2352 layer.sharing_info->tag_ensured_mutable();
2356 const void *old_data =
layer.data;
2360 layer.sharing_info->remove_user_and_delete_if_last();
2370 return layer.sharing_info->is_mutable();
2392 for (
int i = 0; i <
data->totlayer; i++) {
2399 new_size_in_bytes, typeInfo->
alignment, __func__) :
2401 if (old_size_in_bytes > 0) {
2402 if (new_layer_data !=
nullptr) {
2404 if (typeInfo->
copy) {
2405 typeInfo->
copy(
layer->data, new_layer_data, std::min(old_size, new_size));
2409 memcpy(new_layer_data,
layer->data, std::min(old_size_in_bytes, new_size_in_bytes));
2413 layer->sharing_info->remove_user_and_delete_if_last();
2414 layer->sharing_info =
nullptr;
2417 layer->data = new_layer_data;
2423 if (new_size > old_size) {
2424 const int new_elements_num = new_size - old_size;
2426 switch (alloctype) {
2430 typeInfo->
construct(new_elements_begin, new_elements_num);
2439 memset(new_elements_begin, 0, typeInfo->
size * new_elements_num);
2479 if (!
layer->sharing_info) {
2483 layer->sharing_info->remove_user_and_delete_if_last();
2484 layer->sharing_info =
nullptr;
2489 if (
data->external) {
2490 MEM_delete(
data->external);
2491 data->external =
nullptr;
2503 for (
int i = 0; i <
data->totlayer; i++) {
2508 MEM_delete(
data->layers);
2517 return (value + (alignment - 1)) & ~(alignment - 1);
2525 int max_alignment = 1;
2527 for (
int i = 0; i <
data->totlayer; i++) {
2531 data->layers[i].offset = offset;
2532 offset += typeInfo->
size;
2533 max_alignment = std::max(max_alignment, typeInfo->
alignment);
2544 for (
int i = 0; i <
data->totlayer; i++) {
2545 if (
data->layers[i].type == type) {
2559 return data->typemap[type];
2569 i = (i + n <
data->totlayer &&
data->layers[i + n].type == type) ? (i + n) : (-1);
2579 for (
int i = 0; i <
data->totlayer; i++) {
2580 if (
data->layers[i].type == type) {
2581 if (
data->layers[i].name == name) {
2592 for (
int i = 0; i <
data->totlayer; i++) {
2593 if (
data->layers[i].name == name) {
2603 const int layer_index =
data->typemap[type];
2605 return (layer_index != -1) ? layer_index +
data->layers[layer_index].active : -1;
2610 const int layer_index =
data->typemap[type];
2612 return (layer_index != -1) ? layer_index +
data->layers[layer_index].active_rnd : -1;
2623 const int layer_index =
data->typemap[type];
2625 return (named_index != -1) ? named_index - layer_index : -1;
2630 const int layer_index =
data->typemap[type];
2632 return (layer_index != -1) ?
data->layers[layer_index].active : -1;
2637 const int layer_index =
data->typemap[type];
2639 return (layer_index != -1) ?
data->layers[layer_index].active_rnd : -1;
2646 return layer_index < 0 ?
nullptr :
data->layers[layer_index].name;
2652 return layer_index < 0 ?
nullptr :
data->layers[layer_index].name;
2660 for (
int i = 0; i <
data->totlayer; i++) {
2661 if (
data->layers[i].type == type) {
2663 data->layers[i].active = n;
2673 for (
int i = 0; i <
data->totlayer; i++) {
2674 if (
data->layers[i].type == type) {
2676 data->layers[i].active_rnd = n;
2686 const int layer_index = n -
data->typemap[type];
2689 for (
int i = 0; i <
data->totlayer; i++) {
2690 if (
data->layers[i].type == type) {
2692 data->layers[i].active = layer_index;
2702 const int layer_index = n -
data->typemap[type];
2705 for (
int i = 0; i <
data->totlayer; i++) {
2706 if (
data->layers[i].type == type) {
2708 data->layers[i].active_rnd = layer_index;
2717 for (
int i = 0; i <
data->totlayer; i++) {
2718 if (
data->layers[i].type == type) {
2719 data->layers[i].flag |= flag;
2728 data->maxlayer += grow_amount;
2734 const std::optional<eCDAllocType> alloctype,
2735 void *layer_data_to_assign,
2773 if (alloctype.has_value()) {
2774 switch (*alloctype) {
2778 size_in_bytes, type_info.
alignment, alloc_name);
2784 memset(new_layer.
data, 0, size_in_bytes);
2792 size_in_bytes, type_info.
alignment, alloc_name);
2802 if (totelem == 0 && sharing_info_to_assign ==
nullptr) {
2803 MEM_SAFE_DELETE_VOID(layer_data_to_assign);
2806 new_layer.
data = layer_data_to_assign;
2819 new_layer.
type = type;
2820 new_layer.
flag = flag;
2832 if (
STR_ELEM(new_layer.
name,
"skin_modifier_root",
"skin_modifier_loose")) {
2837 new_layer.
name[0] =
'\0';
2862 data, type, alloctype,
nullptr,
nullptr, totelem, typeInfo->
defaultname);
2881 data, type, std::nullopt, layer_data, sharing_info, totelem, typeInfo->
defaultname);
2898 data, type, alloctype,
nullptr,
nullptr, totelem, name);
2915 data, type, std::nullopt, layer_data, sharing_info, totelem, name);
2927 const int n =
index - index_first;
2930 if ((index_first == -1) || (n < 0)) {
2937 for (
int i =
index + 1; i <
data->totlayer; i++) {
2938 data->layers[i - 1] =
data->layers[i];
2948 const int index_nonzero = n ? n : 1;
2952 if (
layer->active >= index_nonzero) {
2955 if (
layer->active_rnd >= index_nonzero) {
2956 layer->active_rnd--;
2994 bool any_removed =
false;
3017 for (
int i = 0; i <
data->totlayer; i++) {
3018 if (
data->layers[i].type == type) {
3030 for (
int i = 0; i <
data->totlayer; i++) {
3043 for (
int i = 0; i <
data->totlayer; i++) {
3054 for (
int i = 0; i <
data->totlayer; i++) {
3062 const void *src_data,
3068 if (typeInfo->
copy) {
3069 typeInfo->
copy(src_data, dst_data, count);
3072 memcpy(dst_data, src_data,
size_t(count) * typeInfo->
size);
3078 const int src_layer_index,
3079 const int dst_layer_index,
3080 const int src_index,
3081 const int dst_index,
3088 const void *src_data = source->
layers[src_layer_index].
data;
3089 void *dst_data = dest->
layers[dst_layer_index].
data;
3093 const size_t src_offset = size_t(src_index) * typeInfo->
size;
3094 const size_t dst_offset = size_t(dst_index) * typeInfo->
size;
3096 if (!count || !src_data || !dst_data) {
3097 if (count && !(src_data ==
nullptr && dst_data ==
nullptr)) {
3099 "null data for %s type (%p --> %p), skipping",
3107 if (typeInfo->
copy) {
3114 size_t(count) * typeInfo->
size);
3120 const int source_index,
3121 const int dest_index,
3126 for (
int src_i = 0; src_i < source->
totlayer; src_i++) {
3157 int destination_index,
3161 if (source_layer_index == -1) {
3165 if (destinaiton_layer_index == -1) {
3171 destinaiton_layer_index,
3179 for (
int i = 0; i <
data->totlayer; i++) {
3182 if (typeInfo->
free) {
3183 size_t offset = size_t(
index) * typeInfo->
size;
3191#define SOURCE_BUF_SIZE 100
3195 const int *src_indices,
3196 const float *weights,
3205 const void **sources = source_buf;
3214 float *default_weights =
nullptr;
3215 if (weights ==
nullptr) {
3218 default_weights_buf;
3219 std::fill_n(default_weights, count, 1.0f / count);
3220 weights = default_weights;
3225 for (
int src_i = 0; src_i < source->
totlayer; src_i++) {
3247 for (
int j = 0; j < count; j++) {
3266 MEM_delete(sources);
3268 if (!
ELEM(default_weights,
nullptr, default_weights_buf)) {
3269 MEM_delete(default_weights);
3275 for (
int i = 0; i <
data->totlayer; i++) {
3278 if (typeInfo->
swap) {
3279 const size_t offset = size_t(
index) * typeInfo->
size;
3314 if (layer_index == -1) {
3318 return data->layers[layer_index].data;
3326 if (layer_index == -1) {
3337 if (layer_index == -1) {
3340 return data->layers[layer_index].data;
3349 if (layer_index == -1) {
3362 if (layer_index == -1) {
3365 return data->layers[layer_index].data;
3374 if (layer_index == -1) {
3385 if (layer_index == -1) {
3388 return data->layers[layer_index].offset;
3394 if (layer_index == -1) {
3398 return data->layers[layer_index].offset;
3406 if (layer_index == -1) {
3410 return data->layers[layer_index].offset;
3419 if (layer_index == -1) {
3434 return (layer_index == -1) ?
nullptr :
data->layers[layer_index].name;
3466 if (
data->totlayer) {
3492 MEM_delete(destold.
layers);
3525 dest->
pool =
nullptr;
3533 void *tmp =
nullptr;
3548 void *tmp =
nullptr;
3560 MEM_delete(destold.
layers);
3567 if (*block ==
nullptr) {
3571 for (
int i = 0; i <
data->totlayer; i++) {
3574 if (typeInfo->
free) {
3575 int offset =
data->layers[i].offset;
3580 if (
data->totsize) {
3589 if (block ==
nullptr) {
3592 for (
int i = 0; i <
data->totlayer; i++) {
3594 if (typeInfo->
free) {
3595 const size_t offset =
data->layers[i].offset;
3599 if (
data->totsize) {
3600 memset(block, 0,
data->totsize);
3610 if (
data->totsize > 0) {
3625 memset(elem, 0, typeInfo->
size);
3631 const int offset =
data->layers[n].offset;
3638 if (*block ==
nullptr) {
3642 for (
int i = 0; i <
data->totlayer; i++) {
3653 const int dst_offset = layer_dst.offset;
3667 if (type_info.
copy) {
3668 map.
copies.append({type_info.
copy, src_offset, dst_offset});
3677 if (type_info.
free) {
3678 map.
free.append({type_info.
free, dst_offset});
3686 const void *src_block,
3730 if (
data.totsize == 0) {
3737 const int offset =
layer.offset;
3751 if (layer_index == -1) {
3764 if (layer_index == -1) {
3773 if (n < 0 || n >=
data->totlayer) {
3807 for (
int i = 0; i <
data->totlayer; i++) {
3818 for (
int i = 0; i <
data->totlayer; i++) {
3820 if (typeInfo->
free) {
3830 for (
int i = 0; i <
data->totlayer; i++) {
3847 if (typeInfo->
copy) {
3848 typeInfo->
copy(source, dest, 1);
3851 memcpy(dest, source, typeInfo->
size);
3859 const float mixfactor)
3868 typeInfo->
copyvalue(source, dest, mixmode, mixfactor);
3872 memcpy(dest, source, typeInfo->
size);
3880 if (typeInfo->
equal) {
3881 return typeInfo->
equal(data1, data2);
3884 return !memcmp(data1, data2, typeInfo->
size);
3918 if (typeInfo->
add) {
3919 typeInfo->
add(data1, data2);
3933 if (typeInfo->
copy) {
3934 typeInfo->
copy(source, dest, 1);
3937 memcpy(dest, source, typeInfo->
size);
3942 const void **src_blocks_ofs,
3943 const float *weights,
3945 void *dst_block_ofs,
3959 typeInfo->
interp(src_blocks_ofs, weights, count, dst_block_ofs);
3963 CustomData *
data,
const void **src_blocks,
const float *weights,
int count,
void *dst_block)
3970 const void **sources =
const_cast<const void **
>(source_buf);
3979 float *default_weights =
nullptr;
3980 if (weights ==
nullptr) {
3983 default_weights_buf;
3984 std::fill_n(default_weights, count, 1.0f / count);
3985 weights = default_weights;
3989 for (
int i = 0; i <
data->totlayer; i++) {
3993 for (
int j = 0; j < count; j++) {
4002 MEM_delete(sources);
4004 if (!
ELEM(default_weights,
nullptr, default_weights_buf)) {
4005 MEM_delete(default_weights);
4013 return typeInfo->
size;
4031 return (typeInfo->
free !=
nullptr);
4055 for (
int i = 0; i <
data->totlayer; i++) {
4061 layer->name == name)
4103 if (nlayer->
name[0] ==
'\0') {
4107 const char *defname =
"";
4122 bool keeplayer =
true;
4147 CD_SCULPT_FACE_SETS,
4151 CLOG_WARN(&
LOG,
".blend file read: removing a data layer that should not have been written");
4156 for (
int i =
index + 1; i <
data->totlayer; i++) {
4157 data->layers[i - 1] =
data->layers[i];
4171 if (
layer->data || count == 0) {
4175 switch (
layer->type) {
4223 for (
int i = 0; i <
data->totlayer; i++) {
4231 if (typeInfo->
free) {
4251 for (
int i = 0; i <
data->totlayer; i++) {
4276 "Failed to read %s layer from %s.",
4282 for (
int i = 0; i <
data->totlayer; i++) {
4297 if (typeInfo->
read(cdf,
layer->data, totelem)) {
4332 for (
int i = 0; i <
data->totlayer; i++) {
4354 for (
int i = 0; i <
data->totlayer; i++) {
4371 CLOG_ERROR(&
LOG,
"Failed to open %s for writing.", filepath);
4377 for (i = 0; i <
data->totlayer; i++) {
4385 if (typeInfo->
write(cdf,
layer->data, totelem)) {
4398 if (i !=
data->totlayer) {
4405 for (i = 0; i <
data->totlayer; i++) {
4411 if (typeInfo->
free) {
4427 const char *filepath)
4432 if (layer_index == -1) {
4443 external = MEM_new<CustomDataExternal>(__func__);
4459 if (layer_index == -1) {
4482 if (layer_index == -1) {
4498 const void **sources,
4499 const float *weights,
4501 const float mix_factor)
4510 int best_src_idx = 0;
4512 const int data_type = laymap->
data_type;
4513 const int mix_mode = laymap->
mix_mode;
4525 if (
int(data_type) &
CD_FAKE) {
4531 data_size = size_t(type_info->
size);
4532 interp_cd = type_info->
interp;
4533 copy_cd = type_info->
copy;
4538 if (count > 1 && !interp_cd) {
4540 float max_weight = 0.0f;
4542 for (
int i = 0; i < count; i++) {
4543 if (weights[i] > max_weight) {
4544 max_weight = weights[i];
4553 interp_cd(sources, weights, count, tmp_dst);
4557 copy_cd(sources[best_src_idx], tmp_dst, 1);
4560 memcpy(tmp_dst, sources[best_src_idx], data_size);
4563 if (!(
int(data_type) &
CD_FAKE)) {
4569 if (mix_factor >= 0.5f) {
4570 memcpy(data_dst, tmp_dst, data_size);
4579 const void **sources,
4580 const float *weights,
4582 const float mix_factor)
4589 const int mix_mode = laymap->
mix_mode;
4603 interp_cd(sources, weights, count, tmp_dst);
4604 if (space_transform) {
4615 const int totelem = me_remap->
items_num;
4617 const int data_type = laymap->
data_type;
4619 const void *data_src = [&]() ->
const void * {
4620 if (std::holds_alternative<const void *>(laymap->
data_src)) {
4621 return std::get<const void *>(laymap->
data_src);
4623 data_src_span = std::get<GVArray>(laymap->
data_src);
4624 return data_src_span.
data();
4626 void *data_dst = [&]() ->
void * {
4627 if (std::holds_alternative<void *>(laymap->
data_dst)) {
4628 return std::get<void *>(laymap->
data_dst);
4630 return std::get<GMutableVArraySpan>(laymap->
data_dst).data();
4639 size_t tmp_buff_size = 32;
4640 const void **tmp_data_src =
nullptr;
4651 if (
int(data_type) &
CD_FAKE) {
4660 data_size = size_t(type_info->
size);
4667 for (
int i = 0; i < totelem; i++, data_dst =
POINTER_OFFSET(data_dst, data_step), mapit++) {
4669 const float mix_factor = laymap->
mix_factor *
4678 if (sources_num > tmp_buff_size) [[unlikely]] {
4679 tmp_buff_size = size_t(sources_num);
4681 (
void *)tmp_data_src,
sizeof(*tmp_data_src) * tmp_buff_size));
4684 for (
int j = 0; j < sources_num; j++) {
4685 const size_t src_idx = size_t(mapit->
indices_src[j]);
4686 tmp_data_src[j] =
POINTER_OFFSET(data_src, (data_step * src_idx) + data_offset);
4701 if (std::holds_alternative<GMutableVArraySpan>(laymap->
data_dst)) {
4702 std::get<GMutableVArraySpan>(laymap->
data_dst).save();
4705 MEM_SAFE_DELETE(tmp_data_src);
4715 const char **r_struct_name,
4737 data.totlayer = layers_to_write.
size();
4742 data.layers =
nullptr;
4749 if (!
data.layers && layers_to_write.
size() > 0) {
4762 for (
int i = 0; i < count; i++) {
4763 const MDisps *md = &mdlist[i];
4782 if (grid_paint_mask) {
4784 for (
int i = 0; i < count; i++) {
4798 switch (
layer.type) {
4814 "bool type is expected to have the same size as uint8_t")
4818 const char *structname;
4821 if (structnum > 0) {
4822 int datasize = structnum * count;
4825 else if (!writer->
is_undo()) {
4826 printf(
"%s error: layer '%s':%d - can't be written to file\n",
4850 blend_write_layer_data(writer, layer, count);
4856 if (
data->external) {
4867 for (
int i = 0; i < count; i++) {
4894 if (grid_paint_mask) {
4895 for (
int i = 0; i < count; i++) {
4909 switch (
layer.type) {
4931 "bool type is expected to have the same size as uint8_t")
4935 const char *structname;
4938 if (structnum > 0) {
4939 const int data_num = structnum * count;
4946 reader,
reinterpret_cast<std::byte **
>(&
layer.data), count, elem_size);
4956 "Allocated custom data layer that was not saved correctly for layer.type = %d.",
4967 if (count == 0 &&
data->layers ==
nullptr &&
data->totlayer != 0) [[unlikely]] {
4974 if (
data->layers ==
nullptr &&
data->totlayer != 0) [[unlikely]] {
4982 while (i < data->totlayer) {
4989 layer->sharing_info =
nullptr;
4994 blend_read_layer_data(reader, *layer, count);
4995 if (layer->data == nullptr) {
5031 const char *structname;
5035 "%sdict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d),\n",
5068 return std::nullopt;
5084 return std::nullopt;
5102 const int64_t elem_size = CustomData_get_elem_size(&layer);
5103 shared_memory.add(totelem * elem_size);
CustomData interface, see also DNA_customdata_types.h.
#define BLI_BITMAP_SIZE(_num)
A dynamically sized string ADT.
#define STRNCPY_UTF8(dst, src)
#define BLO_read_struct(reader, struct_name, ptr_p)
#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)
Read Blender memory allocation and freeing.
#define PRF_scope(category)
#define INIT_MINMAX2(min, max)
#define BLI_assert_unreachable()
#define POINTER_OFFSET(v, ofs)
#define BLI_assert_msg(a, msg)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
#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_PROP_INT32_2D
#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 MEM_realloc_uninitialized(vmemh, len)
#define CD_MASK_ORIGSPACE
#define CD_MASK_MLOOPTANGENT
#define MAX_CUSTOMDATA_LAYER_NAME_NO_PREFIX
CustomDataLayerImplicitSharing(const void *data, const int totelem, const eCustomDataType type)
const void * data() const
constexpr IndexRange()=default
constexpr MutableSpan()=default
constexpr const T * data() const
constexpr const char * c_str() const
void append(const T &value)
const T & last(const int64_t n=0) const
constexpr bool startswith(StringRef prefix) const
constexpr bool is_empty() const
void copy_utf8_truncated(char *dst, int64_t dst_size) const
void add_shared(const ImplicitSharingInfo *sharing_info, const FunctionRef< void(MemoryCounter &shared_memory)> count_fn)
const void * ImplicitSharingInfo
ccl_device_inline float interp(const float a, const float b, const float t)
typename DefaultMixerStruct< T >::type DefaultMixer
void free(Subdiv *subdiv)
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)
QuaternionBase< float > Quaternion
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)
void CustomData_MeshMasks_update(CustomData_MeshMasks *mask_dst, const CustomData_MeshMasks *mask_src)
bool CustomData_external_test(CustomData *data, eCustomDataType type)
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
@ CDT_MIX_REPLACE_ABOVE_THRESHOLD
@ CDT_MIX_REPLACE_BELOW_THRESHOLD
MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f)
int CustomData_get_offset(const CustomData *data, eCustomDataType type)
bool CustomData_layer_has_interp(const CustomData *data, int layer_n)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static void layerDefault_propcol(void *data, const int count)
static void layerFree_grid_paint_mask(void *data, const int count)
void cdf_write_close(CDataFile *cdf)
int CustomData_layertype_layers_max(eCustomDataType type)
bool CustomData_merge_layout(const CustomData *source, CustomData *dest, eCustomDataMask mask, eCDAllocType alloctype, int totelem)
bool cdf_read_data(CDataFile *cdf, unsigned int size, void *data)
void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format,...) ATTR_PRINTF_FORMAT(2
static void layerSwap_flnor(void *data, const int *corner_indices)
BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings)==CTX_MODE_NUM+1, "Must have a string for each context mode") const char *CTX_data_mode_string(const bContext *C)
static void layerConstruct_mdeformvert(void *data, const int count)
const ImplicitSharingInfo * BLO_read_shared(BlendDataReader *reader, T **data_ptr, FunctionRef< const ImplicitSharingInfo *()> read_fn)
static void layerCopyValue_mloop_origspace(const void *source, void *dest, const int, const float)
static void layerConstruct_mdisps(void *data, const int count)
char * STRNCPY(char(&dst)[N], const char *src)
void * CustomData_bmesh_get(const CustomData *data, void *block, eCustomDataType type)
void(*)(void *data, int count) cd_free
static void layerCopy_origspace_face(const void *source, void *dest, const int count)
void CustomData_bmesh_alloc_block(CustomData *data, void **block)
const CustomData_MeshMasks CD_MASK_BAREMESH
void CustomData_bmesh_set_n(CustomData *data, void *block, eCustomDataType type, int n, const void *source)
bool CustomData_free_layer_active(CustomData *data, eCustomDataType type)
static void layerInitMinMax_mloopcol(void *vmin, void *vmax)
int CustomData_number_of_layers(const CustomData *data, eCustomDataType type)
static bool customdata_merge_internal(const CustomData *source, CustomData *dest, const eCustomDataMask mask, const std::optional< eCDAllocType > alloctype, const int totelem)
void CustomData_swap_corners(CustomData *data, int index, const int *corner_indices)
void CustomData_copy_elements(eCustomDataType type, const void *src_data, void *dst_data, int count)
void CustomData_data_mix_value(eCustomDataType type, const void *source, void *dest, int mixmode, float mixfactor)
static void layerInterp_mloopcol(const void **sources, const float *weights, int count, void *dest)
static int CustomData_get_layer_index__notypemap(const CustomData *data, const eCustomDataType type)
static bool cd_layer_find_dupe(CustomData *data, const StringRef name, const eCustomDataType type, const int index)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
void * BLO_read_struct_by_name_array(BlendDataReader *reader, StringRef struct_name, int64_t items_num, const void *old_address)
bool cdf_write_layer(CDataFile *cdf, CDataFileLayer *blay)
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
void * CustomData_get_layer_n_for_write(CustomData *data, eCustomDataType type, int n, int totelem)
static void ensure_layer_data_is_mutable(CustomDataLayer &layer, const int totelem)
bool CustomData_free_layers(CustomData *data, eCustomDataType type)
void CustomData_realloc(CustomData *data, int old_size, int new_size, eCDAllocType alloctype=CD_CONSTRUCT)
void CustomData_free_elem(CustomData *data, int index, int count)
static const char * layerType_getName(const eCustomDataType type)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
static void layerDoMinMax_propfloat2(const void *data, void *vmin, void *vmax)
static void layerDefault_mloopcol(void *data, const int count)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void blend_color_add_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
const void * CustomData_add_layer_named_with_data(CustomData *data, eCustomDataType type, void *layer_data, int totelem, StringRef name, const ImplicitSharingInfo *sharing_info)
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
MINLINE void mul_v2_fl(float r[2], float f)
void(*)(const void *source, void *dest, int count) cd_copy
void CustomData_external_add(CustomData *data, ID *id, eCustomDataType type, int totelem, const char *filepath)
static void layerMultiply_mloop_origspace(void *data, const float fac)
MINLINE void copy_v2_v2(float r[2], const float a[2])
static void customData_update_offsets(CustomData *data)
BMCustomDataCopyMap CustomData_bmesh_copy_map_calc(const CustomData &src, const CustomData &dst, eCustomDataMask mask_exclude=0)
static void layerCopyValue_mloopcol(const void *source, void *dest, const int mixmode, const float mixfactor)
bool CustomData_has_interp(const CustomData *data)
static void layerInterp_propFloat(const void **sources, const float *weights, const int count, void *dest)
static void layerInterp_propcol(const void **sources, const float *weights, int count, void *dest)
static void layerInterp_propbool(const void **sources, const float *weights, int count, void *dest)
void CustomData_bmesh_interp(CustomData *data, const void **src_blocks, const float *weights, int count, void *dst_block)
bool CustomData_MeshMasks_are_matching(const CustomData_MeshMasks *mask_ref, const CustomData_MeshMasks *mask_required)
int CustomData_get_n_offset(const CustomData *data, eCustomDataType type, int n)
static void layerDefault_tface(void *data, const int count)
static bool CustomData_layer_ensure_data_exists(CustomDataLayer *layer, size_t count)
void BKE_defvert_blend_read(BlendDataReader *reader, int count, MDeformVert *mdverts)
const ImplicitSharingInfo * CustomData_make_layer_sharing_info(eCustomDataType type, const void *data, int totelem)
static void layerDoMinMax_mloopcol(const void *data, void *vmin, void *vmax)
static void get_type_file_write_info(const eCustomDataType type, const char **r_struct_name, int *r_struct_num)
void BKE_defvert_blend_write(BlendWriter *writer, int count, const MDeformVert *dvlist)
MINLINE void blend_color_sub_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void copy_v3_v3_short(short r[3], const short a[3])
size_t CustomData_get_elem_size(const CustomDataLayer *layer)
MINLINE void blend_color_mix_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
bool CustomData_bmesh_merge_layout(const CustomData *source, CustomData *dest, eCustomDataMask mask, eCDAllocType alloctype, BMesh *bm, char htype)
static void layerInterp_propfloat4(const void **sources, const float *weights, int count, void *dest)
bool CustomData_data_equals(eCustomDataType type, const void *data1, const void *data2)
static bool layerRead_mdisps(CDataFile *cdf, void *data, const int count)
@ CD_FLAG_RUNTIME_NOINTERP
static void layerCopy_mdeformvert(const void *source, void *dest, const int count)
MINLINE void copy_v4_fl(float r[4], float f)
static size_t layerFilesize_mdisps(CDataFile *, const void *data, const int count)
static void write_mdisps(BlendWriter *writer, const int count, const MDisps *mdlist, const int external)
static void layerMultiply_propfloat4(void *data, const float fac)
static void layerInterp_mcol(const void **sources, const float *weights, const int count, void *dest)
int CustomData_get_layer_index(const CustomData *data, eCustomDataType type)
int CustomData_sizeof(eCustomDataType type)
bool CustomData_free_layer_named(CustomData *data, StringRef name)
void CustomData_bmesh_copy_block(CustomData &data, void *src_block, void **dst_block)
static void layerCopyValue_propfloat2(const void *source, void *dest, const int mixmode, const float mixfactor)
static int layerMaxNum_tface()
MatBase< float, 4, 4 > float4x4
static void layerCopy_bmesh_elem_py_ptr(const void *, void *dest, const int count)
static void layerInterp_propInt(const void **sources, const float *weights, const int count, void *dest)
void(*)(const void **sources, const float *weights, int count, void *dest) cd_interp
void CustomData_copy_data(const CustomData *source, CustomData *dest, int source_index, int dest_index, int count)
int CustomData_get_active_layer_index(const CustomData *data, eCustomDataType type)
bool cdf_write_data(CDataFile *cdf, unsigned int size, const void *data)
void cdf_free(CDataFile *cdf)
void MEM_delete_void(void *vmemh)
constexpr std::enable_if_t< blenlib_internal::IsBoundedArray< T >::value, size_t > BOUNDED_ARRAY_TYPE_SIZE() noexcept
static void layerCopyValue_normal(const void *source, void *dest, const int mixmode, const float mixfactor)
static void layerInterp_mloop_origspace(const void **sources, const float *weights, int count, void *dest)
static void layerMultiply_propfloat2(void *data, const float fac)
static void layerMultiply_mloopcol(void *data, const float fac)
static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES]
void CustomData_external_reload(CustomData *data, ID *id, eCustomDataMask mask, int totelem)
static void layerInterp_mdeformvert(const void **sources, const float *weights, const int count, void *dest)
MINLINE void blend_color_sub_float(float dst[4], const float src1[4], const float src2[4])
bool cdf_read_open(CDataFile *cdf, const char *filepath)
static void blend_write_layer_data(BlendWriter *writer, const CustomDataLayer &layer, const int count)
static void layerInterp_normal(const void **sources, const float *weights, const int count, void *dest)
const BMAllocTemplate bm_mesh_chunksize_default
static bool layerEqual_propcol(const void *data1, const void *data2)
const void * CustomData_get_layer_named(const CustomData *data, eCustomDataType type, StringRef name)
static const char * LAYERTYPENAMES[CD_NUMTYPES]
void BLI_mempool_free(BLI_mempool *pool, void *addr) ATTR_NONNULL(1
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)
VecBase< float, 4 > float4
static void layerAdd_mloopcol(void *data1, const void *data2)
const char * CustomData_get_render_layer_name(const CustomData *data, eCustomDataType type)
static void layerInterp_propfloat2(const void **sources, const float *weights, int count, void *dest)
static void layerAdd_propfloat2(void *data1, const void *data2)
static bool layerValidate_propFloat(void *data, const uint totitems, const bool do_fixes)
void * CustomData_get_n_for_write(CustomData *data, eCustomDataType type, int index, int n, int totelem)
static void CustomData_bmesh_set_default_n(CustomData *data, void **block, const int n)
size_t void BLI_uniquename_cb(FunctionRef< bool(StringRefNull)> unique_check, const char *defname, char delim, char *name, size_t name_maxncpy) ATTR_NONNULL(2
void * MEM_new_uninitialized_aligned(size_t len, size_t alignment, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(3)
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
void CustomData_interp(const CustomData *source, CustomData *dest, const int *src_indices, const float *weights, int count, int dest_index)
int CustomData_get_render_layer(const CustomData *data, eCustomDataType type)
static void customData_resize(CustomData *data, const int grow_amount)
void CustomData_set_layer_render_index(CustomData *data, eCustomDataType type, int n)
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)
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
MINLINE void blend_color_interpolate_float(float dst[4], const float src1[4], const float src2[4], float t)
static void layerDefault_mcol(void *data, const int count)
const void * CustomData_add_layer_with_data(CustomData *data, eCustomDataType type, void *layer_data, int totelem, const ImplicitSharingInfo *sharing_info)
void CustomData_bmesh_free_block(CustomData *data, void **block)
void(*)(void *data, int count) cd_set_default_value
void CustomData_bmesh_set_default(CustomData *data, void **block)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
MINLINE void blend_color_add_float(float dst[4], const float src1[4], const float src2[4])
bool CustomData_layertype_is_singleton(eCustomDataType type)
VecBase< int32_t, 2 > int2
void CustomData_init_layout_from(const CustomData *source, CustomData *dest, eCustomDataMask mask, eCDAllocType alloctype, int totelem)
VecBase< float, 2 > float2
int multires_mdisp_corners(const MDisps *s)
static void layerFree_mdisps(void *data, const int count)
void CustomData_data_set_default_value(eCustomDataType type, void *elem)
MINLINE void add_v2_v2(float r[2], const float a[2])
void CustomData_bmesh_interp_n(CustomData *data, const void **src_blocks, const float *weights, int count, void *dst_block_ofs, int n)
static void layerInterp_propfloat3(const void **sources, const float *weights, int count, void *dest)
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 minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
void CustomData_reset(CustomData *data)
MINLINE void add_v4_v4(float r[4], const float a[4])
void CustomData_blend_write(BlendWriter *writer, CustomData *data, Span< CustomDataLayer > layers_to_write, int count, eCustomDataMask cddata_mask, ID *id)
static void CustomData_external_free(CustomData *data)
BMesh const char void * data
static void layerInterp_shapekey(const void **sources, const float *weights, int count, void *dest)
bool CustomData_bmesh_has_free(const CustomData *data)
@ VOLUME_GRID_VECTOR_FLOAT
void CustomData_data_copy_value(eCustomDataType type, const void *source, void *dest)
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 CustomData_set_layer_flag(CustomData *data, eCustomDataType type, eCustomDataLayer_Flag flag)
void * CustomData_add_layer_named(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem, StringRef name)
static void layerSwap_tface(void *data, const int *corner_indices)
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, StringRef name)
static void blend_read_mdisps(BlendDataReader *reader, const int count, MDisps *mdisps, const int external)
const CustomData_MeshMasks CD_MASK_BMESH
static void layerInterp_propquaternion(const void **sources, const float *weights, int count, void *dest)
static bool layerValidate_propfloat2(void *data, const uint totitems, const bool do_fixes)
static int customData_pad_up_to_alignment(const int value, const int alignment)
bool cdf_read_layer(CDataFile *cdf, const CDataFileLayer *blay)
void CustomData_data_multiply(eCustomDataType type, void *data, float fac)
static void * copy_layer_data(const eCustomDataType type, const void *data, const int totelem)
CDataFileLayer * cdf_layer_find(CDataFile *cdf, int type, const char *name)
CDataFileLayer * cdf_layer_add(CDataFile *cdf, int type, const char *name, size_t datasize)
static void customdata_external_filename(char filepath[FILE_MAX], StringRefNull basepath, ID *id, CustomDataExternal *external)
void CustomData_blend_write_prepare(CustomData &data, Vector< CustomDataLayer, 16 > &layers_to_write)
void CustomData_ensure_data_is_mutable(CustomDataLayer *layer, int totelem)
static void layerDoMinMax_propcol(const void *data, void *vmin, void *vmax)
bool CustomData_free_layer(CustomData *data, eCustomDataType type, int index)
eCustomDataMask CD_TYPE_AS_MASK(eCustomDataType type)
static bool layerEqual_mloopcol(const void *data1, const void *data2)
static void layerInitMinMax_mloop_origspace(void *vmin, void *vmax)
static void layerDoMinMax_mloop_origspace(const void *data, void *vmin, void *vmax)
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
void minmax_v4v4_v4(float min[4], float max[4], const float vec[4])
const char * CustomData_get_active_layer_name(const CustomData *data, eCustomDataType type)
int CustomData_number_of_anonymous_layers(const CustomData *data, eCustomDataType type)
bool CustomData_verify_versions(CustomData *data, int index)
bool CustomData_merge(const CustomData *source, CustomData *dest, eCustomDataMask mask, int totelem)
MINLINE void zero_v3(float r[3])
CDataFile * cdf_create(int type)
void CustomData_external_remove(CustomData *data, ID *id, eCustomDataType type, int totelem)
bool BLO_read_array(BlendDataReader *reader, T **ptr_p, const SizeT array_size, const int elems=1)
static bool customdata_typemap_is_valid(const CustomData *data)
static void write_grid_paint_mask(BlendWriter *writer, int count, const GridPaintMask *grid_paint_mask)
static bool layer_is_mutable(CustomDataLayer &layer)
int CustomData_get_named_layer_index(const CustomData *data, eCustomDataType type, StringRef name)
static void layerCopy_propString(const void *source, void *dest, const int count)
MINLINE float normalize_v3_v3(float r[3], const float a[3])
void interp_v3_v3v3_slerp_safe(float target[3], const float a[3], const float b[3], float t)
void BLO_read_array_and_validate_size(BlendDataReader *reader, T **ptr_p, SizeT *array_size, const int elems=1)
void CustomData_set_layer_render(CustomData *data, eCustomDataType type, int n)
const void * CustomData_get_layer_n(const CustomData *data, eCustomDataType type, int n)
const CustomData_MeshMasks CD_MASK_DERIVEDMESH
void customData_mask_layers__print(const CustomData_MeshMasks *mask)
MINLINE float normalize_v3(float n[3])
void CustomData_count_memory(const CustomData &data, int totelem, MemoryCounter &memory)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
int CustomData_get_layer_index_n(const CustomData *data, eCustomDataType type, int n)
int CustomData_name_maxncpy_calc(StringRef name)
static bool layerValidate_propfloat3(void *data, const uint totitems, const bool do_fixes)
MINLINE void blend_color_mul_float(float dst[4], const float src1[4], const float src2[4])
static void layerInitMinMax_propcol(void *vmin, void *vmax)
MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
static void layerInterp_tface(const void **sources, const float *weights, const int count, void *dest)
const CustomData_MeshMasks CD_MASK_MESH
VecBase< int16_t, 2 > short2
void CustomData_free(CustomData *data)
static void layerDefault_propfloat4x4(void *data, const int count)
const char * CustomData_layertype_name(eCustomDataType type)
void CustomData_update_typemap(CustomData *data)
const char * CustomData_get_layer_name(const CustomData *data, eCustomDataType type, int n)
int CustomData_get_render_layer_index(const CustomData *data, eCustomDataType type)
static void layerCopy_propFloat(const void *source, void *dest, const int count)
void * CustomData_get_layer_named_for_write(CustomData *data, eCustomDataType type, StringRef name, int totelem)
void * CustomData_bmesh_get_layer_n(const CustomData *data, void *block, int n)
static void layerFree_mdeformvert(void *data, const int count)
int CCG_grid_size(const int level)
static void layerInitMinMax_propfloat2(void *vmin, void *vmax)
void CustomData_bmesh_init_pool(CustomData *data, int totelem, char htype)
void CustomData_set_layer_active(CustomData *data, eCustomDataType type, int n)
void CustomData_set_layer_unique_name(CustomData *data, int index)
void CustomData_bmesh_free_block_data(CustomData *data, void *block)
static void blend_read_layer_data(BlendDataReader *reader, CustomDataLayer &layer, const int count)
int CustomData_get_active_layer(const CustomData *data, eCustomDataType type)
static void layerConstruct_grid_paint_mask(void *data, const int count)
MINLINE unsigned char round_fl_to_uchar_clamp(float a)
void(*)(const CustomDataTransferLayerMap *laymap, void *dest, const void **sources, const float *weights, int count, float mix_factor) cd_datatransfer_interp
static void layerSwap_origspace_face(void *data, const int *corner_indices)
static void layerInterp_origspace_face(const void **sources, const float *weights, const int count, void *dest)
static void layerAdd_mloop_origspace(void *data1, const void *data2)
static void layerSwap_mdisps(void *data, const int *ci)
static bool layerWrite_mdisps(CDataFile *cdf, const void *data, const int count)
void CustomData_copy_layer_type_data(const CustomData *source, CustomData *destination, eCustomDataType type, int source_index, int destination_index, int count)
bool cdf_write_open(CDataFile *cdf, const char *filepath)
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void CustomData_debug_info_from_layers(const CustomData *data, const char *indent, DynStr *dynstr)
static bool layerEqual_mloop_origspace(const void *data1, const void *data2)
MINLINE void copy_v4_v4(float r[4], const float a[4])
void CustomData_set_layer_active_index(CustomData *data, eCustomDataType type, int n)
bool(*)(void *item, uint totitems, bool do_fixes) cd_validate
static void layerDefault_origindex(void *data, const int count)
static void layerMultiply_propcol(void *data, const float fac)
static bool layerEqual_propfloat2(const void *data1, const void *data2)
void * CustomData_get_layer_for_write(CustomData *data, eCustomDataType type, int totelem)
void * CustomData_get_for_write(CustomData *data, int index, eCustomDataType type, int totelem)
static void layerDefault_origspace_face(void *data, const int count)
bool CustomData_has_math(const CustomData *data)
MINLINE void mul_v4_fl(float r[4], float f)
VecBase< float, 3 > float3
void CustomData_ensure_layers_are_mutable(CustomData *data, int totelem)
static void layerCopy_mdisps(const void *source, void *dest, const int count)
int CustomData_get_named_layer_index_notype(const CustomData *data, StringRef name)
const CustomData_MeshMasks CD_MASK_EVERYTHING
MINLINE void mul_v3_v3v3(float r[3], const float v1[3], const float v2[3])
void CustomData_copy_data_layer(const CustomData *source, CustomData *dest, int src_layer_index, int dst_layer_index, int src_index, int dst_index, int count)
bool CustomData_has_layer_named(const CustomData *data, eCustomDataType type, StringRef name)
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void CustomData_external_read(CustomData *data, StringRefNull basepath, ID *id, eCustomDataMask mask, int totelem)
static void free_layer_data(const eCustomDataType type, const void *data, const int totelem)
bool CustomData_set_layer_name(CustomData *data, eCustomDataType type, int n, StringRef name)
static void layerCopyValue_propcol(const void *source, void *dest, const int mixmode, const float mixfactor)
int CustomData_get_named_layer(const CustomData *data, eCustomDataType type, StringRef name)
static void layerAdd_propcol(void *data1, const void *data2)
void cdf_read_close(CDataFile *cdf)
const CustomData_MeshMasks CD_MASK_BAREMESH_ORIGINDEX
void CustomData_init_from(const CustomData *source, CustomData *dest, eCustomDataMask mask, int totelem)
void CustomData_data_initminmax(eCustomDataType type, void *min, void *max)
static void layerFree_bmesh_elem_py_ptr(void *data, const int count)
MINLINE void zero_v2(float r[2])
int CustomData_number_of_layers_typemask(const CustomData *data, eCustomDataMask mask)
static void layerSwap_mcol(void *data, const int *corner_indices)
MINLINE void blend_color_interpolate_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], float ft)
static void layerMultiply_propfloat3(void *data, const float fac)
void CustomData_set_only_copy(const CustomData *data, eCustomDataMask mask)
void CustomData_data_add(eCustomDataType type, void *data1, const void *data2)
void bpy_bm_generic_invalidate(struct BPy_BMGeneric *)
static void layerDefault_propquaternion(void *data, const int count)
static void layerCopy_grid_paint_mask(const void *source, void *dest, const int count)
bool CustomData_layer_has_math(const CustomData *data, int layer_n)
static void layerAdd_propfloat4(void *data1, const void *data2)
void CustomData_data_transfer(const MeshPairRemap *me_remap, CustomDataTransferLayerMap *laymap)
MINLINE void blend_color_mul_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
static void layerCopy_tface(const void *source, void *dest, const int count)
void CustomData_data_dominmax(eCustomDataType type, const void *data, void *min, void *max)
bool CustomData_layertype_is_dynamic(eCustomDataType type)
void BLI_space_transform_invert_normal(const struct SpaceTransform *data, float no[3])
static void customData_free_layer__internal(CustomDataLayer *layer)
void CustomData_external_write(CustomData *data, StringRefNull basepath, ID *id, eCustomDataMask mask, int totelem, int free)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void * CustomData_add_layer(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem)
static void layerAdd_propfloat3(void *data1, const void *data2)
void * CustomData_bmesh_get_n(const CustomData *data, void *block, eCustomDataType type, int n)
void CustomData_blend_read(BlendDataReader *reader, CustomData *data, int count)
static void blend_read_paint_mask(BlendDataReader *reader, int count, GridPaintMask *grid_paint_mask)
static const LayerTypeInfo * layerType_getInfo(const eCustomDataType type)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
static Quaternion identity()
Vector< TrivialDefault > trivial_defaults
Vector< Default > defaults
Vector< TrivialCopy > trivial_copies
void write_struct_array_by_name(const char *struct_name, int64_t array_size, const void *data, BlendStructWriterFn fn=nullptr)
void write_shared(const void *data, size_t approximate_size_in_bytes, const ImplicitSharingInfo *sharing_info, FunctionRef< void()> write_fn)
void write_uint8_array(int64_t num, const uint8_t *data)
void write_int8_array(int64_t num, const int8_t *data)
void write_float_array(int64_t num, const float *data)
void write_float3_array(int64_t num, const float *data)
void write_struct(const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct_array_at_address(const int64_t array_size, const void *address, const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct_array(const int64_t array_size, const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
StringRefNull filepath() const
eCustomDataLayer_Flag flag
const ImplicitSharingInfoHandle * sharing_info
std::function< void()> tag_modified_fn
std::variant< const void *, GVArray > data_src
std::variant< void *, GMutableVArraySpan > data_dst
cd_datatransfer_interp interp
const float * mix_weights
struct BLI_mempool * pool
CustomDataExternal * external
bool(*) read(CDataFile *cdf, void *data, int count)
void(*) construct(void *data, int count)
void(*) swap(void *data, const int *corner_indices)
void(*) initminmax(void *min, void *max)
void(*) add(void *data1, const void *data2)
bool(*) equal(const void *data1, const void *data2)
void(*) copyvalue(const void *source, void *dest, int mixmode, const float mixfactor)
void(*) multiply(void *data, float fac)
bool(*) write(CDataFile *cdf, const void *data, int count)
cd_set_default_value set_default_value
size_t(*) filesize(CDataFile *cdf, const void *data, int count)
void(*) dominmax(const void *data1, void *min, void *max)
static MatBase identity()
MeshPairRemapItem * items
static QuaternionBase identity()