Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-05-19 12:02:25 +0300
committerJacques Lucke <jacques@blender.org>2021-05-19 12:02:25 +0300
commit5e6f3b85646fe96031c3eafe65e9bc7b55468685 (patch)
treeebfa3f017a7d9ac702d3a9c92783ad078fffe57a /source/blender/blenkernel/intern/material.c
parent02b80276b3f20c5b2502d0c4d689f30590350607 (diff)
Geometry Nodes: take materials into account when joining geometries
Materials are now kept intact when using the Join Geometry node or when realizing instaces.
Diffstat (limited to 'source/blender/blenkernel/intern/material.c')
-rw-r--r--source/blender/blenkernel/intern/material.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 73afea98163..73a7a69f5a5 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -768,6 +768,31 @@ int BKE_object_material_count_eval(Object *ob)
return len_p ? *len_p : 0;
}
+void BKE_id_material_eval_assign(ID *id, int slot, Material *material)
+{
+ Material ***materials_ptr = BKE_id_material_array_p(id);
+ short *len_ptr = BKE_id_material_len_p(id);
+ if (ELEM(NULL, materials_ptr, len_ptr)) {
+ BLI_assert_unreachable();
+ return;
+ }
+
+ const int slot_index = slot - 1;
+ const int old_length = *len_ptr;
+
+ if (slot_index >= old_length) {
+ /* Need to grow slots array. */
+ const int new_length = slot_index + 1;
+ *materials_ptr = MEM_reallocN(*materials_ptr, sizeof(void *) * new_length);
+ *len_ptr = new_length;
+ for (int i = old_length; i < new_length; i++) {
+ (*materials_ptr)[i] = NULL;
+ }
+ }
+
+ (*materials_ptr)[slot_index] = material;
+}
+
Material *BKE_gpencil_material(Object *ob, short act)
{
Material *ma = BKE_object_material_get(ob, act);