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:
authorPhilipp Oeser <info@graphics-engineer.com>2020-04-09 19:49:40 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2020-09-17 23:39:57 +0300
commit39de0b79fd635ed67e8b1816c32199177d7f9f07 (patch)
treeb2838abd1c39d3c17e08438740c40c95c33a94f1 /source/blender/blenkernel/intern/material.c
parent9ee588cd4af881f3432fddce3044e90bad4e30f6 (diff)
Pointclouds: support mesh <-> pointcloud in convert operator
Just converts verts to points and vice versa. Materials and Attribute layers are preserved (so for example if you set custom radii on the pointcloud, convert to mesh, then convert back to pointcloud, this will be preserved). Also not add a Radius layer by default (it is still added and filled when adding a pointcloud object from the menu), a global Radius property that will be used if there is no radius attribute can be added later. A Radius attribute can also be added in the pointcloud data properties (and filled via python). This will also add a new utility function that copies materials between datablocks: BKE_id_materials_copy ref T75717 Differential Revision: https://developer.blender.org/D7391
Diffstat (limited to 'source/blender/blenkernel/intern/material.c')
-rw-r--r--source/blender/blenkernel/intern/material.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 885cc1baefc..d8c0b5d6dce 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -535,6 +535,27 @@ static void material_data_index_clear_id(ID *id)
}
}
+void BKE_id_materials_copy(Main *bmain, ID *id_src, ID *id_dst)
+{
+ Material ***matar_src = BKE_id_material_array_p(id_src);
+ const short *materials_len_p_src = BKE_id_material_len_p(id_src);
+
+ Material ***matar_dst = BKE_id_material_array_p(id_dst);
+ short *materials_len_p_dst = BKE_id_material_len_p(id_dst);
+
+ *materials_len_p_dst = *materials_len_p_src;
+ if (*materials_len_p_src != 0) {
+ (*matar_dst) = MEM_dupallocN(*matar_src);
+
+ for (int a = 0; a < *materials_len_p_src; a++) {
+ id_us_plus((ID *)(*matar_dst)[a]);
+ }
+
+ DEG_id_tag_update(id_dst, ID_RECALC_COPY_ON_WRITE);
+ DEG_relations_tag_update(bmain);
+ }
+}
+
void BKE_id_material_resize(Main *bmain, ID *id, short totcol, bool do_id_user)
{
Material ***matar = BKE_id_material_array_p(id);