20#define DNA_DEPRECATED_ALLOW
91 Material *material = id_cast<Material *>(
id);
95 nullptr, &material->id,
"Shader Nodetree",
"ShaderNodeTree");
99 std::optional<Library *> owner_library,
104 Material *material_dst = id_cast<Material *>(id_dst);
105 const Material *material_src = id_cast<const Material *>(id_src);
113 if (material_src->nodetree !=
nullptr) {
120 &material_src->nodetree->id,
122 reinterpret_cast<ID **
>(&material_dst->nodetree),
123 flag_embedded_id_data);
131 material_dst->preview =
nullptr;
134 if (material_src->texpaintslot !=
nullptr) {
136 material_dst->texpaintslot = is_localized ?
nullptr :
138 MEM_dupalloc(material_src->texpaintslot));
141 if (material_src->gp_style !=
nullptr) {
143 MEM_dupalloc(material_src->gp_style));
145 if (material_src->gp_style->gradient !=
nullptr) {
146 material_dst->gp_style->gradient =
static_cast<ColorBand *
>(
147 MEM_dupalloc(material_src->gp_style->gradient));
151 material_dst->gpumaterial.clear_no_delete();
158 Material *material = id_cast<Material *>(
id);
164 if (material->nodetree) {
166 MEM_delete(material->nodetree);
167 material->nodetree =
nullptr;
170 MEM_SAFE_DELETE(material->texpaintslot);
172 if (material->gp_style) {
173 MEM_SAFE_DELETE(material->gp_style->gradient);
176 MEM_SAFE_DELETE(material->gp_style);
190 if (material->texpaintslot !=
nullptr) {
193 if (material->gp_style !=
nullptr) {
204 fn.single(&material->r);
205 fn.single(&material->specr);
206 fn.single(material->line_col);
208 if (material->gp_style) {
209 fn.single(material->gp_style->stroke_rgba);
210 fn.single(material->gp_style->fill_rgba);
211 if (material->gp_style->gradient) {
219 Material *ma = id_cast<Material *>(
id);
222 ma->texpaintslot =
nullptr;
223 ma->gpumaterial.clear_no_delete();
226 ma->use_nodes =
true;
246 if (ma->gp_style->gradient) {
254 Material *ma = id_cast<Material *>(
id);
256 ma->texpaintslot =
nullptr;
261 ma->gpumaterial.clear_no_delete();
271 .id_code = Material::id_type,
277 .name_plural =
N_(
"materials"),
280 .asset_type_info =
nullptr,
285 .make_local =
nullptr,
287 .foreach_cache =
nullptr,
288 .foreach_path =
nullptr,
290 .foreach_asset_weak_reference =
nullptr,
291 .owner_pointer_get =
nullptr,
295 .blend_read_after_liblink =
nullptr,
297 .blend_read_undo_preserve =
nullptr,
299 .lib_override_apply_post =
nullptr,
304 if ((ma) && (ma->gp_style ==
nullptr)) {
305 ma->gp_style = MEM_new<MaterialGPencilStyle>(
"Grease Pencil Material Settings");
331 if (tree ==
nullptr) {
336 if (
node->is_group()) {
345 if (ma && ma->nodetree) {
392 return &(pointcloud->
mat);
396 return &(volume->
mat);
409 return &(
mesh->totcol);
425 return &(pointcloud->
totcol);
443 switch (
GS(
id->name)) {
445 return &((id_cast<Mesh *>(
id))->mat);
447 return &((id_cast<Curve *>(
id))->mat);
449 return &((id_cast<MetaBall *>(
id))->mat);
451 return &((id_cast<bGPdata *>(
id))->mat);
453 return &((id_cast<Curves *>(
id))->mat);
455 return &((id_cast<PointCloud *>(
id))->mat);
457 return &((id_cast<Volume *>(
id))->mat);
459 return &((id_cast<GreasePencil *>(
id))->material_array);
471 switch (
GS(
id->name)) {
473 return &((id_cast<Mesh *>(
id))->totcol);
475 return &((id_cast<Curve *>(
id))->totcol);
477 return &((id_cast<MetaBall *>(
id))->totcol);
479 return &((id_cast<bGPdata *>(
id))->totcol);
481 return &((id_cast<Curves *>(
id))->totcol);
483 return &((id_cast<PointCloud *>(
id))->totcol);
485 return &((id_cast<Volume *>(
id))->totcol);
487 return &((id_cast<GreasePencil *>(
id))->material_array_num);
499 switch (
GS(
id->name)) {
532 ID *ob_data =
object->data;
537 switch (
GS(ob_data->
name)) {
558 switch (
GS(
id->name)) {
584 *materials_len_p_dst = *materials_len_p_src;
585 if (*materials_len_p_src != 0) {
586 (*matar_dst) = MEM_dupalloc(*matar_src);
588 for (
int a = 0; a < *materials_len_p_src; a++) {
602 if (matar ==
nullptr) {
605 if (totcol == *totcolp) {
610 if (do_id_user && totcol < (*totcolp)) {
612 for (i = totcol; i < (*totcolp); i++) {
639 memcpy(mat, *matar,
sizeof(
void *) * (*totcol));
646 (*matar)[(*totcol)++] = ma;
658 short index = short(index_i);
673 if (
index + 1 != (*totcol)) {
674 memmove((*matar) +
index,
675 (*matar) + (
index + 1),
676 sizeof(
void *) * ((*totcol) - (
index + 1)));
701 while ((*totcol)--) {
702 id_us_min(id_cast<ID *>((*matar)[*totcol]));
721 const short *totcolp;
729 if (totcolp ==
nullptr || *totcolp == 0) {
734 const int slot_index =
clamp_i(act - 1, 0, *totcolp - 1);
740 if (slot_index < ob->totcol && ob->
matbits && ob->
matbits[slot_index]) {
742 ma_p = &ob->
mat[slot_index];
748 if (matarar && *matarar) {
749 ma_p = &(*matarar)[slot_index];
767 return ma->gp_style !=
nullptr ? ma :
nullptr;
770 return ma_p ? *ma_p :
nullptr;
780 if (
mesh->runtime->edit_mesh && editmesh_eval_final) {
781 data = &editmesh_eval_final->
id;
799 if (slots_num == 0) {
804 const int slot_index =
clamp_i(act - 1, 0, slots_num - 1);
805 const int tot_slots_object = ob.
totcol;
808 if (slot_index < tot_slots_object) {
812 if (material !=
nullptr) {
821 if (!data_slots_num_ptr) {
824 const int data_slots_num = *data_slots_num_ptr;
826 if (slot_index < data_slots_num) {
827 Material *material = data_materials[slot_index];
842 return std::max(ob->
totcol, len_p ? *len_p : 0);
853 return std::max(ob.
totcol, len_p ? *len_p : 0);
858 switch (
GS(
id.name)) {
860 return reinterpret_cast<const Mesh &
>(
id).material_index_max();
862 return reinterpret_cast<const Curve &
>(
id).material_index_max();
864 return reinterpret_cast<const Curves &
>(
id).
geometry.wrap().material_index_max();
866 return reinterpret_cast<const PointCloud &
>(
id).material_index_max();
868 return reinterpret_cast<const GreasePencil &
>(
id).material_index_max();
886 return *max_index + 1;
894 return max_material_index + 1;
908 if (
ELEM(
nullptr, materials_ptr, len_ptr)) {
913 const int slot_index = slot - 1;
914 const int old_length = *len_ptr;
916 if (slot_index >= old_length) {
918 const int new_length = slot_index + 1;
919 *materials_ptr =
static_cast<Material **
>(
921 *len_ptr = new_length;
922 for (
int i = old_length; i < new_length; i++) {
923 (*materials_ptr)[i] =
nullptr;
927 (*materials_ptr)[slot_index] = material;
933 if (len_ptr ==
nullptr) {
945 for (
short i = 0; i < *totcol; i++) {
957 if ((hint_index >= 0) && (hint_index < *totcol)) {
995 if (ma->gp_style ==
nullptr) {
1012 const int min_index = (ob->
totcol) ? 1 : 0;
1018 if (totcol == ob->
totcol) {
1026 if (do_id_user && totcol < ob->totcol) {
1027 for (
int i = totcol; i < ob->
totcol; i++) {
1034 MEM_delete(ob->
mat);
1040 else if (ob->
totcol < totcol) {
1044 memcpy(newmatar, ob->
mat,
sizeof(
void *) * ob->
totcol);
1046 MEM_delete(ob->
mat);
1062 const short *totcol;
1085 const short *totcol;
1092 int processed_objects = 0;
1094 if (ob->
data ==
id) {
1097 processed_objects++;
1098 BLI_assert(processed_objects <= id->us && processed_objects > 0);
1099 if (processed_objects ==
id->us) {
1109 Material *mao, **matar, ***matarar;
1115 act = std::max<int>(act, 1);
1122 if (totcolp ==
nullptr || matarar ==
nullptr) {
1126 if (act > *totcolp) {
1130 memcpy(matar, *matarar,
sizeof(
void *) * (*totcolp));
1131 MEM_delete(*matarar);
1139 mao = (*matarar)[act - 1];
1143 (*matarar)[act - 1] = ma;
1157 Material *mao, **matar, ***matarar;
1164 act = std::max<int>(act, 1);
1171 if (totcolp ==
nullptr || matarar ==
nullptr) {
1175 if (act > *totcolp) {
1179 memcpy(matar, *matarar,
sizeof(
void *) * (*totcolp));
1180 MEM_delete(*matarar);
1191 ob->
matbits =
static_cast<char *
>(
1207 switch (assign_type) {
1225 mao = ob->
mat[act - 1];
1229 ob->
mat[act - 1] = ma;
1233 mao = (*matarar)[act - 1];
1237 (*matarar)[act - 1] = ma;
1264 const int remap_num)
1270 if (!material_indices) {
1273 for (
const int i : material_indices.
span.index_range()) {
1274 const int index = material_indices.
span[i];
1276 material_indices.
span[i] = remap[
index];
1279 material_indices.
finish();
1328 if (ob_src->
totcol == 0) {
1335 for (
int i = 0; i < ob_dst->
totcol; i++) {
1337 mat_map.
add(ma_src, i);
1344 for (; i < ob_src->
totcol; i++) {
1345 remap_src_to_dst[i] = i;
1349 for (; i < ob_dst->
totcol; i++) {
1350 remap_src_to_dst[i] = i;
1352 for (; i < ob_src->
totcol; i++) {
1353 remap_src_to_dst[i] = 0;
1358 for (
int i = 0; i < ob_src->
totcol; i++) {
1365 if (
const int *index_src_p = mat_map.
lookup_ptr(ma_src)) {
1366 remap_src_to_dst[i] = *index_src_p;
1374 ID *data_orig = ob_orig->
data;
1383 if (
ELEM(
nullptr, orig_totcol, orig_mat, eval_totcol, eval_mat)) {
1388 for (
int i = 0; i < *orig_totcol; i++) {
1391 MEM_SAFE_DELETE(*orig_mat);
1394 *orig_totcol = *eval_totcol;
1397 for (
int i = 0; i < *eval_totcol; i++) {
1398 Material *material_eval = (*eval_mat)[i];
1399 if (material_eval !=
nullptr) {
1401 (*orig_mat)[i] = material_orig;
1411 int actcol_orig = ob->
actcol;
1418 for (
int i = 0; i < totcol; i++) {
1430 actcol_orig = std::min(actcol_orig, ob->
totcol);
1432 ob->
actcol = actcol_orig;
1440 if (ma ==
nullptr) {
1447 if (totcolp ==
nullptr || matarar ==
nullptr) {
1451 for (a = 0; a < *totcolp; a++) {
1452 if ((*matarar)[a] == ma) {
1464 if (ob ==
nullptr) {
1485 if (ob ==
nullptr || ob->
totcol == 0) {
1502 if (
ELEM(
nullptr, matarar, *matarar)) {
1510 mao = (*matarar)[ob->
actcol - 1];
1515 for (
int a = ob->
actcol; a < ob->totcol; a++) {
1516 (*matarar)[a - 1] = (*matarar)[a];
1520 if (*totcolp == 0) {
1521 MEM_delete(*matarar);
1525 const int actcol = ob->
actcol;
1527 for (
Object *obt = bmain->
objects.first(); obt; obt =
static_cast<Object *
>(obt->id.next)) {
1528 if (obt->data == ob->
data) {
1530 if (actcol > obt->totcol) {
1534 mao = obt->mat[actcol - 1];
1539 for (
int a = actcol; a < obt->totcol; a++) {
1540 obt->mat[a - 1] = obt->mat[a];
1541 obt->matbits[a - 1] = obt->matbits[a];
1546 if (obt->totcol == 0) {
1547 MEM_delete(obt->mat);
1548 MEM_delete(obt->matbits);
1550 obt->matbits =
nullptr;
1571 for (
int slot = 1; slot <= ob->
totcol; slot++) {
1579 if (actcol >= slot) {
1598 for (
int slot = 1; slot <= ob->
totcol; slot++) {
1599 while (slot <= ob->totcol) {
1606 if (actcol >= slot) {
1652 for (
bNode *
node : nodetree->all_nodes()) {
1653 if (do_image_nodes && node->typeinfo->nclass == NODE_CLASS_TEXTURE &&
1654 node->typeinfo->type_legacy == SH_NODE_TEX_IMAGE && node->id)
1656 if (!callback(nodetree, node, userdata)) {
1661 if (!callback(nodetree, node, userdata)) {
1665 else if (
node->is_group() &&
node->id) {
1667 if (!ntree_foreach_texnode_recursive(
1668 id_cast<bNodeTree *>(node->id), callback, userdata, slot_filter))
1679 (*(
static_cast<int *
>(userdata)))++;
1708 ma->paint_active_slot =
index;
1711 switch (
node->type_legacy) {
1714 slot->
ima = id_cast<Image *>(
node->id);
1729 slot->
valid =
false;
1782 const TexPaintSlot *prev_texpaintslot = ma->texpaintslot;
1783 const int prev_paint_active_slot = ma->paint_active_slot;
1784 const int prev_paint_clone_slot = ma->paint_clone_slot;
1785 const int prev_tot_slots = ma->tot_slots;
1787 ma->texpaintslot =
nullptr;
1791 ma->paint_active_slot = 0;
1792 ma->paint_clone_slot = 0;
1794 else if (!(ma->nodetree)) {
1795 ma->paint_active_slot = 0;
1796 ma->paint_clone_slot = 0;
1802 ma->paint_active_slot = 0;
1803 ma->paint_clone_slot = 0;
1806 ma->texpaintslot = MEM_new_array<TexPaintSlot>(count,
"texpaint_slots");
1812 ma->tot_slots = count;
1814 if (ma->paint_active_slot >= count) {
1815 ma->paint_active_slot = count - 1;
1818 if (ma->paint_clone_slot >= count) {
1819 ma->paint_clone_slot = count - 1;
1826 if (ma->tot_slots != prev_tot_slots || ma->paint_active_slot != prev_paint_active_slot ||
1827 ma->paint_clone_slot != prev_paint_clone_slot ||
1828 (ma->texpaintslot && prev_texpaintslot &&
1829 memcmp(ma->texpaintslot, prev_texpaintslot,
sizeof(*ma->texpaintslot) * ma->tot_slots) !=
1835 MEM_SAFE_DELETE(prev_texpaintslot);
1840 for (
int i = 1; i < ob->
totcol + 1; i++) {
1856 Image *node_ima = id_cast<Image *>(
node->id);
1857 if (find_data->
slot->
ima == node_ima) {
1877 short texpaint_slot)
1879 if (ma->texpaintslot ==
nullptr) {
1883 if (texpaint_slot >= ma->tot_slots) {
1894 return std::pair<bNodeTree *, bNode *>(find_data.
r_nodetree, find_data.
r_node);
1897void ramp_blend(
int type,
float r_col[4],
const float fac,
const float col[4])
1899 float tmp, facm = 1.0f - fac;
1903 r_col[0] = facm * (r_col[0]) + fac * col[0];
1904 r_col[1] = facm * (r_col[1]) + fac * col[1];
1905 r_col[2] = facm * (r_col[2]) + fac * col[2];
1906 r_col[3] = facm * (r_col[3]) + fac * col[3];
1909 r_col[0] += fac * col[0];
1910 r_col[1] += fac * col[1];
1911 r_col[2] += fac * col[2];
1914 r_col[0] *= (facm + fac * col[0]);
1915 r_col[1] *= (facm + fac * col[1]);
1916 r_col[2] *= (facm + fac * col[2]);
1919 r_col[0] = 1.0f - (facm + fac * (1.0f - col[0])) * (1.0f - r_col[0]);
1920 r_col[1] = 1.0f - (facm + fac * (1.0f - col[1])) * (1.0f - r_col[1]);
1921 r_col[2] = 1.0f - (facm + fac * (1.0f - col[2])) * (1.0f - r_col[2]);
1924 if (r_col[0] < 0.5f) {
1925 r_col[0] *= (facm + 2.0f * fac * col[0]);
1928 r_col[0] = 1.0f - (facm + 2.0f * fac * (1.0f - col[0])) * (1.0f - r_col[0]);
1930 if (r_col[1] < 0.5f) {
1931 r_col[1] *= (facm + 2.0f * fac * col[1]);
1934 r_col[1] = 1.0f - (facm + 2.0f * fac * (1.0f - col[1])) * (1.0f - r_col[1]);
1936 if (r_col[2] < 0.5f) {
1937 r_col[2] *= (facm + 2.0f * fac * col[2]);
1940 r_col[2] = 1.0f - (facm + 2.0f * fac * (1.0f - col[2])) * (1.0f - r_col[2]);
1944 r_col[0] -= fac * col[0];
1945 r_col[1] -= fac * col[1];
1946 r_col[2] -= fac * col[2];
1949 if (col[0] != 0.0f) {
1950 r_col[0] = facm * (r_col[0]) + fac * (r_col[0]) / col[0];
1952 if (col[1] != 0.0f) {
1953 r_col[1] = facm * (r_col[1]) + fac * (r_col[1]) / col[1];
1955 if (col[2] != 0.0f) {
1956 r_col[2] = facm * (r_col[2]) + fac * (r_col[2]) / col[2];
1960 r_col[0] = facm * (r_col[0]) + fac *
fabsf(r_col[0] - col[0]);
1961 r_col[1] = facm * (r_col[1]) + fac *
fabsf(r_col[1] - col[1]);
1962 r_col[2] = facm * (r_col[2]) + fac *
fabsf(r_col[2] - col[2]);
1965 r_col[0] =
max_ff(facm * (r_col[0]) + fac * (r_col[0] + col[0] - 2.0f * r_col[0] * col[0]),
1967 r_col[1] =
max_ff(facm * (r_col[1]) + fac * (r_col[1] + col[1] - 2.0f * r_col[1] * col[1]),
1969 r_col[2] =
max_ff(facm * (r_col[2]) + fac * (r_col[2] + col[2] - 2.0f * r_col[2] * col[2]),
1973 r_col[0] =
min_ff(r_col[0], col[0]) * fac + r_col[0] * facm;
1974 r_col[1] =
min_ff(r_col[1], col[1]) * fac + r_col[1] * facm;
1975 r_col[2] =
min_ff(r_col[2], col[2]) * fac + r_col[2] * facm;
1978 r_col[0] =
max_ff(r_col[0], col[0]) * fac + r_col[0] * facm;
1979 r_col[1] =
max_ff(r_col[1], col[1]) * fac + r_col[1] * facm;
1980 r_col[2] =
max_ff(r_col[2], col[2]) * fac + r_col[2] * facm;
1983 if (r_col[0] != 0.0f) {
1984 tmp = 1.0f - fac * col[0];
1988 else if ((tmp = (r_col[0]) / tmp) > 1.0f) {
1995 if (r_col[1] != 0.0f) {
1996 tmp = 1.0f - fac * col[1];
2000 else if ((tmp = (r_col[1]) / tmp) > 1.0f) {
2007 if (r_col[2] != 0.0f) {
2008 tmp = 1.0f - fac * col[2];
2012 else if ((tmp = (r_col[2]) / tmp) > 1.0f) {
2021 tmp = facm + fac * col[0];
2026 else if ((tmp = (1.0f - (1.0f - (r_col[0])) / tmp)) < 0.0f) {
2029 else if (tmp > 1.0f) {
2036 tmp = facm + fac * col[1];
2040 else if ((tmp = (1.0f - (1.0f - (r_col[1])) / tmp)) < 0.0f) {
2043 else if (tmp > 1.0f) {
2050 tmp = facm + fac * col[2];
2054 else if ((tmp = (1.0f - (1.0f - (r_col[2])) / tmp)) < 0.0f) {
2057 else if (tmp > 1.0f) {
2066 float colH, colS, colV;
2067 float tmpr, tmpg, tmpb;
2068 rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV);
2070 rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV);
2071 hsv_to_rgb(colH, rS, rV, &tmpr, &tmpg, &tmpb);
2072 r_col[0] = facm * (r_col[0]) + fac * tmpr;
2073 r_col[1] = facm * (r_col[1]) + fac * tmpg;
2074 r_col[2] = facm * (r_col[2]) + fac * tmpb;
2080 float colH, colS, colV;
2081 rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV);
2083 rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV);
2084 hsv_to_rgb(rH, (facm * rS + fac * colS), rV, r_col + 0, r_col + 1, r_col + 2);
2090 float colH, colS, colV;
2091 rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV);
2092 rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV);
2093 hsv_to_rgb(rH, rS, (facm * rV + fac * colV), r_col + 0, r_col + 1, r_col + 2);
2098 float colH, colS, colV;
2099 float tmpr, tmpg, tmpb;
2100 rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV);
2102 rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV);
2103 hsv_to_rgb(colH, colS, rV, &tmpr, &tmpg, &tmpb);
2104 r_col[0] = facm * (r_col[0]) + fac * tmpr;
2105 r_col[1] = facm * (r_col[1]) + fac * tmpg;
2106 r_col[2] = facm * (r_col[2]) + fac * tmpb;
2111 float scr, scg, scb;
2114 scr = 1.0f - (1.0f - col[0]) * (1.0f - r_col[0]);
2115 scg = 1.0f - (1.0f - col[1]) * (1.0f - r_col[1]);
2116 scb = 1.0f - (1.0f - col[2]) * (1.0f - r_col[2]);
2118 r_col[0] = facm * (r_col[0]) +
2119 fac * (((1.0f - r_col[0]) * col[0] * (r_col[0])) + (r_col[0] * scr));
2120 r_col[1] = facm * (r_col[1]) +
2121 fac * (((1.0f - r_col[1]) * col[1] * (r_col[1])) + (r_col[1] * scg));
2122 r_col[2] = facm * (r_col[2]) +
2123 fac * (((1.0f - r_col[2]) * col[2] * (r_col[2])) + (r_col[2] * scb));
2127 if (col[0] > 0.5f) {
2128 r_col[0] = r_col[0] + fac * (2.0f * (col[0] - 0.5f));
2131 r_col[0] = r_col[0] + fac * (2.0f * (col[0]) - 1.0f);
2133 if (col[1] > 0.5f) {
2134 r_col[1] = r_col[1] + fac * (2.0f * (col[1] - 0.5f));
2137 r_col[1] = r_col[1] + fac * (2.0f * (col[1]) - 1.0f);
2139 if (col[2] > 0.5f) {
2140 r_col[2] = r_col[2] + fac * (2.0f * (col[2] - 0.5f));
2143 r_col[2] = r_col[2] + fac * (2.0f * (col[2]) - 1.0f);
2186 add_v3_fl(&ma->gp_style->stroke_rgba[0], 0.6f);
2208 output->location[0] = 200.0f;
2209 output->location[1] = 100.0f;
2231 output->location[0] = 200.0f;
2232 output->location[1] = 100.0f;
2254 output->location[0] = 300.0f;
2255 output->location[1] = 300.0f;
2292 output->location[0] = 200.0f;
2293 output->location[1] = 100.0f;
2333 if (ma && ma->gpumaterial.first()) {
2345 "Default material pointers should always be null when initializing them, maybe "
2346 "missing a call to `BKE_materials_exit` first?");
Generic geometry attributes built on CustomData.
Low-level operations for curves.
display list (or rather multi purpose list) stuff.
Low-level operations for grease pencil.
#define BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data_, func_call_)
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
General operations, lookup, etc. for materials.
#define SH_NODE_TEX_IMAGE
#define SH_NODE_BSDF_PRINCIPLED
#define SH_NODE_OUTPUT_MATERIAL
#define SH_NODE_VOLUME_PRINCIPLED
#define SH_NODE_ATTRIBUTE
General operations, lookup, etc. for blender objects.
General operations for point clouds.
Generic array manipulation API.
#define BLI_array_permute(arr, arr_len, order)
#define ENUM_OPERATORS(_enum_type)
#define BLO_read_struct(reader, struct_name, ptr_p)
#define BLT_I18NCONTEXT_ID_MATERIAL
#define CLOG_ERROR(clg_ref,...)
ID and Library types, which are fundamental for SDNA.
Object is a sort of wrapper for general info.
#define OB_DATA_SUPPORT_ID(_id_type)
#define IMAGEPAINT_MODE_IMAGE
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define ARRAY_SET_ITEMS(...)
#define STREQLEN(a, b, n)
#define INIT_DEFAULT_STRUCT_AFTER(struct_dst, member)
#define BLI_assert_msg(a, msg)
#define MEM_realloc_zeroed(vmemh, len)
#define MEM_realloc_uninitialized(vmemh, len)
constexpr IndexRange()=default
const Value * lookup_ptr(const Key &key) const
bool add(const Key &key, const Value &value)
std::optional< AttributeMetaData > lookup_meta_data(StringRef name) const
GSpanAttributeWriter lookup_for_write_span(StringRef name)
uint32_t previews_refresh_state
#define storage(slot, qualifiers)
bool is_color_attribute(const AttributeMetaData &meta_data)
bNodeTree * node_tree_add_tree_embedded(Main *bmain, ID *owner_id, StringRefNull name, StringRefNull idname)
void node_tree_blend_write(BlendWriter *writer, bNodeTree *ntree)
bNodeTree * node_tree_localize(bNodeTree *ntree, std::optional< ID * > new_owner_id)
bNode * node_get_active_paint_canvas(bNodeTree &ntree)
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
void node_set_active(bNodeTree &ntree, bNode &node)
void node_tree_free_embedded_tree(bNodeTree *ntree)
static Material ** default_materials[]
MINLINE float min_ff(float a, float b)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static void material_default_holdout_init(Material **ma_p)
void BKE_id_material_eval_assign(ID *id, int slot, Material *material)
void BKE_icon_id_delete(ID *id)
static void material_free_data(ID *id)
int BKE_object_material_count_eval(const Object *ob)
void BKE_previewimg_id_free(ID *id)
void ramp_blend(int type, float r_col[4], float fac, const float col[4])
char * STRNCPY(char(&dst)[N], const char *src)
int BKE_object_material_used_with_fallback_eval(const Object &ob)
void BKE_object_material_remap(Object *ob, const unsigned int *remap)
static int count_texture_nodes_recursive(bNodeTree *nodetree, ePaintSlotFilter slot_filter)
static Material * default_material_surface
Material * BKE_gpencil_material(Object *ob, short act)
static void material_default_gpencil_init(Material **ma_p)
MINLINE void copy_v3_v3(float r[3], const float a[3])
int BKE_object_material_remove_unused(Main *bmain, Object *ob)
void BKE_previewimg_blend_read(BlendDataReader *reader, PreviewImage *prv)
bool BKE_object_material_slot_remove(Main *bmain, Object *ob)
short * BKE_object_material_len_p(Object *ob)
void hsv_to_rgb(float h, float s, float v, float *r_r, float *r_g, float *r_b)
Material * BKE_material_default_surface()
@ GP_MATERIAL_PLACEMENT_RADIUS
void BKE_pointcloud_material_remap(PointCloud *pointcloud, const unsigned int *remap, int remap_num)
Material *** BKE_object_material_array_p(Object *ob)
static void fill_texpaint_slots_recursive(bNodeTree *nodetree, bNode *active_node, const Object *ob, Material *ma, int slot_len, ePaintSlotFilter slot_filter)
Material * BKE_gpencil_material_add(Main *bmain, const char *name)
bool BKE_mesh_material_index_used(Mesh *mesh, short index)
void BKE_displist_free(ListBaseT< DispList > *lb)
void BKE_materials_exit()
static void material_default_gsplat_init(Material **ma_p)
static bool fill_texpaint_slots_cb(bNodeTree *, bNode *node, void *userdata)
bool BKE_object_material_slot_add(Main *bmain, Object *ob, bool set_active=true)
Material * BKE_object_material_get(Object *ob, short act)
void BKE_previewimg_blend_write(BlendWriter *writer, const PreviewImage *prv)
static Material * default_material_holdout
short * BKE_id_material_len_p(ID *id)
static bNode * nodetree_uv_node_recursive(bNode *node)
const Mesh * BKE_object_get_editmesh_eval_final(const Object *object)
void DEG_debug_print_eval(Depsgraph *depsgraph, const char *function_name, const char *object_name, const void *object_address)
Material *** BKE_id_material_array_p(ID *id)
int BKE_id_material_used_eval(const ID &id)
int BKE_object_material_index_get_with_hint(Object *ob, const Material *ma, int hint_index)
void BKE_curves_material_remap(struct Curves *curves, const unsigned int *remap, int remap_num)
static void material_blend_read_data(BlendDataReader *reader, ID *id)
MINLINE void add_v3_fl(float r[3], float f)
Material * BKE_material_default_empty()
void BKE_object_material_active_index_sanitize(Object *ob)
void BKE_object_material_assign(Main *bmain, Object *ob, Material *ma, short act, int assign_type)
void rgb_to_hsv(float r, float g, float b, float *r_h, float *r_s, float *r_v)
void BKE_id_materials_copy(Main *bmain, ID *id_src, ID *id_dst)
void BKE_curve_material_remap(Curve *cu, const unsigned int *remap, unsigned int remap_len)
Material * BKE_material_default_gpencil()
static void material_foreach_working_space_color(ID *id, const IDTypeForeachColorFunctionCallback &fn)
Material * BKE_material_default_volume()
void BKE_id_blend_write(BlendWriter *writer, ID *id)
static bool texpaint_slot_node_find_cb(bNodeTree *nodetree, bNode *node, void *userdata)
int BKE_object_material_ensure(Main *bmain, Object *ob, Material *material)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
@ LIB_ID_CREATE_NO_ALLOCATE
static void material_init_data(ID *id)
bool BKE_grease_pencil_material_index_used(GreasePencil *grease_pencil, int index)
void BKE_colorband_foreach_working_space_color(ColorBand *coba, const IDTypeForeachColorFunctionCallback &fn)
bool(*)(bNodeTree *nodetree, bNode *node, void *userdata) ForEachTexNodeCallback
MaterialGPencilStyle * BKE_gpencil_material_settings(Object *ob, short act)
int BKE_id_material_used_with_fallback_eval(const ID &id)
void GPU_material_free(ListBaseT< LinkData > *gpumaterial)
void BKE_gpencil_material_attr_init(Material *ma)
void BKE_id_material_assign(Main *bmain, ID *id, Material *ma, short act)
bool BKE_object_material_slot_used(Object *object, short actcol)
static Material * default_material_gpencil
void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma, const Object *ob)
void BKE_mesh_material_index_remove(Mesh *mesh, short index)
void DEG_id_tag_update(ID *id, unsigned int flags)
BMesh const char void * data
void BKE_object_materials_sync_length(Main *bmain, Object *ob, ID *id)
void BKE_object_material_remap_calc(Object *ob_dst, Object *ob_src, short *remap_src_to_dst)
void BKE_id_material_resize(Main *bmain, ID *id, short totcol, bool do_id_user)
static void material_default_volume_init(Material **ma_p)
void BKE_library_foreach_ID_embedded(LibraryForeachIDData *data, ID **id_pp)
void BKE_id_material_append(Main *bmain, ID *id, Material *ma)
@ BKE_MAT_ASSIGN_EXISTING
@ BKE_MAT_ASSIGN_USERPREF
void BKE_grease_pencil_material_index_remove(GreasePencil *grease_pencil, int index)
static void material_blend_write(BlendWriter *writer, ID *id, const void *id_address)
bool BKE_curve_material_index_used(const Curve *cu, int index)
void BKE_materials_init()
void BKE_id_material_eval_ensure_default_slot(ID *id)
static void material_default_surface_init(Material **ma_p)
Material * BKE_id_material_pop(Main *bmain, ID *id, int index)
static bool count_texture_nodes_cb(bNodeTree *, bNode *, void *userdata)
void BKE_material_make_node_previews_dirty(Material *ma)
BMDataLayerLookup BM_data_layer_lookup(const BMesh &bm, const StringRef name)
static Material * material_default_create(Material **ma_p, const char *name)
int BKE_object_material_index_get(Object *ob, const Material *ma)
void BKE_curve_material_index_remove(Curve *cu, int index)
void BKE_objects_materials_sync_length_all(Main *bmain, ID *id)
void BKE_id_free(Main *bmain, void *idv)
void BKE_object_material_array_assign(Main *bmain, Object *ob, Material ***matar, int totcol, bool to_object_only)
void BKE_material_eval(Depsgraph *depsgraph, Material *material)
void BKE_id_material_clear(Main *bmain, ID *id)
void BKE_object_material_resize(Main *bmain, Object *ob, short totcol, bool do_id_user)
static Material * default_material_empty
static void material_foreach_id(ID *id, LibraryForeachIDData *data)
void BKE_ntree_update_without_main(bNodeTree &tree)
static void material_data_index_clear_id(ID *id)
static Material * default_material_volume
void * BKE_id_new_nomain(short type, const char *name)
std::optional< int > BKE_id_material_index_max_eval(const ID &id)
void BKE_previewimg_id_copy(ID *new_id, const ID *old_id)
int BKE_object_material_remove_all(Main *bmain, Object *ob)
T * DEG_get_original(T *id)
Material ** BKE_object_material_get_p(Object *ob, short act)
MINLINE float max_ff(float a, float b)
void BKE_main_unlock(Main *bmain)
Material * BKE_object_material_get_eval(Object *ob, short act)
short BKE_object_material_slot_find_index(Object *ob, Material *ma)
ID_Type GS(const char *name)
static void nodetree_mark_previews_dirty_reccursive(bNodeTree *tree)
bool BKE_object_supports_material_slots(Object *ob)
const BMesh * BKE_editmesh_bmesh_get(const Object *ob)
void BKE_main_lock(Main *bmain)
void BKE_mesh_material_index_clear(Mesh *mesh)
void BKE_object_material_assign_single_obdata(Main *bmain, Object *ob, Material *ma, short act)
@ PAINT_SLOT_COLOR_ATTRIBUTE
static bool ntree_foreach_texnode_recursive(bNodeTree *nodetree, ForEachTexNodeCallback callback, void *userdata, ePaintSlotFilter slot_filter)
static void material_data_index_remove_id(ID *id, short index)
void DEG_relations_tag_update(Main *bmain)
void BKE_mesh_material_remap(Mesh *mesh, const unsigned int *remap, unsigned int remap_len)
void BKE_texpaint_slots_refresh_object(Scene *scene, Object *ob)
void BKE_material_defaults_free_gpu()
void BKE_material_attr_indices_remap(bke::MutableAttributeAccessor attributes, const unsigned int *remap, int remap_num)
std::pair< bNodeTree *, bNode * > BKE_texpaint_slot_material_find_node(Material *ma, short texpaint_slot)
Material * BKE_material_add(Main *bmain, const char *name)
Material * BKE_material_default_gsplat()
Material * BKE_material_default_holdout()
bool DEG_is_evaluated(const T *id)
static const ID * get_evaluated_object_data_with_materials(const Object *ob)
void BKE_grease_pencil_material_remap(GreasePencil *grease_pencil, const uint *remap, int totcol)
void *(*) MEM_realloc_zeroed_id(void *vmemh, size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
MINLINE int clamp_i(int value, int min, int max)
void BKE_curve_material_index_clear(Curve *cu)
void BKE_object_material_from_eval_data(Main *bmain, Object *ob_orig, const ID *data_eval)
void * BKE_id_new(Main *bmain, short type, const char *name)
static void material_copy_data(Main *bmain, std::optional< Library * > owner_library, ID *id_dst, const ID *id_src, const int flag)
struct ID * BKE_id_copy_in_lib(Main *bmain, std::optional< Library * > owner_library, const ID *id, std::optional< const ID * > new_owner_id, ID **new_id_p, int flag)
static Material * default_material_gsplat
static void object_material_assign(Main *bmain, Object *ob, Material *ma, short act, int assign_type, bool do_test_all)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
void write_embedded_id_struct(const void *id_address, const T *id, BlendStructWriterTypedFn< T > fn=nullptr)
void write_id_struct(const void *id_address, const T *id, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct(const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
ListBaseT< DispList > disp
ListBaseT< Object > objects
float random_rotation_factor
float random_strength_factor
eMaterialGPencilPlacementMode placement_mode
float random_saturation_factor
float placement_radius_spacing
float random_value_factor
bke::ObjectRuntime * runtime
struct ToolSettings * toolsettings
struct ImageUser * image_user
bke::bNodeTreeRuntime * runtime
bke::bNodeType * typeinfo
MutableVArraySpan< T > span